3333from lib .core .common import shellExec
3434from lib .core .compat import round
3535from lib .core .compat import xrange
36+ from lib .core .convert import encodeBase64
3637from lib .core .convert import getUnicode
3738from lib .core .data import conf
3839from lib .core .data import kb
@@ -64,10 +65,13 @@ def vulnTest():
6465 """
6566
6667 TESTS = (
67- ("-r <request> --flush-session" , ("CloudFlare" ,)),
68- ("-u <url> --flush-session --encoding=ascii --forms --crawl=2 --banner" , ("total of 2 targets" , "might be injectable" , "Type: UNION query" , "banner: '3" )),
68+ ("--list-tampers" , ("between" , "MySQL" , "xforwardedfor" )),
69+ ("-r <request> --flush-session" , ("CloudFlare" , "possible DBMS: 'SQLite'" )),
70+ ("-l <log> --flush-session --skip-waf -v 3 --technique=U --union-from=users --banner --parse-errors" , ("banner: '3" , "ORDER BY term out of range" , "~xp_cmdshell" )),
71+ ("-l <log> --offline --banner -v 5" , ("banner: '3" , "~[TRAFFIC OUT]" )),
72+ ("-u <url> --flush-session --encoding=ascii --forms --crawl=2 --threads=2 --banner" , ("total of 2 targets" , "might be injectable" , "Type: UNION query" , "banner: '3" )),
6973 ("-u <url> --flush-session --data='{\" id\" : 1}' --banner" , ("might be injectable" , "3 columns" , "Payload: {\" id\" " , "Type: boolean-based blind" , "Type: time-based blind" , "Type: UNION query" , "banner: '3" )),
70- ("-u <url> --flush-session --data='<root><param name=\" id\" value=\" 1*\" /></root>' --union-char=1 --mobile --banner --smart" , ("might be injectable" , "Payload: <root><param name=\" id\" value=\" 1" , "Type: boolean-based blind" , "Type: time-based blind" , "Type: UNION query" , "banner: '3" )),
74+ ("-u <url> --flush-session --data='<root><param name=\" id\" value=\" 1*\" /></root>' --union-char=1 --mobile --answers='smartphone=3' -- banner --smart -v 5 " , ("might be injectable" , "Payload: <root><param name=\" id\" value=\" 1" , "Type: boolean-based blind" , "Type: time-based blind" , "Type: UNION query" , "banner: '3" , "Nexus " )),
7175 ("-u <url> --flush-session --method=PUT --data='a=1&b=2&c=3&id=1' --skip-static --dump -T users --start=1 --stop=2" , ("might be injectable" , "Parameter: id (PUT)" , "Type: boolean-based blind" , "Type: time-based blind" , "Type: UNION query" , "2 entries" )),
7276 ("-u <url> --flush-session -H 'id: 1*' --tables" , ("might be injectable" , "Parameter: id #1* ((custom) HEADER)" , "Type: boolean-based blind" , "Type: time-based blind" , "Type: UNION query" , " users " )),
7377 ("-u <url> --flush-session --banner --invalid-logical --technique=B --test-filter='OR boolean' --tamper=space2dash" , ("banner: '3" , " LIKE " )),
@@ -113,7 +117,13 @@ def _thread():
113117 handle , request = tempfile .mkstemp (suffix = ".req" )
114118 os .close (handle )
115119
116- open (request , "w+" ).write ("POST / HTTP/1.0\n Host: %s:%s\n \n id=1\n " % (address , port ))
120+ handle , log = tempfile .mkstemp (suffix = ".log" )
121+ os .close (handle )
122+
123+ content = "POST / HTTP/1.0\n Host: %s:%s\n \n id=1\n " % (address , port )
124+
125+ open (request , "w+" ).write (content )
126+ open (log , "w+" ).write ('<port>%d</port><request base64="true"><![CDATA[%s]]></request>' % (port , encodeBase64 (content , binary = False )))
117127
118128 url = "http://%s:%d/?id=1" % (address , port )
119129 direct = "sqlite3://%s" % database
@@ -122,10 +132,10 @@ def _thread():
122132 status = '%d/%d (%d%%) ' % (count , len (TESTS ), round (100.0 * count / len (TESTS )))
123133 dataToStdout ("\r [%s] [INFO] complete: %s" % (time .strftime ("%X" ), status ))
124134
125- cmd = "%s %s %s --batch" % (sys .executable , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , "sqlmap.py" )), options .replace ("<url>" , url ).replace ("<direct>" , direct ).replace ("<request>" , request ))
135+ cmd = "%s %s %s --batch" % (sys .executable , os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." , ".." , "sqlmap.py" )), options .replace ("<url>" , url ).replace ("<direct>" , direct ).replace ("<request>" , request ). replace ( "<log>" , log ) )
126136 output = shellExec (cmd )
127137
128- if not all (check in output for check in checks ):
138+ if not all (( check in output if not check . startswith ( '~' ) else check [ 1 :] not in output ) for check in checks ):
129139 dataToStdout ("---\n \n $ %s\n " % cmd )
130140 dataToStdout ("%s---\n " % clearColors (output ))
131141 retVal = False
0 commit comments