コード例 #1
0
ファイル: amun_request_handler.py プロジェクト: zeroq/amun
	def handle_incoming_connection(self, socket_object, currSockets, currConn, decodersDict, event_dict, config_dict, vuln_modules, divLogger, addr):
		""" handles incoming connections at first and inits all objects """
		asynchat.async_chat.__init__(self, socket_object)
		self.socket_object = socket_object
		self.divLogger = divLogger
		self.shellcode_manager = shellcode_mgr_core.shell_mgr(decodersDict, divLogger['shellcode'], config_dict)
		self.replace_locals = config_dict['replace_locals']
		self.blocksucexpl = config_dict['block_sucexpl']
		self.verboseLogging = config_dict['verbose_logging']
		try:
			(self.remote_ip, self.remote_port) = socket_object.getpeername()
			(self.own_ip, self.own_port) = socket_object.getsockname()
			self.identifier = "%s%s%s%s" % (self.remote_ip,self.remote_port,self.own_ip,self.own_port)
		except socket.error, e:
			### 107: Transport endpoint is not connected
			if e[0]==107:
				self.log_obj.log("Transport endpoint is not connected", 6, "crit", False, True)
			else:
				self.log_obj.log("[handle_incoming_connection] socket error: %s" % (e), 6, "crit", False, True)
			### add host to refused list, block connections for 3 minutes
			if config_dict['block_refused'] == 1:
				item_id = str(addr[0])
				event_dict['refused_connections'][item_id] = int(time.time())
			try:
				self.shutdown(socket.SHUT_RDWR)
			except:
				pass
			self.connected = False
			self.close()
			return
コード例 #2
0
ファイル: amun_bindport_core.py プロジェクト: BeeKeepers/amun
	def __init__(self, divLogger, config_dict, decodersDict):
		self.shellcmds = []
		self.bindport_closed = False
		self.divLogger = divLogger
		self.config_dict = config_dict
		self.shellcode_manager = shellcode_mgr_core.shell_mgr(decodersDict, divLogger['shellcode'], config_dict)
		self.log_obj = amun_logging.amun_logging("bindport", divLogger['download'])
		self.shellemu = shellemulator.shellemulator(divLogger['shellemulator'])
		self.shellInfo = self.shellemu.getShellInfoLine()
コード例 #3
0
	def __init__(self, divLogger, config_dict, decodersDict):
		self.shellcmds = []
		self.bindport_closed = False
		self.divLogger = divLogger
		self.config_dict = config_dict
		self.shellcode_manager = shellcode_mgr_core.shell_mgr(decodersDict, divLogger['shellcode'], config_dict)
		self.log_obj = amun_logging.amun_logging("bindport", divLogger['download'])
		self.shellemu = shellemulator.shellemulator(divLogger['shellemulator'])
		self.shellInfo = self.shellemu.getShellInfoLine()
コード例 #4
0
ファイル: download_core.py プロジェクト: BeeKeepers/amun
	def __init__(self, item, currDownl, currentSockets, divLogger, event_dict, config_dict, display_shell, authkey, decodersDict):
		asyncore.dispatcher.__init__(self)
		self.log_obj = amun_logging.amun_logging("connback_download", divLogger['download'])
		self.connection_closed = False
		self.shellcode_manager = shellcode_mgr_core.shell_mgr(decodersDict, divLogger['shellcode'], config_dict)
		self.currentDownloads = currDownl
		self.currentSockets = currentSockets
		self.event_dict = event_dict
		self.config_dict = config_dict
		self.vulnName = item['vulnname']
		self.downURL = item['displayURL']
		self.dlident = item['dlident']
		self.victimIP = item['own_host']
		self.display_shell = display_shell
		self.active = False
		self.authkey = authkey
		self.content = []
		if self.display_shell:
			if config_dict['verbose_logging']==1:
				self.log_obj.log("displaying shell to %s" % (item['host']), 12, "debug", True, True)
			self.shellemu = shellemulator.shellemulator(divLogger['shellemulator'])
			self.buffer = self.shellemu.getShellInfoLine()
		elif authkey!="None":
			self.authkey = base64.b64decode(authkey)
			self.buffer = self.authkey
		else:
			self.buffer = ''
		self._address = (item['host'], int(item['port']))
		self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
		#self.bind( (item['own_host'], 0) )
		self.set_reuse_addr()
		self.identifier = "%s%s%s%s" % (self.dlident, item['host'], item['port'], item['own_host'])
		try:
			self.connect( self._address )
			self.active = True
		except socket.error, e:
			if e[0]==111:
				if config_dict['verbose_logging']==1:
					self.log_obj.log("failed to connect: connection refused (%s)" % (item['host']), 12, "crit", True, True)
				else:
					self.log_obj.log("failed to connect: connection refused (%s)" % (item['host']), 12, "crit", False, False)
			else:
				if config_dict['verbose_logging']==1:
					self.log_obj.log("failed to connect: %s (%s)" % (e, item['host']), 12, "crit", True, True)
				else:
					self.log_obj.log("failed to connect: %s (%s)" % (e, item['host']), 12, "crit", False, False)
			### add host to refused list, block connections for 3 minutes
			if self.config_dict['block_refused'] == 1:
				item_id = str(item['host'])
				self.event_dict['refused_connections'][item_id] = int(time.time())
			### close connection
			self.active = False
			self.handle_close()
