Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93b7994

Browse files
committed
added new cloaking functionality for shell scripts
1 parent a78bf9a commit 93b7994

5 files changed

Lines changed: 200 additions & 0 deletions

File tree

extra/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id: $
5+
6+
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
7+
8+
Copyright (c) 2007-2009 Bernardo Damele A. G. <[email protected]>
9+
Copyright (c) 2006 Daniele Bellucci <[email protected]>
10+
11+
sqlmap is free software; you can redistribute it and/or modify it under
12+
the terms of the GNU General Public License as published by the Free
13+
Software Foundation version 2 of the License.
14+
15+
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
16+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18+
details.
19+
20+
You should have received a copy of the GNU General Public License along
21+
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
22+
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23+
"""
24+
25+
pass

extra/cloak/README.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
To use cloak.py you need to pass it the original file,
2+
and optionally the output file name.
3+
4+
Example:
5+
6+
$ python ./cloak.py -i backdoor.asp -o backdoor.asp_
7+
8+
This will create an encrypted and compressed binary file backdoor.asp_.
9+
10+
Such file can then be converted to its original form by using the -d
11+
functionality of the cloak.py program:
12+
13+
$ python ./cloak.py -d -i backdoor.asp_ -o backdoor.asp
14+
15+
If you skip the output file name, general rule is that the compressed
16+
file names are suffixed with the character '_', while the original is
17+
get by skipping the last character. So, that means that the upper
18+
examples can also be written in the following form:
19+
20+
$ python ./cloak.py -i backdoor.asp
21+
22+
$ python ./cloak.py -d -i backdoor.asp_

extra/cloak/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id: $
5+
6+
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
7+
8+
Copyright (c) 2007-2009 Bernardo Damele A. G. <[email protected]>
9+
Copyright (c) 2006 Daniele Bellucci <[email protected]>
10+
11+
sqlmap is free software; you can redistribute it and/or modify it under
12+
the terms of the GNU General Public License as published by the Free
13+
Software Foundation version 2 of the License.
14+
15+
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
16+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18+
details.
19+
20+
You should have received a copy of the GNU General Public License along
21+
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
22+
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23+
"""
24+
25+
pass

extra/cloak/__init__.py.bak

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
$Id: __init__.py 516 2009-02-19 21:55:19Z inquisb $
5+
6+
This file is part of the sqlmap project, http://sqlmap.sourceforge.net.
7+
8+
Copyright (c) 2007-2009 Bernardo Damele A. G. <[email protected]>
9+
Copyright (c) 2006 Daniele Bellucci <[email protected]>
10+
11+
sqlmap is free software; you can redistribute it and/or modify it under
12+
the terms of the GNU General Public License as published by the Free
13+
Software Foundation version 2 of the License.
14+
15+
sqlmap is distributed in the hope that it will be useful, but WITHOUT ANY
16+
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17+
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18+
details.
19+
20+
You should have received a copy of the GNU General Public License along
21+
with sqlmap; if not, write to the Free Software Foundation, Inc., 51
22+
Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23+
"""
24+
25+
pass

extra/cloak/cloak.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
cloak.py - Simple file encryption and/or compression utility
5+
Copyright (C) 2010 Miroslav Stampar, Bernardo Damele A. G.
6+
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General Public
19+
License along with this library; if not, write to the Free Software
20+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
"""
22+
23+
import os
24+
import sys
25+
import bz2
26+
27+
from optparse import OptionError
28+
from optparse import OptionParser
29+
30+
def hideAscii(data):
31+
retVal = ""
32+
for i in xrange(len(data)):
33+
if ord(data[i]) < 128:
34+
retVal += chr(ord(data[i]) ^ 127)
35+
else:
36+
retVal += data[i]
37+
38+
return retVal
39+
40+
def cloak(inputFile):
41+
retVal = ""
42+
43+
f = open(inputFile, 'rb')
44+
original = f.read()
45+
f.close()
46+
47+
data = bz2.compress(original)
48+
49+
return hideAscii(data)
50+
51+
def decloak(inputFile):
52+
retVal = ""
53+
54+
f = open(inputFile, 'rb')
55+
original = f.read()
56+
f.close()
57+
58+
data = bz2.decompress(hideAscii(original))
59+
60+
return data
61+
62+
def main():
63+
usage = '%s [-d] -i <input file> [-o <output file>]' % sys.argv[0]
64+
parser = OptionParser(usage=usage, version='0.1')
65+
66+
try:
67+
parser.add_option('-d', dest='decrypt', action="store_true", help='Decrypt')
68+
parser.add_option('-i', dest='inputFile', help='Input file')
69+
parser.add_option('-o', dest='outputFile', help='Output file')
70+
71+
(args, _) = parser.parse_args()
72+
73+
if not args.inputFile:
74+
parser.error('Missing the input file, -h for help')
75+
76+
except (OptionError, TypeError), e:
77+
parser.error(e)
78+
79+
if args.inputFile == '*':
80+
pass
81+
elif not os.path.isfile(args.inputFile):
82+
print 'ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile
83+
sys.exit(1)
84+
85+
if not args.decrypt:
86+
data = cloak(args.inputFile)
87+
else:
88+
data = decloak(args.inputFile)
89+
90+
if not args.outputFile:
91+
if not args.decrypt:
92+
args.outputFile = args.inputFile + '_'
93+
else:
94+
args.outputFile = args.inputFile[:-1]
95+
96+
fpOut = open(args.outputFile, 'wb')
97+
sys.stdout = fpOut
98+
sys.stdout.write(data)
99+
sys.stdout.close()
100+
101+
102+
if __name__ == '__main__':
103+
main()

0 commit comments

Comments
 (0)