CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/burp-proxy/wmap_plugin_v0.1-burp_v1.2.jar
Views: 11701
PKÄ(:META-INF/MANIFEST.MF���M��LK-.�
K-*��ϳR0�3����PK��PK
:�(:bIe��BurpExtender.class����26BurpExtenderjava/lang/Objectburp/IBurpExtender
db_connectionLjava/sql/Connection;burpRequestsLjava/util/HashMap;	Signature1Ljava/util/HashMap<Ljava/lang/Integer;LRequest;>;<init>()VCode

			
	java/lang/SystemoutLjava/io/PrintStream;[+] Loading WMAP plugin 0.1
! java/io/PrintStream"#println(Ljava/lang/String;)V%java/util/HashMap
$LineNumberTableLocalVariableTablethisLBurpExtender;applicationClosing-[+] Closing database connection/10java/sql/Connection2close4*[-] Error: Can't close database connection6[+] Unloading WMAP plugin8java/sql/SQLException	exceptionLjava/sql/SQLException;
StackMapTableprocessProxyMessagex(IZLjava/lang/String;IZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[B[I)[B
?A@java/net/InetAddressBC	getByName*(Ljava/lang/String;)Ljava/net/InetAddress;	EFerrH5[-] Error: can't resolve host. This shouldn't happen.JRequest
IM\?
OQPjava/lang/StringRSsplit'(Ljava/lang/String;)[Ljava/lang/String;
OUVW	substring(I)Ljava/lang/String;
IYZ#setPath
I\]#setQuery
?_`agetHostAddress()Ljava/lang/String;
Icd#setHost
IfghsetPort(I)V
IjklsetSSL(Z)V
Ino#	setMethod
IqrssetBody([B)V
Iuvs	setHeaderxjava/util/Date
w
I{|}setTimestamp(Ljava/util/Date;)V
��java/lang/Integer��valueOf(I)Ljava/lang/Integer;
$���put8(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
$���remove&(Ljava/lang/Object;)Ljava/lang/Object;
I��#setResponseCode
I��ssetResponseHeader
I��ssetResponseBody�java/lang/StringBuilder�[+] Adding request: 
��
#
I��a	getMethod
����append-(Ljava/lang/String;)Ljava/lang/StringBuilder;�|
I��agetPath
I���getTimestamp()Ljava/util/Date;
����-(Ljava/lang/Object;)Ljava/lang/StringBuilder;
���atoString��INSERT INTO requests(host,port,ssl,meth,path,headers,query,body,respcode,resphead,response,created )VALUES(?,?,?,?,?,?,?,?,?,?,?,?)/���prepareStatement0(Ljava/lang/String;)Ljava/sql/PreparedStatement;
I��agetHost���java/sql/PreparedStatement��	setString(ILjava/lang/String;)V
I���getPort()I����setInt(II)V
I���getSSL()Z����
setBoolean(IZ)V
I��a	getHeader
I��agetQuery
I��agetBody
I��agetResponseCode
I��agetResponseHeader
I��agetResponseBody
w�����
executeUpdate�java/lang/ExceptionmessageReferenceImessageIsRequestZ
remoteHostLjava/lang/String;
remotePortserviceIsHttps
httpMethodurlresourceType
statusCoderesponseContentTypemessage[Baction[I	ipAddressLjava/net/InetAddress;Ljava/lang/Exception;request	LRequest;pathAndQuery[Ljava/lang/String;insertStatementLjava/sql/PreparedStatement;���registerExtenderCallbacks (Lburp/IBurpExtenderCallbacks;)V	callbacksLburp/IBurpExtenderCallbacks;usage-[-] Error: Please set the database parameter.
[-] Example: database=test.db
hexitsetCommandLineArgs([Ljava/lang/String;)V
	=database
Oequals(Ljava/lang/Object;)Z[+] Using database:  org.sqlite.JDBC
"$#java/lang/Class%&forName%(Ljava/lang/String;)Ljava/lang/Class;(jdbc:sqlite:
*,+java/sql/DriverManager-.
getConnection)(Ljava/lang/String;)Ljava/sql/Connection;0$[-] Error: Can't create connection: args
parametersex
SourceFileBurpExtender.java!	

`"*�*�*���*�$Y�&��'
	!(")*+�&�,�*��.�L�3��5��7'% (&)*9:;T7<=x�:
-�>:
�
:�DG��|�IY�K:L�N:2�T�X��2�[
�^�b�e�i�m�p�t�wY�y�z*��~��W�*��~���I:	���������Y������������������������*����:���������ȹ����������й��ӹ��ֹ�	�ٹ�
�ܹ��߹��������W�:�	����7'�&*,./25#7,89:I;S<Z=a>h?o@vA�B�I�K�L�M�N�O�STU V-W:XHYVZd[r\�]�^�_�a�g(��)*���������������������������	���
���������
9�#p��,g�������;B�OOOOOO?�	�2I�I�75�'o()*	M�D
��D���'r	stu()*�+��*�+2�NM,2��	,��*����Y��,2������!W*��Y'��,2�����)��!N�D��Y/��,2�������Bcf�'2{|	�%�)�B�I�f�g�����(*�)*�1�r2�g3�;	�|�45PK
:�(:|����BurpExtender.javaimport java.net.InetAddress;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;

import burp.IBurpExtenderCallbacks;

public class BurpExtender implements burp.IBurpExtender {

	Connection db_connection = null;
	HashMap<Integer,Request> burpRequests = null;
	
	public BurpExtender() {
		System.out.println("[+] Loading WMAP plugin 0.1");
		burpRequests = new HashMap<Integer,Request>();
	}
	
	@Override
	public void applicationClosing() {
		System.out.println("[+] Closing database connection");	
		try {
			db_connection.close();
		}
		catch(SQLException exception) {
			System.out.println("[-] Error: Can't close database connection");
		}
		
		System.out.println("[+] Unloading WMAP plugin");
	}

	@Override
	public byte[] processProxyMessage(int messageReference,
			boolean messageIsRequest, String remoteHost, int remotePort,
			boolean serviceIsHttps, String httpMethod, String url,
			String resourceType, String statusCode, String responseContentType,
			byte[] message, int[] action) {

		// resolve the IP:
		InetAddress ipAddress = null;
		try {
			ipAddress = InetAddress.getByName(remoteHost);
		}
		catch (Exception exception) {
			System.err.println("[-] Error: can't resolve host. This shouldn't happen.");
		}
		
		if (messageIsRequest) {

			
			Request request = new Request();
			
			String pathAndQuery[] = url.split("\\?");
			request.setPath(pathAndQuery[0].substring(1));
			
			if(pathAndQuery.length == 2) 	request.setQuery(pathAndQuery[1]);
			request.setHost(ipAddress.getHostAddress());
			request.setPort(remotePort);
			request.setSSL(serviceIsHttps);
			request.setMethod(httpMethod);
			request.setBody(message);
			request.setHeader(message);
			request.setTimestamp(new Date());
			burpRequests.put(messageReference, request);

		}
		else {
			try {
				
				
				Request request = burpRequests.remove(messageReference);
				
				request.setResponseCode(statusCode);
				request.setResponseHeader(message);
				request.setResponseBody(message);
				System.out.println("[+] Adding request: " + request.getMethod() + "|" + request.getPath() + "|" + request.getTimestamp());
				PreparedStatement insertStatement = db_connection.prepareStatement("INSERT INTO requests(host,port,ssl,meth,path,headers,query,body,respcode,resphead,response,created )" +
				"VALUES(?,?,?,?,?,?,?,?,?,?,?,?)");
				
				
				insertStatement.setString(1, request.getHost());
				insertStatement.setInt(2, request.getPort());
				insertStatement.setBoolean(3, request.getSSL());
				insertStatement.setString(4, request.getMethod());
				insertStatement.setString(5, request.getPath());
				insertStatement.setString(6, request.getHeader());
				insertStatement.setString(7, request.getQuery());
				insertStatement.setString(8, request.getBody());
				insertStatement.setString(9, request.getResponseCode());
				insertStatement.setString(10, request.getResponseHeader());
				insertStatement.setString(11, request.getResponseBody());
				insertStatement.setString(12, request.getTimestamp().toString());
				insertStatement.executeUpdate();
			}
			catch(SQLException exception) {
			
			}
		}
		
	
	return null;

	}

	@Override
	public void registerExtenderCallbacks(IBurpExtenderCallbacks callbacks) {
		// TODO Auto-generated method stub

	}

	private void usage() {
		System.err.println("[-] Error: Please set the database parameter.");
		System.err.println("[-] Example: database=test.db");
		System.exit(1);		
	}
	
	@Override
	public void setCommandLineArgs(String[] args) {

		// I know we can solve this with one if, but it doesn't work, don't ask me why...
		if (args.length == 0) {
			usage();
		}
	
		String[] parameters = args[0].split("="); 
		
		if (!parameters[0].equals("database") || parameters.length != 2) {
			usage();
		}
		
		System.out.println("[+] Using database: " + parameters[1]);
		try {
			Class.forName("org.sqlite.JDBC");
			db_connection = DriverManager.getConnection("jdbc:sqlite:" + parameters[1]);
		}
		catch(Exception ex) {
			System.err.println("[-] Error: Can't create connection: " + parameters[1]);
			System.exit(1);
		}
	}

}
PK
�x(:�KY`
Request.class����2�Requestjava/lang/ObjecthostLjava/lang/String;portIsslZmethodpathheaderquerybodyresponsecoderesponseheaderresponsebody	timestampLjava/util/Date;
getHeaders([B)Ljava/lang/String;Codejava/lang/String
<init>([B)V

!"#split'(Ljava/lang/String;)[Ljava/lang/String;%java/lang/StringBuilder
$'(()V
*+,length()I
$./0append-(Ljava/lang/String;)Ljava/lang/StringBuilder;
$234toString()Ljava/lang/String;LineNumberTableLocalVariableTablethis	LRequest;message[B	tmpStringheaderArray[Ljava/lang/String;headersLjava/lang/StringBuilder;i
StackMapTable:=getBodyContent	bodyArray
responsestart
'I	K	M	O	
	Q	S	U
	W	Y	[	]	_getHostsetHost(Ljava/lang/String;)VparamgetPortsetPort(I)VgetSSL()ZsetSSL(Z)V	getMethod	setMethodgetPathsetPathgetQuerysetQuerygetBodysetBody
tD	getHeader	setHeader
xgetResponseCodesetResponseCodegetResponseHeadersetResponseHeadergetResponseBodysetResponseBodygetTimestamp()Ljava/util/Date;	�setTimestamp(Ljava/util/Date;)V
SourceFileRequest.java!	

�O�Y+�M,� N�$Y�&:6�&-2�)��-2�-W�-W�-�����1�5&		-7?I6>O78O9:	F;?<=6>?-@A�BC$
�D3i�Y+�M,� N�$Y�&:66�6-2�)��
�-����`6�-2�-W�-W�-�����1�56
!	"#$&"'&(4&>,G-Q.Y,c16Ri78i9:	`;YE=P?MF@D@A$�"BC$��(�F*�G*H�J*P�L*�N*H�P*H�R*H�T*H�V*H�X*H�Z*H�\*H�^�56
45
6789!:';-<3=9>??E@6F78`4/*�J�5B678ab:*+�J�5C678cd,/*�L�5E678ef:*�L�5F678cgh/*�N�5H678ij:*�N�5I678c
k4/*�P�5K678lb:*+�P�5L678cm4/*�R�5N678nb:*+�R�5O678co4/*�V�5Q678pb:*+�V�5R678cq4/*�X�5T678r>
**+�s�X�5U6
78
c:u4/*�T�5W678v>
**+�w�T�5X6
78
c:y4/*�Z�5Z678zb:*+�Z�5[678c{4/*�\�5]678|>
**+�w�\�5^6
78
c:}4/*�^�5`678~>
**+�s�^�5a6
78
c:�/*���5c678��:*+���5d678c��PK
w(:T�h$((Request.javaimport java.util.Date;

public class Request {
	
	private String host;
	private int    port;
	private boolean ssl;
	private String method;
	private String path;
	private String header;
	private String query;
	private String body;
	private String responsecode;
	private String responseheader;
	private String responsebody;
	private Date timestamp;
	

	private String getHeaders(byte[] message) {
		String   tmpString = new String(message);
		String[] headerArray = tmpString.split("\n");
		StringBuilder headers = new StringBuilder();
		for (int i=1; i< headerArray.length; i++) {
			if (headerArray[i].length() == 1) break;
			headers.append(headerArray[i]);
			headers.append("\n");
		}
		
		return headers.toString();
	}
	
	private String getBodyContent(byte[] message) {
		String   tmpString = new String(message);
		String[] bodyArray = tmpString.split("\n");
		StringBuilder body = new StringBuilder();
		int responsestart = 0;
		
		for (int i=1; i< bodyArray.length; i++) {
			responsestart = i;
			if (bodyArray[i].length() == 1) break;
			
		}
		
		for (int i=responsestart+1; i < bodyArray.length; i++) {
			body.append(bodyArray[i]);
			body.append("\n");
		}
		
		return body.toString();
	}
	
	public Request() {
		host = "";
		port = 80;
		ssl = false;
		method = "";
		path = "";
		header = "";
		query = "";
		body = "";
		responsecode = "";
		responseheader = "";
		responsebody = "";
	}
	
	public String getHost() { return host;}
	public void setHost(String param) { host = param;}
	
	public int getPort() { return port; }
	public void setPort(int param) { port = param; }
	
	public boolean getSSL() { return ssl;}
	public void setSSL(boolean param) {ssl = param; }
	
	public String getMethod() { return method;}
	public void setMethod(String param) { method = param;}
	
	public String getPath() { return path;}
	public void setPath(String param) { path = param;}
	
	public String getQuery() { return query;}
	public void setQuery(String param) { query = param;}
	
	public String getBody() { return body;}
	public void setBody(byte[] param) { body = this.getBodyContent(param);}
	
	public String getHeader() { return header;}
	public void setHeader(byte[] param) { header = this.getHeaders(param);}
	
	public String getResponseCode() { return responsecode;}
	public void setResponseCode(String param) { responsecode = param;}
	
	public String getResponseHeader() { return responseheader;}
	public void setResponseHeader(byte[] param) { responseheader = this.getHeaders(param);}
	
	public String getResponseBody() { return responsebody;}
	public void setResponseBody(byte[] param) { responsebody = this.getBodyContent(param);}
	
	public Date getTimestamp() { return timestamp;}
	public void setTimestamp(Date param) { timestamp = param;}
}
PK
c':�����.project<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>Burp1.2WMAPPlugin</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>
</projectDescription>
PKÄ(:��META-INF/MANIFEST.MF��PK

:�(:bIe��aBurpExtender.classPK

:�(:|����BurpExtender.javaPK

�x(:�KY`
>'Request.classPK

w(:T�h$((o6Request.javaPK

c':������A.projectPKppC