SlideShare a Scribd company logo
Extending Burp with
Python
Defeating web application idiosyncrasies
with common-sense, Python and minimal
knowledge of Java GUIs
What is Burp?
Purpose of this Talk
• Quick tour of Burp APIs with examples to
show what can be achieved
• Demonstrate that Web app assessment
hurdles overcome with minimal coding effort
Why would you need a custom extn?
1. Decode custom encoding/serialization
2. Handle anti-tamper or signed requests
3. Provide a new “view” into an application
4. Automate a manual task with a new scanner check
Setup to run a Python Burp Extn.
1 Download Jython standalone binary
2 Tell Burp where find Jython
3 Load a Python extension
Path to Jython binary goes here
The helloworld of Burp extensions
from burp import IBurpExtender
class BurpExtender(IBurpExtender):
# required
def registerExtenderCallbacks(self, callbacks):
# set our extension name
callbacks.setExtensionName("Hello world extension")
# write a message to the Burp alerts tab
callbacks.issueAlert("Hello alerts")
Just writes “Hello alerts” out to alerts tab
1. Problem: Unsupported encoding
Application uses an encoding not understood
by Burp
Examples:
Serialised Java, SAP’s weird URLenc variant, SAML, Websphere Portlet
Burp APIs: IMessageEditorTab to display
decoded content
Solution: new encoder/decoder
1. Tell Burp about your new message editor
tab
class CustomDecoderTab(IMessageEditorTab):
def __init__(self, extender, controller, editable):
...
def getTabCaption(self):
return "Custom Decoder"
Solution: new decoder/encoder
2. Use setMessage to display decode
def setMessage(self, content, isRequest):
...
if '!ut' in path:
# actual decoding magic omitted
content = response.read()
content = xml.dom.minidom.parseString(content).toprettyxml()
if content:
self._txtInput.setText(content)
self._currentMessage = content
Websphere portlet state decoder
Source: https://github.com/faffi/WebSphere-Portlet-State-Decoder
Encoded content on URL
Gets decoded in new tab
2. Problem: Signed requests
Application requires signature thats generated
client side.
examples
1. Seen in thick client apps as anti-tamper mechanism
2. AWS API calls are signed for authentication
http://rajasaur.blogspot.co.nz/2009/10/hmac-sha-signatures-using-python-for.html
Burp API: processHTTPMessage allows us to
re-write traffic
Solution: automate request signing
1. Catch an outbound request
from burp import IBurpExtender# this function catches requests and
responses
def processHttpMessage(self, toolFlag, messageIsRequest,
currentRequest):
# only process requests
if not messageIsRequest:
return
...
Solution: automate request signing
2. Grab the request body and headers
# requestInfo object allows us to easily spit body and headers
requestInfo = self._helpers.analyzeRequest(currentRequest)
bodyBytes = currentRequest.getRequest()[requestInfo.getBodyOffset():]
bodyStr = self._helpers.bytesToString(bodyBytes)
headers = requestInfo.getHeaders()
newHeaders = list(headers) #it's a Java arraylist; get a python list
Solution: automate request signing
3. Append signature as HTTP Header
# Do custom signing shenanigans
secret = "SuperSecret123"
h = hmac.new(secret, bodyStr, hashlib.sha256)
newHeaders.append("Authorization: " + base64.b64encode(h.digest()))
Solution: automate request signing
4. Create and send request
newMessage = self._helpers.buildHttpMessage(newHeaders, bodyStr)
currentRequest.setRequest(newMessage)
Here’s the new Authorization header being sent out
3. Problem: Big apps, lotsa headers
Large applications may emit different headers
from various locations within the app.
Headers can reveal useful info. Eg. Reverse proxy may hand off from
backend A to backend B.
Burp APIs: processHTTPMessage and ITab to
display result
Solution: View of unique headers
Keep track of unique headers, filter out
uninteresting headers.
# insert an entry if the header is 'interesting’
if header_name.lower() not in boring_headers:
# and we haven't seen this name/value pair before, log it
if header not in self.headers_seen:
self.headers_seen.append(header)
self._log.add(LogEntry(header, …, … )
Solution: View of unique headers
Create a new tab and display collected
headers in the new tab.
# Give the new tab a name
def getTabCaption(self):
return "Response Headers”
# This adds all the Java UI unpleasantness
def getUiComponent(self):
return self._splitpane
Solution: View of unique headers
List of unique headers
displayed in new
“Response Headers” tab
Clicking item in list shows
request/response
4. Problem: Automate a manual task
Locate and decode F5 cookies, display as a
passive scan result
Burp API: doPassiveScan to trigger check
code
Solution: create new check
1. doPassiveScan catches request
def doPassiveScan(self, baseRequestResponse):
# Returns IResponseInfo
analyzedResponse =
self.helpers.analyzeResponse(baseRequestResponse.getResponse())
analyzedRequest = self.helpers.analyzeRequest(baseRequestResponse)
# Get Cookies from IResponseInfo Instance cookieList =
analyzedResponse.getCookies()
Solution: create new check
2. Locate BIGIP cookies and decode them
# Loop though list of cookies
for cookie in cookieList:
cookieName = cookie.getName()
# Look for BIGIP Cookies
if cookieName.lower().startswith("bigip"):
f5CookieName = cookieName
f5RawCookieValue = cookie.getValue()
# Decode and check for RFC 1918 address
f5info = decode(f5RawCookieValue)
Solution: create new check
3. Create Issue class to return useful info
class PassiveScanIssue(IScanIssue):
...
def getIssueName(self):
return "Encoded IP Address Discovered in F5 Cookie Value"
...
def getIssueDetail(self):
msg = "The URL <b>" + str(self.findingurl) + "</b> sets the F5 load
balancer cookie <b>"
F5-BigIP Cookie Checker
Source: http://blog.secureideas.com/2013/08/burp-extension-for-f5-cookie-detection.html
Internal IP address
retrieved from encoded
cookie
Summary
1. Decode custom encoding/serialization
Use IMessageEditorTab interface to display decoded content
2. Handle anti-tamper or signed requests
Use processHTTPMessage to catch and rewrite requests
3. Provide a new “view” into an application
Use ITab interface to display custom view
4. Automate a manual task with a new scanner check
Use doPassiveScan to trigger a check

More Related Content

PPTX
Extending burp with python
PPTX
Cusomizing Burp Suite - Getting the Most out of Burp Extensions
PDF
Python tools for testing web services over HTTP
PPTX
Build restful ap is with python and flask
PDF
AOP in Python API design
ODP
Intro To Spring Python
PDF
The Basic Concept Of IOC
PDF
Connecting with the enterprise - The how and why of connecting to Enterprise ...
Extending burp with python
Cusomizing Burp Suite - Getting the Most out of Burp Extensions
Python tools for testing web services over HTTP
Build restful ap is with python and flask
AOP in Python API design
Intro To Spring Python
The Basic Concept Of IOC
Connecting with the enterprise - The how and why of connecting to Enterprise ...

What's hot (15)

PDF
ES6 metaprogramming unleashed
PDF
Flask Introduction - Python Meetup
PDF
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
PDF
Intro to JavaScript
PDF
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
PDF
스프링 실전 가이드
PDF
Symfony 2
PDF
iPhone Coding For Web Developers
PDF
Python RESTful webservices with Python: Flask and Django solutions
PPTX
Developing on the aloashbei platform
KEY
Morpheus configuration engine (slides from Saint Perl-2 conference)
PDF
Flask RESTful Flask HTTPAuth
PDF
Alex conrad - Pyramid Tweens (PloneConf 2011)
PPTX
Method and decorator
PDF
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
ES6 metaprogramming unleashed
Flask Introduction - Python Meetup
Reliable Python REST API (by Volodymyr Hotsyk) - Web Back-End Tech Hangout - ...
Intro to JavaScript
AWS Lambda Hands-on: How to Create Phone Call Notifications in a Serverless Way
스프링 실전 가이드
Symfony 2
iPhone Coding For Web Developers
Python RESTful webservices with Python: Flask and Django solutions
Developing on the aloashbei platform
Morpheus configuration engine (slides from Saint Perl-2 conference)
Flask RESTful Flask HTTPAuth
Alex conrad - Pyramid Tweens (PloneConf 2011)
Method and decorator
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Ad

Viewers also liked (19)

PPTX
Montage Bamboo terrarium de la marque Reptiles-Planet
PPTX
How to make a terrarium with Emily at Snug Harbor Farm
PDF
Dart Frog Terrarium Build
PPTX
Big picture of data mining
PPTX
Data mining and knowledge discovery
DOCX
Make a terrarium mini
PPTX
Directory based cache coherence
PPTX
Business analytics and data mining
PPTX
Object model
PPTX
Api crash
PPTX
Abstraction file
PPTX
Hardware managed cache
PPTX
Terrarium
PPTX
Object oriented analysis
PPTX
Python language data types
PDF
Python in Action (Part 2)
PPT
Introduction to Python
PPTX
PPTX
Florante at Laura : Ang Kariktan ni Laura
Montage Bamboo terrarium de la marque Reptiles-Planet
How to make a terrarium with Emily at Snug Harbor Farm
Dart Frog Terrarium Build
Big picture of data mining
Data mining and knowledge discovery
Make a terrarium mini
Directory based cache coherence
Business analytics and data mining
Object model
Api crash
Abstraction file
Hardware managed cache
Terrarium
Object oriented analysis
Python language data types
Python in Action (Part 2)
Introduction to Python
Florante at Laura : Ang Kariktan ni Laura
Ad

Similar to Extending burp with python (20)

PPTX
AppSec USA 2015: Customizing Burp Suite
PDF
Working Effectively With Legacy Perl Code
PPTX
slides.pptx
PPT
Spring training
PPTX
Symfony2 Introduction Presentation
PDF
Behavior & Specification Driven Development in PHP - #OpenWest
PDF
Effective testing with pytest
PPTX
-Kotlin_Camp_Unit2.pptx
PPTX
-Kotlin Camp Unit2.pptx
PDF
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
PDF
Android application architecture
PDF
Testing the frontend
PPT
JavaOne 2007 - TS4721
PPTX
Skillwise EJB3.0 training
PDF
Ane for 9ria_cn
PDF
Analysis of bugs in Orchard CMS
PDF
OpenWhisk by Example - Auto Retweeting Example in Python
PPTX
Azure Functions @ global azure day 2017
DOC
Advanced Hibernate Notes
PPTX
DF12 - Process Orchestration using Streaming API and Heroku
AppSec USA 2015: Customizing Burp Suite
Working Effectively With Legacy Perl Code
slides.pptx
Spring training
Symfony2 Introduction Presentation
Behavior & Specification Driven Development in PHP - #OpenWest
Effective testing with pytest
-Kotlin_Camp_Unit2.pptx
-Kotlin Camp Unit2.pptx
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Android application architecture
Testing the frontend
JavaOne 2007 - TS4721
Skillwise EJB3.0 training
Ane for 9ria_cn
Analysis of bugs in Orchard CMS
OpenWhisk by Example - Auto Retweeting Example in Python
Azure Functions @ global azure day 2017
Advanced Hibernate Notes
DF12 - Process Orchestration using Streaming API and Heroku

More from Tony Nguyen (20)

PPTX
Cache recap
PPTX
How analysis services caching works
PPT
Abstract data types
PPTX
Optimizing shared caches in chip multiprocessors
PPT
Abstract class
PPTX
Concurrency with java
PPTX
Data structures and algorithms
PPTX
Inheritance
PPTX
Object oriented programming-with_java
PPTX
Cobol, lisp, and python
PPTX
Learning python
PPTX
Programming for engineers in python
PPTX
Python basics
PPTX
Rest api to integrate with your site
PPTX
Python your new best friend
PPTX
Smm and caching
PDF
How to build a rest api
PPT
Poo java
PPTX
Encapsulation anonymous class
PPT
Data preprocessing
Cache recap
How analysis services caching works
Abstract data types
Optimizing shared caches in chip multiprocessors
Abstract class
Concurrency with java
Data structures and algorithms
Inheritance
Object oriented programming-with_java
Cobol, lisp, and python
Learning python
Programming for engineers in python
Python basics
Rest api to integrate with your site
Python your new best friend
Smm and caching
How to build a rest api
Poo java
Encapsulation anonymous class
Data preprocessing

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
sap open course for s4hana steps from ECC to s4
The Rise and Fall of 3GPP – Time for a Sabbatical?
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
Dropbox Q2 2025 Financial Results & Investor Presentation
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
MIND Revenue Release Quarter 2 2025 Press Release
sap open course for s4hana steps from ECC to s4

Extending burp with python

  • 1. Extending Burp with Python Defeating web application idiosyncrasies with common-sense, Python and minimal knowledge of Java GUIs
  • 3. Purpose of this Talk • Quick tour of Burp APIs with examples to show what can be achieved • Demonstrate that Web app assessment hurdles overcome with minimal coding effort
  • 4. Why would you need a custom extn? 1. Decode custom encoding/serialization 2. Handle anti-tamper or signed requests 3. Provide a new “view” into an application 4. Automate a manual task with a new scanner check
  • 5. Setup to run a Python Burp Extn. 1 Download Jython standalone binary 2 Tell Burp where find Jython 3 Load a Python extension Path to Jython binary goes here
  • 6. The helloworld of Burp extensions from burp import IBurpExtender class BurpExtender(IBurpExtender): # required def registerExtenderCallbacks(self, callbacks): # set our extension name callbacks.setExtensionName("Hello world extension") # write a message to the Burp alerts tab callbacks.issueAlert("Hello alerts") Just writes “Hello alerts” out to alerts tab
  • 7. 1. Problem: Unsupported encoding Application uses an encoding not understood by Burp Examples: Serialised Java, SAP’s weird URLenc variant, SAML, Websphere Portlet Burp APIs: IMessageEditorTab to display decoded content
  • 8. Solution: new encoder/decoder 1. Tell Burp about your new message editor tab class CustomDecoderTab(IMessageEditorTab): def __init__(self, extender, controller, editable): ... def getTabCaption(self): return "Custom Decoder"
  • 9. Solution: new decoder/encoder 2. Use setMessage to display decode def setMessage(self, content, isRequest): ... if '!ut' in path: # actual decoding magic omitted content = response.read() content = xml.dom.minidom.parseString(content).toprettyxml() if content: self._txtInput.setText(content) self._currentMessage = content
  • 10. Websphere portlet state decoder Source: https://github.com/faffi/WebSphere-Portlet-State-Decoder Encoded content on URL Gets decoded in new tab
  • 11. 2. Problem: Signed requests Application requires signature thats generated client side. examples 1. Seen in thick client apps as anti-tamper mechanism 2. AWS API calls are signed for authentication http://rajasaur.blogspot.co.nz/2009/10/hmac-sha-signatures-using-python-for.html Burp API: processHTTPMessage allows us to re-write traffic
  • 12. Solution: automate request signing 1. Catch an outbound request from burp import IBurpExtender# this function catches requests and responses def processHttpMessage(self, toolFlag, messageIsRequest, currentRequest): # only process requests if not messageIsRequest: return ...
  • 13. Solution: automate request signing 2. Grab the request body and headers # requestInfo object allows us to easily spit body and headers requestInfo = self._helpers.analyzeRequest(currentRequest) bodyBytes = currentRequest.getRequest()[requestInfo.getBodyOffset():] bodyStr = self._helpers.bytesToString(bodyBytes) headers = requestInfo.getHeaders() newHeaders = list(headers) #it's a Java arraylist; get a python list
  • 14. Solution: automate request signing 3. Append signature as HTTP Header # Do custom signing shenanigans secret = "SuperSecret123" h = hmac.new(secret, bodyStr, hashlib.sha256) newHeaders.append("Authorization: " + base64.b64encode(h.digest()))
  • 15. Solution: automate request signing 4. Create and send request newMessage = self._helpers.buildHttpMessage(newHeaders, bodyStr) currentRequest.setRequest(newMessage) Here’s the new Authorization header being sent out
  • 16. 3. Problem: Big apps, lotsa headers Large applications may emit different headers from various locations within the app. Headers can reveal useful info. Eg. Reverse proxy may hand off from backend A to backend B. Burp APIs: processHTTPMessage and ITab to display result
  • 17. Solution: View of unique headers Keep track of unique headers, filter out uninteresting headers. # insert an entry if the header is 'interesting’ if header_name.lower() not in boring_headers: # and we haven't seen this name/value pair before, log it if header not in self.headers_seen: self.headers_seen.append(header) self._log.add(LogEntry(header, …, … )
  • 18. Solution: View of unique headers Create a new tab and display collected headers in the new tab. # Give the new tab a name def getTabCaption(self): return "Response Headers” # This adds all the Java UI unpleasantness def getUiComponent(self): return self._splitpane
  • 19. Solution: View of unique headers List of unique headers displayed in new “Response Headers” tab Clicking item in list shows request/response
  • 20. 4. Problem: Automate a manual task Locate and decode F5 cookies, display as a passive scan result Burp API: doPassiveScan to trigger check code
  • 21. Solution: create new check 1. doPassiveScan catches request def doPassiveScan(self, baseRequestResponse): # Returns IResponseInfo analyzedResponse = self.helpers.analyzeResponse(baseRequestResponse.getResponse()) analyzedRequest = self.helpers.analyzeRequest(baseRequestResponse) # Get Cookies from IResponseInfo Instance cookieList = analyzedResponse.getCookies()
  • 22. Solution: create new check 2. Locate BIGIP cookies and decode them # Loop though list of cookies for cookie in cookieList: cookieName = cookie.getName() # Look for BIGIP Cookies if cookieName.lower().startswith("bigip"): f5CookieName = cookieName f5RawCookieValue = cookie.getValue() # Decode and check for RFC 1918 address f5info = decode(f5RawCookieValue)
  • 23. Solution: create new check 3. Create Issue class to return useful info class PassiveScanIssue(IScanIssue): ... def getIssueName(self): return "Encoded IP Address Discovered in F5 Cookie Value" ... def getIssueDetail(self): msg = "The URL <b>" + str(self.findingurl) + "</b> sets the F5 load balancer cookie <b>"
  • 24. F5-BigIP Cookie Checker Source: http://blog.secureideas.com/2013/08/burp-extension-for-f5-cookie-detection.html Internal IP address retrieved from encoded cookie
  • 25. Summary 1. Decode custom encoding/serialization Use IMessageEditorTab interface to display decoded content 2. Handle anti-tamper or signed requests Use processHTTPMessage to catch and rewrite requests 3. Provide a new “view” into an application Use ITab interface to display custom view 4. Automate a manual task with a new scanner check Use doPassiveScan to trigger a check