Merge pull request #25 from sundowndev/hotfix/countryScan
[Fix #24] Country code scan
This commit is contained in:
commit
2a6ecf15dd
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
__version__ = 'v1.1.2-rc1'
|
__version__ = 'v1.0.0-rc3'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sys
|
import sys
|
||||||
|
@ -195,7 +195,7 @@ def search(req, stop):
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
REQ = urlencode({'q': req })
|
REQ = urlencode({'q': req})
|
||||||
URL = 'https://www.google.com/search?tbs=li:1&{}&gws_rd=ssl'.format(
|
URL = 'https://www.google.com/search?tbs=li:1&{}&gws_rd=ssl'.format(
|
||||||
REQ)
|
REQ)
|
||||||
r = s.get(URL + googleAbuseToken, headers=headers)
|
r = s.get(URL + googleAbuseToken, headers=headers)
|
||||||
|
@ -233,7 +233,7 @@ def search(req, stop):
|
||||||
|
|
||||||
return links
|
return links
|
||||||
except:
|
except:
|
||||||
print(code_error + 'Request failed. Please retry or open an issue on GitHub.')
|
print(code_error + 'Request failed. Please retry or open an issue on https://github.com/sundowndev/PhoneInfoga.')
|
||||||
|
|
||||||
|
|
||||||
def formatNumber(InputNumber):
|
def formatNumber(InputNumber):
|
||||||
|
@ -264,9 +264,17 @@ def localScan(InputNumber):
|
||||||
numberCountryCode = phonenumbers.format_number(
|
numberCountryCode = phonenumbers.format_number(
|
||||||
PhoneNumberObject, phonenumbers.PhoneNumberFormat.INTERNATIONAL).split(' ')[0]
|
PhoneNumberObject, phonenumbers.PhoneNumberFormat.INTERNATIONAL).split(' ')[0]
|
||||||
|
|
||||||
countryRequest = json.loads(requests.request(
|
try:
|
||||||
'GET', 'https://restcountries.eu/rest/v2/callingcode/{}'.format(numberCountryCode.replace('+', ''))).content)
|
countries = json.load(open('data/CountryCodes.json'))
|
||||||
numberCountry = countryRequest[0]['alpha2Code']
|
|
||||||
|
for country in countries:
|
||||||
|
if (country['dial_code'].replace(' ', '') == numberCountryCode):
|
||||||
|
print(code_info + 'Country code found: {} ({})'.format(country['name'],country['code']))
|
||||||
|
numberCountry = country['code']
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
print(code_error + 'Unable to find country code.')
|
||||||
|
print(numberCountry)
|
||||||
|
|
||||||
localNumber = phonenumbers.format_number(
|
localNumber = phonenumbers.format_number(
|
||||||
PhoneNumberObject, phonenumbers.PhoneNumberFormat.E164).replace(numberCountryCode, '')
|
PhoneNumberObject, phonenumbers.PhoneNumberFormat.E164).replace(numberCountryCode, '')
|
||||||
|
@ -323,7 +331,7 @@ def numverifyScan():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.request(
|
response = requests.request(
|
||||||
"GET", "https://numverify.com/php_helper_scripts/phone_api.php?secret_key={}&number={}".format(apiKey, number), data="", headers=headers)
|
"GET", "https://numverify.com/php_helper_scripts/phone_api.php?secret_key={}&number={}".format(apiKey, number), data="", headers=headers)
|
||||||
except:
|
except:
|
||||||
print(code_error + 'Numverify is not available')
|
print(code_error + 'Numverify is not available')
|
||||||
return -1
|
return -1
|
||||||
|
@ -371,10 +379,13 @@ def ovhScan():
|
||||||
'cache-control': "no-cache"
|
'cache-control': "no-cache"
|
||||||
}
|
}
|
||||||
|
|
||||||
response = requests.request(
|
try:
|
||||||
"GET", "https://api.ovh.com/1.0/telephony/number/detailedZones", data="", headers=headers, params=querystring)
|
response = requests.request(
|
||||||
|
"GET", "https://api.ovh.com/1.0/telephony/number/detailedZones", data="", headers=headers, params=querystring)
|
||||||
data = json.loads(response.content)
|
data = json.loads(response.content)
|
||||||
|
except:
|
||||||
|
print(code_error + 'OVH API is unreachable. Maybe retry later.')
|
||||||
|
return -1
|
||||||
|
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
askedNumber = "0" + localNumber.replace(localNumber[-4:], 'xxxx')
|
askedNumber = "0" + localNumber.replace(localNumber[-4:], 'xxxx')
|
||||||
|
@ -490,7 +501,6 @@ def osintScan():
|
||||||
global localNumber
|
global localNumber
|
||||||
global internationalNumber
|
global internationalNumber
|
||||||
global numberCountryCode
|
global numberCountryCode
|
||||||
global numberCountry
|
|
||||||
global customFormatting
|
global customFormatting
|
||||||
|
|
||||||
if not args.osint:
|
if not args.osint:
|
||||||
|
@ -576,7 +586,8 @@ def osintScan():
|
||||||
|
|
||||||
osintIndividualScan()
|
osintIndividualScan()
|
||||||
|
|
||||||
retry_input = input(code_info + "Would you like to rerun OSINT scan ? (e.g to use a different format) (y/N) ")
|
retry_input = input(
|
||||||
|
code_info + "Would you like to rerun OSINT scan ? (e.g to use a different format) (y/N) ")
|
||||||
|
|
||||||
if retry_input.lower() == 'y' or retry_input.lower() == 'yes':
|
if retry_input.lower() == 'y' or retry_input.lower() == 'yes':
|
||||||
osintScan()
|
osintScan()
|
||||||
|
@ -622,6 +633,7 @@ def scanNumber(InputNumber):
|
||||||
else:
|
else:
|
||||||
print('\n')
|
print('\n')
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if args.no_ansi or args.output:
|
if args.no_ansi or args.output:
|
||||||
code_info = '[*] '
|
code_info = '[*] '
|
||||||
|
|
Loading…
Reference in New Issue