FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Upgrade phonefy to Python3 · unsecureio/osrframework@941e694 · GitHub

Repository navigation

Commit 941e694

Browse files
febrezo
committed
Upgrade phonefy to Python3
1 parent 857453f commit 941e694

5 files changed

Lines changed: 63 additions & 77 deletions

File tree

‎osrframework/checkfy.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def main(params=None):
142142
print(general.title(banner.text))
143143

144144
saying_hello = """
145-
Checkfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2018
145+
Checkfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020
146146
147147
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
148148
are welcome to redistribute it under certain conditions. For additional info,

‎osrframework/domainfy.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ def main(params=None):
491491
print(general.title(banner.text))
492492

493493
saying_hello = f"""
494-
Domainfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2019
494+
Domainfy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020
495495
496496
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
497497
are welcome to redistribute it under certain conditions. For additional info,

‎osrframework/phonefy.py‎

Lines changed: 48 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#!/usr/bin/python2
2-
# -*- coding: utf-8 -*-
3-
#
41
################################################################################
52
#
6-
# Copyright 2015-2018 Félix Brezo and Yaiza Rubio
3+
# Copyright 2015-2020 Félix Brezo and Yaiza Rubio
74
#
85
# This program is part of OSRFramework. You can redistribute it and/or modify
96
# it under the terms of the GNU Affero General Public License as published by
@@ -20,7 +17,6 @@
2017
#
2118
################################################################################
2219

23-
2420
import argparse
2521
import datetime as dt
2622
import json
@@ -34,93 +30,85 @@
3430
import osrframework.utils.general as general
3531

3632

