Browse Source

made brute_force_keyid use multiple gpg homedirs because gpg gets horrible inefficient and resource-intensive when it has too many keys in a homedir

master
Micah Lee 9 years ago
parent
commit
928b544208
  1. 5
      README.md
  2. 21
      brute_force_keyid.py

5
README.md

@ -27,6 +27,11 @@ The script that brute forces key IDs uses a modified version of gnupg that remov @@ -27,6 +27,11 @@ The script that brute forces key IDs uses a modified version of gnupg that remov
nice -20 ./brute_force_keyid.py
### To do list
* Make keyid and number of threads command line arguements
* Make ctrl-c actually quit so you don't have to kill the process
Download the web of trust
-------------------------

21
brute_force_keyid.py

@ -8,14 +8,20 @@ sys.path.append(cwd+'/lib/python-gnupg') @@ -8,14 +8,20 @@ sys.path.append(cwd+'/lib/python-gnupg')
import gnupg
class BruteForceKeyID_Common:
def __init__(self, gpg, keyid, name_real, name_email, name_comment='', key_type='RSA', key_length=1024):
def __init__(self, keyid, name_real, name_email, name_comment='', key_type='RSA', key_length=1024):
self.collision_key = False
self.tries = 0
self.gpg = gpg
self.gpg_homedir_num = 0
self.keyid = keyid
self.new_gpg_homedir()
self.input = self.gpg.gen_key_input(name_real=name_real, name_email=name_email, name_comment=name_comment, key_type=key_type, key_length=key_length)
def new_gpg_homedir(self):
self.gpg_homedir_num += 1
self.gpg = gnupg.GPG(gnupghome='{0}/homedir_brute_force_keyid/{1}'.format(cwd, self.gpg_homedir_num), gpgbinary=cwd+'/lib/gnupg/g10/gpg', verbose=False)
class BruteForceKeyID(threading.Thread):
def __init__(self, common):
threading.Thread.__init__(self)
@ -47,9 +53,13 @@ class BruteForceKeyID(threading.Thread): @@ -47,9 +53,13 @@ class BruteForceKeyID(threading.Thread):
except:
keys_per_sec = 0
sys.stdout.write('\r[ {0} seconds ] [ {1} tries ] [ keys per second: {2} ] '.format(time_diff, self.common.tries, keys_per_sec))
sys.stdout.write('\r[ seconds: {0} ] [ tries: {1} ] [ keys per second: {2} ] [ gpg homedirs: {3}] '.format(time_diff, self.common.tries, keys_per_sec, self.common.gpg_homedir_num))
sys.stdout.flush()
# only let gpg homedirs contain up to ~1000 keys, for performance reasons
if self.common.tries % 1000 == 0:
self.common.new_gpg_homedir()
time_diff = int(time() - self.start_time)
sys.stdout.write('\nRan in {0} seconds\n'.format(time_diff))
@ -57,8 +67,7 @@ if __name__ == '__main__': @@ -57,8 +67,7 @@ if __name__ == '__main__':
# todo: make the keyid and number of threads cli args
keyid = '99999999'
gpg = gnupg.GPG(gnupghome=cwd+'/homedir_brute_force_keyid', gpgbinary=cwd+'/lib/gnupg/g10/gpg', verbose=False)
common = BruteForceKeyID_Common(gpg, keyid=keyid, name_real='Test Key', name_email='testkey@micahflee.com')
common = BruteForceKeyID_Common(keyid=keyid, name_real='Test Key', name_email='testkey@micahflee.com')
sys.stdout.write('Brute forcing key id {0}\n'.format(keyid))

Loading…
Cancel
Save