-
Notifications
You must be signed in to change notification settings - Fork 3
add script name_check #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
be0fdc7
aef53f7
c04aeac
969183d
855c83a
c711ae2
9b2867b
64a6d0b
40db700
0af2535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
from pathlib import Path | ||
|
||
import aiohttp | ||
import requests | ||
|
||
from src.core.base.osint import OsintRunner | ||
from src.core.utils.response import ScriptResponse | ||
|
||
|
||
manmolecular marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: | ||
manmolecular marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
twitter.com/ | ||
vk.com/ | ||
ok.ru/ | ||
instagram.com/ | ||
github.com/ | ||
reddit.com/user/ | ||
tiktok.com/@ | ||
mastodon.social/@ | ||
blackplanet.com/ | ||
flickr.com/photos/ | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
aiohttp==3.6.2 | ||
async-timeout==3.0.1 | ||
attrs==19.3.0 | ||
certifi==2020.6.20 | ||
chardet==3.0.4 | ||
idna==2.10 | ||
multidict==4.7.6 | ||
requests==2.24.0 | ||
urllib3==1.25.9 | ||
yarl==1.4.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from src.core.base.osint import OsintRunner, PossibleKeys | ||
from src.core.base.osint import BaseRunner, PossibleKeys | ||
from src.core.utils.response import ScriptResponse | ||
from src.core.utils.validators import validate_kwargs | ||
|
||
|
||
class Runner(OsintRunner): | ||
class Runner(BaseRunner): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Справедливо, но только валидатор всё равно будет валидировать OsintRunner аргументы (посмотри на строку 19 в скрипте): @validate_kwargs(PossibleKeys.KEYS)
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error: Поэтому, если используем BaseRunner, валидатор в скрипте отключаем, если OsintRunner - то оставляем. В данном случае, валидатор тогда нужно удалить (декоратор убрать). |
||
""" | ||
Basic example | ||
""" | ||
|
||
def __init__(self, logger: str = __name__): | ||
""" | ||
Re-init base class instance | ||
|
@@ -25,4 +24,6 @@ def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error | |
:param kwargs: kwargs | ||
:return: ScriptResponse message | ||
""" | ||
return ScriptResponse.success(message="Script finished") | ||
return ScriptResponse.success( | ||
message="Script finished" | ||
) |
Uh oh!
There was an error while loading. Please reload this page.