Created
October 25, 2017 07:44
-
-
Save ismailakkila/15051fbaa6557c4d06155e34f3b8365c to your computer and use it in GitHub Desktop.
ch6_burp_intruder_fuzz_example.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ch6_burp_intruder_fuzz_example.py | |
#Required for Burp Extender | |
from burp import IBurpExtender | |
from burp import IIntruderPayloadGeneratorFactory | |
from burp import IIntruderPayloadGenerator | |
from java.util import List, ArrayList | |
import random | |
#Class to Define Burp Intruder Payload Generator Factory. Please refer to | |
#IIntruderPayloadGeneratorFactory API in Burp | |
class BurpExtender(IBurpExtender, IIntruderPayloadGeneratorFactory): | |
#This is required to register the extender | |
def registerExtenderCallbacks(self, callbacks): | |
self._callbacks = callbacks | |
self._helpers = callbacks.getHelpers() | |
callbacks.registerIntruderPayloadGeneratorFactory(self) | |
return | |
#Name of the Extender. Required according to API | |
def getGeneratorName(self): | |
return "BHP Payload Generator" | |
#The extender will initialize BHPFuzzer Class where the selected payload will be changed. | |
#Required according to API | |
def createNewInstance(self, attack): | |
return BHPFuzzer(self, attack) | |
#Class to Define Burp Intruder Payload Generator. Please refer to | |
#IIntruderPayloadGenerator API in Burp | |
class BHPFuzzer(IIntruderPayloadGenerator): | |
def __init__(self, extender, attack): | |
self._extender = extender | |
self._helpers = extender._helpers | |
self._attack = attack | |
self.num_iterations = 0 | |
self.max_payloads = 1 | |
return | |
#For each payload encountered in Burp, Burp Intruder will act on it unless we return False | |
#The condition set here is based on the number of iterations for a given payload. | |
#Required according to API | |
def hasMorePayloads(self): | |
if self.num_iterations == self.max_payloads: | |
return False | |
else: | |
return True | |
#We construct the string version of the payload and call the fucntion to change/ mutate it. | |
#Required according to API | |
def getNextPayload(self, element_payload): | |
payload = "" | |
for x in element_payload: | |
payload += "".join(chr(x)) | |
payload = self.change_payload(payload) | |
self.num_iterations += 1 | |
return payload | |
#We look for the payload that matches "hello" and chnage it to "world" | |
def change_payload(self, original_payload): | |
if original_payload == "hello": | |
payload = "world" | |
else: | |
payload = original_payload | |
return payload | |
#Reset function. Required according to API | |
def reset(self): | |
self.num_iterations = 0 | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment