Skip to content

Instantly share code, notes, and snippets.

@sonickun
Created July 31, 2016 07:37
Show Gist options
  • Select an option

  • Save sonickun/2d382bde312ea6a15d422ec3e264c168 to your computer and use it in GitHub Desktop.

Select an option

Save sonickun/2d382bde312ea6a15d422ec3e264c168 to your computer and use it in GitHub Desktop.
katagaitai 勉強会 rev_easy crackme
def calc_hash(key):
h = 0x539
target = 0xEF2E3558
for k in key:
h += (h<<5) + ord(k)
h &= 0xFFFFFFFF
return abs(target - h)
charset = [chr(i) for i in range(0x21,0x7e)]
key = ""
MAX_LEN = 10
while True:
min_diff = 0xFFFFFFFF
min_chr = None
tmp_key = key
for c in charset:
for i in range(1, MAX_LEN-len(key)):
test = tmp_key + (c * i)
# print test
diff = calc_hash(test)
if diff < min_diff:
min_diff = diff
min_chr = c
key = tmp_key + min_chr
print "min_diff: %d, key: %s" % (min_diff, key)
if min_diff == 0:
print "Gotcha!:", key
break
if len(key) == MAX_LEN:
print "key not found :("
break
@sonickun
Copy link
Copy Markdown
Author

➜ time python crackme_solver.py
min_diff: 8561025, key: T
min_diff: 8561025, key: TT
min_diff: 138902, key: TTI
min_diff: 9338, key: TTIE
min_diff: 354, key: TTIEM
min_diff: 14, key: TTIEMW
min_diff: 0, key: TTIEMWe
Gotcha!: TTIEMWe
python crackme_solver.py 0.06s user 0.06s system 81% cpu 0.152 total
➜ nc 45.32.49.214 54321
Enter registration code: TTIEMWe
Thank you, valued customer!
Your key is: day 145: they still do not realize this software sucks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment