From 24af1aff33591607fe37ada4929e79733999c3bb Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Thu, 29 May 2025 10:53:07 +0100 Subject: [PATCH 1/7] Added http-header flag --- __main__.py | 5 ++++- build.sh | 22 ++++++++++++---------- htpclient/helpers.py | 14 +++++++++++++- htpclient/jsonRequest.py | 3 ++- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/__main__.py b/__main__.py index b8dce22..9b63f0a 100644 --- a/__main__.py +++ b/__main__.py @@ -15,7 +15,7 @@ from htpclient.generic_cracker import GenericCracker from htpclient.hashcat_cracker import HashcatCracker from htpclient.hashlist import Hashlist -from htpclient.helpers import start_uftpd, file_get_contents +from htpclient.helpers import start_uftpd, file_get_contents, parse_http_headers from htpclient.initialize import Initialize from htpclient.jsonRequest import * from htpclient.dicts import * @@ -140,6 +140,8 @@ def init(args): CONFIG.set_value('zaps-path', os.path.abspath(args.zaps_path)) if args.preprocessors_path and len(args.preprocessors_path): CONFIG.set_value('preprocessors-path', os.path.abspath(args.preprocessors_path)) + if args.http_headers and len(args.http_headers): + CONFIG.set_value('http-headers', parse_http_headers(args.http_headers)) logging.info("Starting client '" + Initialize.get_version() + "'...") @@ -334,6 +336,7 @@ def de_register(): parser.add_argument('--preprocessors-path', type=str, required=False, help='Use given folder path as preprocessors location') parser.add_argument('--zaps-path', type=str, required=False, help='Use given folder path as zaps location') parser.add_argument('--cpu-only', action='store_true', help='Force client to register as CPU only and also only reading out CPU information') + parser.add_argument('--http-headers', type=str, required=False, help='Use given http headers in all HTTP requests') args = parser.parse_args() if args.version: diff --git a/build.sh b/build.sh index 59ea817..5928802 100755 --- a/build.sh +++ b/build.sh @@ -4,14 +4,16 @@ if [ -f hashtopolis.zip ]; then rm hashtopolis.zip fi -# write commit count since release into version number when compiling into zip -count=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline | wc -l) -if [ ${count} \> 0 ]; -then - sed -i -E 's/return "([0-9]+)\.([0-9]+)\.([0-9]+)"/return "\1.\2.\3.'$count'"/g' htpclient/initialize.py -fi; +# Get latest tag, fallback to initial commit hash if no tags found +latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo $(git rev-list --max-parents=0 HEAD)) +count=$(git log ${latest_tag}..HEAD --oneline | wc -l) + +if [ "$count" -gt 0 ]; then + sed -i -E 's/return "([0-9]+)\.([0-9]+)\.([0-9]+)"/return "\1.\2.\3.'$count'"/g' htpclient/initialize.py +fi + zip -r hashtopolis.zip __main__.py htpclient -x "*__pycache__*" -if [ ${count} \> 0 ]; -then - sed -i -E 's/return "([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)"/return "\1.\2.\3"/g' htpclient/initialize.py -fi; \ No newline at end of file + +if [ "$count" -gt 0 ]; then + sed -i -E 's/return "([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)"/return "\1.\2.\3"/g' htpclient/initialize.py +fi diff --git a/htpclient/helpers.py b/htpclient/helpers.py index eb4d1df..05ac4bf 100644 --- a/htpclient/helpers.py +++ b/htpclient/helpers.py @@ -63,7 +63,8 @@ def file_get_contents(filename): def start_uftpd(os_extension, config): try: - subprocess.check_output("killall -s 9 uftpd", shell=True) # stop running service to make sure we can start it again + # stop running service to make sure we can start it again + subprocess.check_output("killall -s 9 uftpd", shell=True) except subprocess.CalledProcessError: pass # ignore in case uftpd was not running path = './uftpd' + os_extension @@ -132,3 +133,14 @@ def update_files(command, prince=False): def escape_ansi(line): ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]') return ansi_escape.sub('', line) + + +def parse_http_headers(header_str): + headers = {} + if header_str: + pairs = header_str.split(',') + for pair in pairs: + if ':' in pair: + key, value = pair.split(':', 1) + headers[key.strip()] = value.strip() + return headers diff --git a/htpclient/jsonRequest.py b/htpclient/jsonRequest.py index 1d68e45..f2f538a 100644 --- a/htpclient/jsonRequest.py +++ b/htpclient/jsonRequest.py @@ -13,7 +13,8 @@ def __init__(self, data): def execute(self): try: logging.debug(self.data) - r = self.session.post(self.config.get_value('url'), json=self.data, timeout=30) + headers = self.config.get_value('http_headers') or {} + r = self.session.post(self.config.get_value('url'), json=self.data, timeout=30, headers=headers) if r.status_code != 200: logging.error("Status code from server: " + str(r.status_code)) return None From 6c9f2354eb247c2382d29a72e40148ff3d0806fc Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Thu, 29 May 2025 11:58:28 +0100 Subject: [PATCH 2/7] Fixed typo --- htpclient/jsonRequest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htpclient/jsonRequest.py b/htpclient/jsonRequest.py index f2f538a..7c8636c 100644 --- a/htpclient/jsonRequest.py +++ b/htpclient/jsonRequest.py @@ -13,7 +13,7 @@ def __init__(self, data): def execute(self): try: logging.debug(self.data) - headers = self.config.get_value('http_headers') or {} + headers = self.config.get_value('http-headers') or {} r = self.session.post(self.config.get_value('url'), json=self.data, timeout=30, headers=headers) if r.status_code != 200: logging.error("Status code from server: " + str(r.status_code)) From f74846780db19328a02897085bad07d411e7e800 Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Thu, 29 May 2025 12:02:17 +0100 Subject: [PATCH 3/7] Testing 1 --- htpclient/jsonRequest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htpclient/jsonRequest.py b/htpclient/jsonRequest.py index 7c8636c..c33ecca 100644 --- a/htpclient/jsonRequest.py +++ b/htpclient/jsonRequest.py @@ -16,7 +16,7 @@ def execute(self): headers = self.config.get_value('http-headers') or {} r = self.session.post(self.config.get_value('url'), json=self.data, timeout=30, headers=headers) if r.status_code != 200: - logging.error("Status code from server: " + str(r.status_code)) + logging.error("Status code from server aaaaaaaaaaaaaaa: " + str(r.status_code)) return None logging.debug(r.content) return r.json() From 2f20567efa021f02127cd8e2983b571e34b2cd88 Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Thu, 29 May 2025 12:17:01 +0100 Subject: [PATCH 4/7] Fixed typo --- htpclient/jsonRequest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htpclient/jsonRequest.py b/htpclient/jsonRequest.py index c33ecca..7c8636c 100644 --- a/htpclient/jsonRequest.py +++ b/htpclient/jsonRequest.py @@ -16,7 +16,7 @@ def execute(self): headers = self.config.get_value('http-headers') or {} r = self.session.post(self.config.get_value('url'), json=self.data, timeout=30, headers=headers) if r.status_code != 200: - logging.error("Status code from server aaaaaaaaaaaaaaa: " + str(r.status_code)) + logging.error("Status code from server: " + str(r.status_code)) return None logging.debug(r.content) return r.json() From 00d8c2e71787fced7581f37d7397ebe80c123ee6 Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Thu, 29 May 2025 15:28:10 +0100 Subject: [PATCH 5/7] Fixing error while creating a task --- __main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/__main__.py b/__main__.py index 9b63f0a..11ba9a3 100644 --- a/__main__.py +++ b/__main__.py @@ -155,6 +155,7 @@ def init(args): session = Session(requests.Session()).s session.headers.update({'User-Agent': Initialize.get_version()}) + session.headers.update(CONFIG.get_value('http-headers')) if CONFIG.get_value('proxies'): session.proxies = CONFIG.get_value('proxies') From 06826c9a4d57f6dccdafb6a974ced5af40c42513 Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Tue, 1 Sep 2026 11:51:21 +0100 Subject: [PATCH 6/7] added info about the new http-headers flag --- README.md | 3 +++ __main__.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d81f4b..54e687d 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Please note: ``` usage: python3 hashtopolis.zip [-h] [--de-register] [--version] [--number-only] [--disable-update] [--debug] [--voucher VOUCHER] [--url URL] [--cert CERT] [--files-path FILES_PATH] [--crackers-path CRACKERS_PATH] [--hashlists-path HASHLISTS_PATH] [--preprocessors-path PREPROCESSORS_PATH] [--zaps-path ZAPS_PATH] [--cpu-only] + [--http-headers HTTP_HEADERS] Hashtopolis Client v0.7.3 @@ -58,6 +59,8 @@ optional arguments: --zaps-path ZAPS_PATH Use given folder path as zaps location --cpu-only Force client to register as CPU only and also only reading out CPU information + --http-headers HTTP_HEADERS + Use given http headers in all HTTP requests, format: "Header1: Value1, Header2: Value2" ``` ### Config diff --git a/__main__.py b/__main__.py index 11ba9a3..54d38f3 100644 --- a/__main__.py +++ b/__main__.py @@ -337,7 +337,7 @@ def de_register(): parser.add_argument('--preprocessors-path', type=str, required=False, help='Use given folder path as preprocessors location') parser.add_argument('--zaps-path', type=str, required=False, help='Use given folder path as zaps location') parser.add_argument('--cpu-only', action='store_true', help='Force client to register as CPU only and also only reading out CPU information') - parser.add_argument('--http-headers', type=str, required=False, help='Use given http headers in all HTTP requests') + parser.add_argument('--http-headers', type=str, required=False, help='Use given http headers in all HTTP requests, format: "Header1: Value1, Header2: Value2"') args = parser.parse_args() if args.version: From 857af41ca7a526dae7ba9ead0f731f23f573cdfb Mon Sep 17 00:00:00 2001 From: BrunoTeixeira1996 Date: Tue, 1 Sep 2026 11:54:06 +0100 Subject: [PATCH 7/7] Fix version count in build.sh falling back to commit count since repo root git describe would fail whenever tags aren't available locally (e.g. a fork with no tags), and the old fallback counted commits since the very first commit instead of since the last release tag, producing bogus version suffixes like 0.7.3.781. Now it fetches tags best-effort and falls back to count=0 (no suffix) if no tag can be found. --- build.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 5928802..3bb8ce0 100755 --- a/build.sh +++ b/build.sh @@ -4,9 +4,18 @@ if [ -f hashtopolis.zip ]; then rm hashtopolis.zip fi -# Get latest tag, fallback to initial commit hash if no tags found -latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo $(git rev-list --max-parents=0 HEAD)) -count=$(git log ${latest_tag}..HEAD --oneline | wc -l) +# Make sure tags are available locally (some CI/PR checkouts or forks only +# have a single branch without tags), so git describe can actually find the +# latest release tag instead of silently failing. +git fetch --tags --quiet 2>/dev/null || true + +# write commit count since release into version number when compiling into zip +latest_tag=$(git describe --tags --abbrev=0 2>/dev/null) +if [ -n "$latest_tag" ]; then + count=$(git log "${latest_tag}"..HEAD --oneline | wc -l) +else + count=0 +fi if [ "$count" -gt 0 ]; then sed -i -E 's/return "([0-9]+)\.([0-9]+)\.([0-9]+)"/return "\1.\2.\3.'$count'"/g' htpclient/initialize.py