37-
def processPhoneList(platformNames=[], numbers=[], excludePlatformNames=[]):
38-
"""
39-
Method to perform searchs on a series of numbers.
33+
def process_phone_list(platformNames=[], numbers=[], exclude_platform_names=[]):
34+
"""Method to perform searchs on a series of numbers
4035
4136
Args:
42-
-----
4337
platformNames: List of names of the platforms.
4438
numbers: List of numbers to be queried.
45-
excludePlatformNames: A list of platforms not to be searched.
39+
exclude_platform_names: A list of platforms not to be searched.
4640
4741
Return:
48-
-------
4942
A list of verified emails.
5043
"""
5144
# Grabbing the <Platform> objects
52-
platforms = platform_selection.getPlatformsByName(platformNames, mode="phonefy", excludePlatformNames=excludePlatformNames)
45+
platforms = platform_selection.get_platforms_by_name(platformNames, mode="phonefy", exclude_platform_names=exclude_platform_names)
5346

5447
results = []
5548
for num in numbers:
5649
for pla in platforms:
5750
# This returns a json.txt!
58-
entities = pla.getInfo(query=num, process=True, mode="phonefy")
51+
entities = pla.get_info(query=num, mode="phonefy")
5952
if entities != {}:
60-
results+=json.loads(entities)
53+
results += json.loads(entities)
6154
return results
6255

6356

64-
def getParser():
65-
DEFAULT_VALUES = configuration.returnListOfConfigurationValues("phonefy")
57+
def get_parser():
58+
DEFAULT_VALUES = configuration.get_configuration_values_for("phonefy")
6659
# Capturing errors just in case the option is not found in the configuration
6760
try:
68-
excludeList = [DEFAULT_VALUES["exclude_platforms"]]
61+
exclude_list = [DEFAULT_VALUES["exclude_platforms"]]
6962
except:
70-
excludeList = []
63+
exclude_list = []
7164

7265
parser = argparse.ArgumentParser(description='phonefy - Piece of software that checks the existence of a given series of phones in a bunch of phone number lists associated to malicious activities.', prog='phonefy', epilog='Check the README.md file for further details on the usage of this program or follow us on Twitter in <http://twitter.com/i3visio>.', add_help=False, conflict_handler='resolve')
7366
parser._optionals.title = "Input options (one required)"
7467

7568
# Defining the mutually exclusive group for the main options
76-
groupMainOptions = parser.add_mutually_exclusive_group(required=True)
69+
group_main_options = parser.add_mutually_exclusive_group(required=True)
7770
# Adding the main options
78-
groupMainOptions.add_argument('--license', required=False, action='store_true', default=False, help='shows the GPLv3+ license and exists.')
79-
groupMainOptions.add_argument('-n', '--numbers', metavar='<phones>', nargs='+', action='store', help='the list of phones to process (at least one is required).')
71+
group_main_options.add_argument('--license', required=False, action='store_true', default=False, help='shows the GPLv3+ license and exists.')
72+
group_main_options.add_argument('-n', '--numbers', metavar='<phones>', nargs='+', action='store', help='the list of phones to process (at least one is required).')
8073

81-
listAll = platform_selection.getAllPlatformNames("phonefy")
74+
list_all = platform_selection.get_all_platform_names("phonefy")
8275

8376
# Configuring the processing options
84-
groupProcessing = parser.add_argument_group('Processing arguments', 'Configuring the way in which usufy will process the identified profiles.')
85-
#groupProcessing.add_argument('-L', '--logfolder', metavar='<path_to_log_folder', required=False, default = './logs', action='store', help='path to the log folder. If none was provided, ./logs is assumed.')
86-
groupProcessing.add_argument('-e', '--extension', metavar='<sum_ext>', nargs='+', choices=['csv', 'gml', 'json', 'ods', 'png', 'txt', 'xls', 'xlsx' ], required=False, default=DEFAULT_VALUES["extension"], action='store', help='output extension for the summary files. Default: xls.')
87-
groupProcessing.add_argument('-o', '--output_folder', metavar='<path_to_output_folder>', required=False, default=DEFAULT_VALUES["output_folder"], action='store', help='output folder for the generated documents. While if the paths does not exist, usufy.py will try to create; if this argument is not provided, usufy will NOT write any down any data. Check permissions if something goes wrong.')
88-
groupProcessing.add_argument('-p', '--platforms', metavar='<platform>', choices=listAll, nargs='+', required=False, default=DEFAULT_VALUES["platforms"] ,action='store', help='select the platforms where you want to perform the search amongst the following: ' + str(listAll) + '. More than one option can be selected.')
89-
# Getting a sample header for the output files
90-
groupProcessing.add_argument('-F', '--file_header', metavar='<alternative_header_file>', required=False, default=DEFAULT_VALUES["file_header"], action='store', help='Header for the output filenames to be generated. If None was provided the following will be used: profiles.<extension>.' )
91-
groupProcessing.add_argument('--quiet', required=False, action='store_true', default=False, help='tells the program not to show anything.')
92-
groupProcessing.add_argument('-w', '--web_browser', required=False, action='store_true', help='opening the URIs returned in the default web browser.')
93-
groupProcessing.add_argument('-x', '--exclude', metavar='<platform>', choices=listAll, nargs='+', required=False, default=excludeList, action='store', help='select the platforms that you want to exclude from the processing.')
77+
group_processing = parser.add_argument_group('Processing arguments', 'Configuring the way in which usufy will process the identified profiles.')
78+
group_processing.add_argument('-e', '--extension', metavar='<sum_ext>', nargs='+', choices=['csv', 'gml', 'json', 'ods', 'png', 'txt', 'xls', 'xlsx' ], required=False, default=DEFAULT_VALUES["extension"], action='store', help='output extension for the summary files. Default: xls.')
79+
group_processing.add_argument('-o', '--output_folder', metavar='<path_to_output_folder>', required=False, default=DEFAULT_VALUES["output_folder"], action='store', help='output folder for the generated documents. While if the paths does not exist, usufy.py will try to create; if this argument is not provided, usufy will NOT write any down any data. Check permissions if something goes wrong.')
80+
group_processing.add_argument('-p', '--platforms', metavar='<platform>', choices=list_all, nargs='+', required=False, default=DEFAULT_VALUES["platforms"] ,action='store', help='select the platforms where you want to perform the search amongst the following: ' + str(list_all) + '. More than one option can be selected.')
81+
group_processing.add_argument('-F', '--file_header', metavar='<alternative_header_file>', required=False, default=DEFAULT_VALUES["file_header"], action='store', help='Header for the output filenames to be generated. If None was provided the following will be used: profiles.<extension>.' )
82+
group_processing.add_argument('--quiet', required=False, action='store_true', default=False, help='tells the program not to show anything.')
83+
group_processing.add_argument('-w', '--web_browser', required=False, action='store_true', help='opening the URIs returned in the default web browser.')
84+
group_processing.add_argument('-x', '--exclude', metavar='<platform>', choices=list_all, nargs='+', required=False, default=exclude_list, action='store', help='select the platforms that you want to exclude from the processing.')
9485

9586

9687
# About options
97-
groupAbout = parser.add_argument_group('About arguments', 'Showing additional information about this program.')
98-
groupAbout.add_argument('-h', '--help', action='help', help='shows this help and exists.')
99-
groupAbout.add_argument('--version', action='version', version='[%(prog)s] OSRFramework ' + osrframework.__version__, help='shows the version of the program and exists.')
88+
group_about = parser.add_argument_group('About arguments', 'Showing additional information about this program.')
89+
group_about.add_argument('-h', '--help', action='help', help='shows this help and exists.')
90+
group_about.add_argument('--version', action='version', version='[%(prog)s] OSRFramework ' + osrframework.__version__, help='shows the version of the program and exists.')
10091

10192
return parser
10293

10394

10495
def main(params=None):
105-
"""
106-
Main function to launch phonefy.
96+
"""Main function to launch phonefy
10797
10898
The function is created in this way so as to let other applications make
10999
use of the full configuration capabilities of the application. The
110-
parameters received are used as parsed by this modules `getParser()`.
100+
parameters received are used as parsed by this modules `get_parser()`.
111101
112102
Args:
113-
-----
114103
params: A list with the parameters as grabbed by the terminal. It is
115104
None when this is called by an entry_point. If it is called by osrf
116105
the data is already parsed.
117106
118107
Returns:
119-
--------
120108
A list of i3visio entities.
121109
"""
122110
if params == None:
123-
parser = getParser()
111+
parser = get_parser()
124112
args = parser.parse_args(params)
125113
else:
126114
args = params
@@ -130,25 +118,25 @@ def main(params=None):
130118
if not args.quiet:
131119
print(general.title(banner.text))
132120

