mirror of
https://github.com/autistic-symposium/sec-pentesting-toolkit.git
synced 2025-06-17 11:29:14 -04:00
some small fixes
This commit is contained in:
parent
56dec30f70
commit
ab70b811db
14 changed files with 196 additions and 0 deletions
41
Cryptography/md5/brute_force_hex_digest_chars.py
Normal file
41
Cryptography/md5/brute_force_hex_digest_chars.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
'''
|
||||
EXAMPLE FROM ASIS 2013, WITH THE CONCATENATED HASH:
|
||||
|
||||
7e1321b3c8423b30c1cb077a2e3ac4f0a2a551a6458a8de22446cc76d639a9e98fc42c6cddf9966db3b09e843650343578b04d5e377d298e78455efc5ca404d5f4c9385f1902f7334b00b9b4ecd164de8bf8854bebe108183caeb845c7676ae48fc42c6ddf9966db3b09e84365034357327a6c4304ad5938eaf0efb6cc3e53dc7ff9ea9a069bd793691c422fb818c07b
|
||||
|
||||
'''
|
||||
|
||||
import md5
|
||||
|
||||
|
||||
# the entire flag
|
||||
|
||||
m1 = '7e1321b3c8423b30c1cb077a2e3ac4f0'
|
||||
m2 = 'a2a551a6458a8de22446cc76d639a9e9'
|
||||
m3 = '8fc42c6ddf9966db3b09e84365034357'
|
||||
m4 = '8b04d5e3775d298e78455efc5ca404d5'
|
||||
m5 = 'f4c9385f1902f7334b00b9b4ecd164de'
|
||||
m6 = '8bf8854bebe108183caeb845c7676ae4'
|
||||
m7 = '8fc42c6ddf9966db3b09e84365034357'
|
||||
m8 = '327a6c4304ad5938eaf0efb6cc3e53dc'
|
||||
m9 = '7ff9ea9a069bd793691c422fb818c07b'
|
||||
|
||||
all = [m1, m2, m3, m4, m5, m6, m7, m8, m9]
|
||||
|
||||
for m in all:
|
||||
a = md5.md5(m)
|
||||
print "md5 object", a
|
||||
print "digest(): ", a.digest()
|
||||
print "hexdigest(): ", a.hexdigest()
|
||||
print
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# last part
|
||||
|
||||
for a in "abcdef0123456789":
|
||||
for b in "abcdef0123456789":
|
||||
if "7ff9ea9a069bd793691c422fb818c07b" == md5.md5('ASIS_' + a + b).hexdigest():
|
||||
print 'ASIS_' + a + b
|
11
Cryptography/sha/sha-256-bruteforce.py
Normal file
11
Cryptography/sha/sha-256-bruteforce.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
'''
|
||||
from asis 2013: The last crypto (binary numbers) was very puzzling. We couldn’t decipher it. But a few minutes before the CTF ending, we noticed we could brute-force the 6 missing characters offline, because in each task, there was a client-side verification with a sha-256 hash. For this task, the hash of the flag was 6307c5441ebac07051e3b90d53c3106230dd9aa128601dcd5f63efcf824ce1ba. A quick brute-force in Python revealed us the missing chars, and therefore, the final flag to submit!
|
||||
'''
|
||||
|
||||
|
||||
import hashlib, itertools
|
||||
hash = '6307c5441ebac07051e3b90d53c3106230dd9aa128601dcd5f63efcf824ce1ba'
|
||||
ch = 'abcdef0123456789'
|
||||
for a, b, c, d, e, f in itertools.product(ch, ch, ch, ch, ch, ch):
|
||||
if hashlib.sha256('ASIS_a9%s00f497f2eaa4372a7fc21f0d' % (a + b + c + d + e + f)).hexdigest() == hash:
|
||||
print 'ASIS_a9%s00f497f2eaa4372a7fc21f0d' % (a + b + c + d + e + f)
|
24
Cryptography/sha/sha-256-bruteforce_remove_123456789x.py
Normal file
24
Cryptography/sha/sha-256-bruteforce_remove_123456789x.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
'''
|
||||
from asis 2013
|
||||
'''
|
||||
|
||||
from itertools import permutations
|
||||
from hashlib import sha256
|
||||
|
||||
def test(s):
|
||||
e = '9f2a579716af14400c9ba1de8682ca52c17b3ed4235ea17ac12ae78ca24876ef'
|
||||
return sha256('ASIS_' + s).hexdigest() == e
|
||||
|
||||
m = '3c6a1c371b381c943065864b95ae5546'
|
||||
s = '12456789x'
|
||||
for p in permutations(s):
|
||||
def f(sub, c):
|
||||
if c in sub:
|
||||
return sub[c]
|
||||
else:
|
||||
return c
|
||||
sub = {c : d for c, d in zip(s, p)}
|
||||
z = ''.join(f(sub, c) for c in m)
|
||||
if test(z):
|
||||
print z
|
||||
break
|
Loading…
Add table
Add a link
Reference in a new issue