您的位置:首页 > 编程语言 > Python开发

burp扩展小工具

2016-12-23 13:49 543 查看
在做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按钮,可以查看解码后的数据。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python burpsuit