133-
sayingHello = """
134-
Phonefy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2018
121+
saying_hello = f"""
122+
Phonefy | Copyright (C) Yaiza Rubio & Félix Brezo (i3visio) 2014-2020
135123
136124
This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you
137125
are welcome to redistribute it under certain conditions. For additional info,
138-
visit <{}>.
139-
""".format(general.LICENSE_URL)
140-
print(general.info(sayingHello))
126+
visit <{general.LICENSE_URL}>.
127+
"""
128+
print(general.info(saying_hello))
141129

142130
if args.license:
143131
general.showLicense()
144132
else:
145133
# Showing the execution time...
146-
startTime= dt.datetime.now()
147-
#TODO: Get the number searchable platforms in this context
148-
print(str(startTime) + "\tStarting search in different platform(s)... Relax!\n")
134+
start_time = dt.datetime.now()
135+
136+
print(f"\n{start_time}\tStarting search in different platform(s)... Relax!\n")
149137
print(general.emphasis("\tPress <Ctrl + C> to stop...\n"))
150138
try:
151-
results = processPhoneList(platformNames=args.platforms, numbers=args.numbers, excludePlatformNames=args.exclude)
139+
results = process_phone_list(platformNames=args.platforms, numbers=args.numbers, exclude_platform_names=args.exclude)
152140
except KeyboardInterrupt:
153141
print(general.error("\n[!] Process manually stopped by the user. Workers terminated without providing any result.\n"))
154142

@@ -158,32 +146,30 @@ def main(params=None):
158146
if not os.path.exists(args.output_folder):
159147
os.makedirs(args.output_folder)
160148
# Grabbing the results
161-
fileHeader = os.path.join(args.output_folder, args.file_header)
149+
file_header = os.path.join(args.output_folder, args.file_header)
162150
for ext in args.extension:
163151
# Generating output files
164-
general.exportUsufy(results, ext, fileHeader)
152+
general.export_usufy(results, ext, file_header)
165153

166154
# Showing the information gathered if requested
167155
if not args.quiet:
168156
now = dt.datetime.now()
169-
print("\n{}\tResults obtained:\n".format(str(now)))
170-
print(general.success(general.usufyToTextExport(results)))
157+
print(f"\n{now}\tResults obtained:\n")
158+
print(general.success(general.osrf_to_text_export(results)))
171159

172160
if args.web_browser:
173-
general.openResultsInBrowser(results)
161+
general.open_results_in_browser(results)
174162

175163
now = dt.datetime.now()
176-
print("\n" + str(now) + "\tYou can find all the information collected in the following files:")
164+
print(f"\n{now}\tYou can find all the information collected in the following files:")
177165
for ext in args.extension:
178166
# Showing the output files
179-
print("\t" + general.emphasis(fileHeader + "." + ext))
167+
print("\t" + general.emphasis(file_header + "." + ext))
180168

