Skip to content

Instantly share code, notes, and snippets.

@theseanco
Created December 21, 2015 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theseanco/abda7b1a5c4605c04087 to your computer and use it in GitHub Desktop.
Save theseanco/abda7b1a5c4605c04087 to your computer and use it in GitHub Desktop.
Random Whois - Part 1 of HSS project to grab data from random
# a sample program to use ipwhois to dump info about a random IP address
# in order to use this you will need to install ipwhois using pip
import random
from ipwhois import IPWhois
from pprint import pprint
# getting four random numbers for the ipv4 address. Casting them as strings
r1 = str(random.randrange(255))
r2 = str(random.randrange(255))
r3 = str(random.randrange(255))
r4 = str(random.randrange(255))
# a way to join the four numbers as an ipv4 string
objseq = (r1, r2, r3, r4)
sep = "."
#joining the string and analysing it with ipwhois
obj = IPWhois(sep.join(objseq))
results = obj.lookup()
print results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment