Options: -h,--help Show basic help message and exit -hhShow advanced help message and exit --versionShow program's version number and exit -vVERBOSE Verbosity level: 0-6 (default 1)
Target: Atleast one of these options has to be provided to define the target(s)
-uURL, --url=URL Target URL (e.g. "http://www.site.com/vuln.php?id=1") -gGOOGLEDORK Process Google dork results as target URLs
Request: Theseoptions can be used to specify how to connect to the target URL
--data=DATA Data string to be sent through POST (e.g. "id=1") --cookie=COOKIE HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..") --random-agentUse randomly selected HTTP User-Agent header value --proxy=PROXY Use a proxy to connect to the target URL --torUse Tor anonymity network --check-torCheck to see if Tor is used properly
Injection: Theseoptions can be used to specify which parameters to test for, providecustom injection payloads and optional tampering scripts
-pTESTPARAMETER Testable parameter(s) --dbms=DBMS Force back-end DBMS to provided value
Detection: Theseoptions can be used to customize the detection phase
--level=LEVEL Level of tests to perform (1-5, default 1) --risk=RISK Risk of tests to perform (1-3, default 1)
Techniques: Theseoptions can be used to tweak testing of specific SQL injection techniques
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ")
Enumeration: Theseoptions can be used to enumerate the back-end database managementsystem information, structure and data contained in the tables
-a,--all Retrieve everything -b,--banner Retrieve DBMS banner --current-userRetrieve DBMS current user --current-dbRetrieve DBMS current database --passwordsEnumerate DBMS users password hashes --dbsEnumerate DBMS databases --tablesEnumerate DBMS database tables --columnsEnumerate DBMS database table columns --schemaEnumerate DBMS schema --dumpDump DBMS database table entries --dump-allDump all DBMS databases tables entries -DDB DBMS database to enumerate -TTBL DBMS database table(s) to enumerate -CCOL DBMS database table column(s) to enumerate
Operatingsystem access: Theseoptions can be used to access the back-end database management systemunderlying operating system
--os-shellPrompt for an interactive operating system shell --os-pwnPrompt for an OOB shell, Meterpreter or VNC
General: Theseoptions can be used to set some general working parameters
--batchNever ask for user input, use the default behavior --flush-sessionFlush session files for current target
Miscellaneous: Theseoptions do not fit into any other category
--wizardSimple wizard interface for beginner users
Options: -h,--help Show basic help message and exit -hhShow advanced help message and exit --versionShow program's version number and exit -vVERBOSE Verbosity level: 0-6 (default 1)
Target: Atleast one of these options has to be provided to define the target(s)
-uURL, --url=URL Target URL (e.g. "http://www.site.com/vuln.php?id=1") -dDIRECT Connection string for direct database connection -lLOGFILE Parse target(s) from Burp or WebScarab proxy log file -mBULKFILE Scan multiple targets given in a textual file -rREQUESTFILE Load HTTP request from a file -gGOOGLEDORK Process Google dork results as target URLs -cCONFIGFILE Load options from a configuration INI file
Request: Theseoptions can be used to specify how to connect to the target URL
-AAGENT, --user.. HTTP User-Agent header value -HHEADER, --hea.. Extra header (e.g. "X-Forwarded-For: 127.0.0.1") --method=METHOD Force usage of given HTTP method (e.g. PUT) --data=DATA Data string to be sent through POST (e.g. "id=1") --param-del=PARA.. Character used for splitting parameter values (e.g. &) --cookie=COOKIE HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..") --cookie-del=COO.. Character used for splitting cookie values (e.g. ;) --live-cookies=L.. Live cookies file used for loading up-to-date values --load-cookies=L.. File containing cookies in Netscape/wget format --drop-set-cookieIgnore Set-Cookie header from response --mobileImitate smartphone through HTTP User-Agent header --random-agentUse randomly selected HTTP User-Agent header value --host=HOST HTTP Host header value --referer=REFERER HTTP Referer header value --headers=HEADERS Extra headers (e.g. "Accept-Language: fr\nETag: 123") --auth-type=AUTH.. HTTP authentication type (Basic, Digest, NTLM or PKI) --auth-cred=AUTH.. HTTP authentication credentials (name:password) --auth-file=AUTH.. HTTP authentication PEM cert/private key file --ignore-code=IG.. Ignore (problematic) HTTP error code (e.g. 401) --ignore-proxyIgnore system default proxy settings --ignore-redirectsIgnore redirection attempts --ignore-timeoutsIgnore connection timeouts --proxy=PROXY Use a proxy to connect to the target URL --proxy-cred=PRO.. Proxy authentication credentials (name:password) --proxy-file=PRO.. Load proxy list from a file --proxy-freq=PRO.. Requests between change of proxy from a given list --torUse Tor anonymity network --tor-port=TORPORT Set Tor proxy port other than default --tor-type=TORTYPE Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default)) --check-torCheck to see if Tor is used properly --delay=DELAY Delay in seconds between each HTTP request --timeout=TIMEOUT Seconds to wait before timeout connection (default 30) --retries=RETRIES Retries when the connection timeouts (default 3) --randomize=RPARAM Randomly change value for given parameter(s) --safe-url=SAFEURL URL address to visit frequently during testing --safe-post=SAFE.. POST data to send to a safe URL --safe-req=SAFER.. Load safe HTTP request from a file --safe-freq=SAFE.. Regular requests between visits to a safe URL --skip-urlencodeSkip URL encoding of payload data --csrf-token=CSR.. Parameter used to hold anti-CSRF token --csrf-url=CSRFURL URL address to visit for extraction of anti-CSRF token --csrf-method=CS.. HTTP method to use during anti-CSRF token page visit --csrf-retries=C.. Retries for anti-CSRF token retrieval (default 0) --force-sslForce usage of SSL/HTTPS --chunkedUse HTTP chunked transfer encoded (POST) requests --hppUse HTTP parameter pollution method --eval=EVALCODE Evaluate provided Python code before the request (e.g. "importhashlib;id2=hashlib.md5(id).hexdigest()")
Optimization: Theseoptions can be used to optimize the performance of sqlmap
-oTurn on all optimization switches --predict-outputPredict common queries output --keep-aliveUse persistent HTTP(s) connections --null-connectionRetrieve page length without actual HTTP response body --threads=THREADS Max number of concurrent HTTP(s) requests (default 1)
Injection: Theseoptions can be used to specify which parameters to test for, providecustom injection payloads and optional tampering scripts
-pTESTPARAMETER Testable parameter(s) --skip=SKIP Skip testing for given parameter(s) --skip-staticSkip testing parameters that not appear to be dynamic --param-exclude=.. Regexp to exclude parameters from testing (e.g. "ses") --param-filter=P.. Select testable parameter(s) by place (e.g. "POST") --dbms=DBMS Force back-end DBMS to provided value --dbms-cred=DBMS.. DBMS authentication credentials (user:password) --os=OS Force back-end DBMS operating system to provided value --invalid-bignumUse big numbers for invalidating values --invalid-logicalUse logical operations for invalidating values --invalid-stringUse random strings for invalidating values --no-castTurn off payload casting mechanism --no-escapeTurn off string escaping mechanism --prefix=PREFIX Injection payload prefix string --suffix=SUFFIX Injection payload suffix string --tamper=TAMPER Use given script(s) for tampering injection data
Detection: Theseoptions can be used to customize the detection phase
--level=LEVEL Level of tests to perform (1-5, default 1) --risk=RISK Risk of tests to perform (1-3, default 1) --string=STRING String to match when query is evaluated to True --not-string=NOT.. String to match when query is evaluated to False --regexp=REGEXP Regexp to match when query is evaluated to True --code=CODE HTTP code to match when query is evaluated to True --smartPerform thorough tests only if positive heuristic(s) --text-onlyCompare pages based only on the textual content --titlesCompare pages based only on their titles
Techniques: Theseoptions can be used to tweak testing of specific SQL injection techniques
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ") --time-sec=TIMESEC Seconds to delay the DBMS response (default 5) --union-cols=UCOLS Range of columns to test for UNION query SQL injection --union-char=UCHAR Character to use for bruteforcing number of columns --union-from=UFROM Table to use in FROM part of UNION query SQL injection --dns-domain=DNS.. Domain name used for DNS exfiltration attack --second-url=SEC.. Resulting page URL searched for second-order response --second-req=SEC.. Load second-order HTTP request from file
Fingerprint: -f,--fingerprint Perform an extensive DBMS version fingerprint
Enumeration: Theseoptions can be used to enumerate the back-end database managementsystem information, structure and data contained in the tables
-a,--all Retrieve everything -b,--banner Retrieve DBMS banner --current-userRetrieve DBMS current user --current-dbRetrieve DBMS current database --hostnameRetrieve DBMS server hostname --is-dbaDetect if the DBMS current user is DBA --usersEnumerate DBMS users --passwordsEnumerate DBMS users password hashes --privilegesEnumerate DBMS users privileges --rolesEnumerate DBMS users roles --dbsEnumerate DBMS databases --tablesEnumerate DBMS database tables --columnsEnumerate DBMS database table columns --schemaEnumerate DBMS schema --countRetrieve number of entries for table(s) --dumpDump DBMS database table entries --dump-allDump all DBMS databases tables entries --searchSearch column(s), table(s) and/or database name(s) --commentsCheck for DBMS comments during enumeration --statementsRetrieve SQL statements being run on DBMS -DDB DBMS database to enumerate -TTBL DBMS database table(s) to enumerate -CCOL DBMS database table column(s) to enumerate -XEXCLUDE DBMS database identifier(s) to not enumerate -UUSER DBMS user to enumerate --exclude-sysdbsExclude DBMS system databases when enumerating tables --pivot-column=P.. Pivot column name --where=DUMPWHERE Use WHERE condition while table dumping --start=LIMITSTART First dump table entry to retrieve --stop=LIMITSTOP Last dump table entry to retrieve --first=FIRSTCHAR First query output word character to retrieve --last=LASTCHAR Last query output word character to retrieve --sql-query=SQLQ.. SQL statement to be executed --sql-shellPrompt for an interactive SQL shell --sql-file=SQLFILE Execute SQL statements from given file(s)
Bruteforce: Theseoptions can be used to run brute force checks
--common-tablesCheck existence of common tables --common-columnsCheck existence of common columns --common-filesCheck existence of common files
User-definedfunction injection: Theseoptions can be used to create custom user-defined functions
--udf-injectInject custom user-defined functions --shared-lib=SHLIB Local path of the shared library
Filesystem access: Theseoptions can be used to access the back-end database management systemunderlying file system
--file-read=FILE.. Read a file from the back-end DBMS file system --file-write=FIL.. Write a local file on the back-end DBMS file system --file-dest=FILE.. Back-end DBMS absolute filepath to write to
Operatingsystem access: Theseoptions can be used to access the back-end database management systemunderlying operating system
--os-cmd=OSCMD Execute an operating system command --os-shellPrompt for an interactive operating system shell --os-pwnPrompt for an OOB shell, Meterpreter or VNC --os-smbrelayOne click prompt for an OOB shell, Meterpreter or VNC --os-bofStored procedure buffer overflow exploitation --priv-escDatabase process user privilege escalation --msf-path=MSFPATH Local path where Metasploit Framework is installed --tmp-path=TMPPATH Remote absolute path of temporary files directory
Windowsregistry access: Theseoptions can be used to access the back-end database management systemWindows registry
--reg-readRead a Windows registry key value --reg-addWrite a Windows registry key value data --reg-delDelete a Windows registry key value --reg-key=REGKEY Windows registry key --reg-value=REGVAL Windows registry key value --reg-data=REGDATA Windows registry key value data --reg-type=REGTYPE Windows registry key value type
General: Theseoptions can be used to set some general working parameters
-sSESSIONFILE Load session from a stored (.sqlite) file -tTRAFFICFILE Log all HTTP traffic into a textual file --answers=ANSWERS Set predefined answers (e.g. "quit=N,follow=N") --base64=BASE64P.. Parameter(s) containing Base64 encoded data --base64-safeUse URL and filename safe Base64 alphabet (RFC 4648) --batchNever ask for user input, use the default behavior --binary-fields=.. Result fields having binary values (e.g. "digest") --check-internetCheck Internet connection before assessing the target --cleanupClean up the DBMS from sqlmap specific UDF and tables --crawl=CRAWLDEPTH Crawl the website starting from the target URL --crawl-exclude=.. Regexp to exclude pages from crawling (e.g. "logout") --csv-del=CSVDEL Delimiting character used in CSV output (default ",") --charset=CHARSET Blind SQL injection charset (e.g. "0123456789abcdef") --dump-format=DU.. Format of dumped data (CSV (default), HTML or SQLITE) --encoding=ENCOD.. Character encoding used for data retrieval (e.g. GBK) --etaDisplay for each output the estimated time of arrival --flush-sessionFlush session files for current target --formsParse and test forms on target URL --fresh-queriesIgnore query results stored in session file --gpage=GOOGLEPAGE Use Google dork results from specified page number --har=HARFILE Log all HTTP traffic into a HAR file --hexUse hex conversion during data retrieval --output-dir=OUT.. Custom output directory path --parse-errorsParse and display DBMS error messages from responses --preprocess=PRE.. Use given script(s) for preprocessing (request) --postprocess=PO.. Use given script(s) for postprocessing (response) --repairRedump entries having unknown character marker (?) --save=SAVECONFIG Save options to a configuration INI file --scope=SCOPE Regexp for filtering targets --skip-heuristicsSkip heuristic detection of SQLi/XSS vulnerabilities --skip-wafSkip heuristic detection of WAF/IPS protection --table-prefix=T.. Prefix used for temporary tables (default: "sqlmap") --test-filter=TE.. Select tests by payloads and/or titles (e.g. ROW) --test-skip=TEST.. Skip tests by payloads and/or titles (e.g. BENCHMARK) --web-root=WEBROOT Web server document root directory (e.g. "/var/www")
Miscellaneous: Theseoptions do not fit into any other category
-zMNEMONICS Use short mnemonics (e.g. "flu,bat,ban,tec=EU") --alert=ALERT Run host OS command(s) when SQL injection is found --beepBeep on question and/or when SQLi/XSS/FI is found --dependenciesCheck for missing (optional) sqlmap dependencies --disable-coloringDisable console output coloring --list-tampersDisplay list of available tamper scripts --offlineWork in offline mode (only use session data) --purgeSafely remove all content from sqlmap data directory --results-file=R.. Location of CSV results file in multiple targets mode --shellPrompt for an interactive sqlmap shell --tmp-dir=TMPDIR Local directory for storing temporary files --unstableAdjust options for unstable connections --updateUpdate sqlmap --wizardSimple wizard interface for beginner users
可以找到有个参数:
1 2
--eval=EVALCODE Evaluate provided Python code before the request (e.g. "importhashlib;id2=hashlib.md5(id).hexdigest()")
defsetval(name:str, path:str, value:str)-> Optional[bool]: if name.find("__")>=0: returnFalse for word in __forbidden_name__: if name==word: returnFalse for word in __forbidden_path__: if path.find(word)>=0: returnFalse obj=globals()[name] try: pydash.set_(obj,path,value) except: returnFalse returnTrue
defsetval(name:str, path:str, value:str)-> Optional[bool]: if name.find("__")>=0: returnFalse for word in __forbidden_name__: if name==word: returnFalse for word in __forbidden_path__: if path.find(word)>=0: returnFalse obj=globals()[name] try: pydash.set_(obj,path,value) except: returnFalse returnTrue
@bottle.get('/render') defrender_template(): path=bottle.request.query.get('path') iflen(path)>10: return"hacker" blacklist=["{","}",".","%","<",">","_"] for c in path: if c in blacklist: return"hacker" return bottle.template(path) bottle.run(host='0.0.0.0', port=8000)
deftemplate(*args, **kwargs): """ Get a rendered template as a string iterator. You can use a name, a filename or a template string as first parameter. Template rendering arguments can be passed as dictionaries or directly (as keyword arguments). """ tpl = args[0] if args elseNone for dictarg in args[1:]: kwargs.update(dictarg) adapter = kwargs.pop('template_adapter', SimpleTemplate) lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) #去到TEMPLATE_PATH去寻找 tplid = (id(lookup), tpl) if tplid notin TEMPLATES or DEBUG: settings = kwargs.pop('template_settings', {}) ifisinstance(tpl, adapter): TEMPLATES[tplid] = tpl if settings: TEMPLATES[tplid].prepare(**settings) elif"\n"in tpl or"{"in tpl or"%"in tpl or'$'in tpl: TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings) else: TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings) ifnot TEMPLATES[tplid]: abort(500, 'Template (%s) not found' % tpl) return TEMPLATES[tplid].render(kwargs)
TEMPLATE_PATH = ['./', './views/'] TEMPLATES = {} DEBUG = False NORUN = False# If set, run() does nothing. Used by load_app()
接下来通过跟进lookup能够发现基类BaseTemplate中定义了搜索模板文件的方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
@classmethod defsearch(cls, name, lookup=None): """ Search name in all directories specified in lookup. First without, then with common extensions. Return first hit. """ ifnot lookup: raise depr(0, 12, "Empty template lookup path.", "Configure a template lookup path.")
if os.path.isabs(name): raise depr(0, 12, "Use of absolute path for template name.", "Refer to templates with names or paths relative to the lookup path.")
for spath in lookup: spath = os.path.abspath(spath) + os.sep fname = os.path.abspath(os.path.join(spath, name)) ifnot fname.startswith(spath): continue if os.path.isfile(fname): return fname for ext in cls.extensions: if os.path.isfile('%s.%s' % (fname, ext)): return'%s.%s' % (fname, ext)