mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-12-06 04:31:30 +00:00
Some more DREI stuff
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
beep.py - Make a beep sound
|
||||
@@ -8,7 +8,6 @@ See the file 'LICENSE' for copying permission
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import wave
|
||||
|
||||
@@ -16,11 +15,11 @@ BEEP_WAV_FILENAME = os.path.join(os.path.dirname(__file__), "beep.wav")
|
||||
|
||||
def beep():
|
||||
try:
|
||||
if subprocess.mswindows:
|
||||
if sys.platform == "nt":
|
||||
_win_wav_play(BEEP_WAV_FILENAME)
|
||||
elif sys.platform == "darwin":
|
||||
_mac_beep()
|
||||
elif sys.platform == "linux2":
|
||||
elif sys.platform.startswith("linux"):
|
||||
_linux_wav_play(BEEP_WAV_FILENAME)
|
||||
else:
|
||||
_speaker_beep()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
cloak.py - Simple file encryption/compression utility
|
||||
@@ -10,6 +10,7 @@ See the file 'LICENSE' for copying permission
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
import zlib
|
||||
|
||||
@@ -20,12 +21,10 @@ if sys.version_info.major > 2:
|
||||
xrange = range
|
||||
|
||||
def hideAscii(data):
|
||||
retVal = ""
|
||||
retVal = b""
|
||||
for i in xrange(len(data)):
|
||||
if ord(data[i]) < 128:
|
||||
retVal += chr(ord(data[i]) ^ 127)
|
||||
else:
|
||||
retVal += data[i]
|
||||
value = data[i] if isinstance(data[i], int) else ord(data[i])
|
||||
retVal += struct.pack('B', value ^ (127 if value < 128 else 0))
|
||||
|
||||
return retVal
|
||||
|
||||
@@ -42,7 +41,8 @@ def decloak(inputFile=None, data=None):
|
||||
data = f.read()
|
||||
try:
|
||||
data = zlib.decompress(hideAscii(data))
|
||||
except:
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
print('ERROR: the provided input file \'%s\' does not contain valid cloaked content' % inputFile)
|
||||
sys.exit(1)
|
||||
finally:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
dbgtool.py - Portable executable to ASCII debug script converter
|
||||
@@ -34,7 +34,7 @@ def convert(inputFile):
|
||||
fileContent = fp.read()
|
||||
|
||||
for fileChar in fileContent:
|
||||
unsignedFileChar = struct.unpack("B", fileChar)[0]
|
||||
unsignedFileChar = fileChar if sys.version_info.major > 2 else ord(fileChar)
|
||||
|
||||
if unsignedFileChar != 0:
|
||||
counter2 += 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||
# See the file 'LICENSE' for copying permission
|
||||
@@ -10,7 +10,7 @@ from __future__ import print_function
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 0:
|
||||
if len(sys.argv) > 1:
|
||||
items = list()
|
||||
|
||||
with open(sys.argv[1], 'r') as f:
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
#! /usr/bin/env python2
|
||||
|
||||
# Runs pylint on all python scripts found in a directory tree
|
||||
# Reference: http://rowinggolfer.blogspot.com/2009/08/pylint-recursively.html
|
||||
#! /usr/bin/env python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
@@ -11,9 +8,10 @@ import sys
|
||||
def check(filepath):
|
||||
if filepath.endswith(".py"):
|
||||
content = open(filepath, "rb").read()
|
||||
pattern = "\n\n\n".encode("ascii")
|
||||
|
||||
if "\n\n\n" in content:
|
||||
index = content.find("\n\n\n")
|
||||
if pattern in content:
|
||||
index = content.find(pattern)
|
||||
print(filepath, repr(content[index - 30:index + 30]))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#! /usr/bin/env python2
|
||||
#! /usr/bin/env python
|
||||
|
||||
# Runs pylint on all python scripts found in a directory tree
|
||||
# Reference: http://rowinggolfer.blogspot.com/2009/08/pylint-recursively.html
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
# Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
|
||||
# See the file 'LICENSE' for copying permission
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import codecs
|
||||
import inspect
|
||||
import os
|
||||
import re
|
||||
import smtplib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
sys.path.append(os.path.normpath("%s/../../" % os.path.dirname(inspect.getfile(inspect.currentframe()))))
|
||||
|
||||
from lib.core.revision import getRevisionNumber
|
||||
|
||||
START_TIME = time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime())
|
||||
SQLMAP_HOME = "/opt/sqlmap"
|
||||
|
||||
SMTP_SERVER = "127.0.0.1"
|
||||
SMTP_PORT = 25
|
||||
SMTP_TIMEOUT = 30
|
||||
FROM = "regressiontest@sqlmap.org"
|
||||
# TO = "dev@sqlmap.org"
|
||||
TO = ["bernardo.damele@gmail.com", "miroslav.stampar@gmail.com"]
|
||||
SUBJECT = "regression test started on %s using revision %s" % (START_TIME, getRevisionNumber())
|
||||
TARGET = "debian"
|
||||
|
||||
def prepare_email(content):
|
||||
global FROM
|
||||
global TO
|
||||
global SUBJECT
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg["Subject"] = SUBJECT
|
||||
msg["From"] = FROM
|
||||
msg["To"] = TO if isinstance(TO, basestring) else ','.join(TO)
|
||||
|
||||
msg.attach(MIMEText(content))
|
||||
|
||||
return msg
|
||||
|
||||
def send_email(msg):
|
||||
global SMTP_SERVER
|
||||
global SMTP_PORT
|
||||
global SMTP_TIMEOUT
|
||||
|
||||
try:
|
||||
s = smtplib.SMTP(host=SMTP_SERVER, port=SMTP_PORT, timeout=SMTP_TIMEOUT)
|
||||
s.sendmail(FROM, TO, msg.as_string())
|
||||
s.quit()
|
||||
# Catch all for SMTP exceptions
|
||||
except smtplib.SMTPException as ex:
|
||||
print("Failure to send email: '%s" % ex)
|
||||
|
||||
def failure_email(msg):
|
||||
msg = prepare_email(msg)
|
||||
send_email(msg)
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
global SUBJECT
|
||||
|
||||
content = ""
|
||||
test_counts = []
|
||||
attachments = {}
|
||||
|
||||
updateproc = subprocess.Popen("cd /opt/sqlmap/ ; python /opt/sqlmap/sqlmap.py --update", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = updateproc.communicate()
|
||||
|
||||
if stderr:
|
||||
failure_email("Update of sqlmap failed with error:\n\n%s" % stderr)
|
||||
|
||||
regressionproc = subprocess.Popen("python /opt/sqlmap/sqlmap.py --live-test", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=False)
|
||||
stdout, stderr = regressionproc.communicate()
|
||||
|
||||
if stderr:
|
||||
failure_email("Execution of regression test failed with error:\n\n%s" % stderr)
|
||||
|
||||
failed_tests = re.findall(r"running live test case: (.+?) \((\d+)\/\d+\)[\r]*\n.+test failed (at parsing items: (.+))?\s*\- scan folder: (\/.+) \- traceback: (.*?)( - SQL injection not detected)?[\r]*\n", stdout)
|
||||
|
||||
for failed_test in failed_tests:
|
||||
title = failed_test[0]
|
||||
test_count = int(failed_test[1])
|
||||
parse = failed_test[3] if failed_test[3] else None
|
||||
output_folder = failed_test[4]
|
||||
traceback = False if failed_test[5] == "False" else bool(failed_test[5])
|
||||
detected = False if failed_test[6] else True
|
||||
|
||||
test_counts.append(test_count)
|
||||
|
||||
console_output_file = os.path.join(output_folder, "console_output")
|
||||
log_file = os.path.join(output_folder, TARGET, "log")
|
||||
traceback_file = os.path.join(output_folder, "traceback")
|
||||
|
||||
if os.path.exists(console_output_file):
|
||||
console_output_fd = codecs.open(console_output_file, "rb", "utf8")
|
||||
console_output = console_output_fd.read()
|
||||
console_output_fd.close()
|
||||
attachments[test_count] = str(console_output)
|
||||
|
||||
if os.path.exists(log_file):
|
||||
log_fd = codecs.open(log_file, "rb", "utf8")
|
||||
log = log_fd.read()
|
||||
log_fd.close()
|
||||
|
||||
if os.path.exists(traceback_file):
|
||||
traceback_fd = codecs.open(traceback_file, "rb", "utf8")
|
||||
traceback = traceback_fd.read()
|
||||
traceback_fd.close()
|
||||
|
||||
content += "Failed test case '%s' (#%d)" % (title, test_count)
|
||||
|
||||
if parse:
|
||||
content += " at parsing: %s:\n\n" % parse
|
||||
content += "### Log file:\n\n"
|
||||
content += "%s\n\n" % log
|
||||
elif not detected:
|
||||
content += " - SQL injection not detected\n\n"
|
||||
else:
|
||||
content += "\n\n"
|
||||
|
||||
if traceback:
|
||||
content += "### Traceback:\n\n"
|
||||
content += "%s\n\n" % str(traceback)
|
||||
|
||||
content += "#######################################################################\n\n"
|
||||
|
||||
end_string = "Regression test finished at %s" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime())
|
||||
|
||||
if content:
|
||||
content += end_string
|
||||
SUBJECT = "Failed %s (%s)" % (SUBJECT, ", ".join("#%d" % count for count in test_counts))
|
||||
|
||||
msg = prepare_email(content)
|
||||
|
||||
for test_count, attachment in attachments.items():
|
||||
attachment = MIMEText(attachment)
|
||||
attachment.add_header("Content-Disposition", "attachment", filename="test_case_%d_console_output.txt" % test_count)
|
||||
msg.attach(attachment)
|
||||
|
||||
send_email(msg)
|
||||
else:
|
||||
SUBJECT = "Successful %s" % SUBJECT
|
||||
msg = prepare_email("All test cases were successful\n\n%s" % end_string)
|
||||
send_email(msg)
|
||||
|
||||
if __name__ == "__main__":
|
||||
log_fd = open("/tmp/sqlmapregressiontest.log", "wb")
|
||||
log_fd.write("Regression test started at %s\n" % START_TIME)
|
||||
|
||||
try:
|
||||
main()
|
||||
except Exception:
|
||||
log_fd.write("An exception has occurred:\n%s" % str(traceback.format_exc()))
|
||||
|
||||
log_fd.write("Regression test finished at %s\n\n" % time.strftime("%H:%M:%S %d-%m-%Y", time.gmtime()))
|
||||
log_fd.close()
|
||||
Reference in New Issue
Block a user