Ejemplo n.º 1
0
def getNetworksFromRoutes():
    from scapy.all import conf, ltoa, read_routes
    from ipaddr    import IPNetwork, IPAddress

    ## Hide the 'no routes' warnings
    conf.verb = 0

    networks = []
    for nw, nm, gw, iface, addr in read_routes():
        n = IPNetwork( ltoa(nw) )
        (n.netmask, n.gateway, n.ipaddr) = [IPAddress(x) for x in [nm, gw, addr]]
        n.iface = iface
        if not n.compressed in networks:
            networks.append(n)

    return networks
Ejemplo n.º 2
0
def getNetworksFromRoutes():
    from scapy.all import conf, ltoa, read_routes
    from ipaddr import IPNetwork, IPAddress

    ## Hide the 'no routes' warnings
    conf.verb = 0

    networks = []
    for nw, nm, gw, iface, addr in read_routes():
        n = IPNetwork(ltoa(nw))
        (n.netmask, n.gateway,
         n.ipaddr) = [IPAddress(x) for x in [nm, gw, addr]]
        n.iface = iface
        if not n.compressed in networks:
            networks.append(n)

    return networks
Ejemplo n.º 3
0
def gtkui_dependency_check(config):
    '''
    This function verifies that the dependencies that are needed by the GTK user interface are met.
    '''

    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    print('Checking:')
    print('\tGTK UI dependencies...', end='')

    # Check Gtk
    try:
        import gi
        gi.require_version('Gtk', '3.0')
        from gi.repository import Gtk
        assert Gtk.get_major_version(), Gtk.get_minor_version() >= (3, 14)
        print(OKGREEN + "\tOK" + ENDC)
    except:
        print(FAIL + "D'oh!" + ENDC)
        msg = 'You have to install GTK and GObject versions >=3.14 to be able to run the GTK user interface.\n'
        msg += '    - On Debian-based distributions: apt-get install python-gi gir1.2-gtk-3.0\n'
        msg += '    - On Mac: read the Installation instructions in the README'
        print(msg)
        sys.exit(1)

    # Check Scapy
    try:
        print("\tScapy...", end='')
        import scapy.all as scapy
        print(OKGREEN + "\t\tOK" + ENDC)
    except:
        print(FAIL + "\tD'oh!" + ENDC)
        print(WARNING + "No scapy found" + ENDC)
        sys.exit(1)

    # Check Network
    try:
        print("\tNetwork connectivity...", end='')
        for net, mask, gw, iface, addr, metric in scapy.read_routes():
            if iface == scapy.conf.iface and gw != '0.0.0.0':
                pass
        if gw:
            print(OKGREEN + "\tOK" + ENDC)
        else:
            raise Exception("D'Oh!")
    except:
        print(FAIL + "\tD'oh!" + ENDC)
        print(WARNING + "No network connectivity found" + ENDC)
        sys.exit(1)

    # Check GtkSource
    try:
        print("\tGtkSource...", end='')
        gi.require_version('GtkSource', '3.0')
        from gi.repository import GtkSource
        print(OKGREEN + "\tOK" + ENDC)
        # Having GtkSource enables Bokken and hell breaks loose.
        print(
            WARNING +
            "GtkSource found but force-disabled, module and exploits editors will be disabled"
            + ENDC)
        config.HAS_SOURCEVIEW = False
    except:
        print(WARNING + "\tD'oh!" + ENDC)
        print(
            WARNING +
            "GtkSource not found, module and exploits editors will be disabled"
            + ENDC)
        config.HAS_SOURCEVIEW = False

    # Check Vte
    try:
        print("\tVTE Terminal...", end='')
        gi.require_version('Vte', '2.91')
        from gi.repository import Vte
        print(OKGREEN + "\tOK" + ENDC)
    except:
        print(WARNING + "\tD'oh!" + ENDC)
        print(
            WARNING +
            "VTE Terminal not found, Sniffer, Scapy, and terminals will be disabled"
            + ENDC)
        config.HAS_VTE = False

    # Check Impacket
    try:
        print("\tImpacket library...", end='')
        import impacket
        print(OKGREEN + "\tOK" + ENDC)
    except:
        print(WARNING + "\tD'oh!" + ENDC)
        print(WARNING +
              "Impacket library not found, some modules will not work" + ENDC)

    # Check PySNMP
    try:
        print("\tPySNMP library...", end='')
        import pysnmp
        print(OKGREEN + "\tOK" + ENDC)
    except:
        print(WARNING + "\tD'oh!" + ENDC)
        print(WARNING +
              "PySNMP library not found, some modules will not work" + ENDC)

    # Check GeoIP
    try:
        print("\tGeoIP library...", end='')
        from . import GeoIP
        print(OKGREEN + "\tOK" + ENDC)
    except:
        print(WARNING + "\tD'oh!" + ENDC)
        print(WARNING + "GeoIP library not found, some modules will not work" +
              ENDC)
        config.HAS_GEOIP = False

    # Check Nmap
    try:
        print("\t" + config.NMAP_PATH + "...", end='')
        if os.path.exists(config.NMAP_PATH):
            print(OKGREEN + "\tOK" + ENDC)
        else:
            raise
    except:
        print(WARNING + "\tD'oh!" + ENDC)
        print(WARNING + "Nmap not found on: " + config.NMAP_PATH +
              ", so some features will be disabled" + ENDC)
        config.HAS_NMAP = False

    # Check Graphviz
    print("\tGraphviz binaries...", end='')
    if 'PATH' in os.environ:
        for path in os.environ['PATH'].split(os.pathsep):
            progs = __find_executables(path)

            if progs is not None:
                print(OKGREEN + "\tOK" + ENDC)
                return

        print(WARNING + "\tD'oh!" + ENDC)
        print(
            WARNING +
            "Graphviz binaries not found, this software is necessary to run the GUI"
            + ENDC)
        sys.exit(1)
