X-Git-Url: http://git.maemo.org/git/?p=pwnitter;a=blobdiff_plain;f=pwnitter.py;h=6b176f134ca94985dba2ef99897de1c314e61b41;hp=6d0defabf99040890cb7d167848ed19897b71726;hb=6cc1ab74cfd3c4a97c8a49722b52941c8f28ff8d;hpb=cdb4a5c1980db7b083f46a428ad3d27b4d853cf0 diff --git a/pwnitter.py b/pwnitter.py index 6d0defa..6b176f1 100755 --- a/pwnitter.py +++ b/pwnitter.py @@ -7,6 +7,7 @@ import dbus.service import dbus.mainloop.glib import getopt, sys, pcap, dpkt, re, httplib, urllib +import logging import socket import time import gobject @@ -41,7 +42,10 @@ class Pwnitter(dbus.service.Object): def Start(self, filename=None): # FIXME: Prevent double Start() if filename is None: # Then we do *not* want to read from a PCap file but rather a monitor device - self.setup_monitor(self.device) + self.setup_monitor(device) + device = self.device + else: # We have given a filename, so let's make PCap read from the file + device = filename self.is_running = True try: self.cap = pcap.pcap(device) @@ -223,10 +227,26 @@ def main(): if __name__ == '__main__': + from optparse import OptionParser + parser = OptionParser("usage: %prog [options]") + parser.add_option("-l", "--loglevel", dest="loglevel", + help="Sets the loglevel to one of debug, info, warn, error, critical") + parser.add_option("-s", "--session", dest="use_session_bus", + action="store_true", default=False, + help="Bind Pwnitter to the SessionBus instead of the SystemBus") + (options, args) = parser.parse_args() + loglevel = {'debug': logging.DEBUG, 'info': logging.INFO, + 'warn': logging.WARN, 'error': logging.ERROR, + 'critical': logging.CRITICAL}.get(options.loglevel, "warn") + logging.basicConfig(level=loglevel) + log = logging.getLogger("Main") + dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) - #session_bus = dbus.SessionBus() - session_bus = dbus.SystemBus() + if options.use_session_bus: + session_bus = dbus.SessionBus() + else: + session_bus = dbus.SystemBus() name = dbus.service.BusName(NAME, session_bus) pwnitter = Pwnitter(session_bus, '/Pwnitter') #object.Start()