[FreeNX-kNX] nxpassgen ported to python

freenx freenx at skolesys.dk
Thu Sep 13 12:02:47 UTC 2007


By the way - if the scrambled password is to be used in an .nxs file then
remember to replace illegal XML characters with there escaped version:

&  : &
<  : <
"  : " 
'  : '

Best regards Jakob simon-Gaarde


On Thu, 13 Sep 2007 00:14:18 +0200, freenx <freenx at skolesys.dk> wrote:
> 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
> -------------------
> 
> 
> ________________________________________________________________
>      Were you helped on this list with your FreeNX problem?
>     Then please write up the solution in the FreeNX Wiki/FAQ:
>   http://openfacts.berlios.de/index-en.phtml?title=FreeNX_FAQ
>          Don't forget to check the NX Knowledge Base:
>                  http://www.nomachine.com/kb/
> 
> ________________________________________________________________
>        FreeNX-kNX mailing list --- FreeNX-kNX at kde.org
>       https://mail.kde.org/mailman/listinfo/freenx-knx
> ________________________________________________________________




More information about the FreeNX-kNX mailing list