Skip to content

Instantly share code, notes, and snippets.

@andresriancho
Created April 19, 2016 16:45
Show Gist options
  • Select an option

  • Save andresriancho/a6900127cd270f3934f7ecee01edf642 to your computer and use it in GitHub Desktop.

Select an option

Save andresriancho/a6900127cd270f3934f7ecee01edf642 to your computer and use it in GitHub Desktop.
Add random X-Forwarded-For to bypass API throttling
import re
import random
from burp import IBurpExtender, IBurpExtenderCallbacks, ISessionHandlingAction
class BurpExtender(IBurpExtender, ISessionHandlingAction):
NAME = "Add X-Forwarded-For"
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
callbacks.setExtensionName(self.NAME)
self.callbacks.registerSessionHandlingAction(self)
def getActionName(self):
return self.NAME
def performAction(self, currentRequest, macroItems):
request_info = self.helpers.analyzeRequest(currentRequest)
headers = request_info.getHeaders()
req_body = currentRequest.getRequest()[request_info.getBodyOffset():]
# Bypass throttle IP
if 'X-Forwarded-For: ' not in headers.toString():
bypass_ip = '127.0.0.%s' % random.randint(1, 254)
headers.add('X-Forwarded-For: ' + bypass_ip)
# Build request with bypass headers
message = self.helpers.buildHttpMessage(headers, req_body)
# Update Request with New Header
currentRequest.setRequest(message)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment