Example #1
0
 def search_commit(self, query: str) -> list:
     commit_temp_list = []
     if self.orchestra['commit']:
         print(f"{Color.information} Searching for data in Commits")
         commit_search = self.conn.search_commit(query)
         for unit_commit in commit_search:
             commit_url = unit_commit.html_url
             temp_x = "Repo:{} Commit:{}\n".format(colored("/".join(commit_url.split('/')[3:5]), color='cyan'), colored(commit_url.split('/')[6:][-1]), color='cyan')
             print(Color.good + " " + temp_x.rstrip('\n'))
             commit_temp_list.append(temp_x.lstrip(' '))
             self.git_rate_limit()
             commit_response = get(commit_url)
             commit_soup = BeautifulSoup(commit_response.content, 'html.parser')
             commit_data = commit_soup.find_all("span")
             line_searced = False
             for commit_line in commit_data:
                 for regex in search_regex:
                     if search(regex, commit_line):
                         temp_x = f"{colored(commit_line, color='red')}" 
                         temp_x += "<--- File from commit regex \n".rjust(148-len(temp_x))
                         commit_temp_list.append(temp_x.lstrip(' '))
                         line_searched = True
                 if line_searched:
                     line_searched = False
                     continue
                 for commit_word in commit_line.split(' '):
                     temp_x = f"{colored(commit_word, color='red')} "
                     temp_x += "<--- From commit entropy! \n".rjust(148-len(temp_x))
                     if shannon_entropy(commit_word, base64char) >= float(4.6):
                         code_temp_list.append(temp_x.lstrip(' '))
                     if shannon_entropy(commit_word, hexchar) >= float(4.1):
                         code_temp_list.append(temp_x.lstrip(' '))
     self.orchestra['commit'] = False
     return commit_temp_list
Example #2
0
 def search_code(self, query: str) -> list:
     code_temp_list = []
     if self.orchestra['code']:
         print(f"{Color.information} Searching for data in Codes")
         code_search = self.conn.search_code(query) 
         for unit_code in code_search:
             temp_x = "Name:{}, Repo:{}, URL: {}\n".format(colored(unit_code.name, color='cyan'), colored(unit_code.repository.full_name, color='cyan'), colored(unit_code.download_url, color='cyan'))
             print("{} Searching for code in {} from repository {}".format(Color.good, colored(unit_code.name, color='cyan'), colored(unit_code.repository.full_name, color='cyan')))
             code_temp_list.append(temp_x.lstrip(' '))
             self.git_rate_limit()
             code = b64decode(unit_code.content).decode('UTF-8').split('\n')
             line_searched = False
             for code_line in code:
                 for regex in search_regex:
                     if search(regex, code_line):
                         temp_x = f"{colored(code_line, color='red')} "
                         temp_x += " <--- File from code regex \n".rjust(150-len(temp_x))
                         code_temp_list.append(temp_x.lstrip(' '))
                         line_searched = True
                 if line_searched:
                     line_searched = False
                     continue
                 for code_word in code_line.split(' '):
                     temp_x = f"{colored(code_word, color='red')} "
                     temp_x += "<--- From code entropy! \n".rjust(150-len(temp_x))
                     if shannon_entropy(code_word, base64char) >= float(4.6):
                         code_temp_list.append(temp_x.lstrip(' '))
                     if shannon_entropy(code_word, hexchar) >= float(4):
                         code_temp_list.append(temp_x.lstrip(' '))
     self.orchestra['code'] = False
     return code_temp_list
Example #3
0
 def search_repo(self, query: str) -> list:
     repo_temp_list = []
     if self.orchestra['repo']:
         print(f"{Color.information} Searching for data in Repositories!")
         repo_search = self.conn.search_repositories(query)
         self.git_rate_limit()
         for unit_repo in repo_search:
             repo = self.conn.get_repo(unit_repo.full_name)
             temp_x = "Fetching data from this repo: {}\n".format(colored(repo.full_name, color='cyan'))
             repo_temp_list.append(temp_x.lstrip(' '))
             print(Color.good + " " + temp_x.rstrip('\n'))
             repo_list = repo.get_contents("")
             while repo_list:
                 repo_file = repo_list.pop(0)
                 if repo_file.type == "dir":
                     repo_list.extend(repo.get_contents(repo_file.path))
                 else:
                     try:
                         repo_file_lines = b64decode(repo_file.content).decode('UTF-8').split('\n')
                     except Exception as E:
                         print(E,E.__class__)
                         continue
                     temp_x = "File: {}\n".format(colored(repo_file, color='cyan'))
                     repo_temp_list.append(temp_x.lstrip(' '))
                     line_searched = False
                     for repoline in repo_file_lines:
                         for regex in search_regex:
                             if search(regex, repoline):
                                 temp_x = f"{colored(repoline, color='red')} "
                                 temp_x += "<--- File from repo regex \n".rjust(150-len(temp_x))
                                 repo_temp_list.append(temp_x.lstrip(' '))
                                 line_searched = True
                         if line_searched:
                             line_searched = False
                             continue
                         for repoword in repoline.split(' '):
                             temp_x = f"{colored(repoword, color='red')} "
                             temp_x += "<--- From Repo entropy! \n".rjust(150-len(temp_x))
                             if shannon_entropy(repoword, base64char) >= float(4.5):
                                 repo_temp_list.append(temp_x.lstrip(' '))
                             if shannon_entropy(repoword, hexchar) >= float(4.1):
                                 repo_temp_list.append(temp_x.lstrip(' '))
     self.orchestra['repo'] = False
     return repo_temp_list
Example #4
0
 def shannon_extract(self, line: str) -> list:
     output_list = []
     if self.argv.enable_entropy:
         for word in line.split(' '):
             if len(word) > 5:
                 if float(shannon_entropy(
                         word, base64char)) > float(3.43) or float(
                             shannon_entropy(word, hexchar)) > float(3.5):
                     word = self.reduce_string(word.rstrip(';'),
                                               args=['"', "'"])
                     print(
                         f"{Color.good} Suspicious data: {colored(word, color='red', attrs=['bold'])}"
                     )
                     output_list = [
                         manage_output(f"{word} <--- Entropy \n"), "Entropy"
                     ]
                     self.jstext_continuer = 1
                     return output_list
     return []