forked from sundowndev/phoneinfoga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
localscan.py
75 lines (63 loc) · 2.7 KB
/
localscan.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
#
# @name : PhoneInfoga - Phone numbers OSINT tool
# @url : https://github.com/sundowndev
# @author : Raphael Cerveaux (sundowndev)
import phonenumbers
from phonenumbers import carrier
from phonenumbers import geocoder
from phonenumbers import timezone
from lib.output import *
from lib.format import *
def scan(InputNumber, print_results=True):
test("Running local scan...")
FormattedPhoneNumber = "+" + formatNumber(InputNumber)
try:
PhoneNumberObject = phonenumbers.parse(FormattedPhoneNumber, None)
except Exception as e:
throw(e)
else:
if not phonenumbers.is_valid_number(PhoneNumberObject):
return False
number = phonenumbers.format_number(
PhoneNumberObject, phonenumbers.PhoneNumberFormat.E164
).replace("+", "")
numberCountryCode = phonenumbers.format_number(
PhoneNumberObject, phonenumbers.PhoneNumberFormat.INTERNATIONAL
).split(" ")[0]
numberCountry = phonenumbers.region_code_for_country_code(
int(numberCountryCode)
)
localNumber = phonenumbers.format_number(
PhoneNumberObject, phonenumbers.PhoneNumberFormat.E164
).replace(numberCountryCode, "")
internationalNumber = phonenumbers.format_number(
PhoneNumberObject, phonenumbers.PhoneNumberFormat.INTERNATIONAL
)
country = geocoder.country_name_for_number(PhoneNumberObject, "en")
location = geocoder.description_for_number(PhoneNumberObject, "en")
carrierName = carrier.name_for_number(PhoneNumberObject, "en")
if print_results:
plus("International format: {}".format(internationalNumber))
plus("Local format: {}".format(localNumber))
plus("Country found: {} ({})".format(country, numberCountryCode))
plus("City/Area: {}".format(location))
plus("Carrier: {}".format(carrierName))
for timezoneResult in timezone.time_zones_for_number(PhoneNumberObject):
plus("Timezone: {}".format(timezoneResult))
if phonenumbers.is_possible_number(PhoneNumberObject):
info("The number is valid and possible.")
else:
warn("The number is valid but might not be possible.")
numberObj = {}
numberObj["input"] = InputNumber
numberObj["default"] = number
numberObj["local"] = localNumber
numberObj["international"] = internationalNumber
numberObj["country"] = country
numberObj["countryCode"] = numberCountryCode
numberObj["countryIsoCode"] = numberCountry
numberObj["location"] = location
numberObj["carrier"] = carrierName
return numberObj