Skip to content

Commit

Permalink
Added login module + saving access file in a specific path.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaarghhh committed Jan 1, 2024
1 parent b49ea97 commit 8bcfb06
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A TON of privacy v0.1.8
# A TON of privacy v0.1.9
## ATOP - A tool for investigating TON network and its NFT.

"A TON of Privacy" formally called ATOP ... is a tool for conducting OSINT investigations on TON (Telegram 🙃) NFTs.
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

setup(
name="atop",
version="0.1.8-1",
version="0.1.9",
author="Aaarghhh",
author_email="[email protected]",
packages=["atop", "atop.modules"],
package_dir={'':'src'},
package_dir={"": "src"},
include_package_data=True,
entry_points={"console_scripts": ["a-ton-of-privacy = atop.atop:run"]},
url="https://github.com/aaarghhh/a_TON_of_privacy",
Expand All @@ -30,7 +30,7 @@
"rsa>=4.9",
"soupsieve>=2.5",
"Telethon==1.30.3",
"urllib3>=2.0.5"
"urllib3>=2.0.5",
],
zip_safe=False,
)
16 changes: 12 additions & 4 deletions src/atop/atop.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def print_banner():
░░ ░░ ░ ▒ ░ ░░ ░ ▒ ░ ▒ ▒ ░░
░ ░ ░ ░ ░░ ░ ░ ░
░ ░ ░ ░
v 0.1.8 """
v 0.1.9 """
+ Style.RESET_ALL
)

Expand Down Expand Up @@ -538,8 +538,8 @@ def start_searching(self):
self.pivot_ens()

@staticmethod
def telegram_generate_session():
TelegramHelper.generate_string_session()
def telegram_generate_session(session_path=None):
TelegramHelper.generate_string_session(session_path)


def run():
Expand Down Expand Up @@ -602,6 +602,11 @@ def run():
required=False,
help="[?] where to store profile pics ...",
)
parser.add_argument(
"--sessionpath",
required=False,
help="[?] where to store or dump the sesssion string, this an optional parameter, it will printed in stdout without it ...",
)
try:
print_banner()
args = parser.parse_args()
Expand All @@ -611,7 +616,10 @@ def run():
exit(0)

if args.login:
Ton_retriever.telegram_generate_session()
session_path = None
if args.sessionpath:
session_path = args.sessionpath
Ton_retriever.telegram_generate_session(session_path=session_path)
exit(0)
else:
ton_ret = Ton_retriever(
Expand Down
30 changes: 23 additions & 7 deletions src/atop/modules/telegramhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from telethon.sessions import StringSession
from atop.modules.const import user_agent
from atop.modules.util import Util

import requests
import random
Expand All @@ -27,7 +28,7 @@ class TelegramHelper:
_sessionstring = None

@staticmethod
def generate_string_session():
def generate_string_session(path):
api_id = input(" [!] Please enter your API ID:\n")
api_hash = input(" [!] Please enter your API Hash:\n")
phone_number = input(" [!] Please enter your phone number:\n")
Expand All @@ -44,7 +45,22 @@ def generate_string_session():
else:
_api_id = int(api_id)
with TelegramClient(StringSession(), _api_id, api_hash) as client:
print(client.session.save())
saved = False
if path and path != "":
if Util.is_pathname_valid(path):
sessionstring = client.session.save()
with open(path, "w+") as f:
f.write("API_ID=" + api_id + "\n")
f.write("API_HASH=" + api_hash + "\n")
f.write("PHONE_NUMBER=" + phone_number + "\n")
f.write("SESSION_STRING=" + sessionstring + "\n")
print(f" [!] Sessionstring saved to {path}")
saved = True
else:
print(" [-] Path is not valid.")
return -1
if not saved:
print(client.session.save())
return 0

@staticmethod
Expand Down Expand Up @@ -134,7 +150,9 @@ def create_client(self):
)
self._client.connect()
if not self._client.is_user_authorized():
print(f"[-] TELEGRAM ISN'T AUTHENTICATE PLS RECREATE A SESSIONSTRING...")
print(
f"[-] TELEGRAM ISN'T AUTHENTICATE PLS RECREATE A SESSIONSTRING..."
)
exit(1)
else:
self._client = TelegramClient(
Expand Down Expand Up @@ -304,9 +322,7 @@ def check_telegram_number(self, _number_to_check):
if not username:
username = "N/A"
if username != "N/A":
telegram_details = self.check_telegram_nickname(
"@" + username
)
telegram_details = self.check_telegram_nickname("@" + username)
try:
try:
self._client(
Expand All @@ -333,7 +349,7 @@ def check_telegram_number(self, _number_to_check):

except TypeError as e:
print(
f" | TypeError: {e}. --> The error might have occured due to the inability to delete the {_number_to_check} from the contact list."
f" | TypeError: {e}. --> The error might have occurred due to the inability to delete the {_number_to_check} from the contact list."
)
except:
raise
63 changes: 63 additions & 0 deletions src/atop/modules/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import os
import sys
import errno
import math

ERROR_INVALID_NAME = 123


class Util:
def __init__(self):
pass

@staticmethod
def is_pathname_valid(pathname: str) -> bool:
"""
`True` if the passed pathname is a valid pathname for the current OS;
`False` otherwise.
"""
try:
if not isinstance(pathname, str) or not pathname:
return False

_, pathname = os.path.splitdrive(pathname)
root_dirname = (
os.environ.get("HOMEDRIVE", "C:")
if sys.platform == "win32"
else os.path.sep
)
assert os.path.isdir(root_dirname)
root_dirname = root_dirname.rstrip(os.path.sep) + os.path.sep

for pathname_part in pathname.split(os.path.sep):
try:
os.lstat(root_dirname + pathname_part)
except OSError as exc:
if hasattr(exc, "winerror"):
if exc.winerror == ERROR_INVALID_NAME:
return False
elif exc.errno in {errno.ENAMETOOLONG, errno.ERANGE}:
return False
except TypeError as exc:
return False
else:
return True

@staticmethod
def get_file_size(self, path):
return os.path.getsize(path)

@staticmethod
def get_file_size_human(self, path):
size = self.get_file_size(path)
return self.convert_size(size)

@staticmethod
def convert_size(self, size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size_bytes, 1024)))
p = math.pow(1024, i)
s = round(size_bytes / p, 2)
return "%s %s" % (s, size_name[i])

0 comments on commit 8bcfb06

Please sign in to comment.