pile_js / 5alt__GitLeak.jsonl
Hamhams's picture
commit files to HF hub
c7f4bd0
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"init","parameters":"()","argument_list":"","return_statement":"return key_words","docstring":"Initialize GitPrey with module inspection and input inspection\n :return: None","docstring_summary":"Initialize GitPrey with module inspection and input inspection\n :return: None","docstring_tokens":["Initialize","GitPrey","with","module","inspection","and","input","inspection",":","return",":","None"],"function":"def init():\n \"\"\"\n Initialize GitPrey with module inspection and input inspection\n :return: None\n \"\"\"\n try:\n imp.find_module('lxml')\n except ImportError:\n error_print('[!_!]ERROR INFO: You have to install lxml module.')\n exit()\n\n # Get command parameters for searching level and key words\n parser = argparse.ArgumentParser(description=\"Searching sensitive file and content in GitHub.\")\n parser.add_argument(\"-l\", \"--level\", type=int, choices=range(1, 6), default=1, metavar=\"level\",\n help=\"Set search level within 1~5, default is 1.\")\n parser.add_argument(\"-k\", \"--keywords\", metavar=\"keywords\", required=True,\n help=\"Set key words to search projects.\")\n args = parser.parse_args()\n\n SEARCH_LEVEL = args.level if args.level else 1\n key_words = args.keywords if args.keywords else \"\"\n\n # Print GitPrey digital logo and version information.\n info_print(GitPrey.__doc__)\n\n keyword_output = \"[^_^] START INFO: The key word for searching is: {keyword}\"\n info_print(keyword_output.format(keyword=key_words))\n\n return key_words","function_tokens":["def","init","(",")",":","try",":","imp",".","find_module","(","'lxml'",")","except","ImportError",":","error_print","(","'[!_!]ERROR INFO: You have to install lxml module.'",")","exit","(",")","# Get command parameters for searching level and key words","parser","=","argparse",".","ArgumentParser","(","description","=","\"Searching sensitive file and content in GitHub.\"",")","parser",".","add_argument","(","\"-l\"",",","\"--level\"",",","type","=","int",",","choices","=","range","(","1",",","6",")",",","default","=","1",",","metavar","=","\"level\"",",","help","=","\"Set search level within 1~5, default is 1.\"",")","parser",".","add_argument","(","\"-k\"",",","\"--keywords\"",",","metavar","=","\"keywords\"",",","required","=","True",",","help","=","\"Set key words to search projects.\"",")","args","=","parser",".","parse_args","(",")","SEARCH_LEVEL","=","args",".","level","if","args",".","level","else","1","key_words","=","args",".","keywords","if","args",".","keywords","else","\"\"","# Print GitPrey digital logo and version information.","info_print","(","GitPrey",".","__doc__",")","keyword_output","=","\"[^_^] START INFO: The key word for searching is: {keyword}\"","info_print","(","keyword_output",".","format","(","keyword","=","key_words",")",")","return","key_words"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L268-L296"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"project_miner","parameters":"(key_words)","argument_list":"","return_statement":"","docstring":"Search projects for content and path inspection later.\n :param key_words: key words for searching\n :return:","docstring_summary":"Search projects for content and path inspection later.\n :param key_words: key words for searching\n :return:","docstring_tokens":["Search","projects","for","content","and","path","inspection","later",".",":","param","key_words",":","key","words","for","searching",":","return",":"],"function":"def project_miner(key_words):\n \"\"\"\n Search projects for content and path inspection later.\n :param key_words: key words for searching\n :return:\n \"\"\"\n # Search projects according to key words and searching level\n _gitprey = GitPrey(key_words)\n total_project_list = _gitprey.search_project()[:MAX_SEARCH_REPO]\n\n project_info_output = \"\\n[*_*] PROJECT INFO: Found {num} public projects related to the key words.\\n\"\n info_print(project_info_output.format(num=len(total_project_list)))\n\n if not total_project_list:\n return\n\n # Scan all projects with pattern content\n info_print(\"[^_^] START INFO: Begin searching sensitive content.\")\n result = {}\n for i in xrange(len(total_project_list)\/MAX_REPO_SINGLE_SEARCH+1):\n repo_list = total_project_list[i*MAX_REPO_SINGLE_SEARCH:i*MAX_REPO_SINGLE_SEARCH+MAX_REPO_SINGLE_SEARCH]\n # Join projects to together to search\n\n if len(repo_list) == 0: break\n\n repo_string = \" repo:\" + \" repo:\".join(repo_list)\n result.update(_gitprey.sensitive_info_query(repo_string))\n jsonify_result(result)\n info_print(\"[^_^] END INFO: Sensitive content searching is done.\\n\")","function_tokens":["def","project_miner","(","key_words",")",":","# Search projects according to key words and searching level","_gitprey","=","GitPrey","(","key_words",")","total_project_list","=","_gitprey",".","search_project","(",")","[",":","MAX_SEARCH_REPO","]","project_info_output","=","\"\\n[*_*] PROJECT INFO: Found {num} public projects related to the key words.\\n\"","info_print","(","project_info_output",".","format","(","num","=","len","(","total_project_list",")",")",")","if","not","total_project_list",":","return","# Scan all projects with pattern content","info_print","(","\"[^_^] START INFO: Begin searching sensitive content.\"",")","result","=","{","}","for","i","in","xrange","(","len","(","total_project_list",")","\/","MAX_REPO_SINGLE_SEARCH","+","1",")",":","repo_list","=","total_project_list","[","i","*","MAX_REPO_SINGLE_SEARCH",":","i","*","MAX_REPO_SINGLE_SEARCH","+","MAX_REPO_SINGLE_SEARCH","]","# Join projects to together to search","if","len","(","repo_list",")","==","0",":","break","repo_string","=","\" repo:\"","+","\" repo:\"",".","join","(","repo_list",")","result",".","update","(","_gitprey",".","sensitive_info_query","(","repo_string",")",")","jsonify_result","(","result",")","info_print","(","\"[^_^] END INFO: Sensitive content searching is done.\\n\"",")"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L299-L327"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.search_project","parameters":"(self)","argument_list":"","return_statement":"return unique_project_list","docstring":"Search related projects with recently indexed sort according to keyword\n :returns: Related projects list","docstring_summary":"Search related projects with recently indexed sort according to keyword\n :returns: Related projects list","docstring_tokens":["Search","related","projects","with","recently","indexed","sort","according","to","keyword",":","returns",":","Related","projects","list"],"function":"def search_project(self):\n \"\"\"\n Search related projects with recently indexed sort according to keyword\n :returns: Related projects list\n \"\"\"\n unique_project_list = []\n self.__auto_login(USER_NAME, PASSWORD)\n info_print('[@_@] Searching projects hard...')\n\n # Get unique project list of first page searched results\n total_progress = SCAN_DEEP[SEARCH_LEVEL - 1]\n query_string = self.keyword + \" -language:\" + \" -language:\".join(LANG_BLACKLIST)\n for i in xrange(total_progress):\n # Print process of searching project\n progress_point = int((i + 1) * (100 \/ total_progress))\n sys.stdout.write(str(progress_point) + '%|' + '#' * progress_point + '|\\r')\n sys.stdout.flush()\n # Search project in each page\n code_url = self.search_url.format(page=1, keyword=quote(query_string))\n page_html_parse = self.__get_page_html(code_url)\n project_list = self.__page_project_list(page_html_parse) # Project list of per result page\n page_project_num, project_list = len(project_list), list(set(project_list))\n unique_project_list.extend(project_list) # Extend unique project list of per page\n if page_project_num < MAX_RLT_PER_PAGE:\n break\n project = \" -repo:\" + \" -repo:\".join(project_list)\n query_string += project\n # Deal with last progress bar stdout\n sys.stdout.write('100%|' + '#' * 100 + '|\\r')\n sys.stdout.flush()\n return unique_project_list","function_tokens":["def","search_project","(","self",")",":","unique_project_list","=","[","]","self",".","__auto_login","(","USER_NAME",",","PASSWORD",")","info_print","(","'[@_@] Searching projects hard...'",")","# Get unique project list of first page searched results","total_progress","=","SCAN_DEEP","[","SEARCH_LEVEL","-","1","]","query_string","=","self",".","keyword","+","\" -language:\"","+","\" -language:\"",".","join","(","LANG_BLACKLIST",")","for","i","in","xrange","(","total_progress",")",":","# Print process of searching project","progress_point","=","int","(","(","i","+","1",")","*","(","100","\/","total_progress",")",")","sys",".","stdout",".","write","(","str","(","progress_point",")","+","'%|'","+","'#'","*","progress_point","+","'|\\r'",")","sys",".","stdout",".","flush","(",")","# Search project in each page","code_url","=","self",".","search_url",".","format","(","page","=","1",",","keyword","=","quote","(","query_string",")",")","page_html_parse","=","self",".","__get_page_html","(","code_url",")","project_list","=","self",".","__page_project_list","(","page_html_parse",")","# Project list of per result page","page_project_num",",","project_list","=","len","(","project_list",")",",","list","(","set","(","project_list",")",")","unique_project_list",".","extend","(","project_list",")","# Extend unique project list of per page","if","page_project_num","<","MAX_RLT_PER_PAGE",":","break","project","=","\" -repo:\"","+","\" -repo:\"",".","join","(","project_list",")","query_string","+=","project","# Deal with last progress bar stdout","sys",".","stdout",".","write","(","'100%|'","+","'#'","*","100","+","'|\\r'",")","sys",".","stdout",".","flush","(",")","return","unique_project_list"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L68-L98"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__page_project_list","parameters":"(page_html)","argument_list":"","return_statement":"return page_project","docstring":"Get project list of one searching result page\n :param page_html: Html page content\n :returns: Project list of per page","docstring_summary":"Get project list of one searching result page\n :param page_html: Html page content\n :returns: Project list of per page","docstring_tokens":["Get","project","list","of","one","searching","result","page",":","param","page_html",":","Html","page","content",":","returns",":","Project","list","of","per","page"],"function":"def __page_project_list(page_html):\n \"\"\"\n Get project list of one searching result page\n :param page_html: Html page content\n :returns: Project list of per page\n \"\"\"\n cur_par_html = BeautifulSoup(page_html, \"lxml\")\n project_info = cur_par_html.select(\"a.text-bold\")\n page_project = [project.text for project in project_info if not project.text.endswith('.github.io') and not len([i for i in REPO_NAME_BLACKLIST if i in project.text.lower()])]\n return page_project","function_tokens":["def","__page_project_list","(","page_html",")",":","cur_par_html","=","BeautifulSoup","(","page_html",",","\"lxml\"",")","project_info","=","cur_par_html",".","select","(","\"a.text-bold\"",")","page_project","=","[","project",".","text","for","project","in","project_info","if","not","project",".","text",".","endswith","(","'.github.io'",")","and","not","len","(","[","i","for","i","in","REPO_NAME_BLACKLIST","if","i","in","project",".","text",".","lower","(",")","]",")","]","return","page_project"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L101-L110"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.sensitive_info_query","parameters":"(self, project_string)","argument_list":"","return_statement":"return code_dic","docstring":"Search sensitive information and sensitive file from projects\n :param project_string: Key words string for querying\n :returns: None","docstring_summary":"Search sensitive information and sensitive file from projects\n :param project_string: Key words string for querying\n :returns: None","docstring_tokens":["Search","sensitive","information","and","sensitive","file","from","projects",":","param","project_string",":","Key","words","string","for","querying",":","returns",":","None"],"function":"def sensitive_info_query(self, project_string):\n \"\"\"\n Search sensitive information and sensitive file from projects\n :param project_string: Key words string for querying\n :returns: None\n \"\"\"\n # Output code line with sensitive key words like username.\n info_sig_list = self.__pattern_db_list(INFO_DB)\n file_sig_list = self.__pattern_db_list(FILE_DB)\n file_pattern = \" filename:\" + \" filename:\".join(file_sig_list)\n code_dic = {}\n # Most five AND\/OR operators in search function.\n for i in xrange(len(info_sig_list)\/MAX_INFONUM+1):\n project_pattern = info_sig_list[i*MAX_INFONUM:i*MAX_INFONUM+MAX_INFONUM]\n\n if len(project_pattern) == 0: break\n\n repo_code_dic = self.__file_content_inspect(project_string, file_pattern, project_pattern)\n code_dic.update(repo_code_dic)\n return code_dic","function_tokens":["def","sensitive_info_query","(","self",",","project_string",")",":","# Output code line with sensitive key words like username.","info_sig_list","=","self",".","__pattern_db_list","(","INFO_DB",")","file_sig_list","=","self",".","__pattern_db_list","(","FILE_DB",")","file_pattern","=","\" filename:\"","+","\" filename:\"",".","join","(","file_sig_list",")","code_dic","=","{","}","# Most five AND\/OR operators in search function.","for","i","in","xrange","(","len","(","info_sig_list",")","\/","MAX_INFONUM","+","1",")",":","project_pattern","=","info_sig_list","[","i","*","MAX_INFONUM",":","i","*","MAX_INFONUM","+","MAX_INFONUM","]","if","len","(","project_pattern",")","==","0",":","break","repo_code_dic","=","self",".","__file_content_inspect","(","project_string",",","file_pattern",",","project_pattern",")","code_dic",".","update","(","repo_code_dic",")","return","code_dic"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L112-L131"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__file_content_inspect","parameters":"(self, project_string, file_pattern, project_pattern)","argument_list":"","return_statement":"return repo_code_dic","docstring":"Check sensitive code in particular project\n :param content_query_string: Content string for searching\n :param info_sig_match: information signature match regular\n :returns: None","docstring_summary":"Check sensitive code in particular project\n :param content_query_string: Content string for searching\n :param info_sig_match: information signature match regular\n :returns: None","docstring_tokens":["Check","sensitive","code","in","particular","project",":","param","content_query_string",":","Content","string","for","searching",":","param","info_sig_match",":","information","signature","match","regular",":","returns",":","None"],"function":"def __file_content_inspect(self, project_string, file_pattern, project_pattern):\n \"\"\"\n Check sensitive code in particular project\n :param content_query_string: Content string for searching\n :param info_sig_match: information signature match regular\n :returns: None\n \"\"\"\n if not project_pattern: return {}\n query_string = \" OR \".join(project_pattern)\n repo_file_dic = self.__file_name_inspect(query_string + project_string + file_pattern)\n repo_code_dic = {}\n for repo_name in repo_file_dic:\n self.__output_project_info(repo_name)\n repo_code_dic[repo_name] = {} # Set code line dictionary\n for file_url in repo_file_dic[repo_name]:\n file_url_output = \"[-] Compromise File: {file_url}\"\n file_print(file_url_output.format(file_url=file_url))\n repo_code_dic[repo_name][file_url] = [] # Set code block of project file\n # Read codes from raw file by replace host to raw host.\n code_file = self.__get_page_html(file_url.replace(HOST_NAME, RAW_NAME).replace('blob\/', ''))\n for code_line in code_file.split('\\n'):\n if len(repo_code_dic[repo_name][file_url]) > MAX_COUNT_SINGLE_FILE: break\n line_check = [i for i in LINE_MUSTHAVE if i in code_line]\n if not line_check: continue\n account_code = re.search('|'.join(project_pattern), code_line, re.I)\n if account_code:\n code = code_line.encode('utf-8').strip()\n if len(code) > MAX_LINELEN: continue\n code_print(code)\n repo_code_dic[repo_name][file_url].append(code)\n else:\n continue\n if len(repo_code_dic[repo_name][file_url]) > MAX_COUNT_SINGLE_FILE or not repo_code_dic[repo_name][file_url]:\n del repo_code_dic[repo_name][file_url]\n\n return repo_code_dic","function_tokens":["def","__file_content_inspect","(","self",",","project_string",",","file_pattern",",","project_pattern",")",":","if","not","project_pattern",":","return","{","}","query_string","=","\" OR \"",".","join","(","project_pattern",")","repo_file_dic","=","self",".","__file_name_inspect","(","query_string","+","project_string","+","file_pattern",")","repo_code_dic","=","{","}","for","repo_name","in","repo_file_dic",":","self",".","__output_project_info","(","repo_name",")","repo_code_dic","[","repo_name","]","=","{","}","# Set code line dictionary","for","file_url","in","repo_file_dic","[","repo_name","]",":","file_url_output","=","\"[-] Compromise File: {file_url}\"","file_print","(","file_url_output",".","format","(","file_url","=","file_url",")",")","repo_code_dic","[","repo_name","]","[","file_url","]","=","[","]","# Set code block of project file","# Read codes from raw file by replace host to raw host.","code_file","=","self",".","__get_page_html","(","file_url",".","replace","(","HOST_NAME",",","RAW_NAME",")",".","replace","(","'blob\/'",",","''",")",")","for","code_line","in","code_file",".","split","(","'\\n'",")",":","if","len","(","repo_code_dic","[","repo_name","]","[","file_url","]",")",">","MAX_COUNT_SINGLE_FILE",":","break","line_check","=","[","i","for","i","in","LINE_MUSTHAVE","if","i","in","code_line","]","if","not","line_check",":","continue","account_code","=","re",".","search","(","'|'",".","join","(","project_pattern",")",",","code_line",",","re",".","I",")","if","account_code",":","code","=","code_line",".","encode","(","'utf-8'",")",".","strip","(",")","if","len","(","code",")",">","MAX_LINELEN",":","continue","code_print","(","code",")","repo_code_dic","[","repo_name","]","[","file_url","]",".","append","(","code",")","else",":","continue","if","len","(","repo_code_dic","[","repo_name","]","[","file_url","]",")",">","MAX_COUNT_SINGLE_FILE","or","not","repo_code_dic","[","repo_name","]","[","file_url","]",":","del","repo_code_dic","[","repo_name","]","[","file_url","]","return","repo_code_dic"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L133-L168"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__file_name_inspect","parameters":"(self, file_query_string, print_mode=0)","argument_list":"","return_statement":"return repo_file_dic","docstring":"Inspect sensitive file in particular project\n :param file_query_string: File string for searching\n :returns: None","docstring_summary":"Inspect sensitive file in particular project\n :param file_query_string: File string for searching\n :returns: None","docstring_tokens":["Inspect","sensitive","file","in","particular","project",":","param","file_query_string",":","File","string","for","searching",":","returns",":","None"],"function":"def __file_name_inspect(self, file_query_string, print_mode=0):\n \"\"\"\n Inspect sensitive file in particular project\n :param file_query_string: File string for searching\n :returns: None\n \"\"\"\n page_num = 1\n repo_file_dic = {}\n while page_num <= SCAN_DEEP[SEARCH_LEVEL - 1]:\n check_url = self.search_url.format(page=page_num, keyword=quote(file_query_string))\n page_html = self.__get_page_html(check_url)\n project_html = BeautifulSoup(page_html, 'lxml')\n repo_list = project_html.select('div .d-inline-block.col-10 > a:nth-of-type(2)')\n if not repo_list:\n break\n # Handle file links for each project\n for repo in repo_list:\n file_url = repo.attrs['href']\n cur_project_name = \"\/\".join(file_url.split(\"\/\")[1:3])\n if cur_project_name not in repo_file_dic.keys():\n if print_mode:\n self.__output_project_info(cur_project_name)\n file_print(\"[-] Compromise File:\")\n repo_file_dic[cur_project_name] = [] # Set compromise project item\n if os.path.splitext(file_url)[1].lower() not in EXT_BLACKLIST:\n repo_file_dic[cur_project_name].append(HOST_NAME + file_url[1:]) # Set compromise project file item\n if print_mode:\n file_print(HOST_NAME + file_url[1:])\n page_num += 1\n\n return repo_file_dic","function_tokens":["def","__file_name_inspect","(","self",",","file_query_string",",","print_mode","=","0",")",":","page_num","=","1","repo_file_dic","=","{","}","while","page_num","<=","SCAN_DEEP","[","SEARCH_LEVEL","-","1","]",":","check_url","=","self",".","search_url",".","format","(","page","=","page_num",",","keyword","=","quote","(","file_query_string",")",")","page_html","=","self",".","__get_page_html","(","check_url",")","project_html","=","BeautifulSoup","(","page_html",",","'lxml'",")","repo_list","=","project_html",".","select","(","'div .d-inline-block.col-10 > a:nth-of-type(2)'",")","if","not","repo_list",":","break","# Handle file links for each project","for","repo","in","repo_list",":","file_url","=","repo",".","attrs","[","'href'","]","cur_project_name","=","\"\/\"",".","join","(","file_url",".","split","(","\"\/\"",")","[","1",":","3","]",")","if","cur_project_name","not","in","repo_file_dic",".","keys","(",")",":","if","print_mode",":","self",".","__output_project_info","(","cur_project_name",")","file_print","(","\"[-] Compromise File:\"",")","repo_file_dic","[","cur_project_name","]","=","[","]","# Set compromise project item","if","os",".","path",".","splitext","(","file_url",")","[","1","]",".","lower","(",")","not","in","EXT_BLACKLIST",":","repo_file_dic","[","cur_project_name","]",".","append","(","HOST_NAME","+","file_url","[","1",":","]",")","# Set compromise project file item","if","print_mode",":","file_print","(","HOST_NAME","+","file_url","[","1",":","]",")","page_num","+=","1","return","repo_file_dic"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L170-L200"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__pattern_db_list","parameters":"(file_path)","argument_list":"","return_statement":"return item_list","docstring":"Read file name pattern item from signature file\n :param file_path: Pattern file path\n :returns: Signature item list","docstring_summary":"Read file name pattern item from signature file\n :param file_path: Pattern file path\n :returns: Signature item list","docstring_tokens":["Read","file","name","pattern","item","from","signature","file",":","param","file_path",":","Pattern","file","path",":","returns",":","Signature","item","list"],"function":"def __pattern_db_list(file_path):\n \"\"\"\n Read file name pattern item from signature file\n :param file_path: Pattern file path\n :returns: Signature item list\n \"\"\"\n item_list = []\n with open(file_path, 'r') as pattern_file:\n item_line = pattern_file.readline()\n while item_line:\n item_list.append(item_line.strip())\n item_line = pattern_file.readline()\n return item_list","function_tokens":["def","__pattern_db_list","(","file_path",")",":","item_list","=","[","]","with","open","(","file_path",",","'r'",")","as","pattern_file",":","item_line","=","pattern_file",".","readline","(",")","while","item_line",":","item_list",".","append","(","item_line",".","strip","(",")",")","item_line","=","pattern_file",".","readline","(",")","return","item_list"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L203-L215"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__output_project_info","parameters":"(project)","argument_list":"","return_statement":"","docstring":"Output user information and project information of particular project\n :returns: None","docstring_summary":"Output user information and project information of particular project\n :returns: None","docstring_tokens":["Output","user","information","and","project","information","of","particular","project",":","returns",":","None"],"function":"def __output_project_info(project):\n \"\"\"\n Output user information and project information of particular project\n :returns: None\n \"\"\"\n user_name, project_name = project.split(r\"\/\")\n user_info = \"[+_+] User Nickname: {nickname}\"\n project_print(user_info.format(nickname=user_name))\n project_info = \"[+_+] Project Name: {name}\"\n project_print(project_info.format(name=project_name))\n project_info = \"[+_+] Project Link: {link}\"\n project_print(project_info.format(link=HOST_NAME + project))","function_tokens":["def","__output_project_info","(","project",")",":","user_name",",","project_name","=","project",".","split","(","r\"\/\"",")","user_info","=","\"[+_+] User Nickname: {nickname}\"","project_print","(","user_info",".","format","(","nickname","=","user_name",")",")","project_info","=","\"[+_+] Project Name: {name}\"","project_print","(","project_info",".","format","(","name","=","project_name",")",")","project_info","=","\"[+_+] Project Link: {link}\"","project_print","(","project_info",".","format","(","link","=","HOST_NAME","+","project",")",")"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L218-L229"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__auto_login","parameters":"(self, username, password)","argument_list":"","return_statement":"","docstring":"Get cookie for logining GitHub\n :returns: None","docstring_summary":"Get cookie for logining GitHub\n :returns: None","docstring_tokens":["Get","cookie","for","logining","GitHub",":","returns",":","None"],"function":"def __auto_login(self, username, password):\n \"\"\"\n Get cookie for logining GitHub\n :returns: None\n \"\"\"\n login_request = requests.Session()\n login_html = login_request.get(\"https:\/\/github.com\/login\", headers=self.headers)\n post_data = {}\n soup = BeautifulSoup(login_html.text, \"lxml\")\n input_items = soup.find_all('input')\n for item in input_items:\n post_data[item.get('name')] = item.get('value')\n post_data['login'], post_data['password'] = username, password\n login_request.post(\"https:\/\/github.com\/session\", data=post_data, headers=self.headers)\n self.cookies = login_request.cookies\n if self.cookies['logged_in'] == 'no':\n error_print('[!_!] ERROR INFO: Login Github failed, please check account in config file.')\n exit()","function_tokens":["def","__auto_login","(","self",",","username",",","password",")",":","login_request","=","requests",".","Session","(",")","login_html","=","login_request",".","get","(","\"https:\/\/github.com\/login\"",",","headers","=","self",".","headers",")","post_data","=","{","}","soup","=","BeautifulSoup","(","login_html",".","text",",","\"lxml\"",")","input_items","=","soup",".","find_all","(","'input'",")","for","item","in","input_items",":","post_data","[","item",".","get","(","'name'",")","]","=","item",".","get","(","'value'",")","post_data","[","'login'","]",",","post_data","[","'password'","]","=","username",",","password","login_request",".","post","(","\"https:\/\/github.com\/session\"",",","data","=","post_data",",","headers","=","self",".","headers",")","self",".","cookies","=","login_request",".","cookies","if","self",".","cookies","[","'logged_in'","]","==","'no'",":","error_print","(","'[!_!] ERROR INFO: Login Github failed, please check account in config file.'",")","exit","(",")"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L231-L248"}
{"nwo":"5alt\/GitLeak","sha":"43c64199a3c09c6357085e6acae9a2f38fea4d37","path":"GitLeak.py","language":"python","identifier":"GitPrey.__get_page_html","parameters":"(self, url)","argument_list":"","return_statement":"","docstring":"Get parse html page from requesting url\n :param url: Requesting url\n :returns: Parsed html page","docstring_summary":"Get parse html page from requesting url\n :param url: Requesting url\n :returns: Parsed html page","docstring_tokens":["Get","parse","html","page","from","requesting","url",":","param","url",":","Requesting","url",":","returns",":","Parsed","html","page"],"function":"def __get_page_html(self, url):\n \"\"\"\n Get parse html page from requesting url\n :param url: Requesting url\n :returns: Parsed html page\n \"\"\"\n try:\n page_html = requests.get(url, headers=self.headers, cookies=self.cookies, timeout=SCAN_DEEP[SEARCH_LEVEL - 1])\n if page_html.status_code == 429:\n time.sleep(SCAN_DEEP[SEARCH_LEVEL - 1])\n self.__get_page_html(url)\n return page_html.text\n except requests.ConnectionError, e:\n error_print(\"[!_!] ERROR INFO: There is '%s' problem in requesting html page.\" % str(e))\n exit()\n except requests.ReadTimeout:\n return ''","function_tokens":["def","__get_page_html","(","self",",","url",")",":","try",":","page_html","=","requests",".","get","(","url",",","headers","=","self",".","headers",",","cookies","=","self",".","cookies",",","timeout","=","SCAN_DEEP","[","SEARCH_LEVEL","-","1","]",")","if","page_html",".","status_code","==","429",":","time",".","sleep","(","SCAN_DEEP","[","SEARCH_LEVEL","-","1","]",")","self",".","__get_page_html","(","url",")","return","page_html",".","text","except","requests",".","ConnectionError",",","e",":","error_print","(","\"[!_!] ERROR INFO: There is '%s' problem in requesting html page.\"","%","str","(","e",")",")","exit","(",")","except","requests",".","ReadTimeout",":","return","''"],"url":"https:\/\/github.com\/5alt\/GitLeak\/blob\/43c64199a3c09c6357085e6acae9a2f38fea4d37\/GitLeak.py#L250-L266"}