Ejemplo n.º 1
0
def binary(bin, arg_str='', out_name=None, in_fname=None):
  """
  Runs an external binary, handles arguments, writes out
  equivalent .sh file, log file, and can pipe in in_fname.
  """
  if bin in binaries and binaries[bin]:
    bin = binaries[bin]
  else:
    util.check_program(bin)
  if arg_str:
    util.run_with_output_file(
        '%s %s' % (bin, arg_str), out_name, in_fname)
  return '"%s"' % bin
Ejemplo n.º 2
0
    def initialize(self):
        """Initialize AP"""
        if not util.check_program('airbase-ng'):
            util.Error('\'airbase-ng\' not found in local path.')
            return False

        self.running = True
        ap_proc = None

        try:
            self.mon_adapt = util.get_monitor_adapter()
            if self.mon_adapt is None:
                self.mon_adapt = util.enable_monitor()

            if self.mon_adapt is None:
                util.Error('Could not find a wireless card in monitor mode')
                self.running = False
                return None

            airbase_cmd = [
                        'airbase-ng',
                        '--essid', self.config['ap_essid'].value,
                        self.mon_adapt
                          ]
            ap_proc = util.init_app(airbase_cmd, False)
            util.Msg('Access point %s running.' % \
                                    self.config['ap_essid'].value)
            raw_input()    # block
        except KeyboardInterrupt:
            self.running = False
        except Exception, er:
            util.Error('Error with wireless AP: %s' % er)
Ejemplo n.º 3
0
    def initialize(self):
        """Initialize AP"""
        if not util.check_program('airbase-ng'):
            util.Error('\'airbase-ng\' not found in local path.')
            return False

        self.running = True
        ap_proc = None

        try:
            self.mon_adapt = util.get_monitor_adapter()
            if self.mon_adapt is None:
                self.mon_adapt = util.enable_monitor()

            if self.mon_adapt is None:
                util.Error('Could not find a wireless card in monitor mode')
                return None

            airbase_cmd = [
                'airbase-ng', '--essid', self.ap_essid, self.mon_adapt
            ]
            ap_proc = util.init_app(airbase_cmd, False)
            util.Msg('Access point %s running.' % self.ap_essid)
            raw_input()  # block
        except KeyboardInterrupt:
            self.running = False
        except Exception, er:
            util.Error('Error with wireless AP: %s' % er)
Ejemplo n.º 4
0
    def initialize_bg(self):
        """Initialize in background thread"""
        if not util.check_program('airbase-ng'):
            util.Error('\'airbase-ng\' not found in local path.')
            return False

        while True:
            try:
                tmp = raw_input('[!] Enter ESSID [%s]: ' % self.ap_essid)
                if len(tmp) > 2:
                    self.ap_essid = tmp
                break
            except KeyboardInterrupt:
                break
            except:
                continue

        util.Msg('Initializing access point..')
        thread = Thread(target=self.initialize)
        thread.start()

        sleep(2)
        if self.running:
            return True
        else:
            return False
Ejemplo n.º 5
0
	def initialize(self):
		"""Initialize AP"""
		if not util.check_program('airbase-ng'):
			util.Error('\'airbase-ng\' not found in local path.')
			return False
	
		self.running = True
		ap_proc = None
			
		try:
			self.mon_adapt = util.get_monitor_adapter()
			if self.mon_adapt is None:
				self.mon_adapt = util.enable_monitor()
					
			airbase_cmd = [
						'airbase-ng',
						'--essid', self.ap_essid,
						self.mon_adapt
						  ]
			ap_proc = util.init_app(airbase_cmd, False)
			util.Msg('Access point %s running.'%self.ap_essid)
			while self.running: pass
		except KeyboardInterrupt:
			self.running = False
		except Exception, er:
			util.Error('Error with wireless AP: %s'%er)
Ejemplo n.º 6
0
    def initialize_bg(self):
        """Initialize in background thread"""
        if not util.check_program('airbase-ng'):
            util.Error('\'airbase-ng\' not found in local path.')
            return False

        while True:
            try:
                tmp = raw_input('[!] Enter ESSID [%s]: ' % self.ap_essid)
                if len(tmp) > 2:
                    self.ap_essid = tmp
                break
            except KeyboardInterrupt:
                break
            except:
                continue

        util.Msg('Initializing access point..')
        thread = Thread(target=self.initialize)
        thread.start()

        sleep(2)
        if self.running:
            return True
        else:
            return False
