Skip to content

Commit

Permalink
Use processHttpMessage for proxy requests to mitigate #42
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey-Dean Arthur committed May 1, 2020
1 parent 222eed2 commit f1dd6fb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Created by corey on 07/09/17.
*/
public class LogProcessor implements IHttpListener, IProxyListener {
public class LogProcessor implements IHttpListener {
public static final SimpleDateFormat LOGGER_DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
public static final SimpleDateFormat SERVER_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");

Expand Down Expand Up @@ -62,30 +62,29 @@ public LogProcessor(LoggerPlusPlus loggerPlusPlus, LogTableController logTableCo
this.cleanupExecutor.scheduleAtFixedRate(new AbandonedRequestCleanupRunnable(),30, 30, TimeUnit.SECONDS);

LoggerPlusPlus.callbacks.registerHttpListener(this);
LoggerPlusPlus.callbacks.registerProxyListener(this);
// LoggerPlusPlus.callbacks.registerProxyListener(this);
}

/**
* Process messages from all tools but proxy.
* Process messages from all tools.
* Adds to queue for later processing.
* @param toolFlag Tool used to make request
* @param isRequestOnly If the message is request only or complete with response
* @param httpMessage The request and potentially response received.
*/
@Override
public void processHttpMessage(final int toolFlag, final boolean isRequestOnly, final IHttpRequestResponse httpMessage) {
if(toolFlag == IBurpExtenderCallbacks.TOOL_PROXY) return; //Proxy messages handled by proxy method
if(httpMessage == null || !(Boolean) preferences.getSetting(PREF_ENABLED) || !isValidTool(toolFlag)) return;
Date arrivalTime = new Date();

if(!(Boolean) preferences.getSetting(PREF_LOG_OTHER_LIVE)){
//Submit normally, we're not tracking requests and responses separately.
if(!isRequestOnly) { //But only add entries complete with a response.
final LogEntry logEntry = new LogEntry(toolFlag, arrivalTime, httpMessage);
submitNewEntryProcessingRunnable(logEntry);
}
return;
}
// if(!(Boolean) preferences.getSetting(PREF_LOG_OTHER_LIVE)){
// //Submit normally, we're not tracking requests and responses separately.
// if(!isRequestOnly) { //But only add entries complete with a response.
// final LogEntry logEntry = new LogEntry(toolFlag, arrivalTime, httpMessage);
// submitNewEntryProcessingRunnable(logEntry);
// }
// return;
// }

if(isRequestOnly){
final LogEntry logEntry = new LogEntry(toolFlag, arrivalTime, httpMessage);
Expand All @@ -100,38 +99,38 @@ public void processHttpMessage(final int toolFlag, final boolean isRequestOnly,
}
}

/**
* Process messages received from the proxy tool.
* For requests, a new processing job is added to the executor.
* @param isRequestOnly
* @param proxyMessage
*/
@Override
public void processProxyMessage(final boolean isRequestOnly, final IInterceptedProxyMessage proxyMessage) {
final int toolFlag = IBurpExtenderCallbacks.TOOL_PROXY;
if(proxyMessage == null || !(Boolean) preferences.getSetting(PREF_ENABLED) || !isValidTool(toolFlag)) return;
Date arrivalTime = new Date();

if(isRequestOnly){
//The request is not yet sent, process the request object
final LogEntry logEntry = new LogEntry(toolFlag, arrivalTime, proxyMessage.getMessageInfo());
//Store our proxy specific info now.
logEntry.clientIP = String.valueOf(proxyMessage.getClientIpAddress());
logEntry.listenerInterface = proxyMessage.getListenerInterface();

//Make a note of the entry UUID corresponding to the message identifier.
proxyIdToUUIDMap.put(proxyMessage.getMessageReference(), logEntry.getIdentifier());
submitNewEntryProcessingRunnable(logEntry);
}else{
//We're handling a response.
UUID uuid = proxyIdToUUIDMap.remove(proxyMessage.getMessageReference());
if(uuid != null){
updateRequestWithResponse(uuid, arrivalTime, proxyMessage.getMessageInfo());
}else{
System.out.println("LOST");
}
}
}
// /**
// * Process messages received from the proxy tool.
// * For requests, a new processing job is added to the executor.
// * @param isRequestOnly
// * @param proxyMessage
// */
// @Override
// public void processProxyMessage(final boolean isRequestOnly, final IInterceptedProxyMessage proxyMessage) {
// final int toolFlag = IBurpExtenderCallbacks.TOOL_PROXY;
// if(proxyMessage == null || !(Boolean) preferences.getSetting(PREF_ENABLED) || !isValidTool(toolFlag)) return;
// Date arrivalTime = new Date();
//
// if(isRequestOnly){
// //The request is not yet sent, process the request object
// final LogEntry logEntry = new LogEntry(toolFlag, arrivalTime, proxyMessage.getMessageInfo());
// //Store our proxy specific info now.
// logEntry.clientIP = String.valueOf(proxyMessage.getClientIpAddress());
// logEntry.listenerInterface = proxyMessage.getListenerInterface();
//
// //Make a note of the entry UUID corresponding to the message identifier.
// proxyIdToUUIDMap.put(proxyMessage.getMessageReference(), logEntry.getIdentifier());
// submitNewEntryProcessingRunnable(logEntry);
// }else{
// //We're handling a response.
// UUID uuid = proxyIdToUUIDMap.remove(proxyMessage.getMessageReference());
// if(uuid != null){
// updateRequestWithResponse(uuid, arrivalTime, proxyMessage.getMessageInfo());
// }else{
// System.out.println("LOST");
// }
// }
// }

/**
* When a response comes in, determine if the request has already been processed or not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void actionPerformed(ActionEvent e) {
strutConstraints = logFromPanel.generateNextConstraints(true);
strutConstraints.weighty = strutConstraints.weightx = 0;
logFromPanel.add(Box.createVerticalStrut(10), strutConstraints);
logFromPanel.addPreferenceComponent(preferences, PREF_LOG_OTHER_LIVE, "Log Non-Proxy Tools Live");
// logFromPanel.addPreferenceComponent(preferences, PREF_LOG_OTHER_LIVE, "Log Non-Proxy Tools Live");

{ //Disable check boxes if global logging is enabled.
boolean globalDisabled = !logAllTools.isSelected();
Expand Down

0 comments on commit f1dd6fb

Please sign in to comment.