mirror of
https://github.com/soxoj/maigret.git
synced 2026-05-06 22:19:01 +00:00
+94
-7
@@ -26,6 +26,7 @@ from .notify import QueryNotifyPrint
|
|||||||
from .result import QueryResult, QueryStatus
|
from .result import QueryResult, QueryStatus
|
||||||
from .sites import SitesInformation
|
from .sites import SitesInformation
|
||||||
|
|
||||||
|
import xmind
|
||||||
|
|
||||||
__version__ = '0.1.7'
|
__version__ = '0.1.7'
|
||||||
|
|
||||||
@@ -139,6 +140,10 @@ def process_site_result(response, query_notify, logger, results_info, net_info,
|
|||||||
if not response:
|
if not response:
|
||||||
return results_info
|
return results_info
|
||||||
|
|
||||||
|
fulltags = []
|
||||||
|
if ("tags" in net_info.keys()):
|
||||||
|
fulltags = net_info["tags"]
|
||||||
|
|
||||||
# Retrieve other site information again
|
# Retrieve other site information again
|
||||||
username = results_info['username']
|
username = results_info['username']
|
||||||
is_parsing_enabled = results_info['parsing_enabled']
|
is_parsing_enabled = results_info['parsing_enabled']
|
||||||
@@ -191,7 +196,7 @@ def process_site_result(response, query_notify, logger, results_info, net_info,
|
|||||||
url,
|
url,
|
||||||
QueryStatus.UNKNOWN,
|
QueryStatus.UNKNOWN,
|
||||||
query_time=response_time,
|
query_time=response_time,
|
||||||
context=f'{error_text}: {site_error_text}')
|
context=f'{error_text}: {site_error_text}', tags=fulltags)
|
||||||
elif error_type == "message":
|
elif error_type == "message":
|
||||||
absence_flags = net_info.get("errorMsg")
|
absence_flags = net_info.get("errorMsg")
|
||||||
is_absence_flags_list = isinstance(absence_flags, list)
|
is_absence_flags_list = isinstance(absence_flags, list)
|
||||||
@@ -203,13 +208,13 @@ def process_site_result(response, query_notify, logger, results_info, net_info,
|
|||||||
social_network,
|
social_network,
|
||||||
url,
|
url,
|
||||||
QueryStatus.CLAIMED,
|
QueryStatus.CLAIMED,
|
||||||
query_time=response_time)
|
query_time=response_time, tags=fulltags)
|
||||||
else:
|
else:
|
||||||
result = QueryResult(username,
|
result = QueryResult(username,
|
||||||
social_network,
|
social_network,
|
||||||
url,
|
url,
|
||||||
QueryStatus.AVAILABLE,
|
QueryStatus.AVAILABLE,
|
||||||
query_time=response_time)
|
query_time=response_time, tags=fulltags)
|
||||||
elif error_type == "status_code":
|
elif error_type == "status_code":
|
||||||
# Checks if the status code of the response is 2XX
|
# Checks if the status code of the response is 2XX
|
||||||
if (not status_code >= 300 or status_code < 200) and is_presense_detected:
|
if (not status_code >= 300 or status_code < 200) and is_presense_detected:
|
||||||
@@ -217,13 +222,13 @@ def process_site_result(response, query_notify, logger, results_info, net_info,
|
|||||||
social_network,
|
social_network,
|
||||||
url,
|
url,
|
||||||
QueryStatus.CLAIMED,
|
QueryStatus.CLAIMED,
|
||||||
query_time=response_time)
|
query_time=response_time, tags=fulltags)
|
||||||
else:
|
else:
|
||||||
result = QueryResult(username,
|
result = QueryResult(username,
|
||||||
social_network,
|
social_network,
|
||||||
url,
|
url,
|
||||||
QueryStatus.AVAILABLE,
|
QueryStatus.AVAILABLE,
|
||||||
query_time=response_time)
|
query_time=response_time, tags=fulltags)
|
||||||
elif error_type == "response_url":
|
elif error_type == "response_url":
|
||||||
# For this detection method, we have turned off the redirect.
|
# For this detection method, we have turned off the redirect.
|
||||||
# So, there is no need to check the response URL: it will always
|
# So, there is no need to check the response URL: it will always
|
||||||
@@ -235,13 +240,13 @@ def process_site_result(response, query_notify, logger, results_info, net_info,
|
|||||||
social_network,
|
social_network,
|
||||||
url,
|
url,
|
||||||
QueryStatus.CLAIMED,
|
QueryStatus.CLAIMED,
|
||||||
query_time=response_time)
|
query_time=response_time, tags=fulltags)
|
||||||
else:
|
else:
|
||||||
result = QueryResult(username,
|
result = QueryResult(username,
|
||||||
social_network,
|
social_network,
|
||||||
url,
|
url,
|
||||||
QueryStatus.AVAILABLE,
|
QueryStatus.AVAILABLE,
|
||||||
query_time=response_time)
|
query_time=response_time, tags=fulltags)
|
||||||
else:
|
else:
|
||||||
# It should be impossible to ever get here...
|
# It should be impossible to ever get here...
|
||||||
raise ValueError(f"Unknown Error Type '{error_type}' for "
|
raise ValueError(f"Unknown Error Type '{error_type}' for "
|
||||||
@@ -340,6 +345,11 @@ async def maigret(username, site_data, query_notify, logger,
|
|||||||
|
|
||||||
# First create futures for all requests. This allows for the requests to run in parallel
|
# First create futures for all requests. This allows for the requests to run in parallel
|
||||||
for social_network, net_info in site_data.items():
|
for social_network, net_info in site_data.items():
|
||||||
|
|
||||||
|
fulltags = []
|
||||||
|
if ("tags" in net_info.keys()):
|
||||||
|
fulltags = net_info["tags"]
|
||||||
|
|
||||||
if net_info.get('type', 'username') != id_type:
|
if net_info.get('type', 'username') != id_type:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -359,6 +369,7 @@ async def maigret(username, site_data, query_notify, logger,
|
|||||||
results_site['parsing_enabled'] = recursive_search
|
results_site['parsing_enabled'] = recursive_search
|
||||||
results_site['url_main'] = net_info.get("urlMain")
|
results_site['url_main'] = net_info.get("urlMain")
|
||||||
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11.1; rv:55.0) Gecko/20100101 Firefox/55.0',
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11.1; rv:55.0) Gecko/20100101 Firefox/55.0',
|
||||||
}
|
}
|
||||||
@@ -574,6 +585,66 @@ async def self_check(json_file, logger):
|
|||||||
data['sites'] = all_sites
|
data['sites'] = all_sites
|
||||||
json.dump(data, f, indent=4)
|
json.dump(data, f, indent=4)
|
||||||
|
|
||||||
|
def genxmindfile(filename, username,results):
|
||||||
|
print("Generating XMIND8 file")
|
||||||
|
if os.path.exists(filename):
|
||||||
|
os.remove(filename)
|
||||||
|
workbook = xmind.load(filename)
|
||||||
|
sheet = workbook.getPrimarySheet()
|
||||||
|
design_sheet1(sheet, username, results)
|
||||||
|
xmind.save(workbook, path=filename)
|
||||||
|
|
||||||
|
## detect if tag rappresent a nation
|
||||||
|
def checknation(tag):
|
||||||
|
if re.match("^([a-z]){2}$", tag):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def design_sheet1(sheet, username, results):
|
||||||
|
##all tag list
|
||||||
|
alltags = {}
|
||||||
|
|
||||||
|
sheet.setTitle("%s Analysis"%(username))
|
||||||
|
root_topic1 = sheet.getRootTopic()
|
||||||
|
root_topic1.setTitle("%s"%(username))
|
||||||
|
|
||||||
|
undefinedsection = root_topic1.addSubTopic()
|
||||||
|
undefinedsection.setTitle("Undefined")
|
||||||
|
alltags["undefined"] = undefinedsection
|
||||||
|
|
||||||
|
for website_name in results:
|
||||||
|
dictionary = results[website_name]
|
||||||
|
|
||||||
|
if dictionary.get("status").status == QueryStatus.CLAIMED:
|
||||||
|
## firsttime I found that entry
|
||||||
|
for tag in dictionary.get("status").tags.split(","):
|
||||||
|
if(tag.strip() == ""):
|
||||||
|
continue
|
||||||
|
if( tag not in alltags.keys()):
|
||||||
|
if (not checknation(tag)):
|
||||||
|
tagsection = root_topic1.addSubTopic()
|
||||||
|
tagsection.setTitle(tag)
|
||||||
|
alltags[tag] = tagsection
|
||||||
|
|
||||||
|
category = None
|
||||||
|
userlink= None
|
||||||
|
for tag in dictionary.get("status").tags.split(","):
|
||||||
|
if(tag.strip() == ""):
|
||||||
|
continue
|
||||||
|
if(not checknation(tag)):
|
||||||
|
category = tag
|
||||||
|
|
||||||
|
if(category is None):
|
||||||
|
category = "undefined"
|
||||||
|
userlink = undefinedsection.addSubTopic()
|
||||||
|
else:
|
||||||
|
userlink = alltags[category].addSubTopic()
|
||||||
|
userlink.addLabel(dictionary.get("status").site_url_user)
|
||||||
|
|
||||||
|
#for tag in dictionary.get("status").tags.split(","):
|
||||||
|
# if( tag != category ):
|
||||||
|
# sheet.createRelationship(userlink.getID(), alltags[tag].getID(),"other tag")
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
version_string = f"%(prog)s {__version__}\n" + \
|
version_string = f"%(prog)s {__version__}\n" + \
|
||||||
@@ -673,6 +744,13 @@ async def main():
|
|||||||
dest="tags", default='',
|
dest="tags", default='',
|
||||||
help="Specify tags of sites."
|
help="Specify tags of sites."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument("-x","--xmind",
|
||||||
|
action="store_true",
|
||||||
|
dest="xmind", default=False,
|
||||||
|
help="Generate an xmind 8 mindmap"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
@@ -830,13 +908,22 @@ async def main():
|
|||||||
|
|
||||||
if args.output:
|
if args.output:
|
||||||
result_file = args.output
|
result_file = args.output
|
||||||
|
if (args.xmind):
|
||||||
|
xmind_path = f"{username}.xmind"
|
||||||
elif args.folderoutput:
|
elif args.folderoutput:
|
||||||
# The usernames results should be stored in a targeted folder.
|
# The usernames results should be stored in a targeted folder.
|
||||||
# If the folder doesn't exist, create it first
|
# If the folder doesn't exist, create it first
|
||||||
os.makedirs(args.folderoutput, exist_ok=True)
|
os.makedirs(args.folderoutput, exist_ok=True)
|
||||||
result_file = os.path.join(args.folderoutput, f"{username}.txt")
|
result_file = os.path.join(args.folderoutput, f"{username}.txt")
|
||||||
|
if (args.xmind):
|
||||||
|
xmind_path = os.path.join(args.folderoutput, f"{username}.xmind")
|
||||||
else:
|
else:
|
||||||
result_file = f"{username}.txt"
|
result_file = f"{username}.txt"
|
||||||
|
if (args.xmind):
|
||||||
|
xmind_path = f"{username}.xmind"
|
||||||
|
|
||||||
|
if (args.xmind):
|
||||||
|
genxmindfile(xmind_path, username, results)
|
||||||
|
|
||||||
with open(result_file, "w", encoding="utf-8") as file:
|
with open(result_file, "w", encoding="utf-8") as file:
|
||||||
exists_counter = 0
|
exists_counter = 0
|
||||||
|
|||||||
+7
-1
@@ -34,7 +34,7 @@ class QueryResult():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, username, site_name, site_url_user, status, ids_data=None,
|
def __init__(self, username, site_name, site_url_user, status, ids_data=None,
|
||||||
query_time=None, context=None):
|
query_time=None, context=None, tags=None):
|
||||||
"""Create Query Result Object.
|
"""Create Query Result Object.
|
||||||
|
|
||||||
Contains information about a specific method of detecting usernames on
|
Contains information about a specific method of detecting usernames on
|
||||||
@@ -73,6 +73,12 @@ class QueryResult():
|
|||||||
self.context = context
|
self.context = context
|
||||||
self.ids_data = ids_data
|
self.ids_data = ids_data
|
||||||
|
|
||||||
|
self.tags = ""
|
||||||
|
if (tags is not None):
|
||||||
|
TAGstring = "".join(['%s,' % tags for tags in tags])
|
||||||
|
TAGstring = TAGstring[:-1]
|
||||||
|
self.tags = TAGstring
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
+22
-12
@@ -1,15 +1,25 @@
|
|||||||
beautifulsoup4>=4.8.0
|
|
||||||
bs4>=0.0.1
|
|
||||||
certifi>=2019.6.16
|
|
||||||
colorama>=0.4.1
|
|
||||||
lxml>=4.4.0
|
|
||||||
PySocks>=1.7.0
|
|
||||||
requests>=2.22.0
|
|
||||||
requests-futures>=1.0.0
|
|
||||||
soupsieve>=1.9.2
|
|
||||||
stem>=1.8.0
|
|
||||||
torrequest>=0.1.0
|
|
||||||
socid-extractor>=0.0.2
|
|
||||||
aiohttp==3.7.3
|
aiohttp==3.7.3
|
||||||
aiohttp-socks==0.5.5
|
aiohttp-socks==0.5.5
|
||||||
|
async-timeout==3.0.1
|
||||||
|
attrs==20.3.0
|
||||||
|
beautifulsoup4==4.9.3
|
||||||
|
bs4==0.0.1
|
||||||
|
certifi==2020.12.5
|
||||||
|
chardet==3.0.4
|
||||||
|
colorama==0.4.4
|
||||||
|
idna==2.10
|
||||||
|
lxml==4.6.2
|
||||||
mock==4.0.2
|
mock==4.0.2
|
||||||
|
multidict==5.1.0
|
||||||
|
PySocks==1.7.1
|
||||||
|
python-socks==1.1.2
|
||||||
|
requests==2.25.1
|
||||||
|
requests-futures==1.0.0
|
||||||
|
socid-extractor==0.0.2
|
||||||
|
soupsieve==2.1
|
||||||
|
stem==1.8.0
|
||||||
|
torrequest==0.1.0
|
||||||
|
typing-extensions==3.7.4.3
|
||||||
|
urllib3==1.26.2
|
||||||
|
XMind==1.2.0
|
||||||
|
yarl==1.6.3
|
||||||
|
|||||||
Reference in New Issue
Block a user