-
Notifications
You must be signed in to change notification settings - Fork 0
/
burp2requests.html
96 lines (89 loc) · 3.52 KB
/
burp2requests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Burp Suite to Python Requests Converter</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
textarea {
width: 100%;
height: 200px;
margin-bottom: 20px;
white-space: pre-wrap;
word-wrap: break-word;
}
button {
display: block;
margin: 0 auto 20px;
}
pre {
background-color: #f8f8f8;
padding: 10px;
border: 1px solid #ddd;
white-space: pre-wrap; /* CSS3 */
white-space: -moz-pre-wrap; /* Firefox */
white-space: -pre-wrap; /* Opera <7 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* IE */
}
</style>
</head>
<body>
<h1>Burp to Python Requests Converter by n0mi1k (v1.0)</h1>
<textarea id="burpRequest" placeholder="Paste Burp Suite request here"></textarea>
<button onclick="convertRequest()">Convert to Python Requests</button>
<h2>Python Requests Code</h2>
<pre id="pythonCode"></pre>
<script>
function convertRequest() {
const burpRequest = document.getElementById('burpRequest').value;
const lines = burpRequest.split('\n');
let method, path, host = '', headers = {}, data = '';
const firstLine = lines.shift().split(' ');
method = firstLine[0];
path = firstLine[1];
let isHeader = true;
for (const line of lines) {
if (isHeader && line.trim() === '') {
isHeader = false;
continue;
}
if (isHeader) {
const [key, value] = line.split(': ');
if (key.toLowerCase() === 'host') {
host = value;
} else {
headers[key] = value;
}
} else {
data += line + '\n';
}
}
data = data.trim();
const url = `https://${host}${path}`;
const contentType = headers['Content-Type'] || headers['content-type'];
let pythonCode = `import requests\n\nurl = "${url}"\n`;
pythonCode += `\nheaders = ${JSON.stringify(headers, null, 4)}\n`;
if (method.toUpperCase() === 'GET') {
pythonCode += `\nresponse = requests.get(url, headers=headers)\n`;
} else if (method.toUpperCase() === 'POST') {
if (contentType && contentType.includes('application/json')) {
pythonCode += `\njson_data = ${data}\n`;
pythonCode += `\nresponse = requests.post(url, headers=headers, json=json_data)\n`;
} else {
pythonCode += `\ndata = """${data}"""\n`;
pythonCode += `\nresponse = requests.post(url, headers=headers, data=data)\n`;
}
}
pythonCode += `\nprint(response.status_code)\n`;
pythonCode += `print(response.headers)\n`;
pythonCode += `print(response.text)`;
document.getElementById('pythonCode').textContent = pythonCode;
}
</script>
</body>
</html>