mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-23 06:37:15 +00:00
Added Python Phonenumbers module to parse numbers and retrieves stats from countrycode
This commit is contained in:
parent
55be38987f
commit
747fff1df1
2 changed files with 16 additions and 0 deletions
15
bin/Phone.py
15
bin/Phone.py
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import phonenumbers
|
||||||
from packages import Paste
|
from packages import Paste
|
||||||
from pubsublogger import publisher
|
from pubsublogger import publisher
|
||||||
from Helper import Process
|
from Helper import Process
|
||||||
|
@ -27,6 +28,20 @@ def search_phone(message):
|
||||||
p.populate_set_out('phone;{}'.format(message), 'BrowseWarningPaste')
|
p.populate_set_out('phone;{}'.format(message), 'BrowseWarningPaste')
|
||||||
#Send to duplicate
|
#Send to duplicate
|
||||||
p.populate_set_out(message, 'Duplicate')
|
p.populate_set_out(message, 'Duplicate')
|
||||||
|
stats = {}
|
||||||
|
for phone_number in results:
|
||||||
|
try:
|
||||||
|
x = phonenumbers.parse(phone_number, None)
|
||||||
|
country_code = x.country_code
|
||||||
|
if stats.get(country_code) is None:
|
||||||
|
stats[country_code] = 1
|
||||||
|
else:
|
||||||
|
stats[country_code] = stats[country_code] + 1
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
for country_code in stats:
|
||||||
|
if stats[country_code] > 4:
|
||||||
|
publisher.warning('{} contains Phone numbers with country code {}'.format(paste.p_name, country_code))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# If you wish to use an other port of channel, do not forget to run a subscriber accordingly (see launch_logs.sh)
|
# If you wish to use an other port of channel, do not forget to run a subscriber accordingly (see launch_logs.sh)
|
||||||
|
|
|
@ -26,6 +26,7 @@ ssdeep
|
||||||
python-magic
|
python-magic
|
||||||
pybloomfiltermmap
|
pybloomfiltermmap
|
||||||
psutil
|
psutil
|
||||||
|
phonenumbers
|
||||||
|
|
||||||
ipython
|
ipython
|
||||||
flask
|
flask
|
||||||
|
|
Loading…
Reference in a new issue