I have a program that generates random ips and grabs banners but when i run python3 main.py :80/
there's no output.
main.py
import ipaddress, concurrent.futures, requests, sys, random
def ipv4():
for _ in range(10000):
ip = (ipaddress.IPv4Address(random.randint(0,2 ** 32)))
IP_list = []
IP_list.append(str(ip).strip('\n'))
return IP_list
def scan(IP):
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'}
r = requests.get('http://' + IP + sys.argv[1], headers=headers, timeout=0.5)
print(r.url, r.status_code, r.headers['Server'])
ipv4_list = ipv4()
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
executor.map(scan, ipv4_list)
test.py
import ipaddress
import random
def ipv4():
for _ in range(1000):
ip = (ipaddress.IPv4Address(random.randint(0,2 ** 32)))
IP_list = []
IP_list.append(str(ip).strip('\n'))
print(IP_list)
ipv4()
I've checked the output of ipv4()
function and the problem seems to be that it encloses ips in brackets and apostrophes. I also looked at this SO question for IP_list.append(str(ip).strip('\n'))
, but it doesn't seem to work.