Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions HashmobAPI.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from configparser import ConfigParser
from configparser import ConfigParser, DuplicateSectionError
from pathlib import Path
import logging
import requests
Expand All @@ -7,8 +7,7 @@
import time

CONFIG_PATH = 'hashmob_config.ini'
POTFILE_PATH = 'hashcat.potfile'
API_ENDPOINT = 'https://hashmob.net/api/v2/submit'
DEFAULT_API_ENDPOINT = 'https://hashmob.net/api/v2/submit'


def setup():
Expand Down Expand Up @@ -74,14 +73,27 @@ def main():

# Use defined config or ask for defaults on first time
try:
api_endpoint = config['API']['api_endpoint']
except KeyError:
try:
config.add_section('API')
except DuplicateSectionError:
pass

# We're here because no api_endpoint was defined, so don't need to worry about overwriting it
config['API']['api_endpoint'] = DEFAULT_API_ENDPOINT
api_endpoint = DEFAULT_API_ENDPOINT

try:
# If we've got this far, we can safely assume the API section exists
api_key = config['API']['api_key']
resubmission_delay = int(config['API']['resubmission_delay'])
except KeyError:
config.add_section('API')

api_key = input("Enter your API key: ")
config['API']['api_key'] = api_key

try:
resubmission_delay = int(config['API']['resubmission_delay'])
except KeyError:
while not (resubmission_delay := input("Enter the delay between resubmissions in seconds: ")).isdigit():
print('Please provide an integer for the delay!')

Expand Down Expand Up @@ -116,7 +128,7 @@ def main():

# Upload data to API
try:
response = upload_to_api(data, API_ENDPOINT, api_key)
response = upload_to_api(data, api_endpoint, api_key)
if response.status_code == 200:
logging.info('Successfully sent new finds!')
previous_size = os.path.getsize(potfile_path)
Expand All @@ -128,6 +140,7 @@ def main():
else:
logging.error(f'Failed to send new finds! We were given a status code of {response.status_code}. '
'Retrying after resubmission delay...')
time.sleep(resubmission_delay)
except Exception as e:
logging.error(f'Error encountered when trying to send new finds: {e}')

Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This Python script allows you to parse a `hashcat.potfile`, convert its contents
Before using this script, ensure you have the following installed:

- Python 3
- Requests library (install via `pip install requests`)
- Requests library (install via `pip install -r requirements.txt`)

## Usage

Expand All @@ -17,20 +17,19 @@ Before using this script, ensure you have the following installed:

3. Run the script using the following command:

python hashcat_parser.py
python HashmobAPI.py /path/to/hashcat.potfile


4. Follow the prompts to enter the required information:
- Path to the `hashcat.potfile`
- Path for the JSON output file
- API endpoint URL
- API key
- Value for the 'algorithm'
- Delay between resubmissions in seconds
- Value for the 'algorithm' (i.e. hashcat mode number)

5. The script will continuously monitor the `hashcat.potfile`, converting its contents into JSON format and uploading them to the specified API endpoint. It will wait for the specified delay between resubmissions.

**Note:** This script was written to submit hashes to Hashmob.net's API and does not currently support salted submissions, though their API does.
**Note 1:** This script was written to submit hashes to Hashmob.net's API and does not currently support salted submissions, though their API does.

**Note 2:** The API endpoint can be modified in the `hashmob_config.ini` file created on first run.

## Contributing

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests