|
Message-ID: <4C865751.2040001@16systems.com> Date: Tue, 07 Sep 2010 11:16:33 -0400 From: Brad Tilley <brad@...ystems.com> To: john-users@...ts.openwall.com Subject: Re: patch of JtR's netscreen.py script, now version 2.01 Robert Harris wrote: > John-Users, > > > > I made a minor change to the current netscreen python script, netscreen.py > in the "/run" directory > > > > The file initially looked ok, but gave errors when ran. > > > > The enhanced version had a "tab" in it that caused the problem (since > indention in Python is very important). > > > > Please note this and previous versions do not run in Python version 3.x > > > > I'm thinking about converting this script into a Perl script, so we don't > have separate versions, one for python 2.x and one for python 3.x] I believe I have the script working in Python 2.4, 2.6 and 3.x: $ python2.4 netscreen.py 123 123 123:123$nAU8NurYC15Kcb5IasHCAJOt2QEArn $ python2.6 netscreen.py 123 123 netscreen.py:14: DeprecationWarning: the md5 module is deprecated; use hashlib instead import md5 123:123$nAU8NurYC15Kcb5IasHCAJOt2QEArn $ python3 netscreen.py 123 123 123:123$nAU8NurYC15Kcb5IasHCAJOt2QEArn Here is the script (only tested on Debian Linux): # netscreen.py # Generate passwords in netscreen format. import sys def net(user, password): b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" middle = "Administration Tools" s = "%s:%s:%s" % (user, middle, password) # For versions of Python 2.5 and older (Python will complain on 2.6 or higher) if sys.version_info[0] == 2 and sys.version_info[0] < 6: import md5 m = md5.new(s).digest() else: import hashlib m = hashlib.md5(s.encode('latin_1')).digest() narray = [] for i in range(8): if sys.version_info[0] == 2: n1 = ord(m[2*i]) n2 = ord(m[2*i+1]) narray.append( (n1<<8 & 0xff00) | (n2 & 0xff) ) if sys.version_info[0] == 3: n1 = ord(chr(m[2*i])) n2 = ord(chr(m[2*i+1])) narray.append( (n1<<8 & 0xff00) | (n2 & 0xff) ) res = "" for i in narray: p1 = i >> 12 & 0xf p2 = i >> 6 & 0x3f p3 = i & 0x3f res = res + b64[p1] + b64[p2] + b64[p3] for c, n in zip("nrcstn", [0, 6, 12, 17, 23, 29]): res = res[:n] + c + res[n:] return res if __name__ == '__main__': user = sys.argv[1] password = sys.argv[2] ciphertext = net(user,password) print(("%s:%s$%s" % (user,user,ciphertext)))
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.