-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPhoneValidationTransform.py
More file actions
40 lines (32 loc) · 1.37 KB
/
PhoneValidationTransform.py
File metadata and controls
40 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
import httplib, urllib, json, sys
from MaltegoTransform import *
API_DOMAIN = "www.phone-validator.net"
API_URL = "/api/verify?"
API_KEY = "INSERT YOUR API KEY"
def validateNumber( phoneNumber, countryCode, locale):
params = urllib.urlencode({ "PhoneNumber" : phoneNumber,
"CountryCode" : countryCode,
"Locale" : locale,
"APIKey" : API_KEY})
conn = httplib.HTTPConnection(API_DOMAIN)
url = API_URL + params
conn.request("GET", API_URL + params)
response = conn.getresponse()
data = response.read()
return json.loads(data)
#Read the input
phoneNumber = sys.argv[1]
countryCode = ""
locale = ""
#validate the number
data = validateNumber(phoneNumber, countryCode, locale)
#create and return the new transform
me = MaltegoTransform()
entity = me.addEntity("maltego.PhoneNumber", phoneNumber)
entity.addAdditionalFields("lineType", "Line Type", True, data["linetype"])
entity.addAdditionalFields("geoLocation", "GeoLocation", True, data["geolocation"])
entity.addAdditionalFields("regionCode", "Region", True, data["regioncode"])
entity.addAdditionalFields("nationalFormat", "Region Formated", True, data["formatnational"])
entity.addAdditionalFields("internationalFormat", "International Formated", True, data["formatinternational"])
me.returnOutput()