Just Do IT的行者之路
在做Web滲透的時候,用burp抓取資料包時,經常會遇到請求包經過Url編碼了,想找哪個欄位,眼都要花了。本人視力本來就不行,為了檢視經過Url編碼的資料方便,於是便有了這個Burp擴充套件小工具。
首先要學會檢視Burp API文件,判定哪些Burp類需要在編寫工具時進行擴充套件。這個API文件在burp工具當中就有的。單擊Extender標籤,然後單擊後面的APIS標籤檢視相關文件。這些API都是Java的風格。但是使用Python、Ruby或者純Java,都可以對Burp進行擴充套件(這裡使用Python)。仔細檢視這些文件,我們會注意到開發Burp的人員對每一個類都進行了適當的命名,這樣我們就可以輕鬆地找到從哪裡開始。
這裡將此工具擴充套件到右鍵選單中,我們找到IBurpExtender和IContextMenuFactory。讓我們看下文件對IBurpExtender和IContextMenuFactory類的介紹。
/**
* All extensions must implement this interface.
*
* Implementations must be called BurpExtender, in the package burp, must be
* declared public, and must provide a default (public, no-argument)
* constructor.
*/
public interface IBurpExtender
{
/**
* This method is invoked when the extension is loaded. It registers an
* instance of the
* <code>IBurpExtenderCallbacks</code> interface, providing methods that may
* be invoked by the extension to perform various actions.
*
* @param callbacks An
* <code>IBurpExtenderCallbacks</code> object.
*/
void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks);
}
這個文件告訴我們所有的擴充套件類都必須實現IBurpExtender介面。當擴充套件程式被呼叫時,registerExtenderCallbacks方法被呼叫,同時會初始化一個IBurpExtenderCallbacks的例項,提供擴充套件程式功能性方法。
/**
* Extensions can implement this interface and then call
* <code>IBurpExtenderCallbacks.registerContextMenuFactory()</code> to register
* a factory for custom context menu items.
*/
public interface IContextMenuFactory
{
/**
* This method will be called by Burp when the user invokes a context menu
* anywhere within Burp. The factory can then provide any custom context
* menu items that should be displayed in the context menu, based on the
* details of the menu invocation.
*
* @param invocation An object that implements the
* <code>IMessageEditorTabFactory</code> interface, which the extension can
* query to obtain details of the context menu invocation.
* @return A list of custom menu items (which may include sub-menus,
* checkbox menu items, etc.) that should be displayed. Extensions may
* return
* <code>null</code> from this method, to indicate that no menu items are
* required.
*/
List<JMenuItem> createMenuItems(IContextMenuInvocation invocation);
}
這個文件告訴我們,擴充套件程式實現這個介面,並呼叫IBurpExtenderCallbacks.registerContextMenuFactory()來實現右鍵選單功能。
本例程式涉及到的其他文件可以參考Burp APIS。
完整程式碼如下:
#-*- coding:utf8 -*-
from burp import IBurpExtender
from burp import IContextMenuFactory
from java.util import List, ArrayList
from javax.swing import JMenuItem
import urllib
class BurpExtender(IBurpExtender, IContextMenuFactory):
def registerExtenderCallbacks(self,callbacks):
self._callbacks = callbacks
self._helpers = callbacks.getHelpers()
self.context = None
# 我們建立起擴充套件工具
callbacks.setExtensionName("RequestSerialize Tools")
callbacks.registerContextMenuFactory(self)
return
# 建立選單並處理點選事件,就是actionPerformed那裡,點選呼叫charConvert函式
def createMenuItems(self, context_menu):
self.context = context_menu
menu_list = ArrayList()
menu_list.add(JMenuItem("Send to CharConvert", actionPerformed=self.charConvert))
return menu_list
def charConvert(self, event):
# 獲取使用者點選的詳細資訊
http_traffic = self.context.getSelectedMessages()
request=http_traffic[0].getRequest()
if request:
print urllib.unquote(request.tostring())
return
是不是很簡單!!!接下來看使用方法。
1.新增Jython直譯器
單擊Extender標籤,然後單擊Options按鈕。在Python環境部分,選擇Jython Jar檔案路徑,如下圖所示:
2.將擴充套件工具新增到Burp
單擊Extender下的Extensions標籤,然後單擊Add按鈕,選擇新增檔案,如下圖:
單擊Next,載入成功後顯示如下圖所示:
3.如何使用擴充套件工具
用Burp抓取資料包,此資料包是經過Url編碼的。右鍵單擊,選擇此擴充套件程式,如下圖:
4.檢視解碼後的資料
單擊Extender,選擇我們新增的擴充套件程式,單擊輸出結果的output按鈕,可以檢視解碼後的資料。