Skip to content

Commit db3bed3

Browse files
committed
Update related to the last commit
1 parent 7672b9a commit db3bed3

File tree

29 files changed

+140
-116
lines changed

29 files changed

+140
-116
lines changed

extra/cloak/cloak.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
See the file 'LICENSE' for copying permission
88
"""
99

10+
from __future__ import print_function
11+
1012
import os
1113
import sys
1214
import zlib
@@ -38,7 +40,7 @@ def decloak(inputFile=None, data=None):
3840
try:
3941
data = zlib.decompress(hideAscii(data))
4042
except:
41-
print 'ERROR: the provided input file \'%s\' does not contain valid cloaked content' % inputFile
43+
print('ERROR: the provided input file \'%s\' does not contain valid cloaked content' % inputFile)
4244
sys.exit(1)
4345
finally:
4446
f.close()
@@ -63,7 +65,7 @@ def main():
6365
parser.error(e)
6466

6567
if not os.path.isfile(args.inputFile):
66-
print 'ERROR: the provided input file \'%s\' is non existent' % args.inputFile
68+
print('ERROR: the provided input file \'%s\' is non existent' % args.inputFile)
6769
sys.exit(1)
6870

6971
if not args.decrypt:

extra/dbgtool/dbgtool.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
See the file 'LICENSE' for copying permission
88
"""
99

10+
from __future__ import print_function
11+
1012
import os
1113
import sys
1214
import struct
@@ -19,7 +21,7 @@ def convert(inputFile):
1921
fileSize = fileStat.st_size
2022

2123
if fileSize > 65280:
22-
print "ERROR: the provided input file '%s' is too big for debug.exe" % inputFile
24+
print("ERROR: the provided input file '%s' is too big for debug.exe" % inputFile)
2325
sys.exit(1)
2426

2527
script = "n %s\nr cx\n" % os.path.basename(inputFile.replace(".", "_"))
@@ -59,7 +61,7 @@ def convert(inputFile):
5961

6062
def main(inputFile, outputFile):
6163
if not os.path.isfile(inputFile):
62-
print "ERROR: the provided input file '%s' is not a regular file" % inputFile
64+
print("ERROR: the provided input file '%s' is not a regular file" % inputFile)
6365
sys.exit(1)
6466

6567
script = convert(inputFile)
@@ -70,7 +72,7 @@ def main(inputFile, outputFile):
7072
sys.stdout.write(script)
7173
sys.stdout.close()
7274
else:
73-
print script
75+
print(script)
7476

7577
if __name__ == "__main__":
7678
usage = "%s -i <input file> [-o <output file>]" % sys.argv[0]

