Javascript 为什么单击按钮时此警报框不会弹出?
我一直在编写一个脚本来检查反射XSS漏洞。到目前为止,它有一个URL输入,用*代替查询,并有一个错误检查程序来检查格式错误的URL。它还有一个文件上传器,用户可以上传“有效载荷”。但是,我最近制作了一个用有效负载的内容替换*的部分,然后出于调试目的,我将其Javascript 为什么单击按钮时此警报框不会弹出?,javascript,html,input,replace,alert,Javascript,Html,Input,Replace,Alert,我一直在编写一个脚本来检查反射XSS漏洞。到目前为止,它有一个URL输入,用*代替查询,并有一个错误检查程序来检查格式错误的URL。它还有一个文件上传器,用户可以上传“有效载荷”。但是,我最近制作了一个用有效负载的内容替换*的部分,然后出于调试目的,我将其alert()作为带有文件内容的变量。但是,它不起作用。这是我的密码: 功能选择有效载荷(y){ var fr=new FileReader(); fr.readAsText(document.getElementById('file').f
alert()
作为带有文件内容的变量。但是,它不起作用。这是我的密码:
功能选择有效载荷(y){
var fr=new FileReader();
fr.readAsText(document.getElementById('file').files[0]);
fr.onload=函数(){
var dir=fr.result;
var有效载荷=y.replace(“*”,fr.result);
警报(有效载荷);
};
}
函数myFunction(){
var错误=[];
var x=document.getElementById(“myText”).value;
如果(!x.includes(“http://”)和&!x.includes(“https://”)){
错误。推送('URL中缺少HTTP或HTTPS');
}
如果(!x.includes(“*”){
错误。推送('缺少*代替查询')
}
//呈现错误
if(errors.length){
x='错误:'+错误。加入(',')+'!';
}
document.getElementById(“demo”).innerHTML=x;
选择有效载荷(x);
}
Slingshot.XSS
Slingshot.XSS
Slingshot.XSS是一个脚本,用于在目标上启动预加载的XSS有效负载,以测试其漏洞。
请将所有问题报告给
或者联系我email@example.com.
在查询位置输入带*的URL。
示例:https://www.google.com/#q=*
提交
没有提交的URL
选择有效负载:
有效载荷中的默认有效载荷
提交
第二个按钮调用了错误的函数。更改为调用myFunction()
,而不是selectPayload()
。除非您打算用第二个按钮调用selectPayload()
,否则在这种情况下,您需要像预期的那样向它传递一个参数
功能选择有效载荷(y){
var fr=new FileReader();
fr.readAsText(document.getElementById('file').files[0]);
fr.onload=函数(){
var dir=fr.result;
var有效载荷=y.replace(“*”,fr.result);
警报(有效载荷);
};
}
函数myFunction(){
var错误=[];
var x=document.getElementById(“myText”).value;
如果(!x.includes(“http://”)和&!x.includes(“https://”)){
错误。推送('URL中缺少HTTP或HTTPS');
}
如果(!x.includes(“*”){
错误。推送('缺少*代替查询')
}
//呈现错误
if(errors.length){
x='错误:'+错误。加入(',')+'!';
}
document.getElementById(“demo”).innerHTML=x;
选择有效载荷(x);
}
Slingshot.XSS
Slingshot.XSS
Slingshot.XSS是一个脚本,用于在目标上启动预加载的XSS有效负载,以测试其漏洞。
请将所有问题报告给
或者联系我keeganjkuhn@gmail.com.
在查询位置输入带*的URL。
示例:https://www.google.com/#q=*
提交
没有提交的URL
选择有效负载:
有效载荷中的默认有效载荷
提交
这里:我找到了可以工作的代码:
<!DOCTYPE html>
<html>
<head>
<title>Slingshot.XSS</title>
</head>
<body style="font-family:monospace;" align="center">
<script>
function selectPayload() {
var x = document.getElementById("myText").value;
var fr = new FileReader();
fr.readAsText(document.getElementById('file').files[0]);
fr.onload = function() {
var dir = fr.result;
var payload = x.replace("*", fr.result);
alert(payload);
};
}
function myFunction() {
var errors = [];
var x = document.getElementById("myText").value;
if (!x.includes("http://") && !x.includes("https://")) {
errors.push('missing HTTP or HTTPS in URL');
}
if (!x.includes("*")) {
errors.push('missing * in place of query')
}
// Renders errors
if (errors.length) {
x = 'Error: ' + errors.join(', ') + '!';
}
document.getElementById("demo").innerHTML = x;
}
</script>
<h2>Slingshot.XSS</h2>
<h3>Slingshot.XSS is a script that launches pre-loaded XSS payloads at a target to test its vulnerabilities.</h3>
<h4>Please report all issues to
<a href="https://github.com/keeganjk/slingshot.xss/issues"></a> or contact me at keeganjkuhn@gmail.com.</h4>
<a href="github.com/keeganjk/slingshot.xss" style="font-family:monospace" align="center">Source Code / Learn More</a>
<br />
<h4>Enter a URL with <b>*</b> in the place of query.</h4>
<h5>Example: <code>https://www.google.com/#q=*</code></h5>
<input type="text" id="myText" placeholder="Enter a URL"> <button onclick="myFunction()">Submit</button>
<p id="demo">No Submitted URL</p>
<h4>Select a payload:</h4>
<h5>Default payloads in <code>payloads</code></h5>
<input type="file" id="file"> <button onclick="selectPayload()">Submit</button>
</body>
</html>
您收到一个错误,因为y
未定义,并且您试图对其使用replace
。在文件输入提交按钮的onclick
上,您可以调用selectPayload
,而不是myFunction