Advertisement
YeiZea

Coded by Christian Martorella

Aug 13th, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #Geoedge v0.1
  3. #Coded by laramies
  4. #Remember that maxmind allows just 25 queries per day. Don't abuse ;)
  5.  
  6. import sys
  7. import re
  8. import httplib
  9.  
  10. def banner():
  11. print "*************************************"
  12. print "*Geoedge v0.2 *"
  13. print "*Coded by Christian Martorella *"
  14. print "*[email protected] *"
  15. print "*************************************"
  16.  
  17. def usage():
  18. banner()
  19. print "\n"
  20. print "Usage:"
  21. print " python geoedge.py host/ip\n"
  22. return
  23.  
  24. if len(sys.argv) < 2:
  25. usage()
  26. sys.exit()
  27.  
  28. host=sys.argv[1]
  29. cmd=sys.argv[1]
  30.  
  31. banner()
  32. body="ips="+host
  33. print "\nSearching in Maxmind....\n"
  34. try:
  35. h = httplib.HTTP("www.maxmind.com")
  36. h.putrequest('POST',"/app/locate_ip" )
  37. h.putheader('content-type',"application/x-www-form-urlencoded")
  38. h.putheader('content-length', str(len(body)))
  39. h.endheaders()
  40. h.send(body)
  41. errcode, errmsg, headers = h.getreply()
  42. response=h.file.read()
  43.  
  44. limit=re.compile("reached.*")
  45. if limit.findall(response)!=[]:
  46. print "Limit reached in maxmind :(\n"
  47. else:
  48. res=re.compile("<td><font size=\"-1\">.*</font>")
  49. results=res.findall(response)
  50. res=[]
  51. for x in results:
  52. x=x.replace("<td><font size=\"-1\">","")
  53. x=x.replace("</font>","")
  54. res.append(x)
  55.  
  56. print "Information for "+host+ " by Maxmind"
  57. print "===========================================\n"
  58. print "IP/Host: "+host
  59. country=re.sub("<.*nk>\">","",res[1])
  60. country2=country.replace("</a>","")
  61. country=re.sub("<.*middle\" >","",country2)
  62. print "Country: " +country +","+res[2]
  63. print "City: " + res[4] +","+res[5]
  64. print "Coordinates: "+ res[7] + "," + res[8]
  65. print "Provider: "+ res[9] + "," + res[10]
  66. print "Google Maps Link: " + "http://maps.google.com/maps?q="+res[7]+", "+res[8]
  67. print "Mapquest Link: " + "http://www.mapquest.es/mq/maps/latlong.do?pageId=latlong&latLongType=decimal&txtLatitude="+res[7]+"&txtLongitude="+res[8]
  68. print "\n"
  69. except:
  70. print "Connection error...\n"
  71.  
  72. print "Searching in Geoiptool....\n"
  73. try:
  74.  
  75. h = httplib.HTTP("www.geoiptool.com")
  76. h.putrequest('GET',"/es/?IP="+host )
  77. h.putheader('Host', 'www.geoiptool.com')
  78. h.putheader('User-agent', 'Internet Explorer 6.0 ')
  79. h.endheaders()
  80. returncode, returnmsg, headers = h.getreply()
  81. response=h.file.read()
  82.  
  83. res=re.compile("<td align=\"left\" class=\"arial_bold\">.*</td>")
  84. results=res.findall(response)
  85. res=[]
  86.  
  87. for x in results:
  88. x=x.replace("<td align=\"left\" class=\"arial_bold\">","")
  89. x=x.replace("</td>","")
  90. res.append(x)
  91.  
  92. print "Information by Geoiptool"
  93. print "========================\n"
  94. print "IP/Host: "+res[0]
  95. country=re.sub("<.*nk\">","",res[1])
  96. country=country.replace("</a>","")
  97. country=re.sub("<.*middle\" >","",country)
  98. print "Country: " + country + ","+ res[2]
  99. city=re.sub("<.*nk\">","",res[3])
  100. city=city.replace("</a>","")
  101. print "City: " + city + ","+ res[4]
  102. print "Coordinates: " + res[8] + ","+res[7]
  103. print "\n"
  104. except:
  105. print "Connection error..\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement