-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core fixes. Provide global variables. Update runner. Upgrade module-p…
…ackage system. (#14) * Clean init all the modules with the __init__.py file * Remove unused gitkeeps * Add base inits for script packages * Update main file * Set __file__ variable at the module level * Add inits for the modules * Modify all the modules * Delete one more .gitkeep * Add WIP test for user_greeting * Update test module for user_greeting * Fix module runner a bit * Add relative imports to the modules * Add run tests script * Update README.md * Fix module-package runner * Update requirements * Format everything with Black * Handle module and execution errors with runner
- Loading branch information
1 parent
01b2b3e
commit 9d50918
Showing
44 changed files
with
712 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
aiodns==2.0.0 | ||
aiohttp==3.6.2 | ||
aiosmtpd==1.2 | ||
async-timeout==3.0.1 | ||
atpublic==1.0 | ||
attrs==19.3.0 | ||
certifi==2020.6.20 | ||
cffi==1.14.0 | ||
chardet==3.0.4 | ||
idna==2.10 | ||
mmh3==2.5.1 | ||
multidict==4.7.6 | ||
pycares==3.1.1 | ||
pycparser==2.20 | ||
requests==2.24.0 | ||
urllib3==1.25.9 | ||
verify-email==2.4.1 | ||
yarl==1.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
python3 -m unittest discover -v |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
def run_module( | ||
runner: type, args: list, arg_name: str, arg_default: str or None = None | ||
) -> dict: | ||
""" | ||
Use module as a 'python3 -m ...' module | ||
:param runner: runner object | ||
:param args: list of args from CLI | ||
:param arg_name: name of arg to use | ||
:param arg_default: default arg value | ||
:return: results | ||
""" | ||
runner = runner() | ||
return runner.run(**{arg_name: args[1] if len(args) >= 2 else arg_default}) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
__root_dir = Path(__file__).parents[4] | ||
sys.path.append(str(__root_dir)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,10 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
from pathlib import Path | ||
from pprint import pprint | ||
from sys import argv | ||
|
||
import aiohttp | ||
import requests | ||
from src.core.utils.module import run_module | ||
from .module import Runner | ||
|
||
from src.core.base.osint import OsintRunner | ||
from src.core.utils.response import ScriptResponse | ||
|
||
|
||
class Defaults: | ||
NETWORKS_LIST = "social_networks.txt" | ||
|
||
|
||
class Networks: | ||
def __init__(self): | ||
with open(Path("./src/scripts/osint/check_nickname/data/social_networks.txt")) as file: | ||
self.net = file.read().splitlines() | ||
|
||
|
||
def check_nickname_sync(nickname: str) -> list: | ||
""" | ||
checks nicknames from social networks(sync) | ||
:param nickname: just nickname :) | ||
:return: list with links to user from social | ||
networks which have this nickname | ||
""" | ||
ans = [] | ||
social = Networks().net | ||
for site in social: | ||
try: | ||
url = "https://{site}{nickname}".format(site=site, nickname=nickname) | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
ans.append(url) | ||
except: | ||
pass | ||
return ans | ||
|
||
|
||
async def check_nickname_async(nickname: str, social) -> list: | ||
""" | ||
checks nicknames from social networks(async) | ||
:param nickname: just nickname :) | ||
:param social: social | ||
:return: list with links to user from social | ||
networks which have this nickname | ||
""" | ||
ans = [] | ||
async with aiohttp.ClientSession() as session: | ||
while not social.empty(): | ||
url = await social.get() | ||
try: | ||
async with session.get(url) as response: | ||
if response.status == 200: | ||
ans.append(url) | ||
except: | ||
pass | ||
return ans | ||
|
||
|
||
class Runner(OsintRunner): | ||
def __init__(self, logger: str = __name__): | ||
super().__init__(logger=logger) | ||
|
||
@staticmethod | ||
async def __run(*args, **kwargs): | ||
try: | ||
username = kwargs.get("username") | ||
social = asyncio.Queue() | ||
for site in Networks().net: | ||
await social.put( | ||
"https://{site}{username}".format(site=site, username=username) | ||
) | ||
temp_result = await asyncio.gather( | ||
*[ | ||
asyncio.create_task(check_nickname_async(username, social)) | ||
for _ in range(10) | ||
] | ||
) | ||
result = {username: []} | ||
for sub_massive in temp_result: | ||
for site in sub_massive: | ||
result[username].append(site) | ||
return ScriptResponse.success( | ||
result=result, | ||
message="Found {count} user accounts".format( | ||
count=len(result[username]) | ||
), | ||
) | ||
except Exception as err: | ||
return ScriptResponse.error(message=str(err)) | ||
|
||
def run(self, *args, **kwargs): | ||
username = kwargs.get("username") | ||
return asyncio.run(self.__run(username=username)) | ||
result = run_module(Runner, args=argv, arg_name="username", arg_default="johndoe") | ||
pprint(result) |
Oops, something went wrong.