patch for issue #49, bo longer need to restart the sqlmap API each iteration

This commit is contained in:
ekultek 2017-10-07 08:09:16 -05:00
parent 97b620aef4
commit 671e77b984
3 changed files with 21 additions and 7 deletions

View file

@ -44,11 +44,21 @@ class SqlmapHook(object):
"""
get the ID of the current API scan
"""
current_scan_id = None
id_re = re.compile(r"[a-fA-F0-9]{16}")
api_id_url = "{}{}".format(self.connection, self.commands["id"])
req = requests.get(api_id_url)
to_check = str(json.loads(req.content)["tasks"]).lower()
current_scan_id = ''.join(id_re.findall(to_check))
found = ''.join(id_re.findall(to_check))
if len(found) > 16:
data_found = [found[i:i+split_by] for i in range(0, len(found), split_by)]
for item in data_found:
if item not in lib.settings.ALREADY_USED:
lib.settings.ALREADY_USED.add(item)
current_scan_id = item
else:
lib.settings.ALREADY_USED.add(found)
current_scan_id = found
return current_scan_id
def start_scan(self, api_id, opts=None):
@ -123,9 +133,6 @@ def sqlmap_scan_main(url, port=None, verbose=None, auto_search=False, opts=None,
if path:
subprocess.check_output(["python", path, "-s"])
else:
lib.settings.prompt(
"start the sqlmap API server and press enter when ready..."
)
try:
sqlmap_scan = SqlmapHook(url, port=port)
lib.settings.logger.info(lib.settings.set_color(
@ -163,8 +170,7 @@ def sqlmap_scan_main(url, port=None, verbose=None, auto_search=False, opts=None,
lib.settings.logger.warning(lib.settings.set_color(
"please keep in mind that this is the API, output will "
"not be saved to log file, it may take a little longer "
"to finish processing, and you will need to restart the sqlmap "
"API server after each iteration, launching sqlmap...", level=30
"to finish processing, launching sqlmap...", level=30
))
sqlmap_scan.start_scan(api_id, opts=opts)
print("-" * 30)

View file

@ -22,7 +22,7 @@ except NameError:
# clone link
CLONE = "https://github.com/ekultek/zeus-scanner.git"
# current version <major.minor.commit.patch ID>
VERSION = "1.0.29.1f59"
VERSION = "1.0.30.133a"
# colors to output depending on the version
VERSION_TYPE_COLORS = {"dev": 33, "stable": 92, "other": 30}
# version string formatting
@ -63,6 +63,8 @@ CURRENT_LOG_FILE_PATH = "{}/log".format(os.getcwd())
NMAP_MAN_PAGE_URL = "https://nmap.org/book/man-briefoptions.html"
# sqlmap's manual page for their options
SQLMAP_MAN_PAGE_URL = "https://github.com/sqlmapproject/sqlmap/wiki/Usage"
# holder for sqlmap API ID hashes, makes it so that they are all unique
ALREADY_USED = set()
# search engines that the application can use
AUTHORIZED_SEARCH_ENGINES = {
"aol": "http://aol.com",

View file

@ -112,6 +112,7 @@ if __name__ == "__main__":
engines.add_option("-A", "--search-engine-aol", dest="useAOL", action="store_true",
help="Use AOL as the search engine")
# arguments to edit your search patterns
search_items = optparse.OptionGroup(parser, "Search options",
"Arguments that will control the search criteria")
search_items.add_option("-L", "--links", dest="amountToSearch", type=int, metavar="HOW-MANY-LINKS",
@ -168,6 +169,11 @@ if __name__ == "__main__":
start_up()
if opt.runSqliScan:
prompt(
"make sure you have started the sqlmap API, press enter when ready to continue..."
)
if opt.showSqlmapArguments:
logger.info(set_color(
"there are a total of {} arguments understood by sqlmap API, "