我正在尝试将代码注入(inject)到第二个页面 (XSSthissite),然后单击此自定义 html 页面上的按钮。我可以通过使用 Ajax 调用表单的 javascript 函数重定向到第二页。从技术上讲,检查开发人员工具,似乎 POST 已通过,但无法实际登录/重定向,并且字段未显示填充。具体来说,如果在该页面上手动提交数据,我会收到 302 POST 重定向,而不是看到 200 POST。知道为什么吗?
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Having Fun on a Tuesday</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form action="" method="POST" id="second">
<input type="hidden" name="aufnausindulasdnf" value="aufnausindulasdnf"/>
<input type="hidden" name="treasure" value="urghrugh?"/>
<input type="hidden" name="login" value="testing" />
<input type="hidden" name="password"/>
<input type="hidden" name="action" value="entryway" />
</form>
<script>
function submitFormAjax() {
window.location.assign("http://XSSthissite");
$("#second").submit(function(e) {
e.preventDefault();
$.ajax({
url: 'http://XSSthissite',
type: "POST",
// data: $(this).serialize(),
});
});
$("#second").trigger('submit');
}
</script>
</head>
<body>
<form onsubmit="" method="POST" action="" >
<input id="login_target" value="username"/>
<button type="button" id="unique" onclick="submitFormAjax()">MESSAGE</button>
</form>
</body>
</html>
更新了代码,删除了位置和 Ajax。仍然发布 - 并填充所有字段,但拒绝提交!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Having Fun on a Wednesday</title>
</head>
<body>
<input id="login_target" value="username"/>
<button type="button" id="unique" onclick="submitForm()">MESSAGE</button>
<form action="http://XSSthissite" method="POST" id="second">
<input type="hidden" name="aufnausindulasdnf" value="aufnausindulasdnf"/>
<input type="hidden" name="treasure" value="urghrugh?"/>
<input type="hidden" name="login" value="testing" />
<input type="hidden" name="password"/>
<input type="hidden" name="action" value="entryway" />
</form>
<script>
function submitForm() {
document.getElementById("second").submit()
}
</script>
</body>
</html>
最佳答案
在您的submitFormAjax 上您有以下行:
window.location.assign("http://XSSthissite");
该行将您网站的当前 URL 更改为“http://XSSthissite ” (http 200),这样您就可以绕过提交功能与第二个按钮的绑定(bind)。
尝试在不更改当前 URL 的情况下发送信息,但请记住,如果“http://XSSthissite ”没有启用 CORS,则您无法从不同的来源执行 POST,这是由浏览器安全设计造成的。
PS:你的第二个表单位于“head”标签之上,将表单放在正文中作为 HTML 的良好实践。还有“脚本”部分。 引用:Why scripts at the end of body tag
关于javascript - XSS Ajax,辅助表单无法正确发布,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53181853/