Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bc596d4e
authored
Feb 06, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
laborclient: Fixed enc.py
parent
a8d35c33
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
21 deletions
+27
-21
miscellaneous/laborclient/enc.pl
+11
-3
miscellaneous/laborclient/enc.py
+16
-18
No files found.
miscellaneous/laborclient/enc.pl
View file @
bc596d4e
...
@@ -13,6 +13,7 @@ $::dummyString = "{{{{";
...
@@ -13,6 +13,7 @@ $::dummyString = "{{{{";
#
#
my
$password
=
@ARGV
[
0
];
my
$password
=
@ARGV
[
0
];
print
$password
,
"\n"
;
print
$password
,
"\n"
;
print
encodePassword
(
$password
),
"\n"
;
my
$scrambled_string
=
scrambleString
(
$password
);
my
$scrambled_string
=
scrambleString
(
$password
);
print
$scrambled_string
,
"\n"
;
print
$scrambled_string
,
"\n"
;
...
@@ -83,7 +84,7 @@ sub getRandomValidCharFromList
...
@@ -83,7 +84,7 @@ sub getRandomValidCharFromList
my
$tm
=
localtime
;
my
$tm
=
localtime
;
my
$k
=
(
$tm
->
sec
);
my
$k
=
(
$tm
->
sec
);
return
0
;
return
getvalidCharList
(
0
)
;
}
}
...
@@ -100,6 +101,7 @@ sub scrambleString
...
@@ -100,6 +101,7 @@ sub scrambleString
if
(
length
(
$str
)
<
32
)
if
(
length
(
$str
)
<
32
)
{
{
$sRet
.=
$::dummyString
;
$sRet
.=
$::dummyString
;
print
"Added dummy $sRet\n"
;
}
}
for
(
my
$iR
=
(
length
(
$str
)
-
1
);
$iR
>=
0
;
$iR
--
)
for
(
my
$iR
=
(
length
(
$str
)
-
1
);
$iR
>=
0
;
$iR
--
)
...
@@ -108,32 +110,38 @@ sub scrambleString
...
@@ -108,32 +110,38 @@ sub scrambleString
#Reverse string.
#Reverse string.
#
#
$sRet
.=
substr
(
$str
,
$iR
,
1
);
$sRet
.=
substr
(
$str
,
$iR
,
1
);
print
"Reverse: $sRet\n"
;
}
}
if
(
length
(
$sRet
)
<
32
)
if
(
length
(
$sRet
)
<
32
)
{
{
$sRet
.=
$::dummyString
;
$sRet
.=
$::dummyString
;
print
"Added dummy2 $sRet\n"
;
}
}
my
$app
=
getRandomValidCharFromList
();
my
$app
=
getRandomValidCharFromList
();
print
"Random valid char: $app\n"
;
my
$k
=
ord
(
$app
);
my
$k
=
ord
(
$app
);
my
$l
=
$k
+
length
(
$sRet
)
-
2
;
my
$l
=
$k
+
length
(
$sRet
)
-
2
;
$sRet
=
$app
.
$sRet
;
$sRet
=
$app
.
$sRet
;
print
"Random $sRet\n\n"
;
for
(
my
$i1
=
1
;
$i1
<
length
(
$sRet
);
$i1
++
)
for
(
my
$i1
=
1
;
$i1
<
length
(
$sRet
);
$i1
++
)
{
{
my
$app2
=
substr
(
$sRet
,
$i1
,
1
);
my
$app2
=
substr
(
$sRet
,
$i1
,
1
);
print
"For cycle app2= $app2\n}"
;
my
$j
=
findCharInList
(
$app2
);
my
$j
=
findCharInList
(
$app2
);
print
"For cícle j= $j\n"
;
if
(
$j
==
-
1
)
if
(
$j
==
-
1
)
{
{
return
$sRet
;
return
$sRet
;
}
}
my
$i
=
(
$j
+
$l
*
(
$i1
+
1
))
%
$
::numValidCharList
;
my
$i
=
(
$j
+
$l
*
(
$i1
+
1
))
%
$
::numValidCharList
;
print
"For cícle: i= $i\n"
;
my
$car
=
getvalidCharList
(
$i
);
my
$car
=
getvalidCharList
(
$i
);
$sRet
=
substr_replace
(
$sRet
,
$car
,
$i1
,
1
);
$sRet
=
substr_replace
(
$sRet
,
$car
,
$i1
,
1
);
print
"For cycle sRet: $sRet\n\n"
}
}
my
$c
=
(
ord
(
getRandomValidCharFromList
()))
+
2
;
my
$c
=
(
ord
(
getRandomValidCharFromList
()))
+
2
;
...
...
miscellaneous/laborclient/enc.py
View file @
bc596d4e
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
sys
import
sys
import
random
import
random
import
re
import
re
from
xml.sax.saxutils
import
escape
numValidCharList
=
85
numValidCharList
=
85
dummyString
=
"{{{{"
dummyString
=
"{{{{"
...
@@ -51,8 +52,8 @@ def findCharInList(c):
...
@@ -51,8 +52,8 @@ def findCharInList(c):
return
i
return
i
def
getRandomValidCharFromList
():
def
getRandomValidCharFromList
():
#
return getvalidCharList(random.randint(0,60))
return
getvalidCharList
(
random
.
randint
(
0
,
60
))
return
getvalidCharList
(
0
)
#
return getvalidCharList(0)
def
scrambleString
(
s
):
def
scrambleString
(
s
):
...
@@ -63,24 +64,31 @@ def scrambleString(s):
...
@@ -63,24 +64,31 @@ def scrambleString(s):
strp
=
encodePassword
(
s
)
strp
=
encodePassword
(
s
)
if
len
(
strp
)
<
32
:
if
len
(
strp
)
<
32
:
sRet
+=
dummyString
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
]
sRet
+=
strp
[
iR
:
iR
+
1
]
#print "Reverse: "+sRet
if
len
(
sRet
)
<
32
:
if
len
(
sRet
)
<
32
:
sRet
+=
dummyString
sRet
+=
dummyString
#print "Added dummy2 "+sRet
app
=
getRandomValidCharFromList
()
app
=
getRandomValidCharFromList
()
#print "Random valid char: "+app
k
=
ord
(
app
)
k
=
ord
(
app
)
l
=
k
+
len
(
sRet
)
-
2
l
=
k
+
len
(
sRet
)
-
2
sRet
=
app
+
sRet
sRet
=
app
+
sRet
#print "Random "+sRet+"\n"
for
i1
in
range
(
1
,
len
(
sRet
)):
for
i1
in
range
(
1
,
len
(
sRet
)):
app2
=
sRet
[
i1
:
i1
+
1
]
app2
=
sRet
[
i1
:
i1
+
1
]
#print "For cycle app2= "+str(app2)
j
=
findCharInList
(
app2
)
j
=
findCharInList
(
app2
)
#print "For cycle j= "+str(j)
if
j
==
-
1
:
if
j
==
-
1
:
return
sRet
return
sRet
i
=
(
j
+
l
*
(
i1
+
1
))
%
numValidCharList
i
=
(
j
+
l
*
(
i1
+
1
))
%
numValidCharList
#print "For cycle i= "+str(i)
car
=
getvalidCharList
(
i
)
car
=
getvalidCharList
(
i
)
sRet
=
substr_replace
(
sRet
,
car
,
i1
,
1
)
sRet
=
substr_replace
(
sRet
,
car
,
i1
,
1
)
#print "For cycle sRet: "+sRet+"\n"
c
=
(
ord
(
getRandomValidCharFromList
()))
+
2
c
=
(
ord
(
getRandomValidCharFromList
()))
+
2
c2
=
chr
(
c
)
c2
=
chr
(
c
)
sRet
=
sRet
+
c2
sRet
=
sRet
+
c2
...
@@ -88,18 +96,7 @@ def scrambleString(s):
...
@@ -88,18 +96,7 @@ def scrambleString(s):
def
URLEncode
(
url
):
def
URLEncode
(
url
):
theURL
=
url
return
escape
(
url
)
#theURL =~ s/&/&/g;
url
=
re
.
sub
(
"&"
,
"&"
,
url
)
#theURL =~ s/\"\"/"/g;
url
=
re
.
sub
(
"
\"
"
,
"""
,
url
)
#theURL =~ s/\'/'/g;
url
=
re
.
sub
(
"
\"
"
,
"""
,
url
)
#theURL =~ s/</</g;
url
=
re
.
sub
(
"<"
,
"<"
,
url
)
#theURL =~ s/>/>/g;
url
=
re
.
sub
(
">"
,
">"
,
url
)
return
theURL
def
substr_replace
(
in_str
,
ch
,
pos
,
qt
):
def
substr_replace
(
in_str
,
ch
,
pos
,
qt
):
clist
=
list
(
in_str
)
clist
=
list
(
in_str
)
...
@@ -116,6 +113,7 @@ def substr_replace(in_str,ch,pos,qt):
...
@@ -116,6 +113,7 @@ def substr_replace(in_str,ch,pos,qt):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
password
=
sys
.
argv
[
0
]
password
=
sys
.
argv
[
1
]
print
password
print
password
#print encodePassword(password)
print
scrambleString
(
password
)
print
scrambleString
(
password
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment