-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlessbrute.py
More file actions
105 lines (77 loc) · 3.16 KB
/
lessbrute.py
File metadata and controls
105 lines (77 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import argparse
import hashlib
import hmac
import time
import sys
import os
ICONS = (
'#️', '❤️', '🏨', '🎓', '🔌',
'🚑', '🚌', '🚗', '✈️', '🚀',
'🚢', '🚇', '🚚', '💴', '💶',
'₿', '💵', '💷', '🗄️', '📈',
'🛏️', '🍺', '🔔', '🔭', '🎂',
'💣', '💼', '🐛', '📷', '🛒',
'⭐', '☕', '☁️', '☕', '🗨️',
'📦', '🍴', '🖥️', '💎', '❗',
'👁️', '🏁', '⚗️', '⚽', '🎮',
'🎓'
)
def get_icon(hash_slice):
return int(hash_slice, base=16) % 46
def get_fingerprint(hmac_sha256):
return (
get_icon(hmac_sha256[0:6]),
get_icon(hmac_sha256[6:12]),
get_icon(hmac_sha256[12:18])
)
def get_hmac_sha256(password_bytes):
return hmac.new(password_bytes, digestmod=hashlib.sha256).hexdigest()
def process_line(line, fingerprint, output_file, find_first):
line = line.strip()
hmac_sha256 = get_hmac_sha256(line.encode('utf-8'))
if get_fingerprint(hmac_sha256) == fingerprint:
print(line)
with open(output_file, 'a') as f:
f.write(line + '\n')
if find_first:
sys.exit(0)
def process_file(wordlist, fingerprint, output_file, find_first):
with open(wordlist, 'r', encoding='utf-8', errors='ignore') as file:
for line in file:
process_line(line, fingerprint, output_file, find_first)
def main():
start_time = time.time()
parser = argparse.ArgumentParser(description='Filter lesspass wordlist by fingerprint')
parser.add_argument('wordlist', metavar='wordlist', type=str, help='path to word list')
parser.add_argument('fingerprint', metavar='fingerprint', type=str, help='the fingerprint to match (e.g., "💴 🎓 ₿")')
parser.add_argument('-o', '--output', type=str, default='match.txt', help='output file (default: match.txt)')
parser.add_argument('-f', '--first', action='store_true', help='stop after first match')
parser.add_argument('-i', '--icons', action='store_true', help='show available icons')
args = parser.parse_args()
if args.icons:
print('/'.join(ICONS))
sys.exit(0)
if ' ' not in args.fingerprint:
print(f'Error: Icons must be separated by spaces.')
sys.exit(1)
fingerprint = args.fingerprint.split()
if len(fingerprint) != 3:
print(f'Error: There should be 3 icons ({len(fingerprint)} provided)')
sys.exit(1)
for icon in fingerprint:
if icon not in ICONS:
print(f'Error: Invalid fingerprint icon - {icon}.')
sys.exit(1)
if not os.path.isfile(args.wordlist):
print(f'Error: The file "{args.wordlist}" does not exist.')
sys.exit(1)
with open(args.output, 'w') as f:
pass
print(f'Searching for fingerprint: {args.fingerprint}')
fingerprint = tuple([ICONS.index(icon) for icon in fingerprint])
process_file(args.wordlist, fingerprint, args.output, args.first)
end_time = time.time()
elapsed_time = end_time - start_time
print(f'Processing time: {elapsed_time:.2f} seconds')
if __name__ == '__main__':
main()