extra/safe2bin/safe2bin.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
See the file 'LICENSE' for copying permission
88
"""
99

10+
from __future__ import print_function
11+
1012
import binascii
1113
import re
1214
import string
@@ -112,7 +114,7 @@ def main():
112114
parser.error(e)
113115

114116
if not os.path.isfile(args.inputFile):
115-
print 'ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile
117+
print('ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile)
116118
sys.exit(1)
117119

118120
f = open(args.inputFile, 'r')

extra/shutils/duplicates.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
# Removes duplicate entries in wordlist like files
77

8+
from __future__ import print_function
9+
810
import sys
911

1012
if len(sys.argv) > 0:
@@ -17,7 +19,7 @@
1719
str.encode(item)
1820
if item in items:
1921
if item:
20-
print item
22+
print(item)
2123
else:
2224
items.append(item)
2325
except:

extra/shutils/newlines.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Runs pylint on all python scripts found in a directory tree
44
# Reference: http://rowinggolfer.blogspot.com/2009/08/pylint-recursively.html
55

6+
from __future__ import print_function
7+
68
import os
79
import sys
810

@@ -12,16 +14,16 @@ def check(filepath):
1214

1315
if "\n\n\n" in content:
1416
index = content.find("\n\n\n")
15-
print filepath, repr(content[index - 30:index + 30])
17+
print(filepath, repr(content[index - 30:index + 30]))
1618

1719
if __name__ == "__main__":
1820
try:
1921
BASE_DIRECTORY = sys.argv[1]
2022
except IndexError:
21-
print "no directory specified, defaulting to current working directory"
23+
print("no directory specified, defaulting to current working directory")
2224
BASE_DIRECTORY = os.getcwd()
2325

24-
print "looking for *.py scripts in subdirectories of ", BASE_DIRECTORY
26+
print("looking for *.py scripts in subdirectories of '%s'" % BASE_DIRECTORY)
2527
for root, dirs, files in os.walk(BASE_DIRECTORY):
2628
if any(_ in root for _ in ("extra", "thirdparty")):
2729
continue

extra/shutils/pylint.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Runs pylint on all python scripts found in a directory tree
44
# Reference: http://rowinggolfer.blogspot.com/2009/08/pylint-recursively.html
55

6+
from __future__ import print_function
7+
68
import os
79
import re
810
import sys
@@ -17,26 +19,26 @@ def check(module):
1719

1820
if module[-3:] == ".py":
1921

20-
print "CHECKING ", module
22+
print("CHECKING ", module)
2123
pout = os.popen("pylint --rcfile=/dev/null %s" % module, 'r')
2224
for line in pout:
2325
if re.match(r"\AE:", line):
24-
print line.strip()
26+
print(line.strip())
2527
if __RATING__ and "Your code has been rated at" in line:
26-
print line
28+
print(line)
2729
score = re.findall(r"\d.\d\d", line)[0]
2830
total += float(score)
2931
count += 1
3032

3133
if __name__ == "__main__":
3234
try:
33-
print sys.argv
35+
print(sys.argv)
3436
BASE_DIRECTORY = sys.argv[1]
3537
except IndexError:
36-
print "no directory specified, defaulting to current working directory"
38+
print("no directory specified, defaulting to current working directory")
3739
BASE_DIRECTORY = os.getcwd()
3840

39-
print "looking for *.py scripts in subdirectories of ", BASE_DIRECTORY
41+
print("looking for *.py scripts in subdirectories of ", BASE_DIRECTORY)
4042
for root, dirs, files in os.walk(BASE_DIRECTORY):
4143
if any(_ in root for _ in ("extra", "thirdparty")):
4244
continue
@@ -45,6 +47,6 @@ def check(module):
4547
check(filepath)
4648

4749
if __RATING__:
48-
print "==" * 50
49-
print "%d modules found" % count
50-
print "AVERAGE SCORE = %.02f" % (total / count)
50+
print("==" * 50)
51+
print("%d modules found" % count)
52+
print("AVERAGE SCORE = %.02f" % (total / count))

extra/shutils/regressiontest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
44
# See the file 'LICENSE' for copying permission
55

6+
from __future__ import print_function
7+
68
import codecs
79
import inspect
810
import os
@@ -56,8 +58,8 @@ def send_email(msg):
5658
s.sendmail(FROM, TO, msg.as_string())
5759
s.quit()
5860
# Catch all for SMTP exceptions
59-
except smtplib.SMTPException, e:
60-
print "Failure to send email: %s" % str(e)
61+
except smtplib.SMTPException as ex:
62+
print("Failure to send email: '%s" % ex)
6163

6264
def failure_email(msg):
6365
msg = prepare_email(msg)
@@ -157,7 +159,7 @@ def main():
157159

158160
try:
159161
main()
160-
except Exception, e:
162+
except Exception:
161163
log_fd.write("An exception has occurred:\n%s" % str(traceback.format_exc()))
162164

163165
log_fd.write("Regression test finished at %s\n\n" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime()))

extra/sqlharvest/sqlharvest.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8+
from __future__ import print_function
9+
810
import cookielib
911
import re
1012
import socket
@@ -75,8 +77,8 @@ def main():
7577
except KeyboardInterrupt:
7678
raise
7779

78-
except Exception, msg:
79-
print msg
80+
except Exception as ex:
81+
print(ex)
8082

8183
if abort:
8284
break
@@ -86,7 +88,7 @@ def main():
8688
sys.stdout.write("---------------\n")
8789

8890
for sqlfile in files:
89-
print sqlfile
91+
print(sqlfile)
9092

9193
try:
9294
req = urllib2.Request(sqlfile)
@@ -118,8 +120,8 @@ def main():
118120
except KeyboardInterrupt:
119121
raise
120122

121-
except Exception, msg:
122-
print msg
123+
except Exception as ex:
124+
print(ex)
123125

124126
else:
125127
i += 1

extra/wafdetectify/wafdetectify.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
See the file 'LICENSE' for copying permission
66
"""
77

8+
from __future__ import print_function
9+
810
import cookielib
911
import glob
1012
import httplib
@@ -68,7 +70,7 @@ def colorize(message):
6870
def main():
6971
global WAF_FUNCTIONS
7072

71-
print colorize("%s #v%s\n by: %s\n" % (NAME, VERSION, AUTHOR))
73+
print(colorize("%s #v%s\n by: %s\n" % (NAME, VERSION, AUTHOR)))
7274

7375
if len(sys.argv) < 2:
7476
exit(colorize("[x] usage: python %s <hostname>" % os.path.split(__file__)[-1]))
@@ -104,13 +106,13 @@ def main():
104106

105107
WAF_FUNCTIONS = sorted(WAF_FUNCTIONS, key=lambda _: "generic" in _[1].lower())
106108

107-
print colorize("[i] checking '%s'..." % sys.argv[1])
109+
print(colorize("[i] checking '%s'..." % sys.argv[1]))
108110

109111
hostname = sys.argv[1].split("//")[-1].split('/')[0]
110112
try:
111113
socket.getaddrinfo(hostname, None)
112114
except socket.gaierror:
113-
print colorize("[x] host '%s' does not exist" % hostname)
115+
print(colorize("[x] host '%s' does not exist" % hostname))
114116
exit(1)
115117

116118
found = False
@@ -122,7 +124,7 @@ def main():
122124
exit(colorize("[!] WAF/IPS identified as '%s'" % product))
123125

124126
if not found:
125-
print colorize("[o] nothing found")
127+
print(colorize("[o] nothing found"))
126128

127129
print
128130

lib/controller/checks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,10 +627,10 @@ def genCmpPayload():
627627

628628
injectable = True
629629

630-
except SqlmapConnectionException, msg:
630+
except SqlmapConnectionException as ex:
631631
debugMsg = "problem occurred most likely because the "
632632
debugMsg += "server hasn't recovered as expected from the "
633-
debugMsg += "error-based payload used ('%s')" % msg
633+
debugMsg += "error-based payload used ('%s')" % getSafeExString(ex)
634634
logger.debug(debugMsg)
635635

636636
# In case of time-based blind or stacked queries

0 commit comments

Comments
 (0)