我正在制作一个脚本,通过以下步骤将脚本或“有效负载”上传到站点:
1. User enters URL with * in place of query
2. User selects payload, which is simply a file with a pre-written JS script.
3. The * is replaced with the contents of the payload.
4. The URL with a script replacing the query is opened in an iframe.
我该怎么做?我的主要问题是文件上传到变量部分。到目前为止,这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>Slingshot.XSS</title>
</head>
<body style="font-family:monospace;" align="center">
<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: https://www.google.com/#q=*</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>
<input type="text" id="myPayload" placeholder="Enter payload path"> <button onclick="selectPayload()">Submit</button>
<script>
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;
}
function selectPayload() {
}
</script>
</body>
</html>
如何让用户浏览文件,然后选择一个文件并将其上传到变量中?
发布于 2017-04-28 00:35:57
首先,将type
标记的input
属性更改为"file"
,例如:
<input type="file" id="file">
然后创建一个filereader:
var fr = new FileReader();
由于文件将被异步读取,您应该添加一个回调以进一步进行,例如:
fr.onload = function(){... do something ...};
要读取文件调用readAsText
(例如,将其添加到onclick
事件):
fr.readAsText(document.getElementById('file').files[0]);
一旦加载了文件,内容将是fr.result
中的一个字符串。
MDN有更多的文档和示例。
https://stackoverflow.com/questions/43669894
复制相似问题