Commit bc596d4e by tarokkk

laborclient: Fixed enc.py

parent a8d35c33
......@@ -13,6 +13,7 @@ $::dummyString = "{{{{";
#
my $password = @ARGV[0];
print $password,"\n";
print encodePassword($password),"\n";
my $scrambled_string = scrambleString($password);
print $scrambled_string,"\n";
......@@ -83,7 +84,7 @@ sub getRandomValidCharFromList
my $tm = localtime;
my $k = ($tm->sec);
return 0;
return getvalidCharList(0);
}
......@@ -100,6 +101,7 @@ sub scrambleString
if (length($str) < 32)
{
$sRet .= $::dummyString;
print "Added dummy $sRet\n";
}
for ( my $iR = (length($str) - 1); $iR >= 0; $iR--)
......@@ -108,32 +110,38 @@ sub scrambleString
#Reverse string.
#
$sRet .= substr($str,$iR,1);
print "Reverse: $sRet\n";
}
if (length($sRet) < 32)
{
$sRet .= $::dummyString;
print "Added dummy2 $sRet\n";
}
my $app=getRandomValidCharFromList();
print "Random valid char: $app\n";
my $k=ord($app);
my $l=$k + length($sRet) -2;
$sRet= $app.$sRet;
print "Random $sRet\n\n";
for (my $i1 = 1; $i1 < length($sRet); $i1++)
{
my $app2=substr($sRet,$i1,1);
print "For cycle app2= $app2\n}";
my $j = findCharInList($app2);
print "For cícle j= $j\n";
if ($j == -1)
{
return $sRet;
}
my $i = ($j + $l * ($i1 + 1)) % $::numValidCharList;
print "For cícle: i= $i\n";
my $car=getvalidCharList($i);
$sRet=substr_replace($sRet,$car,$i1,1);
print "For cycle sRet: $sRet\n\n"
}
my $c = (ord(getRandomValidCharFromList())) + 2;
......
......@@ -3,6 +3,7 @@
import sys
import random
import re
from xml.sax.saxutils import escape
numValidCharList = 85
dummyString = "{{{{"
......@@ -51,8 +52,8 @@ def findCharInList(c):
return i
def getRandomValidCharFromList():
#return getvalidCharList(random.randint(0,60))
return getvalidCharList(0)
return getvalidCharList(random.randint(0,60))
#return getvalidCharList(0)
def scrambleString(s):
......@@ -63,24 +64,31 @@ def scrambleString(s):
strp = encodePassword(s)
if len(strp) < 32:
sRet += dummyString
for iR in reversed(range(len(strp)-1)):
#print "Added dummy "+sRet
for iR in reversed(range(len(strp))):
sRet += strp[iR:iR+1]
#print "Reverse: "+sRet
if len(sRet) < 32:
sRet += dummyString
#print "Added dummy2 "+sRet
app = getRandomValidCharFromList()
#print "Random valid char: "+app
k = ord(app)
l = k + len(sRet) - 2
sRet = app + sRet
#print "Random "+sRet+"\n"
for i1 in range(1, len(sRet)):
app2 = sRet[i1 : i1 + 1]
#print "For cycle app2= "+str(app2)
j = findCharInList(app2)
#print "For cycle j= "+str(j)
if j == -1:
return sRet
i = (j + l * (i1 + 1)) % numValidCharList
#print "For cycle i= "+str(i)
car = getvalidCharList(i)
sRet = substr_replace(sRet,car,i1,1)
#print "For cycle sRet: "+sRet+"\n"
c = (ord(getRandomValidCharFromList())) + 2
c2 = chr(c)
sRet = sRet + c2
......@@ -88,18 +96,7 @@ def scrambleString(s):
def URLEncode(url):
theURL = url
#theURL =~ s/&/&amp;/g;
url = re.sub("&","&amp",url)
#theURL =~ s/\"\"/&quot;/g;
url = re.sub("\"","&quot",url)
#theURL =~ s/\'/&#039;/g;
url = re.sub("\"","&quot",url)
#theURL =~ s/</&lt;/g;
url = re.sub("<","&lt",url)
#theURL =~ s/>/&gt;/g;
url = re.sub(">","&gt",url)
return theURL
return escape(url)
def substr_replace(in_str,ch,pos,qt):
clist = list(in_str)
......@@ -116,6 +113,7 @@ def substr_replace(in_str,ch,pos,qt):
if __name__ == "__main__":
password = sys.argv[0]
password = sys.argv[1]
print password
#print encodePassword(password)
print scrambleString(password)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment