[FreeNX-kNX] nxpassgen ported to python
freenx
freenx at skolesys.dk
Wed Sep 12 22:14:18 UTC 2007
I have ported the nx password scrambler
(http://www.nomachine.com/ar/view.php?ar_id=AR01C00125) to python script as
I needed it for single sign-on functionality.
I don't know if anyone else might need this. Anyway here it is:
nxpassgen.py:
-------------
import time
numValidCharList = 85
dummyString = '{{{{'
def encodePassword(p):
sPass = ':'
sTmp = ''
if not p:
return ''
for i in xrange(len(p)):
c = p[i]
sTmp = "%d:" % (ord(c) + i + 1)
sPass += sTmp
sTmp = ""
return sPass
validCharList = [
'!', '#', '$', '%', '&', '(', ')', '*', '+', '-',
'.', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', ':', ';', '<', '>', '?', '@', 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '[', ']', '_', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '{', '|', '}' ]
def findCharInList(c):
i = -1
for j in xrange(numValidCharList):
if validCharList[j] == c:
i = j
return i
return i
def getRandomValidCharFromList():
k = time.localtime()[5]
return validCharList[k]
def scrambleString(s):
sRet = ''
if not s:
return s
str = encodePassword(s)
if len(str) < 32:
str += dummyString
sRet = list(str)
sRet.reverse()
sRet = ''.join(sRet)
if len(sRet) < 32:
sRet += dummyString
k = getRandomValidCharFromList()
l = ord(k) + len(sRet) - 2
sRet = k + sRet
sRet_copy = sRet
sRet = sRet[0]
for i1 in xrange(1,len(sRet_copy)):
j = findCharInList(sRet_copy[i1])
if j == -1:
return s
i = (j + l * (i1 + 1)) % numValidCharList
sRet += validCharList[i]
c = ord(getRandomValidCharFromList()) + 2
sRet += chr(c)
return sRet
-------------------
More information about the FreeNX-kNX
mailing list