<commit_before>#!/usr/bin/env python

import requests, time
from google import search
from lxml import html


# this could be GREATLY improved. need to implement the custom search api
# GHDB password dorks https://www.exploit-db.com/google-hacking-database/9/
# GHDB sensitive dirs https://www.exploit-db.com/google-hacking-database/3/
# uses this awesome module https://pypi.python.org/pypi/google
# https://stackoverflow.com/questions/4082966/what-are-the-alternatives-now-that-the-google-web-search-api-has-been-deprecated/11206266#11206266

class Googledork():

	def run(self, args, lookup, reportDir):
		#need a default dork list

		#C58EA28C-18C0-4a97-9AF2-036E93DDAFB3 is string for open OWA attachments
		#init lists
		googleResult = []

		#if no args provided, default to 'password'. need an inner function?
		if args.googledork is None:
			print '[i] No dork args, defaulting to "password"'
			args.googledork = ['password']

		else:

			for d in args.googledork:
				if args.verbose is True:print '[+] Google dorking for: %s' % d
				
				#default to password if no arg

				#iterate the lookup list
				for i, l in enumerate(lookup):
					googleResult.append('Google query for: '+str(d)+ ' ' + 'site:'+str(l))
					googleFile=open(reportDir+l+'/'+l+'_google_dork_'+str(d)+'.txt','w')

					#show user whiat is being searched
					print '[+] Google query ' + str(i + 1) + ' for "'+str(d)+' ' + 'site:'+str(l) + '"'
					
					try:
						#iterate url results from search of password(for now) and site:current list value
						for url in search(str(d)+ ' ' + 'site:'+str(l), stop = 20):
							
							#append results together
							googleResult.append(url)

							#rate limit to 1 per second
							time.sleep(1)
					#catch exceptions
					except Exception:
						pass
			#iterate results
			for r in googleResult:
				#write results on newlines
				googleFile.writelines(r + '\r\n')

			#verbosity flag
			if args.verbose is True:
				for r in googleResult: print ''.join(r)
					
			#return results list
			return googleResult
		<commit_msg>fix multi dorking. parallel not serial now<commit_after>#!/usr/bin/env python

import requests, time
from google import search
from lxml import html


# this could be GREATLY improved. need to implement the custom search api
# GHDB password dorks https://www.exploit-db.com/google-hacking-database/9/
# GHDB sensitive dirs https://www.exploit-db.com/google-hacking-database/3/
# uses this awesome module https://pypi.python.org/pypi/google
# https://stackoverflow.com/questions/4082966/what-are-the-alternatives-now-that-the-google-web-search-api-has-been-deprecated/11206266#11206266

class Googledork():

	def run(self, args, lookup, reportDir):
		#need a default dork list

		#C58EA28C-18C0-4a97-9AF2-036E93DDAFB3 is string for open OWA attachments
		#init lists
		googleResult = []

		#if no args provided, default to 'password'. need an inner function?
		if args.googledork is None:
			print '[i] No dork args, defaulting to "password"'
			args.googledork = ['password']

		else:
			dorks = ' '.join(args.googledork)
			#iterate the lookup list
			for i, l in enumerate(lookup):
				googleResult.append('Google query for: '+str(dorks)+ ' ' + 'site:'+str(l))
				googleFile=open(reportDir+l+'/'+l+'_google_dork.txt','w')

				#show user whiat is being searched
				print '[+] Google query ' + str(i + 1) + ' for "'+str(dorks)+' ' + 'site:'+str(l) + '"'
				
				try:
					#iterate url results from search of password(for now) and site:current list value
					for url in search(str(dorks)+ ' ' + 'site:'+str(l), stop = 20):
						
						#append results together
						googleResult.append(url)

						#rate limit to 1 per second
						time.sleep(1)
				#catch exceptions
				except Exception:
					pass
		#iterate results
		for r in googleResult:
			#write results on newlines
			googleFile.writelines(r + '\r\n')

		#verbosity flag
		if args.verbose is True:
			for r in googleResult: print ''.join(r)
				
		#return results list
		return googleResult
	
{'fraction_non_alphanumeric': 0.12188434695912263, 'fraction_numerical': 0.023928215353938187, 'mean_word_length': 3.3477789815817984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '771750', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1301, 'n_words': 389}