Skip to content

Instantly share code, notes, and snippets.

@Taiiwo
Last active December 31, 2015 19:19
Show Gist options
  • Save Taiiwo/8033264 to your computer and use it in GitHub Desktop.
Save Taiiwo/8033264 to your computer and use it in GitHub Desktop.
This script slowly cracks a cypher.
import urllib2
def docrypt(password):
# insert hash here
orig = "sl/iECN%22ttp%3AP%20%3Chwxh.Iw3g/TR%22.Prhl/l%201//xhtTD/D1.%20r%20anionaOsTtdxa%22/%3EmhtmlLmY%3CmwDs%20%3D%22p%3A//Dh%20twxB3T.o1999nrH/h%3ETlC%22%3E%3Chea%22mtmmea%3CXmehttpot%20%20qTlvi%3D%22tentTC/nytC%22E%20cent%3DioLtes0/-ht%20chammn%3Bem/uMtf%20/%3Emt-/%22%3C0wtole9%2033g%3E/11im0t%20311%3C/m3m9ttt%3EWmmtyleamlsy%3Ed%3D1%22t/cssoe%20tm%20n%3C%21%21-mbodn-wm%7BdwmU%09bgroula/k-0mlDor00008%3Ad%23%3Bdmmr%7Dmody%2C1m-b%2C%3Ai%20m%7Bmcolo%20m-%09%20meF3FFmmm%7D%3CF%22%3Bm%3Et%3E.mmstylxmr/%3Cb%3De/admmmmm%3Emmoii%3Ewmmiv%20acm%20dgm1%22tcer%22%3Em%20nte%20%20ep-%3E133%200m1%20%201me3t3%20%3C/p%3Em9%221mpm%3Clp%3Esp%3B%3CF%26yb%3E%3Bmm.%20%20%26nbs%3C%3Cn%3E%3Cmo%3Etmmdiv%3Emm0/mtmbmodmm%3C/%3Cytmm%3Dhmummc/F-tmrm%20%3Cpppm9mp-//pte0%20%3Cxm11tmhd%3C/%20%3C%20%20%3Etmmn%23hynl%3Ellm"
#urldeode:
orig = urllib2.unquote(orig)
# Here is the algorithm from the js
passnum = len(orig) % len(str(password))
i = 0
while i >= 0:
passnum -= 1
if passnum <= -1 or passnum >= len(str(password)) - 1:
passnum = len(str(password -1))
pos1 = i
pos2 = i + int(str(password)[passnum-1])
if pos2 >= len(orig):
continue
char1 = orig[pos1]
char2 = orig[pos2]
orig = list(orig)
orig[pos2] = char1
orig[pos1] = char2
i -= 1
orig1 = ""
i = 0
while i < len(orig):
orig1 = orig1 + orig[i]
i += 1
orig1 = orig1.replace('/mmm/g','\r\n')
return orig1
if __name__ == "__main__":
# You can start at whatever number you want.
# as of writing I'm at about 50m, so there's
# no point searching under that if you trust
# me
count = 1
# This simply counts up numbers and tries them
# as passwords. This works for text passwords
# too as the js just converts chars to their
# ASCII value anyway, so we're still going to
# decrypt it, even if we don't have the intended
# password
while 1:
output = docrypt(count)
print count
if '3301' in output or 'alhok' in output or 'http://' in output or 'https://' in output:
print count + '\n\n\n' + output + '\n\n\n'
f = open ('passwords.log','a')
f.write(count + '\n' + output + '\n')
count += 1
@Taiiwo
Copy link
Author

Taiiwo commented Dec 20, 2013

I think line 31 causes some problems as the JS seems strange, and I don't know how to implement that in Python.
From what I can see, it's only applying the cipher to the passwords length at the start of the ciphertext.

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