Ejemplo n.º 4
0
def gtkui_dependency_check(config):
    '''
    This function verifies that the dependencies that are needed by the GTK user interface are met.
    '''

    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    print 'Checking:'
    print '\tGTK UI dependencies...',

    # Check Gtk
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk, gobject
        assert gtk.gtk_version >= (2, 12)
        assert gtk.pygtk_version >= (2, 12)
        print OKGREEN + "\tOK" + ENDC
    except:
        print FAIL + "D'oh!" + ENDC
        msg = 'You have to install GTK and PyGTK versions >=2.12 to be able to run the GTK user interface.\n'
        msg += '    - On Debian based distributions: apt-get install python-gtk2\n'
        msg += '    - On Mac: sudo port install py25-gtk'
        print msg
        sys.exit(1)

    # Check Scapy
    try:
        print "\tScapy...",
        import scapy.all as scapy
        print OKGREEN + "\t\tOK" + ENDC
    except:
        print FAIL + "\tD'oh!" + ENDC
        print WARNING + "No scapy found" + ENDC
        sys.exit(1)

    # Check Network
    try:
        print "\tNetwork connectivity...",
        for net, msk, gw, iface, addr in scapy.read_routes():
            if iface == scapy.conf.iface and gw != '0.0.0.0':
                pass
        if gw:
            print OKGREEN + "\tOK" + ENDC
        else:
            raise Exception("D'Oh!")
    except:
        print FAIL + "\tD'oh!" + ENDC
        print WARNING + "No network connectivity found" + ENDC
        sys.exit(1)

    # Check tkSourceView2
    try:
        print "\tGtkSourceView2...",
        import gtksourceview2 as gtksourceview
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "GtkSourceView2 not found, module and exploits editors will be disabled" + ENDC
        config.HAS_SOURCEVIEW = False

    # Check Vte
    try:
        print "\tVTE Terminal...",
        import vte
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "VTE Terminal not found, Sniffer, Scapy, and terminals will be disabled" + ENDC
        config.HAS_VTE = False

    # Check Nmap
    try:
        print "\t" + config.NMAP_PATH + "...",
        if os.path.exists(config.NMAP_PATH):
            print OKGREEN + "\tOK" + ENDC
        else:
            raise
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "Nmap not found on: " + config.NMAP_PATH + " some features will be disabled" + ENDC
        config.HAS_NMAP = False
Ejemplo n.º 5
0
def gtkui_dependency_check(config):
    '''
    This function verifies that the dependencies that are needed by the GTK user interface are met.
    '''

    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    print 'Checking:'
    print '\tGTK UI dependencies...',

    # Check Gtk
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk, gobject
        assert gtk.gtk_version >= (2, 12)
        assert gtk.pygtk_version >= (2, 12)
        print OKGREEN + "\tOK" + ENDC
    except:
        print FAIL + "D'oh!" + ENDC
        msg = 'You have to install GTK and PyGTK versions >=2.12 to be able to run the GTK user interface.\n'
        msg += '    - On Debian-based distributions: apt-get install python-gtk2\n'
        msg += '    - On Mac: sudo port install py25-gtk'
        print msg
        sys.exit(1)

    # Check Scapy
    try:
        print "\tScapy...",
        import scapy.all as scapy
        print OKGREEN + "\t\tOK" + ENDC
    except:
        print FAIL + "\tD'oh!" + ENDC
        print WARNING + "No scapy found" + ENDC
        sys.exit(1)

    # Check Network
    try:
        print "\tNetwork connectivity...",
        for net, msk, gw, iface, addr in scapy.read_routes():
            if iface == scapy.conf.iface and gw != '0.0.0.0':
                pass
        if gw:
            print OKGREEN + "\tOK" + ENDC
        else:
            raise Exception("D'Oh!")
    except:
        print FAIL + "\tD'oh!" + ENDC
        print WARNING + "No network connectivity found" + ENDC
        sys.exit(1)

    # Check tkSourceView2
    try:
        print "\tGtkSourceView2...",
        import gtksourceview2 as gtksourceview
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "GtkSourceView2 not found, module and exploits editors will be disabled" + ENDC
        config.HAS_SOURCEVIEW = False

    # Check Vte
    try:
        print "\tVTE Terminal...",
        import vte
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "VTE Terminal not found, Sniffer, Scapy, and terminals will be disabled" + ENDC
        config.HAS_VTE = False

    # Check Impacket
    try:
        print "\tImpacket library...",
        import impacket
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "Impacket library not found, some modules would not work" + ENDC

    # Check PySNMP
    try:
        print "\tPySNMP library...",
        import pysnmp
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "PySNMP library not found, some modules would not work" + ENDC

    # Check GeoIP
    try:
        print "\tGeoIP library...",
        import GeoIP
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "GeoIP library not found, some modules would not work" + ENDC
        config.HAS_GEOIP = False

    # Check Nmap
    try:
        print "\t" + config.NMAP_PATH + "...",
        if os.path.exists(config.NMAP_PATH):
            print OKGREEN + "\tOK" + ENDC
        else:
            raise
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "Nmap not found on: " + config.NMAP_PATH + " some features will be disabled" + ENDC
        config.HAS_NMAP = False

    # Check Graphviz
    print "\tGraphviz binaries...",
    if os.environ.has_key('PATH'):
        for path in os.environ['PATH'].split(os.pathsep):
            progs = __find_executables(path)

            if progs is not None:
                #print progs
                print OKGREEN + "\tOK" + ENDC
                return

        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "Graphviz binaries not found, this software is necessary to run the GUI" + ENDC
        sys.exit(1)
