Skip to content

Add script: region check #5

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

Merged
merged 3 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/base/osint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class PossibleKeys:
Defines default values for the function arguments (kwargs, named args)
"""

KEYS = ["email", "username", "fullname", "vk_api_key"]
KEYS = ["email", "username", "fullname", "vk_api_key", "phone"]


class OsintRunner(BaseRunner):
Expand Down
50 changes: 50 additions & 0 deletions src/scripts/osint/region_check/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3

import requests

from src.core.base.osint import OsintRunner, PossibleKeys
from src.core.utils.response import ScriptResponse
from src.core.utils.validators import validate_kwargs


class Runner(OsintRunner):
def __init__(self, logger: str = __name__):
super(Runner, self).__init__(logger)

@staticmethod
def __phone_to_region(phone: str = "Unknown") -> str:
"""
Region recognition using the phone number
:param phone: phone number to check
:return: information about the region and the operator
"""
response = requests.get(
"https://eduscan.net/help/phone_ajax.php", params={"num": phone}
)
return response.text

@validate_kwargs(PossibleKeys.KEYS)
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error:
"""
Main runner function for the script
:param args: args from core runner
:param kwargs: kwargs from core runner
:return: ScriptResponse message
"""
try:
result = self.__phone_to_region(phone=kwargs.get("phone"))
except Exception:
return ScriptResponse.error(result=None, message="Something went wrong!")
result = result.split("~")
if result[1] != "0":
return ScriptResponse.success(result=None, message="Sorry, no such number!")
return ScriptResponse.success(
result=(result[-1], result[-2]),
message=f"Found region: {result[-1]} | found operator: {result[-2]} | for phone number {result[0]}",
)


if __name__ == "__main__":
script_module = Runner()
script_result = script_module.run()
print(script_result)
5 changes: 5 additions & 0 deletions src/scripts/osint/region_check/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
certifi==2020.6.20
chardet==3.0.4
idna==2.10
requests==2.24.0
urllib3==1.25.9