Skip to content
This repository was archived by the owner on Apr 17, 2021. It is now read-only.

Commit 6fc1991

Browse files
committed
Well, the waf stage is mostly finished !
1 parent e599403 commit 6fc1991

File tree

6 files changed

+56
-13
lines changed

6 files changed

+56
-13
lines changed

googler

Submodule googler updated 1 file

src/execute.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
# From AutoSQLi
12
import subprocess
23

34

4-
def execute(command, cwd=None, timeout=None):
5+
def execute(command, cwd=None, timeout=None, yes=None):
56
""" must be an array """
67
""" returns the stdout of command """
7-
print(cwd)
8-
result = subprocess.run(command, stdout=subprocess.PIPE, cwd=cwd, timeout=timeout)
8+
""" command is an array of args """
9+
""" cwd is the current directory in which the command shall be executed """
10+
""" Timeout is the timeout of the command """
11+
""" yes = True: constantly feed stdin with a "y" """
12+
""" yes = False: constantly feed stdin with a "n" """
13+
finalCommand = []
14+
15+
if yes != None:
16+
finalCommand.append("yes |" if yes else "yes n |")
17+
18+
for arg in command:
19+
finalCommant.append(arg)
20+
21+
result = subprocess.run(finalCommand, stdout=subprocess.PIPE, cwd=cwd,
22+
timeout=timeout,
23+
shell=True if yes != None else None)
924
return result.stdout.decode('utf-8')

src/string.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# From AutoSQLi
2+
3+
4+
# tampers we shouldn't use because they're too specifics
5+
BANNED_TAMPERS = ["base64encode"]

src/target.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Target:
55
url = ""
66
waf_detection_done = False
77
is_protected_by_waf = False
8+
waf_name = ""
89
working_tampers = []
910
sqlmap_exploitation_done = False
1011
is_vulnerable = False
@@ -13,10 +14,6 @@ def __init__(self, url):
1314
""" create a new Target """
1415
self.url = url
1516

16-
def setWaf(self, isProtectedByWaf):
17-
""" specify if the target is protected by a WAF """
18-
self.is_protected_by_waf = isProtectedByWaf
19-
2017

2118
def urls_to_targets(urls):
2219
""" convert an url array to a Target array """

src/whatwaf_interface.py

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from .execute import execute
22
from . import paths
3+
import json
4+
from .strings import BANNED_TAMPERS
35

46

57
# this specifies the time that whatwaf is allowed to use to scan a target
6-
WHATWAF_TIMEOUT = 60
8+
# WHATWAF_TIMEOUT = 60
79

810

911
# def isProtectedByWaf(url):
@@ -19,14 +21,38 @@
1921
# # if "no protection identified on target" in whatwafResponse:
2022
# # return False # no protection
2123

24+
def satanize_url(url):
25+
""" satanize a url to be used with bash """
26+
return "'" + url.replace("'", "\\'")
27+
28+
2229
def whatwaf_url(url):
2330
""" return WhatWaf's results for a specified url """
24-
return execute(["python2.7", paths.WHATWAF_NAME, "-u", url, "--ra",
25-
"--hide"], paths.WHATWAF_PATH, WHATWAF_TIMEOUT)
31+
return execute(["python2.7", paths.WHATWAF_NAME, "-u", satanize_url(url),
32+
"--ra", "--hide"],
33+
paths.WHATWAF_PATH, None, True)
2634

2735

2836
def whatwaf_target(target):
2937
""" add whatwaf details to a target and returns it """
38+
3039
whatwaf_report = whatwaf_url(target.url)
31-
# TODO: analyse the report to return the target
40+
if "no protection identified on target" in whatwaf_report:
41+
target.is_protected_by_waf = False
42+
elif '-'*30 in whatwaf_report:
43+
# extract the json part ( using those " - " )
44+
gorgeous_report = whatwaf_report.split('-'*30 + '\n')[1].split(
45+
'\n' + '-'*30)[0]
46+
47+
# load the json
48+
json_report = json.loads(gorgeous_report)
49+
# assign the json to the target
50+
target.is_protected_by_waf = json_report["is protected"]
51+
target.waf_name = json_report["identified firewall"]
52+
for tamper in json_report["apparent working tampers"]:
53+
if tamper not in BANNED_TAMPERS:
54+
target.working_tamper.append(tamper)
55+
56+
# TODO: analyze the report to return the target
57+
target.waf_detection_done = True
3258
return target

0 commit comments

Comments
 (0)