Exemplo n.º 1
0
def launcher(attrs, remote=False):
    logging.debug(attrs)
    logging.info('launcher is starting')
    parameters = ' '.join(attrs)
    principal_dir = os.path.dirname(__file__)
    sys.path.insert(0, principal_dir)
    plugins = os.listdir(os.path.dirname(__file__) + '/plugins')
    for file in plugins:
        if file.endswith('.py'):
            os.system(f'python {principal_dir}/plugins/{file} {parameters}')
        elif file.endswith('.sh'):
            if remote:
                runner = Runner(attrs[2])
                runner.remote_commands()
Exemplo n.º 2
0
 def check(self):
     if self.remote:
         try:
             connect = Runner(self.hostname, self.path)
             connect.get_structure()
             data = connect.output
             logging.debug(data)
             logging.debug(connect.output)
             return data
         except ValueError as e:
             logging.error(f'{e}')
             error = 0
             return error
     else:
         import agent
         return agent.integrity_monitor(self.path)
Exemplo n.º 3
0
    def log(self, type_log, item='0'):
        log = Log(client=self.id, type=type_log, item=item)
        logging.debug(f'type: {type_log} files: {item}')
        # change this time if you want to receive repeated log more often
        interval_min = datetime.now() - timedelta(minutes=INTERVAL_LOG)

        previous_log = Log.objects(
            client=self.id, type=type_log, item=str(
                ','.join(item)), date__gte=interval_min)

        if not previous_log:
            new_log = Log.objects.create(client=self.id,
                                         type=type_log,
                                         item=str(','.join(item)))

            attrs = [self.mail, self.hostname, str(
                type_log), str(','.join(item))]
            logging.debug(attrs)
            launcher(attrs, remote=self.remote)
Exemplo n.º 4
0
 def compare(self):
     '''
     -adding file type 1
     -change file type 2
     -delete file type 3
     '''
     print(self.check())
     if self.check():
         new = self.check()
         if self.status() is True:
             original = self.base
             logging.debug(f'original structure: {original}')
             logging.debug(f'new structure: {new}')
             diffDic = Compare(new, original)
             if diffDic.added():
                 type_log = 1
                 item = diffDic.added()
                 self.log(type_log, item)
             if diffDic.changed():
                 type_log = 2
                 item = diffDic.changed()
                 self.log(type_log, item)
             if diffDic.removed():
                 type_log = 3
                 item = diffDic.removed()
                 self.log(type_log, item)
         else:
             # create new structure base
             client = Client.objects(id=self.id)[0]
             client.update(status=True)
             structure = Structure(client=client, structure=new)
             structure.save()
             print(structure)
     else:
         self.log(4)
         logging.error(f'connection refused - {__name__}.py')
Exemplo n.º 5
0
if __name__ == '__main__':
    logging.info(f'OWASP-Watiqay v{ __version__}')

    while True:
        for client in Client.objects:
            try:
                structure = Structure.objects(
                    client=client).order_by('-_id')[0]['structure']
                get_web = Server(
                    id=client.id,
                    mail=client.email,
                    base=structure,
                    hostname=client.hostname,
                    path=client.path,
                    remote=False)
            except IndexError:
                logging.error('structure not found')
                structure = Structure(client=client)
                structure.save()
                get_web = Server(
                    id=client.id,
                    mail=client.email,
                    base=None,
                    hostname=client.hostname,
                    path=client.path,
                    remote=client.remote)
            logging.debug(get_web.compare())

            sleep(INTERVAL_SCANNING)