salawank

whois.py

Nov 27th, 2013
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. """
  3. Whois.py via vicheck.ca
  4. Need to have pycurl installed
  5. tdr(dot)local(at)gmail(dot)com
  6. """
  7. import re
  8. import sys
  9. import pycurl
  10. import cStringIO
  11. import urllib
  12.    
  13. if len(sys.argv)<=1:
  14.         print 'Usage: whois.py <IP address | Domain name>'
  15.         sys.exit()
  16. input = sys.argv[1]
  17. response = cStringIO.StringIO()
  18. c = pycurl.Curl()
  19. c.setopt(c.POST, 1)
  20. c.setopt(c.URL, "https://www.vicheck.ca/whois.php")
  21. post_params = [('ip', input)]
  22. resp_data = urllib.urlencode(post_params)
  23. c.setopt(c.POSTFIELDS, resp_data)
  24. #c.setopt(c.HTTPPOST, data)
  25. c.setopt(c.SSL_VERIFYPEER, 0)  
  26. c.setopt(c.SSL_VERIFYHOST, 0)
  27. c.setopt(c.WRITEFUNCTION, response.write)
  28. #c.setopt(c.VERBOSE, 1)
  29. c.perform()
  30. c.close()
  31. results = response.getvalue()
  32. #result = re.findall(r'<.+?>', results)
  33. result = re.sub(r'<.+?>', '', results, flags=re.DOTALL)
  34. print '\n\n'+result[345:-450]
RAW Paste Data