Advertisement
YeiZea

Coded by Christian Martorella

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