diff --git a/domain_pastes.py b/domain_pastes.py index e157dc1f..e4b2d3fa 100755 --- a/domain_pastes.py +++ b/domain_pastes.py @@ -33,6 +33,7 @@ def google_search(domain,start_index): url="https://www.googleapis.com/customsearch/v1?key=%s&cx=%s&q=\"%s\"&start=%s" % (cfg.google_cse_key, cfg.google_cse_cx, domain, start_index) res=requests.get(url) results = json.loads(res.text) + #print(results) if 'items' in results.keys(): if start_index == 1: print "[+] %s results found\n" % int(results['searchInformation']['totalResults']) @@ -40,11 +41,11 @@ def google_search(domain,start_index): print "Title: %s\nURL: %s\nSnippet: %s\n" % (x['title'], colorize(x['link']), colorize(x['snippet'])) start_index = +1 return int(results['searchInformation']['totalResults']) - elif results['searchInformation']['totalResults'] == "0": + elif 'searchInformation' in results.keys() and 'totalResults' in results["searchInformation"].keys() and results['searchInformation']['totalResults'] == "0": print '0 Results found' return 0 elif results['error']['code'] == 403: - print 'Rate limit Exceeded' + print results['error']["message"] return 0 else: return 0 @@ -54,7 +55,7 @@ def google_search(domain,start_index): def main(): domain = sys.argv[1] print colored(style.BOLD + '\n---> Finding Paste(s)..\n' + style.END, 'blue') - if cfg.google_cse_key != "" and cfg.google_cse_key != "XYZ" and cfg.google_cse_cx != "" and cfg.google_cse_cx != "XYZ": + if cfg.google_cse_key and cfg.google_cse_key != "XYZ" and cfg.google_cse_cx and cfg.google_cse_cx != "XYZ": total_results = google_search(domain, 1) if (total_results != 0 and total_results > 10): more_iters = (total_results / 10)