Ejemplo n.º 6
0
def gtkui_dependency_check(config):
    '''
    This function verifies that the dependencies that are needed by the GTK user interface are met.
    '''

    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'

    print 'Checking:'
    print '\tGTK UI dependencies...',

    # Check Gtk
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk, gobject
        assert gtk.gtk_version >= (2, 12)
        assert gtk.pygtk_version >= (2, 12)
        print OKGREEN + "\tOK" + ENDC
    except:
        print FAIL + "D'oh!" + ENDC
        msg = 'You have to install GTK and PyGTK versions >=2.12 to be able to run the GTK user interface.\n'
        msg += '    - On Debian based distributions: apt-get install python-gtk2\n'
        msg += '    - On Mac: sudo port install py25-gtk'        
        print msg
        sys.exit( 1 )

    # Check Scapy
    try:
        print "\tScapy...",
        import scapy.all as scapy
        print OKGREEN + "\t\tOK" + ENDC
    except:
        print FAIL + "\tD'oh!" + ENDC
        print WARNING + "No scapy found" + ENDC
        sys.exit( 1 )

    # Check Network
    try:
        print "\tNetwork connectivity...",
        for net,msk,gw,iface,addr in scapy.read_routes():
            if iface == scapy.conf.iface and gw != '0.0.0.0':
                pass
        if gw:
            print OKGREEN + "\tOK" + ENDC
        else:
            raise Exception("D'Oh!")
    except:
        print FAIL + "\tD'oh!" + ENDC
        print WARNING + "No network connectivity found" + ENDC
        sys.exit( 1 )

    # Check tkSourceView2
    try:
        print "\tGtkSourceView2...",
        import gtksourceview2 as gtksourceview
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "GtkSourceView2 not found, module and exploits editors will be disabled" + ENDC
        config.HAS_SOURCEVIEW = False

    # Check Vte
    try:
        print "\tVTE Terminal...",
        import vte
        print OKGREEN + "\tOK" + ENDC
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "VTE Terminal not found, Sniffer, Scapy, and terminals will be disabled" + ENDC
        config.HAS_VTE = False

    # Check Nmap
    try:
        print "\t" + config.NMAP_PATH + "...",
        if os.path.exists(config.NMAP_PATH):
            print OKGREEN + "\tOK" + ENDC
        else:
            raise    
    except:
        print WARNING + "\tD'oh!" + ENDC
        print WARNING + "Nmap not found on: " + config.NMAP_PATH + " some features will be disabled" + ENDC
        config.HAS_NMAP = False
Ejemplo n.º 7
0
 def getLocalNetwork(self):
     for net,msk,gw,iface,addr in scapy.read_routes():
         if iface == scapy.conf.iface and scapy.ltoa(msk) != '0.0.0.0':
             net = IPy.IP( str(net) + "/" + scapy.ltoa(msk) )
             return net
Ejemplo n.º 8
0
 def getLocalGW(self):
     for net,msk,gw,iface,addr in scapy.read_routes():
         if iface == scapy.conf.iface and gw != '0.0.0.0':
             return gw
Ejemplo n.º 9
0
 def getLocalNetwork(self):
     for net, msk, gw, iface, addr in scapy.read_routes():
         if iface == scapy.conf.iface and scapy.ltoa(msk) != '0.0.0.0':
             net = IPy.IP(str(net) + "/" + scapy.ltoa(msk))
             return net
Ejemplo n.º 10
0
 def getLocalGW(self):
     for net, msk, gw, iface, addr in scapy.read_routes():
         if iface == scapy.conf.iface and gw != '0.0.0.0':
             return gw