2018-12-30 10:29:25 +08:00
|
|
|
<<<<<<< HEAD
|
2018-11-21 01:04:57 +08:00
|
|
|
import sys
|
|
|
|
import myparser
|
|
|
|
import time
|
|
|
|
import requests
|
2018-12-18 13:21:05 +08:00
|
|
|
from discovery.constants import *
|
2018-11-21 01:04:57 +08:00
|
|
|
|
|
|
|
class search_bing:
|
|
|
|
|
|
|
|
def __init__(self, word, limit, start):
|
|
|
|
self.word = word.replace(' ', '%20')
|
|
|
|
self.results = ""
|
|
|
|
self.totalresults = ""
|
|
|
|
self.server = "www.bing.com"
|
|
|
|
self.apiserver = "api.search.live.net"
|
|
|
|
self.hostname = "www.bing.com"
|
|
|
|
self.quantity = "50"
|
|
|
|
self.limit = int(limit)
|
2018-12-30 02:14:40 +08:00
|
|
|
self.bingApi = b
|
2018-11-21 01:04:57 +08:00
|
|
|
self.counter = start
|
|
|
|
|
|
|
|
def do_search(self):
|
|
|
|
headers = {
|
|
|
|
'Host': self.hostname,
|
|
|
|
'Cookie':'SRCHHPGUSR=ADLT=DEMOTE&NRSLT=50',
|
|
|
|
'Accept-Language': 'en-us,en',
|
2018-12-18 13:21:05 +08:00
|
|
|
'User-agent': getUserAgent()
|
2018-11-21 01:04:57 +08:00
|
|
|
}
|
|
|
|
h = requests.get(url=('http://'+self.server + "/search?q=%40" + self.word + "&count=50&first=" + str(self.counter)),headers=headers)
|
|
|
|
self.results = h.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def do_search_api(self):
|
2018-12-24 11:54:28 +08:00
|
|
|
url = 'https://api.cognitive.microsoft.com/bing/v7.0/search?'
|
|
|
|
params = {
|
|
|
|
'q': self.word,
|
|
|
|
'count': str(self.limit),
|
|
|
|
'offset': '0',
|
|
|
|
'mkt': 'en-us',
|
|
|
|
'safesearch': 'Off'
|
2018-11-21 01:04:57 +08:00
|
|
|
}
|
2018-12-24 12:10:34 +08:00
|
|
|
headers = {'User-Agent': getUserAgent(), 'Ocp-Apim-Subscription-Key': self.bingApi}
|
2018-12-24 11:54:28 +08:00
|
|
|
h = requests.get(url=url, headers=headers, params=params)
|
2018-11-21 01:04:57 +08:00
|
|
|
self.results = h.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def do_search_vhost(self):
|
|
|
|
headers = {
|
|
|
|
'Host': self.hostname,
|
|
|
|
'Cookie': 'mkt=en-US;ui=en-US;SRCHHPGUSR=NEWWND=0&ADLT=DEMOTE&NRSLT=50',
|
|
|
|
'Accept-Language': 'en-us,en',
|
2018-12-18 13:21:05 +08:00
|
|
|
'User-agent': getUserAgent()
|
2018-11-21 01:04:57 +08:00
|
|
|
}
|
|
|
|
url = 'http://' + self.server + "/search?q=ip:" + self.word + "&go=&count=50&FORM=QBHL&qs=n&first=" + str(self.counter)
|
|
|
|
h = requests.get(url=url, headers=headers)
|
|
|
|
self.results = h.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def get_emails(self):
|
|
|
|
rawres = myparser.parser(self.totalresults, self.word)
|
|
|
|
return rawres.emails()
|
|
|
|
|
|
|
|
def get_hostnames(self):
|
|
|
|
rawres = myparser.parser(self.totalresults, self.word)
|
|
|
|
return rawres.hostnames()
|
|
|
|
|
|
|
|
def get_allhostnames(self):
|
|
|
|
rawres = myparser.parser(self.totalresults, self.word)
|
|
|
|
return rawres.hostnames_all()
|
|
|
|
|
|
|
|
def process(self, api):
|
|
|
|
if api == "yes":
|
|
|
|
if self.bingApi == "":
|
2018-12-24 04:23:01 +08:00
|
|
|
raise MissingKey(True)
|
2018-11-21 01:04:57 +08:00
|
|
|
while (self.counter < self.limit):
|
|
|
|
if api == "yes":
|
|
|
|
self.do_search_api()
|
2018-12-18 13:21:05 +08:00
|
|
|
time.sleep(getDelay())
|
2018-11-21 01:04:57 +08:00
|
|
|
else:
|
|
|
|
self.do_search()
|
2018-12-18 13:21:05 +08:00
|
|
|
time.sleep(getDelay())
|
2018-11-21 01:04:57 +08:00
|
|
|
self.counter += 50
|
|
|
|
print("\tSearching " + str(self.counter) + " results...")
|
|
|
|
|
|
|
|
def process_vhost(self):
|
|
|
|
# Maybe it is good to use other limit for this.
|
|
|
|
while (self.counter < self.limit):
|
|
|
|
self.do_search_vhost()
|
|
|
|
self.counter += 50
|
2018-12-30 10:29:25 +08:00
|
|
|
=======
|
|
|
|
from parsers import myparser
|
|
|
|
import time
|
|
|
|
import requests
|
|
|
|
from discovery.constants import *
|
|
|
|
|
|
|
|
|
|
|
|
class search_bing:
|
|
|
|
|
|
|
|
def __init__(self, word, limit, start):
|
|
|
|
self.word = word.replace(' ', '%20')
|
|
|
|
self.results = ""
|
|
|
|
self.totalresults = ""
|
|
|
|
self.server = "www.bing.com"
|
|
|
|
self.apiserver = "api.search.live.net"
|
|
|
|
self.hostname = "www.bing.com"
|
|
|
|
self.quantity = "50"
|
|
|
|
self.limit = int(limit)
|
|
|
|
self.bingApi = bingAPI_key
|
|
|
|
self.counter = start
|
|
|
|
|
|
|
|
def do_search(self):
|
|
|
|
headers = {
|
|
|
|
'Host': self.hostname,
|
|
|
|
'Cookie':'SRCHHPGUSR=ADLT=DEMOTE&NRSLT=50',
|
|
|
|
'Accept-Language': 'en-us,en',
|
|
|
|
'User-agent': getUserAgent()
|
|
|
|
}
|
|
|
|
h = requests.get(url=('http://'+self.server + "/search?q=%40" + self.word + "&count=50&first=" + str(self.counter)),headers=headers)
|
|
|
|
self.results = h.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def do_search_api(self):
|
|
|
|
url = 'https://api.cognitive.microsoft.com/bing/v7.0/search?'
|
|
|
|
params = {
|
|
|
|
'q': self.word,
|
|
|
|
'count': str(self.limit),
|
|
|
|
'offset': '0',
|
|
|
|
'mkt': 'en-us',
|
|
|
|
'safesearch': 'Off'
|
|
|
|
}
|
|
|
|
headers = {'User-Agent': getUserAgent(), 'Ocp-Apim-Subscription-Key': self.bingApi}
|
|
|
|
h = requests.get(url=url, headers=headers, params=params)
|
|
|
|
self.results = h.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def do_search_vhost(self):
|
|
|
|
headers = {
|
|
|
|
'Host': self.hostname,
|
|
|
|
'Cookie': 'mkt=en-US;ui=en-US;SRCHHPGUSR=NEWWND=0&ADLT=DEMOTE&NRSLT=50',
|
|
|
|
'Accept-Language': 'en-us,en',
|
|
|
|
'User-agent': getUserAgent()
|
|
|
|
}
|
|
|
|
url = 'http://' + self.server + "/search?q=ip:" + self.word + "&go=&count=50&FORM=QBHL&qs=n&first=" + str(self.counter)
|
|
|
|
h = requests.get(url=url, headers=headers)
|
|
|
|
self.results = h.text
|
|
|
|
self.totalresults += self.results
|
|
|
|
|
|
|
|
def get_emails(self):
|
|
|
|
rawres = myparser.parser(self.totalresults, self.word)
|
|
|
|
return rawres.emails()
|
|
|
|
|
|
|
|
def get_hostnames(self):
|
|
|
|
rawres = myparser.parser(self.totalresults, self.word)
|
|
|
|
return rawres.hostnames()
|
|
|
|
|
|
|
|
def get_allhostnames(self):
|
|
|
|
rawres = myparser.parser(self.totalresults, self.word)
|
|
|
|
return rawres.hostnames_all()
|
|
|
|
|
|
|
|
def process(self, api):
|
|
|
|
if api == "yes":
|
|
|
|
if self.bingApi == "":
|
|
|
|
raise MissingKey(True)
|
|
|
|
while self.counter < self.limit:
|
|
|
|
if api == "yes":
|
|
|
|
self.do_search_api()
|
|
|
|
time.sleep(getDelay())
|
|
|
|
else:
|
|
|
|
self.do_search()
|
|
|
|
time.sleep(getDelay())
|
|
|
|
self.counter += 50
|
|
|
|
print("\tSearching " + str(self.counter) + " results...")
|
|
|
|
|
|
|
|
def process_vhost(self):
|
|
|
|
# Maybe it is good to use other limit for this.
|
|
|
|
while self.counter < self.limit:
|
|
|
|
self.do_search_vhost()
|
|
|
|
self.counter += 50
|
|
|
|
>>>>>>> de773b8c23299397a00230e80c0c4fccb92dccc6
|