这两天又重新看了下dvwa,重新写了一份wp,
暴力破解
Low
方法一
为了方便复现,随手弄了两个字典,其中包含正确账户密码。
![v2-d3d7ac714e8b071d5e4724eb852d3663_b.jpg](https://img-blog.csdnimg.cn/img_convert/8fe2d464e65b02c16131b8139c257a9d.png)
设置代理—使用 burpsuite抓包
![v2-2f04bf511bbafff78b62d139e76b66ab_b.jpg](https://img-blog.csdnimg.cn/img_convert/24a6383f39276e9e8298ec982b3c3799.png)
过程不多说了。直接看结果, ----成功
![v2-da1ec7d30f4e0a299e4bf8a941d605f7_b.jpg](https://img-blog.csdnimg.cn/img_convert/4bd252506fe1928c82c5f7dbdc432b5c.png)
方法二
可以看到查询语句并未做防护,所以存在sql注入,但由于pass位置做了md5加密,所以sql注入点应该是在 username处
![v2-da1ec7d30f4e0a299e4bf8a941d605f7_b.jpg](https://img-blog.csdnimg.cn/img_convert/4bd252506fe1928c82c5f7dbdc432b5c.png)
输入 admin' or '1'='1 登录成功
![v2-adbcdeec0ba0e318ead7934b2739faea_b.jpg](https://img-blog.csdnimg.cn/img_convert/0fff2081d047604330113f8c4902ce2d.png)
Medium
先看源码mysqli_real_escape_string()将 输入的username,password中的特殊字符进行转义。
Password md5加密 登陆失败 sleep(2) 秒。
给爆破,及注入带来了困难,但对于爆破来讲,就是增加了爆破的时间。爆破步骤如上。
![v2-3984b1b247acdcdef4e8d8850eff92ad_b.jpg](https://img-blog.csdnimg.cn/img_convert/973f634151a60a94a02f254c34949a83.png)
High
通过审计源码,我们可以知道,新增了一个参数,user_token。每次都需要重新请求token,其他的还有mysql_real_escape_string进行转义,$pass=md5($pass),sleep(rand(0,3))
![v2-07761af2a12454b717ebc35b5c4021ab_b.jpg](https://img-blog.csdnimg.cn/img_convert/b978d78a0285cb05553b948e2486367f.png)
首先抓包,发送到intruder 设置变量
Token设置为递归
并在options—Grep-Extract –Add设置token
![v2-7e0e012be96135d48ee9da0ecb8e0a1b_b.jpg](https://img-blog.csdnimg.cn/img_convert/0a5126c8c593121da4f95cd579caa643.png)
![v2-7e0e012be96135d48ee9da0ecb8e0a1b_b.jpg](https://img-blog.csdnimg.cn/img_convert/0a5126c8c593121da4f95cd579caa643.png)
最后在payloadOptions中设置第一次的token,然后开始攻击。
![v2-678075ede7a971df8d7c426dc30754b4_b.jpg](https://img-blog.csdnimg.cn/img_convert/1656c9dbe1ef92d9622076946613d416.png)
线程设置为1 ,否则报错。
选择长度和其他不一样的那个,查看,成功爆破。
![v2-678075ede7a971df8d7c426dc30754b4_b.jpg](https://img-blog.csdnimg.cn/img_convert/1656c9dbe1ef92d9622076946613d416.png)
文件包含漏洞
LOW
http://192.168.29.1/dvwa/vulnerabilities/fi/?page=../../../../../QQ/QQWhatsnew.txt 直接包含
![v2-f17390ee041ed6ab6b7f8ed0ed877bb2_b.jpg](https://img-blog.csdnimg.cn/img_convert/114682d35802053fae6e5f259f58f559.png)
Medium
查看源码可以看到过滤了 http:// https:// ../和..\
![v2-212de87031c1ae76d022ecc3a4a70a05_b.jpg](https://img-blog.csdnimg.cn/img_convert/26a41dc59846124164691e32f15b8084.png)
可以直接使用绝对路径来读取文件,
![v2-212de87031c1ae76d022ecc3a4a70a05_b.jpg](https://img-blog.csdnimg.cn/img_convert/26a41dc59846124164691e32f15b8084.png)
像这种过滤参数的,可以尝试进行双写,进行绕过。
![v2-0fec1b111367924d488a7a0305b31eab_b.jpg](https://img-blog.csdnimg.cn/img_convert/6180b2374d0effc2d446489d895dd70c.png)
High
对包含的文件名进行了限制,必须为 file* 或者 include.php ,否则会提示Error:File not found。看到必须为file*那就直接用file://来尝试文件包含。
![v2-9b23d02e249cbb20289e0f70fe147ba4_b.jpg](https://img-blog.csdnimg.cn/img_convert/ace8839136cf27b4a54bd5981fe7fe32.png)
![v2-9575c3317fce03b0d4fc9fca0367da08_b.jpg](https://img-blog.csdnimg.cn/img_convert/54e46759f91cfd36143ec8d1422007fb.png)
图片马使用方法与此相同。只需要将info.php文件替换为图片马即可。因为文件包含的特性。所以可以解析。
XSS
Dom型
Low
—dom型
直接在URL中进行传参
![v2-641e4ed108a84473b073392a72f9e16b_b.jpg](https://img-blog.csdnimg.cn/img_convert/26863d85b66b98cf3732d9a1b6f1e1d5.png)
Medium
删除对“ <脚本”的任何引用以禁用任何JavaScript
使用img标签进行弹窗,同时要注意前面标签的闭合,
![v2-32b51d0844ccd7b184a13a3a48b20cac_b.jpg](https://img-blog.csdnimg.cn/img_convert/9f6cacabbbc7129fe7ebac2fcd165cd2.png)
High
URL中#号之后的内容,不会被提交到服务器,可以直接与浏览器进行交互
![v2-1d91bea1ba2709a1f4da54bcc579b08d_b.jpg](https://img-blog.csdnimg.cn/img_convert/e57f53ccf514e2a47fa09e6132865dba.png)
反射型XSS
Low
没做防护,直接script
![v2-7fd6184749491ee6201763a79a08b1fb_b.jpg](https://img-blog.csdnimg.cn/img_convert/60d7c95118d63b1970e5aaf80b46931d.png)
Medium
过滤了script 但不区分大小写,写双层也能 绕过。
![v2-348812c873d1109b7d132d61e2fb22ae_b.jpg](https://img-blog.csdnimg.cn/img_convert/044055456b29c55c5369f48c8fa4ac25.png)
High
XSS的绕过方式太多。
![v2-db3170ba9201da2809334eb2e0eb2e46_b.jpg](https://img-blog.csdnimg.cn/img_convert/9d8bddf4030b28c3ed79f97dfe94fe34.png)
可以是用<a> 标签 <img> <form> <iframe> <svg>等各种标签进行绕过。(html事件)
另外还可以进行转码,
- 如js,html实体编码,URL编码(2次编码),String.fromCharCode编码
CSRF
CSRF,全称Cross-site request forgery,翻译过来就是跨站请求伪造,是指利用受害者尚未失效的身份认证信息(cookie、会话等),诱骗其点击恶意链接或者访问包含攻击代码的页面,在受害人不知情的情况下以受害者的身份向(身份认证信息所对应的)服务器发送请求,从而完成非法操作(如转账、改密等)。CSRF与XSS最大的区别就在于,CSRF并没有盗取cookie而是直接利用。
Low
直接构造链接,使受害者点击即可修改密码。可以通过短链来增加可信度,http://192.168.29.1/DVWA/vulnerabilities/csrf/?password_new=123456789&password_conf=123456789&Change=Change#
![v2-cd545a03232b8d33c0e7a76c690dd405_b.jpg](https://img-blog.csdnimg.cn/img_convert/ac218644736dbbdc479ebe0fa3d54ef1.png)
我们还可以构造钓鱼页面,如下,可以上传到网站上,使他人点击。
![v2-540ebf94ba9067998a0658c177d0afa3_b.jpg](https://img-blog.csdnimg.cn/img_convert/eaaff344ff694f9e3118536c9353fc8a.png)
![v2-60f3cae8e2c5ccdb7eaaf484c138c920_b.jpg](https://img-blog.csdnimg.cn/img_convert/cf26b25cab112bf361a5df6082f9648b.png)
在这里我搭建了两个dvwa,调到同一级别,在第二个dvwa打开页面。密码成功修改!
![v2-66084292b1951ff66cb07423a2b456ee_b.jpg](https://img-blog.csdnimg.cn/img_convert/33eabb72c5f3d6d465ff5ebbe84af54c.png)
![v2-9463bfab8236d1164339727d3af1d1c3_b.jpg](https://img-blog.csdnimg.cn/img_convert/cb8333ce61d37f2ca3bc2c4ecaf744a7.png)
![v2-38a29fb86826517bcfbf74b5641e2501_b.jpg](https://img-blog.csdnimg.cn/img_convert/9e3a5871b0fe958f9098244a7d158c37.png)
Medium
查看源码,发现使用 stripos() 函数添加了HTTP_REFERER 验证。不区分大小写。
![v2-c3e5684a1021a3b634f3babcaeaa3c1b_b.jpg](https://img-blog.csdnimg.cn/img_convert/2b1cfdfc74ebf79ea15c95a8cde6a2d2.png)
我们可以直接更改
前面抓包生成csrf_poc一样,我们进行重放。并添加referer,使其中包含host,
![v2-465b61b983d74eb4ae81bafd123df893_b.jpg](https://img-blog.csdnimg.cn/img_convert/27c3041e6e18ee3fbd75d599885bfe08.png)
可以看到,密码成功修改为123456789
![v2-d04c38af0368b0fc6c171a3fc7038464_b.png](https://img-blog.csdnimg.cn/img_convert/1d7e75a6e851700fc95dfc6e8f2bbb08.png)
High
直接添加了user_token一共需要传入4个参数,其中token在每次访问页面时都会随机更改,我们可以伪造一个页面,当用户点击时,就会获取到token,然后去请求修改密码。但是因为这已经属于跨域,现在的浏览器不允许跨域。所以无法实现。 我们可以使用XSS存储型,来获得token,然后将获得的token传到 url中,自动请求更改密码。
![v2-c0b1d4c39a2890715a92d9e50e0aa0ff_b.jpg](https://img-blog.csdnimg.cn/img_convert/a0f3896701bcf5742adb3da4d7b147c1.png)
具体参考 https://www.freebuf.com/articles/web/203301.html 内容信息量有点大,后面在看
SQL注入
Low
查看源码,没有做任何防护,字符型注入。
![v2-9fdfc1433630b6ec8f9501bc88029a94_b.jpg](https://img-blog.csdnimg.cn/img_convert/85f71639a90254a4ad13531ba49fe766.png)
可以输入单引号 查看是否报错。
使用order by 猜解SQL查询语句中的字段数。 使用union 查询数据库名和版本号。
![v2-4bfb4d838f9ca1368b2256773094646b_b.jpg](https://img-blog.csdnimg.cn/img_convert/45f9faed073a7501dbfbac0a727dffca.png)
![v2-6d5ec168e26b33042d0124e96b7eb595_b.jpg](https://img-blog.csdnimg.cn/img_convert/3329e369bc54b8d23365045808f6e900.png)
![v2-6d5ec168e26b33042d0124e96b7eb595_b.jpg](https://img-blog.csdnimg.cn/img_convert/3329e369bc54b8d23365045808f6e900.png)
![v2-3c40829a650f96ab57be6975d78f8601_b.jpg](https://img-blog.csdnimg.cn/img_convert/8dca237e8afbf7bc3e651d631af536a8.png)
Mysql中有一个information_schema的默认数据库,里面存有需要的信息。Union查询数据库中的表。
1’ union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #
![v2-766cd54d0d161a9601c0c50f297ef7b8_b.jpg](https://img-blog.csdnimg.cn/img_convert/6bb5b9eee421ad1548dfe79073aa70f0.png)
查询列名
1’ union select 1,group_concat(column_name) from information_schema.columns where table_name=’users’#
![v2-0ec143a34839cccabc26e4b77cc0ce25_b.jpg](https://img-blog.csdnimg.cn/img_convert/2fe4b2a8937734f5b898306dc7b76de3.png)
查询数据
1’ union select user,password from users#
![v2-599de5bef2b0d415a3d9c040afc3c23f_b.jpg](https://img-blog.csdnimg.cn/img_convert/c7c80320283022c72b640a5ffd060968.png)
方法二:我们可以直接用sqlmap进行注入。因为需要登陆。所以需要cookie。
sqlmap.py -u "http://192.168.29.1/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=nrng8g1jkurlshkvh3n3aevejj" –dbs
![v2-d38190f9c4e8dab749ef019bc075cbc5_b.jpg](https://img-blog.csdnimg.cn/img_convert/7e9c9933a85aabce036641c147d8b287.png)
跟上数据库名
sqlmap.py -u "http://192.168.29.1/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=nrng8g1jkurlshkvh3n3aevejj" –D dvwa –talbes
![v2-2b67f65261f0cc9f15fd39ab5c118229_b.jpg](https://img-blog.csdnimg.cn/img_convert/f0eef526468f354459387db5ee6ebf0c.png)
查看列名
sqlmap.py -u "http://192.168.29.1/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=nrng8g1jkurlshkvh3n3aevejj" -D dvwa –T –columns
![v2-513419e121695ddf63420627acbe4fbc_b.jpg](https://img-blog.csdnimg.cn/img_convert/f4241ee3fb2c740972a25015432411e4.png)
读取数据
sqlmap.py -u "http://192.168.29.1/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="security=low; PHPSESSID=nrng8g1jkurlshkvh3n3aevejj" -D dvwa -T users "user,password" –dump
![v2-36763113b16707187bce207c9b8a7d42_b.jpg](https://img-blog.csdnimg.cn/img_convert/4e9cead83626287b96e8f1566e5375d9.png)
Medium
通过查看源码,可以之间看到,传进的参数,不需要闭合,同时对传入数据库的特定数据进行了转义,例如 ’ , “ ,
![v2-dd7655fa05762a3a105883625f59aaa5_b.jpg](https://img-blog.csdnimg.cn/img_convert/b2ca6cc0a842ceeb674e764077826a83.png)
我们可以通过sqlmap跑,也可以直接注入。或者通过burpsuite。
![v2-207f83e1386c166dec52ba223763a04b_b.jpg](https://img-blog.csdnimg.cn/img_convert/219025e87cf6d968197c833f1b6fa7e4.png)
可以看到,当我在读取列名的时候, table_name=’users’# 因为单引号被转义了,所以这里会出现报错,对此,我们可以将’ 进行编码。
![v2-1cdf783ac3e332a69dc2f620f74f9640_b.png](https://img-blog.csdnimg.cn/img_convert/9b1d2e71b556e45bfed5694f0b94517d.png)
![v2-804812c33428690e260a0eae31171a50_b.jpg](https://img-blog.csdnimg.cn/img_convert/0a21a330f095d4ea9f4ee2f26a2ab332.png)
后面直接查需要的信息
![v2-1e49ee01df76e738ed0136c93bee82a4_b.jpg](https://img-blog.csdnimg.cn/img_convert/4a7f0d8d332f16f42792383b8aaacd1a.png)
Sqlmap法
可以使用burpsuite中的一个CO2插件,一键发送到sqlmap,进行注入
![v2-8a3623db7a6bb0a812a8cf868d25eb8e_b.jpg](https://img-blog.csdnimg.cn/img_convert/d3794fb67318cf3b49c0bd09b03ebb04.png)
![v2-e838bd401b66814d736bb8911ef69c1d_b.jpg](https://img-blog.csdnimg.cn/img_convert/9966712422607150a3e0c871e24e1c30.png)
![v2-e5397eea7e54f3090ff46a64c448af87_b.jpg](https://img-blog.csdnimg.cn/img_convert/5102db6f93c95ac1707553a36a3996c2.png)
High
看下源代码,多了个limit 1,只是少了输出,我们可以用注释符#将他注释掉。其他的和low没有区别。
![v2-909a869ddbb215617e882e3af53e6946_b.jpg](https://img-blog.csdnimg.cn/img_convert/3e3f204b23ba5e7535630b73b5f6cc65.png)
![v2-f4266b0a0547e079c46663fe75d4d9b5_b.jpg](https://img-blog.csdnimg.cn/img_convert/39f148fa8625dbac7bf08e3f6aad8989.png)
![v2-dc68c4c23382892db07e968f2ab7bbb4_b.jpg](https://img-blog.csdnimg.cn/img_convert/d9a7c85b8b83731a9e0568e725426170.png)
经过检测,有SQL注入。直接注入,因为和low一样,所以我就直接放结果了
![v2-0fefa1212fb4ea55cc5d7b3e1e93e02b_b.jpg](https://img-blog.csdnimg.cn/img_convert/1277d31c195c43ce03217f02b7c9804b.png)
因为注入点和输出不在同一页面,这主要还是防止sqlmap自动注入。
Weak Session IDs (弱会话IDs)
当用户登录后,在服务器就会创建一个会话(session),叫做会话控制,接着访问页面的时候就不用登录,只需要携带Sesion去访问。如果SessionID是保存在Cookie中的,则这种攻击可以称为Cookie劫持。
Low
![v2-6fc21a5fa075425562572a698f4911cf_b.jpg](https://img-blog.csdnimg.cn/img_convert/c38786267fbb5d2b3d0fd5226bf9e348.png)
直接抓包,看下,可以看到生成了session,并且在cookie中,
![v2-54e2c21ae5fc39c0e82ba5908abf8387_b.jpg](https://img-blog.csdnimg.cn/img_convert/60e4bcd159ca5f9ae6026ffbfab15c49.png)
我们直接复制cookie,然后另外清除cookie,进行发包。并post传参这个cookie,看下效果。可以看到,直接登录成功。不需要账号密码,
![v2-5e47c8466955c7ac29467f8b73576260_b.jpg](https://img-blog.csdnimg.cn/img_convert/6ba2ef7e9b94582dffe9dcacbb0aad8e.png)
![v2-ad8afa41c524d395bc0aa819acb68bd3_b.jpg](https://img-blog.csdnimg.cn/img_convert/c16fe2c40a3c607554b1b4ca9dfad296.png)
Medium
使用时间戳,时间戳是指 1970-01-01 08:00:00起到现在 当前时间的秒数。
![v2-3955de5ee94ba3618ca5456f0d42dbf4_b.jpg](https://img-blog.csdnimg.cn/img_convert/363625b44efd90ad1bac1f809752788d.png)
操作步骤,首先获得 别人的cookie,我们去生成未来时间的时间戳,30s至1分钟即可,到时间,我们进行post传参。
![v2-3311fc9b08d2679b10d4287694ab6e1c_b.jpg](https://img-blog.csdnimg.cn/img_convert/f5f6fde745a44000bbbaf403743f338f.png)
![v2-bcd1c6edb698e6ffb3f50303a62b8d02_b.jpg](https://img-blog.csdnimg.cn/img_convert/02b84ab2fa7b5bd398dfc3c0c0413e8a.png)
High
虽然md5加密,但还是从0 开始,时间戳解决方法同上,先抓包
![v2-29fcbd823d117a2d98c4f5c4dd574219_b.jpg](https://img-blog.csdnimg.cn/img_convert/64fdeb6249bf28473c618d8cd1592f39.png)
发现cookie
dvwaSession=aab3238922bcc25a6f606eb525ffdc56; expires=Sun, 25-Oct-2020 08:59:08 GMT; Max-Age=3600; path=/vulnerabilities/weak_id/; domain=192.168.29.1
CSP Bypass
CSP就是浏览器的安全策略,如果 标签,或者是服务器中返回 HTTP 头中有 Content-Security-Policy
标签 ,浏览器会根据标签里面的内容,判断哪些资源可以加载或执行。
Low
如果不看源码的话。看检查器(F12),也可以知道一些被信任的网站。
![v2-3e6b4407ee13e84a2bfe950473c01426_b.png](https://img-blog.csdnimg.cn/img_convert/61fd657188846e0eb36c15a511008cca.png)
意思就是信任这些网站及以上脚本, 。如果我们在这些网站上植入攻击脚本,那么将脚本地址放入dvwa,dvwa将会执行它。比如。https://pastebin.com/raw/VqHmJKjr
![v2-27f4016aef3af6b90428a66662dfbee4_b.jpg](https://img-blog.csdnimg.cn/img_convert/e223491ef6e38bc4be22b032bc1e473e.png)