181169
# Showing the execution time...
182-
endTime= dt.datetime.now()
183-
print("\n" + str(endTime) +"\tFinishing execution...\n")
184-
print("Total time consumed:\t" + general.emphasis(str(endTime-startTime)) + "\n")
185-
#TODO: Get the number searchable platforms in this context
186-
#print("Average seconds/query:\t" + general.emphasis(str((endTime-startTime).total_seconds()/len(listPlatforms))) +" seconds\n")
170+
end_time = dt.datetime.now()
171+
print(f"\n{end_time}\tFinishing execution...\n")
172+
print("Total time consumed:\t" + general.emphasis(str(end_time-start_time)) + "\n")
187173

188174
# Urging users to place an issue on Github...
189175
print(banner.footer)

‎osrframework/utils/configuration.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import osrframework.utils.errors as errors
2626

2727

28-
def changePermissionsRecursively(path, uid, gid):
28+
def change_permissions_recursively(path, uid, gid):
2929
"""Function to recursively change the user id and group id
3030
3131
It sets 700 permissions in the different files.
@@ -54,7 +54,7 @@ def changePermissionsRecursively(path, uid, gid):
5454
# Setting permissions
5555
os.chmod(itempath, 6600)
5656
# Recursive function to iterate the files
57-
changePermissionsRecursively(itempath, uid, gid)
57+
change_permissions_recursively(itempath, uid, gid)
5858

5959

6060
def get_config_path(config_file_name=None):

‎osrframework/utils/general.py‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ def export_usufy(data, ext, fileH):
4848
if ext == "csv":
4949
osrf_to_csv_export(data, fileH+"."+ext)
5050
elif ext == "gml":
51-
usufyToGmlExport(data, fileH+"."+ext)
51+
osrf_to_gml_export(data, fileH+"."+ext)
5252
elif ext == "json":
5353
osrf_to_json_export(data, fileH+"."+ext)
5454
elif ext == "ods":
5555
osrf_to_ods_export(data, fileH+"."+ext)
5656
elif ext == "png":
57-
usufyToPngExport(data, fileH+"."+ext)
57+
osrf_to_png_export(data, fileH+"."+ext)
5858
elif ext == "txt":
5959
osrf_to_text_export(data, fileH+"."+ext)
6060
elif ext == "xls":
61-
usufy_to_xls_export(data, fileH+"."+ext)
61+
osrf_to_xls_export(data, fileH+"."+ext)
6262
elif ext == "xlsx":
63-
usufy_to_xlsx_export(data, fileH+"."+ext)
63+
osrf_to_xlsx_export(data, fileH+"."+ext)
6464

6565

6666
def _generate_tabular_data(res, oldtabular_data={}, is_terminal=False):
@@ -70,8 +70,8 @@ def _generate_tabular_data(res, oldtabular_data={}, is_terminal=False):
7070
This method is used by:
7171
- osrf_to_csv_export
7272
- osrf_to_ods_export
73-
- usufy_to_xls_export
74-
- usufy_to_xlsx_export
73+
- osrf_to_xls_export
74+
- osrf_to_xlsx_export
7575
7676
Args:
7777
res: New data to export.
@@ -363,7 +363,7 @@ def osrf_to_ods_export(data, file_path):
363363
save_data(file_path, tabular_data)
364364

365365

366-
def usufy_to_xls_export(data, file_path):
366+
def osrf_to_xls_export(data, file_path):
367367
"""
368368
Workaround to export to a .xls file.
369369
@@ -387,7 +387,7 @@ def usufy_to_xls_export(data, file_path):
387387
save_data(file_path, tabular_data)
388388

389389

390-
def usufy_to_xlsx_export(data, file_path):
390+
def osrf_to_xlsx_export(data, file_path):
391391
"""
392392
Workaround to export to a .xlsx file.
393393
@@ -555,7 +555,7 @@ def _processAttributes(elems, g):
555555
return graphData
556556

557557

558-
def usufyToGmlExport(d, file_path):
558+
def osrf_to_gml_export(d, file_path):
559559
"""Workaround to export data to a .gml file.
560560
561561
Args:
@@ -584,7 +584,7 @@ def usufyToGmlExport(d, file_path):
584584
nx.write_gml(newGraph,file_path)
585585

586586

587-
def usufyToPngExport(d, file_path):
587+
def osrf_to_png_export(d, file_path):
588588
"""Workaround to export to a png file.
589589
590590
Args:
@@ -688,7 +688,7 @@ def urisToBrowser(uris=[], autoraise=True):
688688
os.dup2(savout2, 2)
689689

690690

691-
def openResultsInBrowser(res):
691+
def open_results_in_browser(res):
692692
"""Method that collects the URI from a list of entities and opens them
693693
694694
Args:

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL