Skip to content

Commit

Permalink
Iknowwhatyoudownload (#24)
Browse files Browse the repository at this point in the history
* added torrent module

* underscores bugfix

* added docstrings

* updated requirements

* changed directory

* Added required changes

* Fix base runners

* Remove API key, fix main runner

* Linting with Black

Co-authored-by: omarkelov <36790281+omarkelov@users.noreply.github.com>
Co-authored-by: Anton Nikolaev <regwebghost@yandex.ru>
  • Loading branch information
3 people authored Jul 29, 2020
1 parent a4e67e6 commit 6810c8a
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/core/base/osint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class PossibleKeys:
Defines default values for the function arguments (kwargs, named args)
"""

KEYS = ["email", "username", "fullname", "vk_api_key", "phone", "region"]
# fmt: off
KEYS = ["email", "username", "fullname", "vk_api_key", "phone"]
# fmt: on


class OsintRunner(BaseRunner):
Expand Down
2 changes: 1 addition & 1 deletion src/core/base/recon.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 = ["host", "hostname", "ip", "url"]
KEYS = ["host", "hostname", "ip", "url", "torrent_api_key"]


class ReconRunner(BaseRunner):
Expand Down
5 changes: 5 additions & 0 deletions src/scripts/recon/torrent/__init__.py
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))
12 changes: 12 additions & 0 deletions src/scripts/recon/torrent/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3

from pprint import pprint
from sys import argv
from requests import get
from src.core.utils.module import run_module
from .module import Runner

result = run_module(
Runner, args=argv, arg_name="ip", arg_default=get("https://ifconfig.me/").text
)
pprint(result)
39 changes: 39 additions & 0 deletions src/scripts/recon/torrent/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3

from requests import get

from src.core.base.recon import ReconRunner, PossibleKeys
from src.core.utils.response import ScriptResponse
from src.core.utils.validators import validate_kwargs


class Defaults:
API_KEY = "API_KEY_HERE"


class Runner(ReconRunner):
"""
Runner class is used for parsing torrents by ip.
"""

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

@validate_kwargs(PossibleKeys.KEYS)
def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error:
"""
Parses torrents by ip.
:param args: args from core runner.
:param kwargs: kwargs from core runner.
:return: ScriptResponse with dictionary of torrents.
"""
ip = kwargs.get("ip")
api_key = kwargs.get("torrent_api_key", Defaults.API_KEY)
if not ip:
return ScriptResponse.error(message="No IP was provided")
response = get(
f"https://api.antitor.com/history/peer/?ip={ip}&key={api_key}"
).json()
return ScriptResponse.success(
message=f"Script finished for {ip}", result=response
)
4 changes: 4 additions & 0 deletions src/scripts/recon/torrent/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
chardet==3.0.4
idna==2.10
requests==2.24.0
urllib3==1.25.9

0 comments on commit 6810c8a

Please sign in to comment.