Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
except Exception as e:
print(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:
print("International format: {}".format(internationalNumber))
print("Local format: {}".format(localNumber))
print("Country found: {} ({})".format(country, numberCountryCode))
print("City/Area: {}".format(location))
print("Carrier: {}".format(carrierName))
for timezoneResult in timezone.time_zones_for_number(PhoneNumberObject):
print("Timezone: {}".format(timezoneResult))
if phonenumbers.is_possible_number(PhoneNumberObject):
print("The number is valid and possible.")
else:
print("The number is valid but might not be possible.")
numberObj = {}
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 = {}
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 = {}
evt = SpiderFootEvent("PHONE_NUMBER", n, self.__name__, event)
if event.moduleDataSource:
evt.moduleDataSource = event.moduleDataSource
else:
evt.moduleDataSource = "Unknown"
self.notifyListeners(evt)
if eventName == 'PHONE_NUMBER':
try:
number = phonenumbers.parse(eventData)
except BaseException as e:
self.sf.debug('Error parsing phone number: ' + str(e))
return None
try:
number_carrier = carrier.name_for_number(number, 'en')
except BaseException as e:
self.sf.debug('Error retrieving phone number carrier: ' + str(e))
return None
if number_carrier:
evt = SpiderFootEvent("PROVIDER_TELCO", number_carrier, self.__name__, event)
self.notifyListeners(evt)
else:
self.sf.debug("No carrier information found for " + eventData)
#try:
# location = geocoder.description_for_number(number, 'en')
#except BaseException as e:
# self.sf.debug('Error retrieving phone number location: ' + str(e))
# return None
u"body_offset_stop": match.end(),
u"excerpt": excerpt,
u"excerpt_value_start": excerpt_value_start,
u"excerpt_value_stop": excerpt_value_stop,
u"possible_area": None,
u"possible_carrier": None
}
# If the phonenumbers module was able to construct an actual phone number object, attempt to
# add some notes about the possible geographic region and telco carrier.
if phone_number_obj is not None:
area_name = geocoder.description_for_number(phone_number_obj, "en")
if area_name:
entity_dict[u'possible_area'] = u"Possible area: %s. " % area_name
carrier_name = carrier.name_for_number(phone_number_obj, "en")
if carrier_name:
entity_dict[u'possible_carrier'] = u"Possible carrier: %s." % carrier_name
tagged_phone_entities.append(entity_dict)
return tagged_phone_entities
u"body_offset_stop": match.end(),
u"excerpt": excerpt,
u"excerpt_value_start": excerpt_value_start,
u"excerpt_value_stop": excerpt_value_stop,
u"possible_area": None,
u"possible_carrier": None
}
# If the phonenumbers module was able to construct an actual phone number object, attempt to
# add some notes about the possible geographic region and telco carrier.
if phone_number_obj is not None:
area_name = geocoder.description_for_number(phone_number_obj, "en")
if area_name:
entity_dict[u'possible_area'] = u"Possible area: %s. " % area_name
carrier_name = carrier.name_for_number(phone_number_obj, "en")
if carrier_name:
entity_dict[u'possible_carrier'] = u"Possible carrier: %s." % carrier_name
tagged_phone_entities.append(entity_dict)
return tagged_phone_entities