forked from thomaspatzke/Burp-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBurp-Randomizer.py
More file actions
55 lines (49 loc) · 2.31 KB
/
Burp-Randomizer.py
File metadata and controls
55 lines (49 loc) · 2.31 KB
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
# Burp Randomizer Extension
# Copyright 2017 Thomas Patzke <thomas@patzke.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from burp import (IBurpExtender, ISessionHandlingAction)
import re
import string
import random
### Configuration ###
# Character set of generated tokens
tokenCharset = string.ascii_letters + string.digits
# String which is replaced with random token
placeholder = "#RANDOM#"
placeholderNum = "#RANDOMNUM#"
# Length of generated token. WARNING: length of token must equal length of placeholder due to a bug in Burp 1.5.21 which cuts off requests under certain conditions.
tokenLength = len(placeholder)
tokenLengthNum = len(placeholderNum)
#####################
class BurpExtender(IBurpExtender, ISessionHandlingAction):
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
callbacks.setExtensionName("Randomizer")
self.callbacks.registerSessionHandlingAction(self)
self.out = callbacks.getStdout()
self.placeholder = re.compile(placeholder)
self.placeholderNum = re.compile(placeholderNum)
random.seed()
### ISessionHandlingAction ###
def getActionName(self):
return "Randomizer"
def performAction(self, currentRequest, macroItems):
request = self.helpers.bytesToString(currentRequest.getRequest())
randomToken = "".join([random.choice(tokenCharset) for i in range(tokenLength)])
randomTokenNum = str(random.randint(10 ** (tokenLengthNum - 1), 10 ** (tokenLengthNum) - 1))
request = self.placeholder.sub(randomToken, request)
result = self.helpers.stringToBytes(self.placeholderNum.sub(randomTokenNum, request))
currentRequest.setRequest(result)