Skip to content

Commit

Permalink
Add quick start tutorial if no traffic has been recorded yet.
Browse files Browse the repository at this point in the history
Add firstflow event
Minor cleanups
  • Loading branch information
mhils committed Aug 5, 2012
1 parent 47ef37b commit 66f3f45
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 47 deletions.
13 changes: 13 additions & 0 deletions gui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ <h3>HoneyProxy</h3>
<tbody id="traffic">
</tbody>
</table>
<div id=tutorial>
<h1>Quick start</h1>
<ul>
<li><h2>Set up your HTTP proxy settings:</h2>
<b>Host: </b><span id=tutorial-proxy-addr>IP</span><br>
<b>Port: </b><span id=tutorial-proxy-port>PORT</span>
<li><h2>Set up SSL interception if required</h2>
Follow the steps from the <a href="http://mitmproxy.org/doc/ssl.html">mitmproxy docs</a>. All certificates are stored in the "ca-cert" subdirectory of your HoneyProxy installation.
<li><h2>Give Feedback!</h2>
HoneyProxy is still in an very early stage. Getting some feedback from you would be awesome. <a href="https://github.com/mhils/HoneyProxy">Thanks!</a>
</ul>
</div>
</div>
<div class=goog-splitpane-second-container id=detail>
<div class=tabs>
Expand Down Expand Up @@ -94,5 +106,6 @@ <h3>HoneyProxy</h3>
<script src="./js/honeyproxy/DetailView.js"></script>
<script src="./js/honeyproxy/popOut.js"></script>
<script src="./js/honeyproxy/dirdump.js"></script>
<script src="./js/honeyproxy/tutorial.js"></script>
</body>
</html>
31 changes: 21 additions & 10 deletions gui/js/honeyproxy/honeyproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,37 @@ _.extend(HoneyProxy, Backbone.Events);
window.HoneyProxy = HoneyProxy;

$(function(){



//$("#splitter").height($(window).height());

//$("#splitter").splitter({outline: true,sizeLeft: $(window).width()-100, minLeft: 500});

//initialize traffic object
HoneyProxy.traffic = new HoneyProxy.Traffic;

HoneyProxy.on("newflow",HoneyProxy.traffic.add.bind(HoneyProxy.traffic));

//establish websocket communication after config has been loaded.
HoneyProxy.on("configLoaded",function(){
HoneyProxy.websocket.initialize();
})

//fetch traffic after websocket authentication
HoneyProxy.on("authenticated",function(){
console.time("fetch");
HoneyProxy.traffic.fetch();
});

HoneyProxy.on("configLoaded",function(){
HoneyProxy.websocket.initialize();
})

//capture first flow
function firstFlowTrigger(reset,traffic){
if(HoneyProxy.traffic.length > 0) {
HoneyProxy.trigger("firstflow");
HoneyProxy.off("firstflow");
HoneyProxy.off("newflow",firstFlowTrigger);
HoneyProxy.traffic.off("reset",firstFlowTrigger);
}
}
HoneyProxy.on("newflow",firstFlowTrigger);
HoneyProxy.traffic.on("reset",firstFlowTrigger);



HoneyProxy.trafficView = new HoneyProxy.TrafficView({collection: HoneyProxy.traffic, el: $("#traffic")[0]});
HoneyProxy.detailView = new HoneyProxy.DetailView({el: $("#detail")});
});
17 changes: 17 additions & 0 deletions gui/js/honeyproxy/tutorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$(function(){

HoneyProxy.on("firstflow",function(){
$("#tutorial").hide();
});

HoneyProxy.on("configLoaded",function(){
var addr = HoneyProxy.config.get("proxy-addr");
if(addr==="")
addr = "HoneyProxy listens on all your network interfaces, choose one (most times localhost)";
$("#tutorial-proxy-addr").text(addr);
$("#tutorial-proxy-port").text(HoneyProxy.config.get("proxy-port"));
});



});
6 changes: 4 additions & 2 deletions honeyproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


import libhproxy.gui.session as session
import sys, json, urllib, os, inspect
import sys, os, inspect

#ensure to load our own version of mitmproxy and netlib
#http://stackoverflow.com/questions/279237/python-import-a-module-from-a-folder
Expand All @@ -39,7 +39,7 @@ def add_subfolder(name):
from twisted.web.resource import Resource

#from libhproxy.websockets import WebSocketsResource
from libhproxy import proxy as hproxy, cmdline as hcmdline, version, content, dirdumper, config
from libhproxy import proxy as hproxy, cmdline as hcmdline, version, content, config
from libhproxy.honey import HoneyProxy

from autobahn.websocket import listenWS
Expand Down Expand Up @@ -91,6 +91,8 @@ def main():
httpGui = "http://honey:"+HoneyProxy.getAuthKey()+"@localhost:"+str(options.guiport)
guiURL = httpGui +"/app"
conf = config.Config({
"proxy-addr":options.addr,
"proxy-port":options.port,
"ws": wsURL,
"auth": HoneyProxy.getAuthKey(),
"dumpdir": True if options.dumpdir else False
Expand Down
62 changes: 27 additions & 35 deletions libhproxy/flowcollection.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
class FlowCollection:
def __init__(self):
self._flows_serialized = []
self._flows = []

def getLastFlow(self):
return self._flows_serialized[-1]

def getFlow(self,flowId):
return self._flows[flowId]

def getFlowsSerialized(self):
return self._flows_serialized

def addFlow(self, flow):
flowRepr = flow._get_state()
flowRepr["id"] = len(self._flows_serialized)

#remove content out of the flowRepr
for i in ["request","response"]:
flowRepr[i]["contentLength"] = len(flowRepr[i]["content"])
del flowRepr[i]["content"]

#store unencoded
#from libmproxy import encoding
#enc = flow.response.headers.get("content-encoding")
#if enc and enc[0] != "identity":
# decoded = encoding.decode(enc[0], content)
# if decoded:
# content = decoded

self._flows.append(flow)
self._flows_serialized.append(flowRepr)
return len(self._flows_serialized)-1

class FlowCollection:
def __init__(self):
self._flows_serialized = []
self._flows = []

def getLastFlow(self):
return self._flows_serialized[-1]

def getFlow(self,flowId):
return self._flows[flowId]

def getFlowsSerialized(self):
return self._flows_serialized

def addFlow(self, flow):
flowRepr = flow._get_state()
flowRepr["id"] = len(self._flows_serialized)

#remove content out of the flowRepr
for i in ["request","response"]:
flowRepr[i]["contentLength"] = len(flowRepr[i]["content"])
del flowRepr[i]["content"]

self._flows.append(flow)
self._flows_serialized.append(flowRepr)
return len(self._flows_serialized)-1

0 comments on commit 66f3f45

Please sign in to comment.