Пример #1
0
 def do_analyse(self, params):
     """analyse
     Analyse the retrieved entities
     """
     argc, argv = param_parser(params)
     if argc == 0:
         print("Please provide what you're looking for (e.g. name, location, ...)")
         return
     expected_types = [expected_type.strip() for expected_type in argv[0].split(',')]
     return self.analyse(expected_types)
Пример #2
0
 def do_show(self, params):
     """show [params]
     Display information of the parameter
     ---
     params - parameters
     """
     argc, argv = param_parser(params)
     if argc == 1 and argv[0] in self.SHOW_PARAMS:
         return {
             'params': self.__show_params,
         }.get(argv[0])()
     else:
         self.do_help('show')
Пример #3
0
 def do_load(self, params):
     """load [db_name]
     Load the saved state of gathered documents
     ---
     db_name - name of the db
     """
     argc, argv = param_parser(params)
     if argc != 1:
         self.do_list()
         return
     self.cur_db_name = './db/' + argv[0]
     self.cur_db = sqlite3.connect(self.cur_db_name + '/documents.db')
     self.cur_db_cursor = self.cur_db.cursor()
     self.cur_db_cursor.execute('SELECT count(*) FROM documents')
     loaded_row = self.cur_db_cursor.fetchall()[0][0]
     print("{} documents are loaded".format(loaded_row))
Пример #4
0
    def do_url(self, params):
        """url [entity]
        Get the source(s) of the retrieved entity
        ---
        entity - The entity that will be traced back to the URL
        """
        argc, argv = param_parser(params)

        if argc == 1:
            entity = argv[0]
        elif argc > 1:
            entity = ' '.join(argv[0:])
        else:
            self.do_help('url')
            return

        if self.cur_db_name is None:
            print("[!] Database is not loaded")
            return

        self.cur_db = sqlite3.connect(self.cur_db_name + '/documents.db')
        self.cur_db_cursor = self.cur_db.cursor()

        query = 'SELECT documents.url FROM documents WHERE documents.did IN ' \
                '(SELECT DISTINCT entities.did FROM entities WHERE entities.entity LIKE \'%{0}%\')'
        self.cur_db_cursor.execute(query.format(entity))

        loaded_rows = self.cur_db_cursor.fetchall()
        if len(loaded_rows):
            print("Entity: {} is not found in the database".format(entity))
            return

        urls = [row[0] for row in loaded_rows]
        print("Entity: {} is retrieved from:".format(entity))
        for url in urls:
            if '%3A' in url:
                url = unquote(url).decode('utf8')
            print("\t{}".format(url))
Пример #5
0
 def do_set(self, params):
     """set [param] [value]
     Set the searching parameter with the input value.
     ---
     Name - First name of the profile
     Email - Emails of the profile (e.g. [email protected], or ['*****@*****.**', '*****@*****.**']
     Phone - Phone number
     Location - Name of the location
     """
     argc, argv = param_parser(params)
     #
     key = argv[0]
     if argc > 1:
         value = ' '.join(argv[1:])
     else:
         value = ""
     value = value.lower()
     if key and key in self.INPUT_PARAMS:
         print(key + ' => ' + value)
         self.params[key] = value
         insert_keyword(self.cur_db_cursor, key, value)
         self.cur_db.commit()
     else:
         self.do_help('set')