def _handle_action_set_nick(self, nick): '''handle e3.Action.ACTION_SET_NICK ''' contact = self.session.contacts.me message = contact.message account = e3.Logger.Account.from_contact(contact) account.nick = nick Requester.ChangeNick(self.session, nick, account, self.command_queue).start() Requester.SetProfile(self.session, nick, message).start()
def fetch(self, mutex, param): while (len(self.urls) > 0): mutex.acquire() if(len(self.urls) > 0): url = self.urls.pop(0) mutex.release() print('scanning..' + url) if re.match(r".+/", url): urlBase = re.findall(r".+/", url)[0] else: urlBase = url + '/' try: html = Requester.fetch(url) if(html): results = re.findall('(?isu)(\d+\.\d+\.\d+\.\d+)\D+(\d+)', html) if len(results) > 0: mutex.acquire() self.ips += results print("当前获取到的IP数量: " + str(len(self.ips))) mutex.release() urls_1 = self.find_urls(html) urls_2= [] for r in urls_1: if re.match(r"^[^http]", r): r = urlBase + r urls_2.append(r) mutex.acquire() self.searched_url += urls_2 mutex.release() except Exception as e: if(self.config['debug']): print(e)
def update_database_registers(): args = request.args result = Requester.update_database_registers(args.get('username'), args.get('password')) response = jsonify(result[0]) response.status_code = result[1] return response
def _handle_action_set_message(self, message): '''handle e3.Action.ACTION_SET_MESSAGE ''' self.socket.send_command('UUX', payload='<Data><PSM>' + \ common.escape(message) + '</PSM><CurrentMedia></CurrentMedia>' + \ '<MachineGuid></MachineGuid></Data>') e3.base.Worker._handle_action_set_message(self, message) Requester.SetProfile(self.session, contact.nick, message).start()
def _handle_action_add_to_group(self, account, gid): '''handle e3.Action.ACTION_ADD_TO_GROUP ''' contact = self.session.contacts.get(account) if contact is None: return Requester.AddToGroup(self.session, contact.identifier, contact.account, gid, self.command_queue).start()
def _handle_action_remove_contact(self, account): '''handle e3.Action.ACTION_REMOVE_CONTACT ''' contact = self.session.contacts.get(account) if contact is None: return Requester.RemoveContact(self.session, contact.identifier, account, \ self.command_queue).start()
def _handle_action_set_contact_alias(self, account, alias): '''handle e3.Action.ACTION_SET_CONTACT_ALIAS ''' contact = self.session.contacts.get(account) if contact is None: return Requester.ChangeAlias(self.session, contact.identifier, account, \ alias, self.command_queue).start()
def get_pokemon_by_page(): page = request.args.get('page') json = {'Error': 'Invalid page number'} status_code = 400 if page.isdigit(): json = Requester.get_pokemon_by_page(int(page)) status_code = 200 response = jsonify(json) response.status_code = status_code return response, headers
def _handle_action_remove_from_group(self, account, gid): '''handle e3.Action.ACTION_REMOVE_FROM_GROUP ''' contact = self.session.contacts.get(account) if contact is None: return Requester.RemoveFromGroup(self.session, contact.identifier, contact.account, gid, self.command_queue).start()
def _handle_action_move_to_group(self, account, src_gid, dest_gid): '''handle e3.Action.ACTION_MOVE_TO_GROUP ''' contact = self.session.contacts.get(account) if contact is None: return Requester.MoveContact(self.session, contact.identifier, contact.account, src_gid, dest_gid, self.command_queue).start()
def _on_login_message(self, message): '''handle server message on login''' for line in message.payload.split('\r\n'): if line: (key, value) = line.split(': ') self.session.extras[key] = value self.session.add_event(e3.Event.EVENT_LOGIN_SUCCEED) self.in_login = False self._set_status(self.session.account.status) started_from_cache = self._start_from_cache() Requester.Membership(self.session, self.command_queue, True, started_from_cache).start()
def __init__(self): """ initing the main compoment in QT """ self.back_end = Requester.Doenets() self.app = QtWidgets.QApplication(sys.argv) self.app.setStyle("Breeze") self.mainWin = QMainWindow() self.gui = Ui_MainWindow() self.text = "" self.res = {} self.tm = time.time() self.state = 0
class MissingImages: def __init__(self, mediaDirectory): self.mediaDirectory = mediaDirectory self.requester = Requester(self.mediaDirectory) self.db = SelfieDB() def __GetURLs(self): return self.db.GetAllURLs() def Get(self): existing = os.listdir(self.mediaDirectory) for i in self.__GetURLs(): if i.split("/").pop() not in existing: logging.debug("Fetching Image at URL: {}".format(i)) r = self.requester.Download(i) if r != True: try: self.db.UpdateErrorOnURL(i, r) except Exception as e: logging.debug(e)
def fetch_server(self, mutex, param): while self.curr < len(self.Proxys): try: #加锁 mutex.acquire() #获取代理服务器,更新当前节点 server_ip = self.Proxys[self.curr] #当前节点位置后移 self.curr += 1 # 打印线程名和当前处理进度 perc = (self.curr / self.total) * 100 self.currPercent = str(float( '%.f' % perc)) #释放锁 mutex.release() html = Requester.fetch(self.url, {'http':server_ip}) if(html): self.successRequest += 1 print("successRequestCount:{0}, {1}% : 请求完毕,{2}".format(self.successRequest, self.currPercent, self.url)) data = html.split(self.successPreMark) code = data[1][0] if(code == self.successMark): #加锁 mutex.acquire() self.voteCount += 1 print('[' + server_ip + '] > Request Success, Vote Success.Total Vote Count: ' + str(self.voteCount)) if self.ipFile != self.ipGreetFile: file_greet = open(self.ipGreetFile,'a',encoding="utf8") file_greet.write(server_ip + "\n") file_greet.close() #释放锁 mutex.release() else: print('Request Success, But Success Mark not Match!') except Exception as e: if(self.config['debug']): print(e) pass
def getUrls(search_string , tor,port): temp= [] url = 'https://www.google.com/search?q=' r = Requester.RequestUrl(port, search_string, tor, url) try: soup = BeautifulSoup(r.text, 'html.parser') except: return h3tags= soup.find_all( 'h3' ) if (len(h3tags)>0): for h3 in h3tags: try: pos= parse.unquote(h3.find('a').get('href').replace("/url?q=", '')).find("&sa") ut = parse.unquote(h3.find('a').get('href').replace("/url?q=", '').replace('&lang=en','')) if (ut.find('&lang=en')>-1):ut.replace('&lang=en','') if (ut.find('http://www.google.com/url?url=')>-1): ut.replace('http://www.google.com/url?url =', '') if (ut.find('&rct=j&q=&esrc=s') > -1): ut.replace('&rct=j&q=&esrc=s', '') if (pos>-1): s =0 ur ="" for ch in ut: if (s<pos):ur =ur+ch else:break s =s +1 temp.append(ur) else:temp.append(ut) except: #print("[-] there is a problem") continue return temp
def crawl (url, host): try: if host=="" : host= url req = Requester.RequestUrl('9050','','no',url.strip()) if (req.status_code!=200): return [] links = link_re.findall(req.text) url=url.strip() for l in links: exp = re.findall('/([^/]+\.(?:jpg|gif|png|pdf|css|js|zip|doc|docx|rar))', l) if (l ==url) or l in set(dirs): continue #if "http" in l : continue if (host in l ==False) :uri = urljoin(host,l) else:uri=l if uri in set(result) or len(exp) > 0: continue result.append(uri) print(uri) dirs.append(l) t = threading.Thread(target=crawl, args=(uri,host,)) threads.append(t) try: try: t.start() time.sleep(0.1) except: time.sleep(0.2) except (KeyboardInterrupt, SystemExit): print(Fore.RED, " [-] Ctrl-c received! Sending kill to threads...") for t in threads: t.kill_received = True sys.exit() except:return []
def _handle_action_unblock_contact(self, account): '''handle e3.Action.ACTION_UNBLOCK_CONTACT ''' Requester.UnblockContact(self.session, account, self.command_queue)\ .start()
def __init__(self, mediaDirectory): self.mediaDirectory = mediaDirectory self.requester = Requester(self.mediaDirectory) self.db = SelfieDB()
# Build a basic request header basicHeaders = { 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', } # Build a xml request header xmlHeaders = basicHeaders['x-requested-with'] = "XMLHttpRequest" requester = Requester.Requester(header=basicHeaders, useProxyPool=useProxyPool, useProxyFun=useProxyFun, ipPool=ipPool) xmlRequester = Requester.Requester(header=xmlHeaders, useProxyPool=useProxyPool, useProxyFun=useProxyFun, ipPool=ipPool) pool = threadpool.ThreadPool(threadNum) # Seedlist - a list of IDs r = range(4345000, 4345003) taskList = [] for id in r: url = 'https://dribbble.com/shots/%d' % id taskList.append(url)
import random import Requester def random_mac(): return "%02x:%02x:%02x:%02x:%02x:%02x" % ( random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) if __name__ == "__main__": mac = random_mac() print("START") print("SEND: Discover") Requester.send_discover(mac) print("RECEIVE: Offer") pkts = Requester.receive_offer() server_mac = pkts[0]["Ether"].src bootp_reply = pkts[0]["BOOTP"] server_ip = bootp_reply.siaddr offered_ip = bootp_reply.yiaddr print("OFFER:", offered_ip) print("SEND: Request for", offered_ip) Requester.send_request(mac, offered_ip, server_ip) print("RECEIVE: Acknowledge") pkts2 = Requester.receive_acknowledge() print("ACKNOWLEDGE:", offered_ip) print("SEND: Test IP Packet") Requester.send_test_ip(mac, offered_ip, server_mac, server_ip)
print(e) print("数据库链接失败!检查~") exit() basicHeaders = { 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'zh-CN,zh;q=0.9', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', } requester = Requester.Requester(basicHeaders, useProxy, ipPool) # 爬取二级类目列表 def crawlSecondaryUrlList(rootUrl, rootCategory): print("开始解析二级类目列表...") rootHtml = requester.sendNewRequest( rootUrl, limit=3).response.content.decode("utf-8") soup = BeautifulSoup(rootHtml, "lxml") soup.prettify() leftNavigation = soup.find('div', attrs={'role': 'region'}) if leftNavigation: secondaryUrlInfoReg = re.compile('<li><a href="(.*?)">(.*?)</a></li>') secondaryUrlInfoRegSearch = re.findall(secondaryUrlInfoReg,
def _handle_action_rename_group(self, gid, name): '''handle e3.Action.ACTION_RENAME_GROUP ''' Requester.RenameGroup(self.session, gid, name, self.command_queue).start()
def _handle_action_remove_group(self, gid): '''handle e3.Action.ACTION_REMOVE_GROUP ''' Requester.RemoveGroup(self.session, gid, self.command_queue).start()
def _handle_action_add_contact(self, account): '''handle e3.Action.ACTION_ADD_CONTACT ''' Requester.AddContact(self.session, account, self.command_queue).start()
def _handle_action_reject_contact(self, account): '''handle e3.Action.ACTION_REJECT_CONTACT ''' Requester.RemovePendingContact(self.session, account).start()
def _handle_action_add_group(self, name): '''handle e3.Action.ACTION_ADD_GROUP ''' Requester.AddGroup(self.session, name, self.command_queue).start()