面试过程中被问到SQLMAP参数,好奇之下学习了一遍。
Options
Target
Request
Optimization
Injection
Detection
Techniques
Fingerprint
Enumeration
Brute force
User-defined function injection
File system access
Operating system access
Windows registry access
General
Miscellaneous
options
-h, --help 显示基本的帮助信息
-hh 显示丰富的帮助信息,全罗列
-version 显示版本信息
-v VERBOSE 设置输出消息的详细程度。有七个详细级别。默认级别为1,其中显示信息,警告,错误,严重消息和Python回溯(如果发生)。
0: 只显示python错误和一些严重信息;
1: 显示基本信息,默认
2:显示debug信息;
3:显示注入过程的payload
4:显示http请求包
5:显示http响应头
6:显示http相应页面
Target
-u URL –url=URL ,形式:"http://www.site.com/vuln.php?id=1"
-d 直接连接目标后端数据库,而不是使用SQL注入漏洞,直接通过目标侦听端口连接,需要目标数据库的账号名和密码。例:-d "mysql://user:[email protected]:3389/databasename" --dbs 查询非常快。
-l logfile burp或WebScarab proxy的日志文件,sqlmap会扫描log中的所有记录,例:-l log.txt
-m 后接txt文件,文件中是多个url,sqlmap自动化检测其中的所有url. 例:-m target.txt
-r 从文件中加载http请求;可以降一个post请求方式的数据包保存在txt中,sqlmap通过post方式检测目标。例:-r post.txt
-g 使用google引擎搜索类似的网址,并且多目标检测。例:-g “inurl:\”.php?id=1\””
-c configfile,将使用的命令写在一个文件中,sqlmap执行文件中的命令,可以用—save命令将配置写入文件。
Request
-A Agent,--user-agent=Agent,指定user-agent值进行测试。
例: --user-agent="aaaaaaa" 默认情况下,sqlmap会使用自己的user-agent进行测试(所以很多服务器发现user-agent是sqlmap的数据包直接认为是入侵),sqlmap自己的user-agent是:sqlmap/1.0-dev-nongit-201603020a89(http://sqlmap.org)
-H --headers 额外的header头,每个占一行。例:--headers="host:www.a.com\nUser-Agent:yuangh"
--headers-HEADERS
--method --method=METHOD,指定get方法还是post方法,例如:--method=GET –method=POST
--data --data=DATA指明参数是哪些,POST提交,例-u "www.abc.com/index.php?id=1" --data="name=1;pass=2"
--param-del=PARA 知名使用的变量分割符。例-u "www.abc.com/index.php?id=1" --data="name=1;pass=2" --param-del=";"
--cookie-COOKIE 指定测试使用的cookie,在一些需要登陆的站点会使用。
--cookie-del=COO.. Character used for splitting cookie values (e.g.
--load-cookies=L.. 从包含Netscape/wget格式的cookie的文件中加载cookie
--drop-set-cookie 默认情况下,sqlmap是开启set-cookie功能的,也就是当收到一个含有set-cookie的http包的时候,下次sql会使用新的cookie进行发包,如果使用这条命令,就会关闭这个功能。在level>=2时会检测cookie注入。
--mobile Imitate smartphone through HTTP User-Agent header
--random-agent 使用随机user-agent进行测试。sqlmap有一个文件中储存了各种各样的user-agent,文件在sqlmap/txt/user-agent.txt 在level>=3时会检测user-agent注入。
--host=HOST 指定http包中的host头参数。例:--host=’aaa’在level>=5时才会检查host头注入
--referer=REFERER 指定http包中的referer字段,例:--referer=’aaaa’,level>=3时才会检测referer注入
--auth-type=AUTH 基于http身份验证的种类,例: --auth-type Basic/Digest/NTLM 一共有三种认证方式。
--auth-cred=AUTH 使用的认证。--auth-type Basic –auth-cred “user:password”
--auth-file=AUTH 使用.PEM文件中的认证, 例:--auth-file="AU.PEM" 少见
--ignore-code=IG..无视http状态码。 --ignore-code=401
--ignore-proxy ,无视本地代理,有时候机器会有最基本的代理配置,在扫描本地网段时候会很麻烦,使用这个参数可以忽略代理。
--ignore-redirects,无视重定向,比如登陆成功会跳转到其他网页。
--ignore-timeout,无视超时。
--proxy=PROXY ,指定一个代理,例如:--proxy=”127.0.0.1:8087”,使用GoAgent代理。
--proxy-cred=PRO.. 代理需要的认证,--proxy=”name:password”
--proxy-file=PRO.. 从文件中加载代理过程
--tor 使用tor匿名网络
--tor-port=TORPORT Set Tor proxy port other than default
--tor-type=TORTYPE Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default))
--check-tor Check to see if Tor is used properly
--delay=DELAY 每次发包的延迟时间,单位为秒。例:--delay 2.5有时候发包频繁会引起服务器注意,使用delay降低发包频率。
--timeout=TIMEOUT 请求超时的时间,单位为秒,默认30s
--retries=RETRIES 超时重连次数default 3
--randomize=RPARAM 随机改变指定参数的值,在参数长度、类型与输入值保持一直的前提下。有时候反复提交同一个参数会引起服务器注意。
--safe-url=SAFEURL 和-u类似,就是一个加载测试url的方法,但额外功能是防止有时候时间长了不通讯服务器会销毁session,开启这种功能会隔一段时间发一个包保持session。
--safe-post=SAFE.. 采用post方式发送数据。
--safe-req=SAFER.. 从文件中加载目标
--safe-freq=SAFE.. 频繁发送错误的请求,服务器也会销毁session或者其他惩罚方式,开着此功能,发几次错的就会发一次对的,用于盲注。
--skip-urlencode 跳过url编码,不排除有的网站url不遵守RFC标准编码。
--csrf-token=CSR.. 保持csrf令牌的token
--csrf-url=CSRFURL 访问URL获取anti-csrf 令牌
--csrf-method=CS.. 访问anti-csrf令牌页面时,设置http访问方式,
--csrf-retries=C.. 设置尝试恢复anti-csrf令牌的次数 (default 0)
--force-ssl 强制使用
--chunked Use HTTP chunked transfer encoded (POST) requests
--hpp 使用http参数污染,通产http传递参数会以名称-值对的形式出现,通常在一个请求中,同样名称的参数只会出现一次。但是在HTTP协议中是允许同样名称的参数出现多次的,就可能造成参数篡改。
--eval=EVALCODE 执行一段指定的python代码,例-u "www.abc.com/index.php?id=1" --eval="import hashlib;hash=hashlib.md5(id).hexdigest()"
Optimization
-o 开启优化开关(--predict-output, --keep-alive, --nul-connection)
--predict-output 预设输出,可以理解为猜一个表存在不存在,根据服务器返回值来进行判断,有点类似暴力破解,但和暴力破解又不同,这个是一个范围性的暴力破解,一次一次的缩小范围。
--keep-alive 使用http(s)长连接,性能更好,避免重复建立连接的开销,但是占用服务器资源,且与—proxy不兼容。
--null-connection 只看页面返回的大小值,不看具体内容,通常用于盲注或者布尔判断,只看对错,不看内容。
--threads=THREADS 多线程,默认1,最大10,和—predict-output不兼容。
Injection
These options can be used to specify which parameters to test for, provide custom injection payloads and optional tampering scripts
-p TESTPARAMETER 测试的参数,使用这个,--level参数就会失效,例-p "user-agent,refere"
--skip=SKIP 排除指定参数,例:--level 5 –skip=”id,user-agent”
--skip-static 跳过测试静态的参数。
--param-exclude=.. 使用正则表达式跳过测试参数 (e.g. "ses")
--param-filter=P.. 选择测试的参数,例如“POST”
--dbms=DBMS 指定目标数据库类型 --dbms="MySQL<5.0>" Oracle<11i> Microsoft SQL Server<2005>
--dbms-cred=DBMS.. 数据库认证,例:--dbms-cred=”name:password”
--os=OS 指定目标操作系统
--invalid-bignum 通常情况下sqlmap使用负值参数使参数失效,比如id=1 -> id=-1,开启此项使用大值使参数失效,如id=999999
--invalid-logical 使用逻辑使参数失效,如id=1and 1=2
--invalid-string 使用随机字符串使参数失效
--no-cast 关闭 payload casting mechanism,获取数据时,sqlmap会将所有数据转换成字符串,并用空格代替null
--no-escape Turn off string escaping mechanism.用于混淆和避免出错,使用单引号的字符串的时候,有时候会被拦截,sqlmap使用char()编码,例如:select “a”-> select char(97)。
--prefix=PREFIX Injection payload prefix string。指定payload前缀,有时候我们猜到了服务端代码的闭合情况,需要使用这个来指定一下。例: -u "www.abc.com/index?id=1" -p id --prefix")" --suffix "and ('abc'='abc"
--suffix=SUFFIX 指定payload后缀
--tamper=TAMPER 使用sqlmap自带的tamper,或者自己写的tamper,来混淆payload,通常用来绕过waf和ips。
Detection
--level=LEVEL 设置测试等级1-5,默认1,2:cookie;3:user-agent;4:refer;5:host;Level of tests to perform (1-5, default 1)
--risk=RISK Risk of tests to perform (1-3, default 1)。升高风险等级会增加数据被篡改的风险,2:基于事件的测试i;3:or语句的测试;4:update的测试。
--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。也是基于布尔的注入时,只不过指定的时http返回码。
--smart Perform thorough tests only if positive heuristic(s) 有大量检测目标时候,只选择基于错误的检测。
--text-only Compare pages based only on the textual content。类似基于布尔的注入,指定页面的一段文本内容作为对比
--titles Compare pages based only on their titles。同上,指定的是页面的标题。
Techniques
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ")指定所使用的技术(布尔盲注,报错注入,联合查询注入,堆叠查询(文件系统、操作系统、注册表相关注入),时间盲注,内敛查询;默认全部使用)
--time-sec=TIMESEC Seconds to delay the DBMS response (default 5)基于时间的盲注的时候,指定判断的时间,单位S,默认5s
--union-cols=UCOLS Range of columns to test for UNION query SQL injection.联合查询的尝试次数,随level增加,最多支持50列,例:--union-cols 6-9
--union-char=UCHAR Character to use for bruteforcing number of columns.联合查询默认使用的占列是null,有些情况null可能会失效,可以手动指定其他的,例如:--union-char 1
--union-from=UFROM Table to use in FROM part of UNION query SQL injection。联合查询从之前的查询结构中选择列。
--dns-domain=DNS.. Domain name used for DNS exfiltration attack,如果控制了一台dns服务器,使用这个参数可以提高效率,例:--dns-domain 123.com
--second-url=SEC.. Resulting page URL searched for second-order response,在一个页面注入的结果,在另一个页面显示。一些网站进行SQL注入测试时,针对一个URL的SQL注入测试可能会在另一个URL中显示。通常是由于用户在原始测试页面上提供的输入,数据库进行了存储而发生的。
--second-req=SEC.. Load second-order HTTP request from file。显示效果的URL地址。
Fingerprint
-f, --fingerprint Perform an extensive DBMS version fingerprint
指纹信息,返回DBMS,操作系统,架构,补丁等信息。
Enumeration
-a, --all Retrieve everything,查找全部,很暴力
-b, --banner Retrieve DBMS banner查找数据库管理系统的标识
--current-user Retrieve DBMS current user当前用户,常用
--current-db Retrieve DBMS current database
--hostname Retrieve DBMS server hostname
--is-dba Detect if the DBMS current user is DBA,探寻当前用户是否是DBA
--users Enumerate DBMS users
--passwords Enumerate DBMS users password hashes,用户密码的哈希
--privileges Enumerate DBMS users privileges特权
--roles Enumerate DBMS users roles角色权限
--dbs Enumerate DBMS databases
--tables Enumerate DBMS database tables
--columns Enumerate DBMS database table columns
--schema Enumerate DBMS schema,数据库系统管理模式
--count Retrieve number of entries for table(s),查询结果返回一个数字,即多少个。
--dump Dump DBMS database table entries,查询指定范围的全部数据,例:--dump -D admin -T admin -C username
--dump-all Dump all DBMS databases tables entries,查询全部数
--search Search column(s), table(s) and/or database name(s),搜索列、表和/数据库名称
--comments Check for DBMS comments during enumeration,检索数据库的备注
--statements Retrieve SQL statements being run on DBMS,检索DBMS运行的声明。
-D DB DBMS database to enumerate
-T TBL DBMS database table(s) to enumerate
-C COL DBMS database table column(s) to enumerate
-X EXCLUDE DBMS database identifier(s) to not enumerate,
-U USER DBMS user to enumerate
--exclude-sysdbs Exclude DBMS system databases when enumerating tables排除数据系统数据库
--pivot-column=P.. Pivot column name枢轴列明
--where=DUMPWHERE Use WHERE condition while table dumping,dump时使用where限制条件
--start=LIMITSTART First dump table entry to retrieve,设置起始dump表入口,和—dump连用
--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语句
--sql-shell Prompt for an interactive SQL shell,执行SQL shell
--sql-file=SQLFILE Execute SQL statements from given file(s),执行给定文件中的sql语句。
Brute force
--common-tables Check existence of common tables,检查有没有记录表信息的公共表,比如mysql>=5.0会有一个information_schema库,储存了整个数据库的基本信息。有
--common-columns Check existence of common columns,有没有记录公共列的表,比如Access就没有列信息。这两种方法都会使用暴力破解。
--common-files Check existence of common files,公共文件。
User-defined function injection
--udf-inject Inject custom user-defined functions,编译共享库创建并上传只DBServer,生成UDF实现高级注入。
--shared-lib=SHLIB Local path of the shared library,共享库本地路径。
File system access
--file-read=FILE.. Read a file from the back-end DBMS file system,读取目标站点文件,例: --file-read="/etc/password"
--file-write=FIL.. Write a local file on the back-end DBMS file system,写入到目标站带你的一个文件,通常和—sql-query连用,例:--sql-query=”select”一句话木马”—file-write=”shell.php”
--file-dest=FILE.. Back-end DBMS absolute filepath to write to,同上,使用绝对路径写入。
Operating system access
--os-cmd=OSCMD Execute an operating system command,执行系统命令,例:--os-cmd=”ipconfig -all”
--os-shell Prompt for an interactive operating system shell,创建一个对方操作系统的shell,远程执行系统命令,直接使用。
--os-pwn Prompt for an OOB shell, Meterpreter or VNC,获取一个OOBshell, Meterpreter or VNC
--os-smbrelay One click prompt for an OOB shell, Meterpreter or VNC,单击获取个OOBshell, Meterpreter or VNC
--os-bof Stored procedure buffer overflow exploitation,利用缓冲区溢出。
--priv-esc Database process user privilege escalation,自动提权,数据库进程用户权限提升
--msf-path=MSFPATH Local path where Metasploit Framework is installed,Metasploit Framework本地安装路径
--tmp-path=TMPPATH Remote absolute path of temporary files directory,远程临时文件目录的绝对路径
Windows registry access
--reg-read Read a Windows registry key value
--reg-add Write a Windows registry key value data
--reg-del Delete a Windows registry key value
--reg-key=REGKEY Windows registry key,和之前连用,注册表key值
--reg-value=REGVAL Windows registry key value,注册表value
--reg-data=REGDATA Windows registry key value data,注册表数据。
--reg-type=REGTYPE Windows registry key value type,数据表类别。
General
-s SESSIONFILE Load session from a stored (.sqlite) file,从文件中加载保存的session
-t TRAFFICFILE Log all HTTP traffic into a textual file,记录http流到文本文件
--answers=ANSWERS Set predefined answers (e.g. "quit=N,follow=N")设置问题答案,在刚刚的--batch 可以跳过很多问题,但只是选择默认值,可以使用者个参数对特定问题设定特定答案。例: --answer "extending=N"
--base64=BASE64P.. Parameter(s) containing Base64 encoded data,参数包含Base64编码数据
--base64-safe Use URL and filename safe Base64 alphabet,URL和文件名使用Base
--batch Never ask for user input, use the default behavior,批处理,在检测过程中会问用户一些问题,使用此参数统统使用默认值
--binary-fields=.. Result fields having binary values (e.g. "digest"),指定二进制结果的字段
--check-internet Check Internet connection before assessing the target,在评估前检查互联网连接。
--cleanup Clean up the DBMS from sqlmap specific UDF and tables 从SqLMAP特定的UDF和表中找数据库,类似暴力破解。
--crawl=CRAWLDEPTH Crawl the website starting from the target URL,从起始未知爬取的深度,例:crawl=3
--crawl-exclude=.. Regexp to exclude pages from crawling (e.g. "logout")排除爬取的页面,--crawl-exclude="abc.com/logout.php"
--csv-del=CSVDEL Delimiting character used in CSV output (default ",")指定在CSV输出中使用的分隔字符。
--charset=CHARSET Blind SQL injection charset (e.g. "0123456789abcdef")强制字符串编码,例,--charset=GBK
--dump-format=DU.. Format of dumped data (CSV (default), HTML or SQLITE) 转储数据的格式 ,有(CSV (默认), HTML,SQLITE)三种。
--encoding=ENCOD.. Character encoding used for data retrieval (e.g. GBK)用于数据检索的字符编码。
--eta Display for each output the estimated time of arrival,显示每个输出的预计到达时间。
--flush-session Flush session files for current target请空会话信息
--forms Parse and test forms on target URL在目标URL上解析和测试表单
--fresh-queries Ignore query results stored in session file,SQLMAP每次查询都会将查询结果存储在.sqlmap文件夹中,下次再有相同查询会调用上次的查询结果,使用此项可以忽略存储的查询结果重新查询。
-gpage=GOOGLEPAGE Use Google dork results from specified page number,从特定页面数字中使用googledork结果
--har=HARFILE Log all HTTP traffic into a HAR file,记录所有http流量再har文件
--hex Use hex conversion during data retrieval,dump非ASCII字符时,将其编码为16禁止,收到后节码还原
--output-dir=OUT.. Custom output directory path,输出结果到文件,--output-dir=/tmp
--parse-errors Parse and display DBMS error messages from responses,解析并显示报错信息
--preprocess=PRE.. Use given script(s) for preprocessing of response data,给定脚本提前处理或反应数据
--repair Redump entries having unknown character marker (?)重dump未知的字符标记
--save=SAVECONFIG Save options to a configuration INI file,将使用的命令保存到配置ini文件
--scope=SCOPE Regexp for filtering targets,和-l类似,只是这个可以过滤信息,使用正则表达式过滤网址。
--skip-waf Skip heuristic detection of WAF/IPS protection跳过WAF/IPS/IDS保护的启发式检测。
--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"),设置web服务器文档根目录
Miscellaneous
该目录下的选项和其他目录不兼容
-z MNEMONICS Use short mnemonics (e.g. "flu,bat,ban,tec=EU")参数助记符,比较傻的一个功能。例: -z "bat,randoma,ign,tec=BEU" 其实就是只要你写的字母可以唯一匹配其他参数,就可以生效。
--alert=ALERT Run host OS command(s) when SQL injection is found。在找到SQL注入时运行主机OS命令。
--beep Beep on question and/or when SQL injection is found,在问题和/或当SQL注入被发现时发出beep声
--dependencies Check for missing (optional) sqlmap dependencies,检查缺少的SQL映射依赖
--disable-coloring Disable console output coloring,禁用控制台输出着色
--list-tampers Display list of available tamper scripts,显示tamper脚本列表
--offline Work in offline mode (only use session data),离线运行
--purge Safely remove all content from sqlmap data directory,移除所有数据
--results-file=R.. Location of CSV results file in multiple targets mode,多目标模式下,定位CSV文件
--sqlmap-shell Prompt for an interactive sqlmap shell,交互式SQLMAP shell
--tmp-dir=TMPDIR Local directory for storing temporary files,存储临时文件目录
--unstable Adjust options for unstable connections,调整选项以适应不稳定连接
--update Update sqlmap,更新SQLMAP
--wizard Simple wizard interface for beginner users,新手教程
来源:freebuf.com 2020-09-09 16:54:48 by: 荷殇

评论