SOURCE IPTRAK IP
Salam From •?((¯°·._.• hąж๏я ƒąяhąɲ (ƒąяhąɲ яǥ) •._.·°¯))؟•
IP Address Lookup Tool.
INFORMATION:
Here is a simple command line program I made to do IP address lookups. This will retrieve the ISP, Country, City and State, if availible. Here is a screenshot of the results :
INFORMATION:
Here is a simple command line program I made to do IP address lookups. This will retrieve the ISP, Country, City and State, if availible. Here is a screenshot of the results :
USAGE:
The usage is simple, it is a command line program, so it takes arguments.
The usage is simple, it is a command line program, so it takes arguments.
Code:
Usage : iptrak.py <ip address>
SOURCE CODE:
# IP Address Lookup Tool
# Version 1.0.0
# Coded by BlackMan in Python 3.3.2
# Download : N/A
# File : iptrak.py
#IMPORTS
import re
import sys
import urllib.request
#BYTE CONTROL
def encodeString(string) : return string.encode('utf-8')
def decodeString(string) : return string.decode('utf-8')
#DEBUG MESSAGES
def action(msg) : print('[#] - ' + msg)
def alert(msg) : print('[+] - ' + msg)
def error(msg) : print('[!] - ' + msg)
def errorExit(msg) : raise SystemExit('[!] - ' + msg)
#GET BETWEEN
def getBetween(source, start, stop):
search = encodeString(start + '(.*?)' + stop)
data = re.compile(search).search(source)
if data:
found = decodeString(data.group(1))
return found.replace('\n', '')
else:
return False
#GET IP INFORMATION
def getIP(ip):
source = urllib.request.urlopen('http://www.whatismyipaddress.com/ip/' + ip).read()
country = getBetween(source, 'Country:</th><td>', ' <img ')
state = getBetween(source, 'State/Region:</th><td>', '</td>')
city = getBetween(source, 'City:</th><td>', '</td>')
isp = getBetween(source, 'ISP:</th><td>', '</td>')
return [isp, country, state, city]
#VERIFY IP ADDRESS
def verifyIP(ip):
if re.match('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$', ip):
return True
else:
return False
#VERSION CHECK (sys)
def versionCheck():
if sys.version_info.major != 3 or sys.version_info.minor != 3:
errorExit('Requires Python version 3.3 to be installed.')
#START
versionCheck()
if len(sys.argv) != 2:
error('Missing command line arguments!')
errorExit('Usage : iptrak.py <ip>')
ip = sys.argv[1]
if verifyIP(ip) == True:
try:
data = getIP(ip)
alert('IP Address : ' + ip)
alert('ISP : ' + data[0])
alert('Country : ' + data[1])
alert('State : ' + data[2])
alert('City : ' + data[3])
except:
errorExit('Failed to retrieve IP address information online!')
else:
error('Invalid IP address!')
errorExit('Usage : iptrak.py <ip>')
Thanks for visiting my BLOG!
0 comments:
Post a Comment