From 1d8de39cd66f6e0d01fe01864025bc65ff495d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Tue, 16 Apr 2024 22:15:48 +0200 Subject: [PATCH 01/16] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 621159d..945b47f 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,9 @@ and bitcoin-cli RPC usage, without requiring students to sync the node themselve ## Install -1. clone repo -2. `pip install -r requirements.txt` +1. Clone repo +2. Create and active a Python Virtual Environment +3. `pip install -r requirements.txt` ## Run From d1dd19fb2aa55d407c27fba256d66c4b10f6be7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Tue, 16 Apr 2024 23:59:42 +0200 Subject: [PATCH 02/16] Create bulk_users.py --- src/bulk_users.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/bulk_users.py diff --git a/src/bulk_users.py b/src/bulk_users.py new file mode 100644 index 0000000..ba98468 --- /dev/null +++ b/src/bulk_users.py @@ -0,0 +1,57 @@ +import argparse +import json +import os +import random +import string + +from werkzeug.security import generate_password_hash + +# Parse command line arguments for username and optional password +parser = argparse.ArgumentParser(description="Add user and hashed password to JSON file.") +parser.add_argument("user_count", type=int, help="Number of users to generate") +parser.add_argument("-l", "--password_length", type=int, default=12, help="Length of the generated password") +args = parser.parse_args() + +# Generate and save user credentials to a text file +with open("users_pass.txt", "w") as user_pass_file: + users = {} + for i in range(args.user_count): + # Generate username + username = f"user_{i+1:03d}" + + # Generate password + characters = string.ascii_letters + string.digits + password = ''.join(random.choice(characters) for _ in range(args.password_length)) + + # Write user and password to the file + user_pass_file.write(f"Username: {username}, Password: {password}\n") + + # Add user and hashed password to dictionary + hashed_password = generate_password_hash(password) + users[username] = hashed_password + +# Output message +print(f"{args.user_count} users and passwords have been generated and saved to users_pass.txt.") + +# File to store hashed passwords +PASSWORD_FILE_PATH = "passwords.json" + +# Load existing data from file +if os.path.exists(PASSWORD_FILE_PATH): + with open(PASSWORD_FILE_PATH, 'r') as file: + try: + existing_users = json.load(file) + except json.JSONDecodeError: + existing_users = {} +else: + existing_users = {} + +# Add or update user passwords +existing_users.update(users) + +# Write back to the file +with open(PASSWORD_FILE_PATH, 'w') as file: + json.dump(existing_users, file, indent=4) + +# Output message +print(f"{args.user_count} users and passwords have been added to {PASSWORD_FILE_PATH}.") From 001bc9579d61366831dc8396f7a1958301615e85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:15:28 +0200 Subject: [PATCH 03/16] Delete src/bulk_users.py --- src/bulk_users.py | 57 ----------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 src/bulk_users.py diff --git a/src/bulk_users.py b/src/bulk_users.py deleted file mode 100644 index ba98468..0000000 --- a/src/bulk_users.py +++ /dev/null @@ -1,57 +0,0 @@ -import argparse -import json -import os -import random -import string - -from werkzeug.security import generate_password_hash - -# Parse command line arguments for username and optional password -parser = argparse.ArgumentParser(description="Add user and hashed password to JSON file.") -parser.add_argument("user_count", type=int, help="Number of users to generate") -parser.add_argument("-l", "--password_length", type=int, default=12, help="Length of the generated password") -args = parser.parse_args() - -# Generate and save user credentials to a text file -with open("users_pass.txt", "w") as user_pass_file: - users = {} - for i in range(args.user_count): - # Generate username - username = f"user_{i+1:03d}" - - # Generate password - characters = string.ascii_letters + string.digits - password = ''.join(random.choice(characters) for _ in range(args.password_length)) - - # Write user and password to the file - user_pass_file.write(f"Username: {username}, Password: {password}\n") - - # Add user and hashed password to dictionary - hashed_password = generate_password_hash(password) - users[username] = hashed_password - -# Output message -print(f"{args.user_count} users and passwords have been generated and saved to users_pass.txt.") - -# File to store hashed passwords -PASSWORD_FILE_PATH = "passwords.json" - -# Load existing data from file -if os.path.exists(PASSWORD_FILE_PATH): - with open(PASSWORD_FILE_PATH, 'r') as file: - try: - existing_users = json.load(file) - except json.JSONDecodeError: - existing_users = {} -else: - existing_users = {} - -# Add or update user passwords -existing_users.update(users) - -# Write back to the file -with open(PASSWORD_FILE_PATH, 'w') as file: - json.dump(existing_users, file, indent=4) - -# Output message -print(f"{args.user_count} users and passwords have been added to {PASSWORD_FILE_PATH}.") From 0618a425cf8f7bda96ed8e88a9531ae2c0a7b1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:22:10 +0200 Subject: [PATCH 04/16] Create bulk_users.py --- src/bulk_users.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/bulk_users.py diff --git a/src/bulk_users.py b/src/bulk_users.py new file mode 100644 index 0000000..338bafd --- /dev/null +++ b/src/bulk_users.py @@ -0,0 +1,64 @@ +import argparse +import csv +import json +import os +import random +import string + +from werkzeug.security import generate_password_hash + +from config import password_file_path + +# Parse command line arguments for username and optional password +parser = argparse.ArgumentParser(description="Add user and hashed password to JSON file.") +parser.add_argument("user_count", type=int, help="Number of users to generate") +parser.add_argument("-l", "--password_length", type=int, default=12, help="Length of the generated password") +args = parser.parse_args() + +# Generate and save user credentials to a CSV file +with open("users_pass.csv", "w", newline='') as user_pass_file: + csv_writer = csv.writer(user_pass_file) + csv_writer.writerow(['Username', 'Password']) + + users = {} + for i in range(args.user_count): + # Generate username + username = f"user_{i+1:03d}" + + # Generate password + characters = string.ascii_letters + string.digits + password = ''.join(random.choice(characters) for _ in range(args.password_length)) + + # Write user and password to the CSV file + csv_writer.writerow([username, password]) + + # Add user and hashed password to dictionary + hashed_password = generate_password_hash(password) + users[username] = hashed_password + +# Output message +print(f"{args.user_count} users and passwords have been generated and saved to users_pass.csv.") + +# File to store hashed passwords +PASSWORD_FILE_PATH = password_file_path() + +# Load existing data from file +if os.path.exists(PASSWORD_FILE_PATH): + with open(PASSWORD_FILE_PATH, 'r') as file: + try: + existing_users = json.load(file) + except json.JSONDecodeError: + existing_users = {} +else: + existing_users = {} + +# Add or update user passwords +existing_users.update(users) + +# Write back to the file +with open(PASSWORD_FILE_PATH, 'w') as file: + json.dump(existing_users, file, indent=4) + +# Output message +print(f"{args.user_count} users and passwords have been added to {PASSWORD_FILE_PATH}.") + From 0255c7907d37cf1aca4d40bec53f510626b24e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:27:15 +0200 Subject: [PATCH 05/16] Update README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 945b47f..1e01f66 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,15 @@ Password for newuser1: lYDk7mbTiN60 ~/rpc-auth-proxy$ python src/users.py newuser2 -p hunter2 Password for newuser2: hunter2 ``` +### Large amount of Users ### +Another utility that you can use for adding large amount of users it's `src/bulk_users.py`. Hashed passwords are saved by +default in a JSON file at `~/.rpc-auth-proxy-passwords.json`, but another file is saved too with the pair of username and clear password. + +```sh +~/rpc-auth-proxy$python3 src/bulk_users.py 100 +100 users and passwords have been generated and saved to users_pass.csv. +100 users and passwords have been added to /home/ubuntu/.rpc-auth-proxy-passwords.json. +``` ## Remote Access From aa74517f4336a27aa179c19f6a12d94971722701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:29:44 +0200 Subject: [PATCH 06/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e01f66..71ed1b8 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ and bitcoin-cli RPC usage, without requiring students to sync the node themselve ## Install 1. Clone repo -2. Create and active a Python Virtual Environment +2. Create and activate a Python Virtual Environment (for isolate problems with other python libraries) 3. `pip install -r requirements.txt` ## Run From 6becb7008235eaa2f3d46a40ae9ab9f38a093dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:31:42 +0200 Subject: [PATCH 07/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71ed1b8..a79c070 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ default in a JSON file at `~/.rpc-auth-proxy-passwords.json`, but another file i ```sh ~/rpc-auth-proxy$python3 src/bulk_users.py 100 100 users and passwords have been generated and saved to users_pass.csv. -100 users and passwords have been added to /home/ubuntu/.rpc-auth-proxy-passwords.json. +100 users and passwords have been added to ~/.rpc-auth-proxy-passwords.json. ``` ## Remote Access From 95f9c76a43f57eeadf28088121310077fd279507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:57:27 +0200 Subject: [PATCH 08/16] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a79c070..a669164 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,11 @@ with bitcoin-cli. Networks supported: `main`, `testnet`, `signet`, `regtest` -- Start Bitcoin Core: `bitcoind -conf=/path/to/repo/rpc-auth-proxy/etc/bitcoin.conf` +- Start Bitcoin Core: `bitcoind -daemon -conf=/path/to/repo/rpc-auth-proxy/etc/bitcoin.conf` - Optionally add `-signet`, etc for different network - Start proxy server: `python src/server.py main` - Optionally replace `main` with `signet`, etc. + - Use `tmux` to ensure that server don't be killed when exists from terminal. ## Adding Users From 0c3fe34c35e4432bd1eca01282eb22a8764daffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Wed, 17 Apr 2024 00:58:47 +0200 Subject: [PATCH 09/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a669164..a42bafa 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Networks supported: `main`, `testnet`, `signet`, `regtest` - Optionally add `-signet`, etc for different network - Start proxy server: `python src/server.py main` - Optionally replace `main` with `signet`, etc. - - Use `tmux` to ensure that server don't be killed when exists from terminal. + - Use `nohup` or `tmux` to ensure that server don't be killed when exists from terminal or session. ## Adding Users From 4a323b364b9481c3663454d963cc3846f4380161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Fuentes?= Date: Mon, 13 May 2024 16:27:27 +0200 Subject: [PATCH 10/16] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a42bafa..ba43e80 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Networks supported: `main`, `testnet`, `signet`, `regtest` - Start Bitcoin Core: `bitcoind -daemon -conf=/path/to/repo/rpc-auth-proxy/etc/bitcoin.conf` - Optionally add `-signet`, etc for different network -- Start proxy server: `python src/server.py main` +- Start proxy server: `python3 src/server.py main` - Optionally replace `main` with `signet`, etc. - Use `nohup` or `tmux` to ensure that server don't be killed when exists from terminal or session. @@ -31,9 +31,9 @@ default in a JSON file at `~/.rpc-auth-proxy-passwords.json`. Provide a password with `-p` or the script will generate one for you: ```sh -~/rpc-auth-proxy$ python src/users.py newuser1 +~/rpc-auth-proxy$ python3 src/users.py newuser1 Password for newuser1: lYDk7mbTiN60 -~/rpc-auth-proxy$ python src/users.py newuser2 -p hunter2 +~/rpc-auth-proxy$ python3 src/users.py newuser2 -p hunter2 Password for newuser2: hunter2 ``` ### Large amount of Users ### From 1fee3ad55abdb3f9d960713f5d9723afbb24be96 Mon Sep 17 00:00:00 2001 From: ifuensan Date: Wed, 17 Jul 2024 23:23:47 +0200 Subject: [PATCH 11/16] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba43e80..a42bafa 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Networks supported: `main`, `testnet`, `signet`, `regtest` - Start Bitcoin Core: `bitcoind -daemon -conf=/path/to/repo/rpc-auth-proxy/etc/bitcoin.conf` - Optionally add `-signet`, etc for different network -- Start proxy server: `python3 src/server.py main` +- Start proxy server: `python src/server.py main` - Optionally replace `main` with `signet`, etc. - Use `nohup` or `tmux` to ensure that server don't be killed when exists from terminal or session. @@ -31,9 +31,9 @@ default in a JSON file at `~/.rpc-auth-proxy-passwords.json`. Provide a password with `-p` or the script will generate one for you: ```sh -~/rpc-auth-proxy$ python3 src/users.py newuser1 +~/rpc-auth-proxy$ python src/users.py newuser1 Password for newuser1: lYDk7mbTiN60 -~/rpc-auth-proxy$ python3 src/users.py newuser2 -p hunter2 +~/rpc-auth-proxy$ python src/users.py newuser2 -p hunter2 Password for newuser2: hunter2 ``` ### Large amount of Users ### From 892a56358a8502f5b6f1bfd2f40a7f27cac2d2d2 Mon Sep 17 00:00:00 2001 From: ifuensan Date: Wed, 17 Jul 2024 23:25:17 +0200 Subject: [PATCH 12/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a42bafa..c45a946 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Another utility that you can use for adding large amount of users it's `src/bulk default in a JSON file at `~/.rpc-auth-proxy-passwords.json`, but another file is saved too with the pair of username and clear password. ```sh -~/rpc-auth-proxy$python3 src/bulk_users.py 100 +~/rpc-auth-proxy$python src/bulk_users.py 100 100 users and passwords have been generated and saved to users_pass.csv. 100 users and passwords have been added to ~/.rpc-auth-proxy-passwords.json. ``` From 8d5e7d44e527a2103735e4d246ad54c9e4dda4b2 Mon Sep 17 00:00:00 2001 From: ifuensan Date: Wed, 17 Jul 2024 23:44:55 +0200 Subject: [PATCH 13/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c45a946..6fdb577 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Networks supported: `main`, `testnet`, `signet`, `regtest` - Optionally add `-signet`, etc for different network - Start proxy server: `python src/server.py main` - Optionally replace `main` with `signet`, etc. - - Use `nohup` or `tmux` to ensure that server don't be killed when exists from terminal or session. + - Use `nohup` or `tmux` to ensure that the server process is not killed when exiting the terminal or session. ## Adding Users From f911cbd407d0745e163697bee7ac59837ce1d2f2 Mon Sep 17 00:00:00 2001 From: ifuensan Date: Wed, 7 Aug 2024 23:30:03 +0200 Subject: [PATCH 14/16] Update README.md Co-authored-by: Matthew Zipkin --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6fdb577..ae9a92c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ and bitcoin-cli RPC usage, without requiring students to sync the node themselve ## Install 1. Clone repo -2. Create and activate a Python Virtual Environment (for isolate problems with other python libraries) +2. Create and activate a Python Virtual Environment 3. `pip install -r requirements.txt` ## Run From eee170b8451b497cddaa5ce788800394af6ba172 Mon Sep 17 00:00:00 2001 From: ifuensan Date: Wed, 7 Aug 2024 23:31:14 +0200 Subject: [PATCH 15/16] Update README.md Co-authored-by: Matthew Zipkin --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae9a92c..110de31 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Password for newuser1: lYDk7mbTiN60 Password for newuser2: hunter2 ``` ### Large amount of Users ### -Another utility that you can use for adding large amount of users it's `src/bulk_users.py`. Hashed passwords are saved by +To add large amount of users a utility is provided in `src/bulk_users.py`. Hashed passwords are saved by default in a JSON file at `~/.rpc-auth-proxy-passwords.json`, but another file is saved too with the pair of username and clear password. ```sh From f348f087c9e68fdfef7a41b63ca28fbf09be0f9f Mon Sep 17 00:00:00 2001 From: ifuensan Date: Wed, 7 Aug 2024 23:31:32 +0200 Subject: [PATCH 16/16] Update README.md Co-authored-by: Matthew Zipkin --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 110de31..35c31f5 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ To add large amount of users a utility is provided in `src/bulk_users.py`. Hashe default in a JSON file at `~/.rpc-auth-proxy-passwords.json`, but another file is saved too with the pair of username and clear password. ```sh -~/rpc-auth-proxy$python src/bulk_users.py 100 +~/rpc-auth-proxy$ python src/bulk_users.py 100 100 users and passwords have been generated and saved to users_pass.csv. 100 users and passwords have been added to ~/.rpc-auth-proxy-passwords.json. ```