mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-07-03 11:25:18 -07:00
Fix asset path resolution: separate hashcat and hate_crack locations
BREAKING CHANGE: Corrected understanding of hcatPath configuration - hcatPath should point to hashcat binary location (or omit if in PATH) - hashcat-utils and princeprocessor are located in hate_crack repo - Changed code to use hate_path for utilities instead of hcatPath - Updated error messages to guide users correctly - Updated README with correct configuration examples - Asset discovery now properly uses HATE_CRACK_HOME environment variable This fixes the issue where users had hcatPath pointing to hashcat installation but the code was looking there for hashcat-utils.
This commit is contained in:
@@ -109,31 +109,26 @@ uv tool install .
|
||||
hate_crack
|
||||
```
|
||||
|
||||
**Important:** The installed tool needs access to `hashcat-utils` and `princeprocessor` subdirectories. These are located in the original repository directory.
|
||||
**Important:** The tool needs access to `hashcat-utils` and `princeprocessor` subdirectories from the hate_crack repository.
|
||||
|
||||
When running from outside the repository, configure the asset location in your `config.json` by setting `hcatPath`:
|
||||
|
||||
```json
|
||||
{
|
||||
"hcatPath": "/opt/hate_crack",
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Then run the tool:
|
||||
|
||||
```bash
|
||||
hate_crack <hash_file> <hash_type>
|
||||
```
|
||||
|
||||
Alternatively, run `hate_crack` from within the repository directory and it will automatically find the assets:
|
||||
The tool will automatically search for these assets in:
|
||||
- Environment variables: `HATE_CRACK_HOME` or `HATE_CRACK_ASSETS`
|
||||
- Current working directory and parent directory
|
||||
- `~/hate_crack`, `~/hate-crack`, or `~/.hate_crack`
|
||||
|
||||
**Option 1 - Run from repository directory:**
|
||||
```bash
|
||||
cd /path/to/hate_crack
|
||||
hate_crack <hash_file> <hash_type>
|
||||
```
|
||||
|
||||
If `hcatPath` is empty in config.json, the tool will search the current directory and parent directory for assets.
|
||||
**Option 2 - Set environment variable:**
|
||||
```bash
|
||||
export HATE_CRACK_HOME=/path/to/hate_crack
|
||||
hate_crack <hash_file> <hash_type>
|
||||
```
|
||||
|
||||
**Note:** The `hcatPath` in config.json is for the hashcat binary location (optional if hashcat is in PATH), not for hate_crack assets.
|
||||
|
||||
### Run as a script
|
||||
The script uses a `uv` shebang. Make it executable and run:
|
||||
@@ -160,38 +155,39 @@ Error: Build directory /opt/hashcat/hashcat-utils does not exist.
|
||||
Expected to find expander at /opt/hashcat/hashcat-utils/bin/expander.
|
||||
```
|
||||
|
||||
This means your `hcatPath` in `config.json` is pointing to the wrong directory. The `hcatPath` should point to the **hate_crack repository directory** (which contains `hashcat-utils/` and `princeprocessor/` subdirectories), not the hashcat installation directory.
|
||||
This means the tool cannot find the hate_crack repository assets. The `hashcat-utils` and `princeprocessor` directories are part of the **hate_crack repository**, not the hashcat installation.
|
||||
|
||||
**Incorrect config.json:**
|
||||
**Understanding the paths:**
|
||||
- `hcatPath` in config.json → points to **hashcat binary location** (optional, can be in PATH)
|
||||
- `hashcat-utils/` and `princeprocessor/` → located in the **hate_crack repository directory**
|
||||
|
||||
The tool automatically searches for hate_crack assets in these locations:
|
||||
1. Directory specified by `HATE_CRACK_HOME` or `HATE_CRACK_ASSETS` environment variables
|
||||
2. Current working directory and parent directory
|
||||
3. `~/hate_crack`, `~/hate-crack`, or `~/.hate_crack`
|
||||
|
||||
**Solution:**
|
||||
Run `hate_crack` from within the repository directory:
|
||||
```bash
|
||||
cd /opt/hate_crack # or wherever you cloned the repository
|
||||
hate_crack <hash_file> <hash_type>
|
||||
```
|
||||
|
||||
Or set an environment variable:
|
||||
```bash
|
||||
export HATE_CRACK_HOME=/opt/hate_crack
|
||||
hate_crack <hash_file> <hash_type>
|
||||
```
|
||||
|
||||
**Example config.json:**
|
||||
```json
|
||||
{
|
||||
"hcatPath": "/opt/hashcat", ❌ Wrong - this is hashcat, not hate_crack
|
||||
"hcatPath": "/usr/local/bin", # Location of hashcat binary (or omit if in PATH)
|
||||
"hcatBin": "hashcat", # Hashcat binary name
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
**Correct config.json:**
|
||||
```json
|
||||
{
|
||||
"hcatPath": "/opt/hate_crack", ✓ Correct - points to hate_crack repo
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Or use the home directory path:
|
||||
```json
|
||||
{
|
||||
"hcatPath": "~/hate_crack", ✓ Also correct
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
The tool will automatically search for assets in:
|
||||
1. The `hcatPath` specified in config.json
|
||||
2. Environment variables `HATE_CRACK_HOME` or `HATE_CRACK_ASSETS`
|
||||
3. Current working directory and parent directory
|
||||
4. `~/hate_crack`, `~/hate-crack`, or `~/.hate_crack`
|
||||
|
||||
-------------------------------------------------------------------
|
||||
### Makefile helpers
|
||||
Install OS dependencies + tool (auto-detects macOS vs Debian/Ubuntu):
|
||||
|
||||
+12
-9
@@ -174,11 +174,12 @@ def ensure_binary(binary_path, build_dir=None, name=None):
|
||||
if not os.path.isdir(build_dir):
|
||||
print(f'Error: Build directory {build_dir} does not exist.')
|
||||
print(f'Expected to find {name or "binary"} at {binary_path}.')
|
||||
print('\nThe hcatPath in your config.json may be incorrect.')
|
||||
print('Please ensure hcatPath points to the hate_crack repository directory')
|
||||
print('that contains hashcat-utils/ and princeprocessor/ subdirectories.')
|
||||
print('\nExample config.json:')
|
||||
print(' "hcatPath": "/opt/hate_crack" (or ~/hate_crack)')
|
||||
print('\nThe hate_crack assets (hashcat-utils, princeprocessor) could not be found.')
|
||||
print('These are part of the hate_crack repository, not hashcat installation.')
|
||||
print('\nPlease run hate_crack from the repository directory:')
|
||||
print(' cd /path/to/hate_crack && hate_crack <hash_file> <hash_type>')
|
||||
print('\nOr set the HATE_CRACK_HOME environment variable:')
|
||||
print(' export HATE_CRACK_HOME=/path/to/hate_crack')
|
||||
quit(1)
|
||||
|
||||
print(f'Attempting to build {name or binary_path} via make in {build_dir}...')
|
||||
@@ -428,7 +429,8 @@ if not SKIP_INIT:
|
||||
quit(1)
|
||||
|
||||
# Verify hashcat-utils binaries exist and work
|
||||
hashcat_utils_path = hcatPath + '/hashcat-utils/bin'
|
||||
# Note: hashcat-utils is part of hate_crack repo, not hashcat installation
|
||||
hashcat_utils_path = hate_path + '/hashcat-utils/bin'
|
||||
required_binaries = [
|
||||
(hcatExpanderBin, 'expander'),
|
||||
(hcatCombinatorBin, 'combinator'),
|
||||
@@ -436,7 +438,7 @@ if not SKIP_INIT:
|
||||
|
||||
for binary, name in required_binaries:
|
||||
binary_path = hashcat_utils_path + '/' + binary
|
||||
ensure_binary(binary_path, build_dir=os.path.join(hcatPath, 'hashcat-utils'), name=name)
|
||||
ensure_binary(binary_path, build_dir=os.path.join(hate_path, 'hashcat-utils'), name=name)
|
||||
# Test binary execution
|
||||
try:
|
||||
test_result = subprocess.run(
|
||||
@@ -457,9 +459,10 @@ if not SKIP_INIT:
|
||||
quit(1)
|
||||
|
||||
# Verify princeprocessor binary
|
||||
prince_path = hcatPath + '/princeprocessor/' + hcatPrinceBin
|
||||
# Note: princeprocessor is part of hate_crack repo, not hashcat installation
|
||||
prince_path = hate_path + '/princeprocessor/' + hcatPrinceBin
|
||||
try:
|
||||
ensure_binary(prince_path, build_dir=os.path.join(hcatPath, 'princeprocessor'), name='PRINCE')
|
||||
ensure_binary(prince_path, build_dir=os.path.join(hate_path, 'princeprocessor'), name='PRINCE')
|
||||
except SystemExit:
|
||||
print('PRINCE attacks will not be available.')
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ def test_ensure_binary_error_message(monkeypatch, capsys):
|
||||
|
||||
# Test with non-existent build directory
|
||||
fake_binary = "/nonexistent/path/to/binary"
|
||||
fake_build_dir = "/opt/hashcat/hashcat-utils" # Simulate user's error
|
||||
fake_build_dir = "/opt/hate_crack/hashcat-utils" # Simulate missing assets
|
||||
|
||||
# Expect SystemExit when binary and build dir don't exist
|
||||
try:
|
||||
@@ -23,11 +23,11 @@ def test_ensure_binary_error_message(monkeypatch, capsys):
|
||||
except SystemExit as e:
|
||||
assert e.code == 1
|
||||
|
||||
# Check that the error message mentions the build directory issue
|
||||
# Check that the error message mentions the correct issue
|
||||
captured = capsys.readouterr()
|
||||
assert "Build directory" in captured.out or "does not exist" in captured.out
|
||||
assert "hcatPath" in captured.out # Should mention config issue
|
||||
assert "hashcat-utils" in captured.out or "princeprocessor" in captured.out
|
||||
assert "hate_crack" in captured.out.lower() # Should mention hate_crack assets
|
||||
assert "HATE_CRACK_HOME" in captured.out or "repository" in captured.out
|
||||
|
||||
|
||||
def test_ensure_binary_with_existing_binary():
|
||||
|
||||
Reference in New Issue
Block a user