Ejemplo n.º 7
0
def smb_info(ip):
	if not util.check_program('smbclient'):
		print '\t  [-] Skipping SMB enumeration.'
		return
	tmp = 'smbclient -U GUEST -N --socket-options=\'TCP_NODELAY IPTOS_LOWDELAY\' -L %s'%(ip)
	data = util.init_app(tmp, True)
	
	# dump smb reponse
	for line in data.split('\n'):
		print '\t  |-', line
Ejemplo n.º 8
0
    def smb_info(self, ip):
        if not util.check_program("smbclient"):
            print "\t  [-] Skipping SMB enumeration."
            return
        tmp = "smbclient -U GUEST -N --socket-options='TCP_NODELAY " "IPTOS_LOWDELAY' -L %s" % (ip)
        data = util.init_app(tmp, True)

        # dump smb reponse
        for line in data.split("\n"):
            print "\t  |-", line
Ejemplo n.º 9
0
    def smb_info(self, ip):
        if not util.check_program('smbclient'):
            print '\t  [-] Skipping SMB enumeration.'
            return
        tmp = 'smbclient -U GUEST -N --socket-options=\'TCP_NODELAY IPTOS_LOWDELAY\' -L %s' % (
            ip)
        data = util.init_app(tmp, True)

        # dump smb reponse
        for line in data.split('\n'):
            print '\t  |-', line
Ejemplo n.º 10
0
def initialize():
	try:
		if not util.check_program('airmon-ng'):
			util.Error('airomon-ng not installed.  Please install to continue.')
			return False
		util.Msg('(ctrl^c) when finished.')
		iface = util.get_monitor_adapter()
		if iface is None:
			util.Msg('No devices found in monitor mode.  Enabling...')
			iface = util.enable_monitor()
		util.debug('Using interface %s'%iface)
		ap_scan(iface)
	except Exception, KeyboardInterrupt:
		return
Ejemplo n.º 11
0
    def initialize_bg(self):
        """Initialize in background thread"""
        if not util.check_program('airbase-ng'):
            util.Error('\'airbase-ng\' not found in local path.')
            return False

        util.Msg('Initializing access point..')
        thread = Thread(target=self.initialize)
        thread.start()

        sleep(2)
        if self.running:
            return True
        else:
            return False
Ejemplo n.º 12
0
 def initialize(self):
     try:
         if not util.check_program('airmon-ng'):
             util.Error(
                 'airomon-ng not installed.  Please install to continue.')
             return False
         util.Msg('(ctrl^c) when finished.')
         iface = util.get_monitor_adapter()
         if iface is None:
             util.Msg('No devices found in monitor mode.  Enabling...')
             iface = util.enable_monitor(self.channel)
         util.debug('Using interface %s' % iface)
         self.ap_scan(iface)
     except Exception, KeyboardInterrupt:
         return
Ejemplo n.º 13
0
    def initialize_bg(self):
        """Initialize in background thread"""
        if not util.check_program('airbase-ng'):
            util.Error('\'airbase-ng\' not found in local path.')
            return False

        util.Msg('Initializing access point..')
        thread = Thread(target=self.initialize)
        thread.start()

        sleep(2)
        if self.running:
            return True
        else:
            return False
Ejemplo n.º 14
0
 def initialize(self):
     """ Initialize the scanner
     """
     try:
         if not util.check_program('airmon-ng'):
             util.Error('airomon-ng not installed.  Please install to continue.')
             return None
         util.Msg('(ctrl^c) when finished.')
         iface = util.get_monitor_adapter()
         if iface is None:
             util.Msg('No devices found in monitor mode.  Enabling...')
             iface = util.enable_monitor(self.channel)
         util.debug('Using interface %s' % iface)
         self.ap_scan(iface)
     except Exception:
         return
