[英]How can i generate random ips from 0.0.0.0/0 range
到目前為止,這是我的代碼。
import requests, sys, concurrent.futures, random
ip = ".".join(str(random.randint(0, 255)) for ip in range(4))
def scan(ip):
headers = {'user-agent': 'Keurig K575 Coffee Maker'}
r = requests.get('http://' + ip + ':80' + sys.argv[1], headers=headers, timeout=0.5)
print(r.url, r.status_code, r.headers['Server'])
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
executor.map(scan, ip)
import random
import socket
import struct
socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
這將生成范圍為0.0.0.0
~ 255.255.255.255
的隨機 IP
為了在范圍內生成,請使用for n in range(0x01020408, 0x08040201)
[這將在1.2.4.8 和 8.4.2.1范圍內生成。]
您也可以使用假 Apache 登錄,但我懷疑這對您的情況有幫助。
from faker import Faker
fakeIP = Faker()
ip_addr = fakeIP.ipv4()
ipcalc 讓你生成 IP
import ipcalc
import random
#This generates 4294967296 ips
ips = ipcalc.Network('0.0.0.0/0')
n = random.randint(1,4294967296)
#select a random ip
print(ips[n])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.