コード例 #5
0
 def handle_incoming_connection(self, socket_object, currSockets, currConn,
                                decodersDict, event_dict, config_dict,
                                vuln_modules, divLogger, addr):
     """ handles incoming connections at first and inits all objects """
     asynchat.async_chat.__init__(self, socket_object)
     self.socket_object = socket_object
     self.divLogger = divLogger
     self.shellcode_manager = shellcode_mgr_core.shell_mgr(
         decodersDict, divLogger['shellcode'], config_dict)
     self.replace_locals = config_dict['replace_locals']
     self.blocksucexpl = config_dict['block_sucexpl']
     self.verboseLogging = config_dict['verbose_logging']
     try:
         (self.remote_ip, self.remote_port) = socket_object.getpeername()
         (self.own_ip, self.own_port) = socket_object.getsockname()
         self.identifier = "%s%s%s%s" % (self.remote_ip, self.remote_port,
                                         self.own_ip, self.own_port)
     except socket.error, e:
         ### 107: Transport endpoint is not connected
         if e[0] == 107:
             self.log_obj.log("Transport endpoint is not connected", 6,
                              "crit", False, True)
         else:
             self.log_obj.log(
                 "[handle_incoming_connection] socket error: %s" % (e), 6,
                 "crit", False, True)
         ### add host to refused list, block connections for 3 minutes
         if config_dict['block_refused'] == 1:
             item_id = str(addr[0])
             event_dict['refused_connections'][item_id] = int(time.time())
         try:
             self.shutdown(socket.SHUT_RDWR)
         except:
             pass
         self.connected = False
         self.close()
         return
コード例 #6
0
 def __init__(self, item, currDownl, currentSockets, divLogger, event_dict,
              config_dict, display_shell, authkey, decodersDict):
     asyncore.dispatcher.__init__(self)
     self.log_obj = amun_logging.amun_logging("connback_download",
                                              divLogger['download'])
     self.connection_closed = False
     self.shellcode_manager = shellcode_mgr_core.shell_mgr(
         decodersDict, divLogger['shellcode'], config_dict)
     self.currentDownloads = currDownl
     self.currentSockets = currentSockets
     self.event_dict = event_dict
     self.config_dict = config_dict
     self.vulnName = item['vulnname']
     self.downURL = item['displayURL']
     self.dlident = item['dlident']
     self.victimIP = item['own_host']
     self.display_shell = display_shell
     self.active = False
     self.authkey = authkey
     self.content = []
     if self.display_shell:
         if config_dict['verbose_logging'] == 1:
             self.log_obj.log("displaying shell to %s" % (item['host']), 12,
                              "debug", True, True)
         self.shellemu = shellemulator.shellemulator(
             divLogger['shellemulator'])
         self.buffer = self.shellemu.getShellInfoLine()
     elif authkey != "None":
         self.authkey = base64.b64decode(authkey)
         self.buffer = self.authkey
     else:
         self.buffer = ''
     self._address = (item['host'], int(item['port']))
     self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
     #self.bind( (item['own_host'], 0) )
     self.set_reuse_addr()
     self.identifier = "%s%s%s%s" % (self.dlident, item['host'],
                                     item['port'], item['own_host'])
     try:
         self.connect(self._address)
         self.active = True
     except socket.error, e:
         if e[0] == 111:
             if config_dict['verbose_logging'] == 1:
                 self.log_obj.log(
                     "failed to connect: connection refused (%s)" %
                     (item['host']), 12, "crit", True, True)
             else:
                 self.log_obj.log(
                     "failed to connect: connection refused (%s)" %
                     (item['host']), 12, "crit", False, False)
         else:
             if config_dict['verbose_logging'] == 1:
                 self.log_obj.log(
                     "failed to connect: %s (%s)" % (e, item['host']), 12,
                     "crit", True, True)
             else:
                 self.log_obj.log(
                     "failed to connect: %s (%s)" % (e, item['host']), 12,
                     "crit", False, False)
         ### add host to refused list, block connections for 3 minutes
         if self.config_dict['block_refused'] == 1:
             item_id = str(item['host'])
             self.event_dict['refused_connections'][item_id] = int(
                 time.time())
         ### close connection
         self.active = False
         self.handle_close()