Advertisement
BaSs_HaXoR

PhoneTrak Python Phone Number Lookup Tool (CLI)

Aug 14th, 2014
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.50 KB | None | 0 0
  1. # Phone Number Lookup Tool
  2. # Version 1.0.0
  3. # Coded by BlackMan in Python 3.3.2
  4. # Download : N/A
  5. # File     : phonetrak.py
  6.  
  7. #IMPORTS
  8. import re
  9. import sys
  10. import urllib.request
  11.  
  12. #BYTE CONTROL
  13. def encodeString(string) : return string.encode('utf-8')
  14. def decodeString(string) : return string.decode('utf-8')
  15.  
  16. #DEBUG MESSAGES
  17. def action(msg)    : print('[#] - ' + msg)
  18. def alert(msg)     : print('[+] - ' + msg)
  19. def error(msg)     : print('[!] - ' + msg)
  20. def errorExit(msg) : raise SystemExit('[!] - ' + msg)
  21.  
  22. #GET BETWEEN
  23. def getBetween(source, start, stop):
  24.     search = encodeString(start + '(.*?)' + stop)
  25.     data   = re.compile(search).search(source)
  26.     if data:
  27.         found = decodeString(data.group(1))
  28.         return found.replace('\n', '')
  29.     else:
  30.         return False
  31.  
  32. #GET CARRIER
  33. def getCarrier(number):
  34.     source   = urllib.request.urlopen('http://www.fonefinder.net/findome.php?npa=' + number[:3] + '&nxx=' + number[3:6] + '&thoublock=' + number[6:]).read()
  35.     carrier  = getBetween(source, '</A><TD><A HREF=\'http://fonefinder.net/', '\'>')
  36.     if carrier == 'att.php':
  37.         alert('Carrier : AT&T')
  38.         alert('SMS Gateway : ' + number + '@txt.att.net')
  39.     elif carrier == 'metropcs.php':
  40.         alert('Carrier : Metro PCS')
  41.         alert('SMS Gateway : ' + number + '@mymetropcs.com')
  42.     elif carrier == 'sprint.php':
  43.         alert('Carrier : Sprint')
  44.         alert('SMS Gateway : ' + number + '@messaging.sprintpcs.com')
  45.     elif carrier == 'tmobile.php':
  46.         alert('Carrier : T-Mobile')
  47.         alert('SMS Gateway : ' + number + '@tmomail.net')
  48.     elif carrier == 'verizon.php':
  49.         alert('Carrier : Verizon')
  50.         alert('SMS Gateway : ' + number + '@vtext.com')
  51.     else:
  52.         errorExit('Carrier : Unknown')
  53.         errorExit('SMS Gateway : Unknown')
  54.  
  55. #VERIFY PHONE
  56. def verifyPhone(number):
  57.     if len(number) == 10 and number.isdigit() == True:
  58.         return True
  59.     else:
  60.         return False
  61.  
  62. #VERSION CHECK
  63. def versionCheck():
  64.     if sys.version_info.major != 3 or sys.version_info.minor != 3:
  65.         errorExit('Requires Python version 3.3 to be installed.')
  66.  
  67. #START
  68. if len(sys.argv) != 2:
  69.     error('Missing command line arguments!')
  70.     errorExit('Usage : phonetrak.py <number>')
  71. number = sys.argv[1]
  72. if verifyPhone(number) == True:
  73.     try:
  74.         getCarrier(number)
  75.     except:
  76.         errorExit('Failed to retrieve carrier!')
  77. else:
  78.     error('Invalid phone number!')
  79.     errorExit('Usage : phonetrak.py <number>')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement