mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-07-29 09:29:50 +03:00
Refactoring for Python 3 print
* 2to3 `ls | grep -v thirdparty` -f print
This commit is contained in:
parent
76905e8728
commit
c67c483fdb
|
@ -38,7 +38,7 @@ def decloak(inputFile=None, data=None):
|
|||
try:
|
||||
data = zlib.decompress(hideAscii(data))
|
||||
except:
|
||||
print 'ERROR: the provided input file \'%s\' does not contain valid cloaked content' % inputFile
|
||||
print('ERROR: the provided input file \'%s\' does not contain valid cloaked content' % inputFile)
|
||||
sys.exit(1)
|
||||
finally:
|
||||
f.close()
|
||||
|
@ -63,7 +63,7 @@ def main():
|
|||
parser.error(e)
|
||||
|
||||
if not os.path.isfile(args.inputFile):
|
||||
print 'ERROR: the provided input file \'%s\' is non existent' % args.inputFile
|
||||
print('ERROR: the provided input file \'%s\' is non existent' % args.inputFile)
|
||||
sys.exit(1)
|
||||
|
||||
if not args.decrypt:
|
||||
|
|
|
@ -19,7 +19,7 @@ def convert(inputFile):
|
|||
fileSize = fileStat.st_size
|
||||
|
||||
if fileSize > 65280:
|
||||
print "ERROR: the provided input file '%s' is too big for debug.exe" % inputFile
|
||||
print("ERROR: the provided input file '%s' is too big for debug.exe" % inputFile)
|
||||
sys.exit(1)
|
||||
|
||||
script = "n %s\nr cx\n" % os.path.basename(inputFile.replace(".", "_"))
|
||||
|
@ -59,7 +59,7 @@ def convert(inputFile):
|
|||
|
||||
def main(inputFile, outputFile):
|
||||
if not os.path.isfile(inputFile):
|
||||
print "ERROR: the provided input file '%s' is not a regular file" % inputFile
|
||||
print("ERROR: the provided input file '%s' is not a regular file" % inputFile)
|
||||
sys.exit(1)
|
||||
|
||||
script = convert(inputFile)
|
||||
|
@ -70,7 +70,7 @@ def main(inputFile, outputFile):
|
|||
sys.stdout.write(script)
|
||||
sys.stdout.close()
|
||||
else:
|
||||
print script
|
||||
print(script)
|
||||
|
||||
if __name__ == "__main__":
|
||||
usage = "%s -i <input file> [-o <output file>]" % sys.argv[0]
|
||||
|
|
|
@ -22,11 +22,11 @@ MSSQL_VERSIONS_URL = "http://www.sqlsecurity.com/FAQs/SQLServerVersionDatabase/t
|
|||
def updateMSSQLXML():
|
||||
if not os.path.exists(MSSQL_XML):
|
||||
errMsg = "[ERROR] file '%s' does not exist. Please run the script from its parent directory" % MSSQL_XML
|
||||
print errMsg
|
||||
print(errMsg)
|
||||
return
|
||||
|
||||
infoMsg = "[INFO] retrieving data from '%s'" % MSSQL_VERSIONS_URL
|
||||
print infoMsg
|
||||
print(infoMsg)
|
||||
|
||||
try:
|
||||
req = urllib2.Request(MSSQL_VERSIONS_URL)
|
||||
|
@ -39,7 +39,7 @@ def updateMSSQLXML():
|
|||
|
||||
warnMsg = "[WARNING] sqlmap was unable to connect to %s," % __mssqlHostname
|
||||
warnMsg += " check your Internet connection and retry"
|
||||
print warnMsg
|
||||
print(warnMsg)
|
||||
|
||||
return
|
||||
|
||||
|
@ -131,7 +131,7 @@ def updateMSSQLXML():
|
|||
mssqlXml.close()
|
||||
|
||||
infoMsg = "[INFO] done. retrieved data parsed and saved into '%s'" % MSSQL_XML
|
||||
print infoMsg
|
||||
print(infoMsg)
|
||||
|
||||
if __name__ == "__main__":
|
||||
updateMSSQLXML()
|
||||
|
|
|
@ -112,7 +112,7 @@ def main():
|
|||
parser.error(e)
|
||||
|
||||
if not os.path.isfile(args.inputFile):
|
||||
print 'ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile
|
||||
print('ERROR: the provided input file \'%s\' is not a regular file' % args.inputFile)
|
||||
sys.exit(1)
|
||||
|
||||
f = open(args.inputFile, 'r')
|
||||
|
|
|
@ -17,7 +17,7 @@ if len(sys.argv) > 0:
|
|||
str.encode(item)
|
||||
if item in items:
|
||||
if item:
|
||||
print item
|
||||
print(item)
|
||||
else:
|
||||
items.append(item)
|
||||
except:
|
||||
|
|
|
@ -17,26 +17,26 @@ def check(module):
|
|||
|
||||
if module[-3:] == ".py":
|
||||
|
||||
print "CHECKING ", module
|
||||
print("CHECKING ", module)
|
||||
pout = os.popen("pylint --rcfile=/dev/null %s" % module, 'r')
|
||||
for line in pout:
|
||||
if re.match(r"\AE:", line):
|
||||
print line.strip()
|
||||
print(line.strip())
|
||||
if __RATING__ and "Your code has been rated at" in line:
|
||||
print line
|
||||
print(line)
|
||||
score = re.findall(r"\d.\d\d", line)[0]
|
||||
total += float(score)
|
||||
count += 1
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
print sys.argv
|
||||
print(sys.argv)
|
||||
BASE_DIRECTORY = sys.argv[1]
|
||||
except IndexError:
|
||||
print "no directory specified, defaulting to current working directory"
|
||||
print("no directory specified, defaulting to current working directory")
|
||||
BASE_DIRECTORY = os.getcwd()
|
||||
|
||||
print "looking for *.py scripts in subdirectories of ", BASE_DIRECTORY
|
||||
print("looking for *.py scripts in subdirectories of ", BASE_DIRECTORY)
|
||||
for root, dirs, files in os.walk(BASE_DIRECTORY):
|
||||
if any(_ in root for _ in ("extra", "thirdparty")):
|
||||
continue
|
||||
|
@ -45,6 +45,6 @@ if __name__ == "__main__":
|
|||
check(filepath)
|
||||
|
||||
if __RATING__:
|
||||
print "==" * 50
|
||||
print "%d modules found" % count
|
||||
print "AVERAGE SCORE = %.02f" % (total / count)
|
||||
print("==" * 50)
|
||||
print("%d modules found" % count)
|
||||
print("AVERAGE SCORE = %.02f" % (total / count))
|
||||
|
|
|
@ -57,7 +57,7 @@ def send_email(msg):
|
|||
s.quit()
|
||||
# Catch all for SMTP exceptions
|
||||
except smtplib.SMTPException, e:
|
||||
print "Failure to send email: %s" % str(e)
|
||||
print("Failure to send email: %s" % str(e))
|
||||
|
||||
def failure_email(msg):
|
||||
msg = prepare_email(msg)
|
||||
|
|
|
@ -76,7 +76,7 @@ def main():
|
|||
raise
|
||||
|
||||
except Exception, msg:
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
if abort:
|
||||
break
|
||||
|
@ -86,7 +86,7 @@ def main():
|
|||
sys.stdout.write("---------------\n")
|
||||
|
||||
for sqlfile in files:
|
||||
print sqlfile
|
||||
print(sqlfile)
|
||||
|
||||
try:
|
||||
req = urllib2.Request(sqlfile)
|
||||
|
@ -119,7 +119,7 @@ def main():
|
|||
raise
|
||||
|
||||
except Exception, msg:
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
else:
|
||||
i += 1
|
||||
|
|
|
@ -167,7 +167,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
|
|||
time.sleep(0.1)
|
||||
|
||||
except (KeyboardInterrupt, SqlmapUserQuitException), ex:
|
||||
print
|
||||
print()
|
||||
kb.threadContinue = False
|
||||
kb.threadException = True
|
||||
|
||||
|
@ -184,7 +184,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
|
|||
raise
|
||||
|
||||
except (SqlmapConnectionException, SqlmapValueException), ex:
|
||||
print
|
||||
print()
|
||||
kb.threadException = True
|
||||
logger.error("thread %s: %s" % (threading.currentThread().getName(), ex.message))
|
||||
|
||||
|
@ -194,7 +194,7 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
|
|||
except:
|
||||
from lib.core.common import unhandledExceptionMessage
|
||||
|
||||
print
|
||||
print()
|
||||
kb.threadException = True
|
||||
errMsg = unhandledExceptionMessage()
|
||||
logger.error("thread %s: %s" % (threading.currentThread().getName(), errMsg))
|
||||
|
|
|
@ -886,7 +886,7 @@ def cmdLineParser(argv=None):
|
|||
command = raw_input("sqlmap-shell> ").strip()
|
||||
command = getUnicode(command, encoding=sys.stdin.encoding)
|
||||
except (KeyboardInterrupt, EOFError):
|
||||
print
|
||||
print()
|
||||
raise SqlmapShellQuitException
|
||||
|
||||
if not command:
|
||||
|
@ -930,7 +930,7 @@ def cmdLineParser(argv=None):
|
|||
argv[i] = argv[i][:-1]
|
||||
conf.skipThreadCheck = True
|
||||
elif argv[i] == "--version":
|
||||
print VERSION_STRING.split('/')[-1]
|
||||
print(VERSION_STRING.split('/')[-1])
|
||||
raise SystemExit
|
||||
elif argv[i] in ("-h", "--help"):
|
||||
advancedHelp = False
|
||||
|
|
|
@ -145,13 +145,13 @@ if __name__ == "__main__":
|
|||
if _ is None:
|
||||
break
|
||||
else:
|
||||
print "[i] %s" % _
|
||||
print("[i] %s" % _)
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
except socket.error, ex:
|
||||
if 'Permission' in str(ex):
|
||||
print "[x] Please run with sudo/Administrator privileges"
|
||||
print("[x] Please run with sudo/Administrator privileges")
|
||||
else:
|
||||
raise
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
@ -276,7 +276,7 @@ def _goInferenceProxy(expression, fromUser=False, batch=False, unpack=True, char
|
|||
raise SqlmapDataException(errMsg)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
warnMsg = "user aborted during dumping phase"
|
||||
logger.warn(warnMsg)
|
||||
|
||||
|
|
|
@ -130,11 +130,11 @@ class Abstraction(Web, UDF, XP_cmdshell):
|
|||
command = raw_input("os-shell> ")
|
||||
command = getUnicode(command, encoding=sys.stdin.encoding)
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
errMsg = "user aborted"
|
||||
logger.error(errMsg)
|
||||
except EOFError:
|
||||
print
|
||||
print()
|
||||
errMsg = "exit"
|
||||
logger.error(errMsg)
|
||||
break
|
||||
|
|
|
@ -492,7 +492,7 @@ class Metasploit:
|
|||
send_all(proc, "getuid\n")
|
||||
|
||||
if conf.privEsc:
|
||||
print
|
||||
print()
|
||||
|
||||
infoMsg = "trying to escalate privileges using Meterpreter "
|
||||
infoMsg += "'getsystem' command which tries different "
|
||||
|
|
|
@ -239,7 +239,7 @@ def _errorFields(expression, expressionFields, expressionFieldsList, num=None, e
|
|||
|
||||
if not suppressOutput:
|
||||
if kb.fileReadMode and output and output.strip():
|
||||
print
|
||||
print()
|
||||
elif output is not None and not (threadData.resumed and kb.suppressResumeInfo) and not (emptyFields and field in emptyFields):
|
||||
status = "[%s] [INFO] %s: %s" % (time.strftime("%X"), "resumed" if threadData.resumed else "retrieved", output if kb.safeCharEncode else safecharencode(output))
|
||||
|
||||
|
|
|
@ -769,7 +769,7 @@ def client(host=RESTAPI_DEFAULT_ADDRESS, port=RESTAPI_DEFAULT_PORT, username=Non
|
|||
command = raw_input("api%s> " % (" (%s)" % taskid if taskid else "")).strip()
|
||||
command = re.sub(r"\A(\w+)", lambda match: match.group(1).lower(), command)
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
print
|
||||
print()
|
||||
break
|
||||
|
||||
if command in ("data", "log", "status", "stop", "kill"):
|
||||
|
|
|
@ -1061,7 +1061,7 @@ def dictionaryAttack(attack_dict):
|
|||
_bruteProcessVariantA(attack_info, hash_regex, suffix, retVal, 0, 1, kb.wordlists, custom_wordlist, conf.api)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
processException = True
|
||||
warnMsg = "user aborted during dictionary-based attack phase (Ctrl+C was pressed)"
|
||||
logger.warn(warnMsg)
|
||||
|
@ -1155,7 +1155,7 @@ def dictionaryAttack(attack_dict):
|
|||
found = found_.value
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
processException = True
|
||||
warnMsg = "user aborted during dictionary-based attack phase (Ctrl+C was pressed)"
|
||||
logger.warn(warnMsg)
|
||||
|
|
|
@ -89,11 +89,11 @@ class Custom:
|
|||
query = raw_input("sql-shell> ")
|
||||
query = getUnicode(query, encoding=sys.stdin.encoding)
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
errMsg = "user aborted"
|
||||
logger.error(errMsg)
|
||||
except EOFError:
|
||||
print
|
||||
print()
|
||||
errMsg = "exit"
|
||||
logger.error(errMsg)
|
||||
break
|
||||
|
|
12
sqlmap.py
12
sqlmap.py
|
@ -185,7 +185,7 @@ def main():
|
|||
raise SystemExit
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print
|
||||
print()
|
||||
|
||||
errMsg = "user aborted"
|
||||
try:
|
||||
|
@ -194,7 +194,7 @@ def main():
|
|||
pass
|
||||
|
||||
except EOFError:
|
||||
print
|
||||
print()
|
||||
errMsg = "exit"
|
||||
|
||||
try:
|
||||
|
@ -206,7 +206,7 @@ def main():
|
|||
pass
|
||||
|
||||
except:
|
||||
print
|
||||
print()
|
||||
errMsg = unhandledExceptionMessage()
|
||||
excMsg = traceback.format_exc()
|
||||
valid = checkIntegrity()
|
||||
|
@ -217,13 +217,13 @@ def main():
|
|||
errMsg += "You should retrieve the latest development version from official GitHub "
|
||||
errMsg += "repository at '%s'" % GIT_PAGE
|
||||
logger.critical(errMsg)
|
||||
print
|
||||
print()
|
||||
dataToStdout(excMsg)
|
||||
raise SystemExit
|
||||
|
||||
elif any(_ in excMsg for _ in ("tamper/", "waf/")):
|
||||
logger.critical(errMsg)
|
||||
print
|
||||
print()
|
||||
dataToStdout(excMsg)
|
||||
raise SystemExit
|
||||
|
||||
|
@ -299,7 +299,7 @@ def main():
|
|||
|
||||
elif "url = url.strip()" in excMsg:
|
||||
dataToStdout(excMsg)
|
||||
print
|
||||
print()
|
||||
errMsg = "please contact 'miroslav@sqlmap.org' with details for this issue "
|
||||
errMsg += "as he is trying to reproduce it for long time"
|
||||
logger.error(errMsg)
|
||||
|
|
Loading…
Reference in New Issue
Block a user