Hello,
Sorry for the delay, I finnally set on the quest to understand obfsproxy.
So with the help of pdb and a few questions here and there I got to some
places, and with a lot of more questions to ask.
## Studying the client
The client launches a connection on obfsproxy/pyofsproxypy do_external_mode()
the
launch_transport.launch_transport_listener method is where the socks listeners
is set.
Right after that the Twisted library reactor module is initiated with
reactor.run() on
line 107 of the file obfsproxy/pyobfsproxy.py
After that the Twisted event loop is started and it will listen to events that
are set on methods like listenTCP() the wiki page about servers[1]
I've set a pdb.set_trace() on the buildProtocol() method in the file
obfsproxy/network/socks.py and the backtrace looks like.
(Pdb) bt
/usr/lib/python2.7/runpy.py(162)_run_module_as_main()
- __main__, fname, loader, pkg_name)
/usr/lib/python2.7/runpy.py(72)_run_code()
- exec code in run_globals
/usr/lib/python2.7/pdb.py(1338)module()
- pdb.main()
/usr/lib/python2.7/pdb.py(1314)main()
- pdb._runscript(mainpyfile)
/usr/lib/python2.7/pdb.py(1233)_runscript()
- self.run(statement)
/usr/lib/python2.7/bdb.py(400)run()
- exec cmd in globals, locals
string(1)module()
/home/masterkorp/Public/obfsproxy/bin/obfsproxy(16)module()
- run()
/home/masterkorp/Public/obfsproxy/obfsproxy/pyobfsproxy.py(207)run()
- pyobfsproxy()
/home/masterkorp/Public/obfsproxy/obfsproxy/pyobfsproxy.py(189)pyobfsproxy()
- do_external_mode(args)
/home/masterkorp/Public/obfsproxy/obfsproxy/pyobfsproxy.py(108)do_external_mode()
- reactor.run()
/usr/lib/python2.7/site-packages/twisted/internet/base.py(1192)run()
- self.mainLoop()
/usr/lib/python2.7/site-packages/twisted/internet/base.py(1204)mainLoop()
- self.doIteration(t)
/usr/lib/python2.7/site-packages/twisted/internet/epollreactor.py(396)doPoll()
- log.callWithLogger(selectable, _drdw, selectable, fd, event)
/usr/lib/python2.7/site-packages/twisted/python/log.py(88)callWithLogger()
- return callWithContext({system: lp}, func, *args, **kw)
/usr/lib/python2.7/site-packages/twisted/python/log.py(73)callWithContext()
- return context.call({ILogContext: newCtx}, func, *args, **kw)
/usr/lib/python2.7/site-packages/twisted/python/context.py(118)callWithContext()
- return self.currentContext().callWithContext(ctx, func, *args, **kw)
/usr/lib/python2.7/site-packages/twisted/python/context.py(81)callWithContext()
- return func(*args,**kw)
/usr/lib/python2.7/site-packages/twisted/internet/posixbase.py(614)_doReadOrWrite()
- why = selectable.doRead()
/usr/lib/python2.7/site-packages/twisted/internet/tcp.py(1062)doRead()
- protocol = self.factory.buildProtocol(self._buildAddr(addr))
/home/masterkorp/Public/obfsproxy/obfsproxy/network/socks.py(183)buildProtocol()
- circuit = network.Circuit(self.transport_class())
It goes directly to this method from Twistedm, which confirms that all the
SOCKS
is set. This creates a new Circuit. And the like the documentation says a
Circuit
is a pair of connections between and the obfsproxy client and openvpn client (in
this case) or obfsproxy server and OpenVPN server.
Then I set a pdb.set_trace() dataReceived() on obfsproxy/network/network.py well
because of the name. And a backtrace looks like:
(Pdb) bt
/usr/lib/python2.7/runpy.py(162)_run_module_as_main()
- __main__, fname, loader, pkg_name)
/usr/lib/python2.7/runpy.py(72)_run_code()
- exec code in run_globals
/usr/lib/python2.7/pdb.py(1338)module()
- pdb.main()
/usr/lib/python2.7/pdb.py(1314)main()
- pdb._runscript(mainpyfile)
/usr/lib/python2.7/pdb.py(1233)_runscript()
- self.run(statement)
/usr/lib/python2.7/bdb.py(400)run()
- exec cmd in globals, locals
string(1)module()
/home/masterkorp/Public/obfsproxy/bin/obfsproxy(3)module()
- import sys, os
/home/masterkorp/Public/obfsproxy/obfsproxy/pyobfsproxy.py(205)run()
- pyobfsproxy()
/home/masterkorp/Public/obfsproxy/obfsproxy/pyobfsproxy.py(187)pyobfsproxy()
- do_external_mode(args)
/home/masterkorp/Public/obfsproxy/obfsproxy/pyobfsproxy.py(106)do_external_mode()
- reactor.run()
/usr/lib/python2.7/site-packages/twisted/internet/base.py(1192)run()
- self.mainLoop()
/usr/lib/python2.7/site-packages/twisted/internet/base.py(1204)mainLoop()
- self.doIteration(t)
/usr/lib/python2.7/site-packages/twisted/internet/epollreactor.py(396)doPoll()
- log.callWithLogger(selectable, _drdw, selectable,fd, event)
/usr/lib/python2.7/site-packages/twisted/python/log.py(88)callWithLogger()
- return callWithContext({system: lp}, func,*args, **kw)
/usr/lib/python2.7/site-packages/twisted/python/log.py(73)callWithContext()
- return context.call({ILogContext: newCtx},func, *args, **kw)
/usr/lib/python2.7/site-packages/twisted/python/context.py(118)callWithContext()
- return self.currentContext().callWithContext(ctx,func, *args, **kw)
/usr/lib/python2.7/site-packages/twisted/python/context.py(81)callWithContext()
- return