Ejemplo n.º 15
0
Archivo: ssh.py Proyecto: 0x0mar/zarp
    def initialize(self):
        priv_key = self.config['priv_key'].value
        try:
            # try importing here so we can catch it right away
            import paramiko
        except ImportError:
            util.Error('Paramiko libraries required for this module.')
            return

        level = getattr(paramiko.common, 'CRITICAL')
        paramiko.common.logging.basicConfig(level=level)
        # if the user did not specify a key, generate one
        if priv_key is None:
            if not util.check_program('openssl'):
                util.Error('OpenSSL required to generate cert/key files.')
                return
            if not util.does_file_exist('./privkey.key'):
                util.debug('Generating RSA private key...')
                util.init_app('openssl genrsa -out privkey.key 2048')
                util.debug('privkey.key was generated.')
            priv_key = self.config['priv_key'].value = './privkey.key'

        try:
            server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True)
            server_socket.settimeout(3)
            server_socket.bind(('0.0.0.0', self.config['port'].value))
            server_socket.listen(1)
            self.running = True

            while self.running:
                try:
                    con, addr = server_socket.accept()
                except KeyboardInterrupt:
                    return
                except:
                    # timeout
                    continue

                pkey = paramiko.RSAKey.from_private_key_file(priv_key)
                transport = paramiko.Transport(con)
                transport.add_server_key(pkey)
                transport.set_subsystem_handler('handler', paramiko.SFTPServer, SSHHandler)

                context = {'dump': self.dump, 'log_data': self.log_data,
                            'log_file': self.log_file}
                server = SSHStub(context)
                try:
                    transport.start_server(server=server)
                    transport.accept()
                    while transport.is_active():
                        sleep(1)
                except socket.error as j:
                    if j.errno == 104:
                        # just means we've got a broken pipe, or
                        # the peer dropped unexpectedly
                        continue
                    else:
                        raise Exception()
                except IOError:
                    util.Error('There was an error reading the keyfile.')
                    return False
                except EOFError:
                    # thrown when we dont get the key correctly, or
                    # remote host gets mad because the key changed
                    continue
                except:
                    raise Exception()
        except KeyboardInterrupt:
            pass
        except Exception as j:
            util.Error('Error with server: %s' % j)
        finally:
            self.running = False
            self.cleanup()
Ejemplo n.º 16
0
    def initialize(self):
        try:
            # try importing here so we can catch it right away
            import paramiko
        except ImportError:
            util.Error('Paramiko libraries required for this module.')
            return

        level = getattr(paramiko.common, 'CRITICAL')
        paramiko.common.logging.basicConfig(level=level)
        # if the user did not specify a key, generate one
        if self.priv_key is None:
            if not util.check_program('openssl'):
                util.Error('OpenSSL required to generate cert/key files.')
                return
            if not util.does_file_exist('./privkey.key'):
                util.debug('Generating RSA private key...')
                tmp = util.init_app('openssl genrsa -out privkey.key 2048',
                                    True)
                util.debug('privkey.key was generated.')
            self.priv_key = './privkey.key'

        try:
            server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                     True)
            server_socket.settimeout(3)
            server_socket.bind(('0.0.0.0', 22))
            server_socket.listen(1)
            self.running = True

            while self.running:
                try:
                    con, addr = server_socket.accept()
                except KeyboardInterrupt:
                    return
                except:
                    # timeout
                    continue
                pkey = paramiko.RSAKey.from_private_key_file(self.priv_key)
                transport = paramiko.Transport(con)
                transport.add_server_key(pkey)
                transport.set_subsystem_handler('handler', paramiko.SFTPServer,
                                                SSHHandler)

                context = {
                    'dump': self.dump,
                    'log_data': self.log_data,
                    'log_file': self.log_file
                }
                server = SSHStub(context)
                try:
                    transport.start_server(server=server)
                    channel = transport.accept()
                    while transport.is_active():
                        sleep(1)
                except socket.error as j:
                    if j.errno == 104:
                        # just means we've got a broken pipe, or
                        # the peer dropped unexpectedly
                        continue
                    else:
                        raise Exception()
                except IOError:
                    util.Error('There was an error reading the keyfile.')
                    return False
                except EOFError:
                    # thrown when we dont get the key correctly, or
                    # remote host gets mad because the key changed
                    continue
                except:
                    raise Exception()
        except KeyboardInterrupt:
            pass
        except Exception as j:
            util.Error('Error with server: %s' % j)
        finally:
            self.running = False
            self.cleanup()