def __init__(self, name: str, handler: HoneyHandler, path: str = None, description: str = None): self._name = name self._handler = handler if description: self._description = description else: self._description = config['filesystem'][name]['description'] if path: self._path = path else: self._path = config['filesystem'][name]['path'] self._fs = self.create_directory('/', self._path, True) self._cwd = self._fs self._modified = False sha = hashlib.sha1() sha.update(config['SENSOR_NAME']) sha.update(self._name.encode('utf-8')) sha.update(self._description.encode('utf-8')) self._uid = sha.digest().hex() self._session_id = uuid.uuid4().hex self._load_from_path(self._path) database.insertData(database.FILESYSTEM_ENTRY, name, self._description, self._uid)
def addThreatInfo(self, key: str, value: bytes) -> bool: global logger if not self.attack_id: logger.debug("Must call createThreat() first!") return False database.insertData(database.THREAT_ACTION_ENTRY, self.attack_id, '{}_{}'.format(self.module._name, key), value) return True
def addFilesystemAction(self, key: str, value: bytes) -> bool: global logger if not self._handler.attack_id: logger.debug( "Attached HoneyHandler must have created a new threat ID!") return False database.insertData(database.FILESYSTEM_ACTION_ENTRY, self._handler.attack_id, self._uid, self._session_id, '{}_{}'.format(self._name, key), value) return True
def createThreat(self, src_ip: str, src_port: int, dst_ip: str, dst_port: int) -> None: self.attack_id = uuid.uuid4().hex database.insertData(database.THREAT_ENTRY, self.attack_id, self.module.get_uid(), src_ip, src_port, dst_ip, dst_port) threat_path = '{}/{}'.format(config['artifacts']['dir_name'], self.attack_id) os.mkdir(threat_path, config['artifacts']['dir_perms']) os.mkdir( '{}/{}'.format(threat_path, config['filesystem']['outfile_dir']), config['artifacts']['dir_perms']) logger.info('New Attack ID ({}) For Module ({})'.format( self.attack_id, self.module.get_uid()))
def __init__(self, name: str, handler: HoneyHandler, description: str = None): self._name = name if description: self._description = description else: self._description = config['modules'][name]['description'] self._handler = handler sha = hashlib.sha1() sha.update(config['SENSOR_NAME']) sha.update(self._name.encode('utf-8')) sha.update(self._description.encode('utf-8')) self._uid = sha.digest().hex() database.insertData(database.MODULE_ENTRY, name, self._description, self._uid)