Skip to content

Commit

Permalink
Bug fixes and help page
Browse files Browse the repository at this point in the history
  • Loading branch information
NotStatilko committed Feb 4, 2021
1 parent 8b1547a commit 111adea
Showing 1 changed file with 165 additions and 14 deletions.
179 changes: 165 additions & 14 deletions TelegramBackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ async def request_confirmation_code(request_coroutine, phone: str, account: Tele
about_qr = '' if qr_available else '(not available)'
print(
f''' - TelegramBackup {VERSION} (bit.ly/tgback) -\n\n'''
'''> 1) Backup Telegram account\n'''
'''>> 2) Open .tgback backup\n'''
'''>>> 3) Exit from TelegramBackup'''
'''> 0) Switch to the help page\n'''
'''>> 1) Backup Telegram account\n'''
'''>>> 2) Open .tgback backup\n'''
'''>>>> 3) Exit from TelegramBackup'''
'''\n\n% Press Ctrl+C to back here'''
)
selected_section = input('\n@ Input: ')
if selected_section and selected_section in '123':
if selected_section and selected_section in '0123':
break

return_to_main = False
Expand All @@ -99,6 +100,147 @@ async def request_confirmation_code(request_coroutine, phone: str, account: Tele
await main()

clear_terminal()
if selected_section == '0':
while True:
clear_terminal()
print(
'''@ Welcome You!\n\n'''
''' 01) Why is it needed?\n'''
''' 02) How it works?\n'''
''' 03) Can tgback back up my messages?\n'''
''' 04) What information do you store?\n'''
''' 05) Do you transfer any of my data?\n'''
''' 06) Why we are need to refresh backups?\n'''
''' 07) Can i use tgback on my Android?\n'''
''' 08) What encryption is used in tgback?\n'''
''' 09) What version do you prefer me to use?\n'''
''' 10) Passwords isn\'t visible. Why?\n'''
''' 11) QR features is unavailable. Why?\n'''
''' 12) Can i use tgback with TOR network?\n'''
''' 13) Tell me more about backup\'s refreshing and disconnecting.\n'''
''' 14) I found a bug or have an idea. How can i help?\n'''
''' 15) I don\'t trust you. Any alternatives?\n\n'''
'''00) Back to the main page\n'''
)
mode = input('@ Input: ')
mode = mode if not mode else mode.zfill(2)
clear_terminal()

if mode == '00':
break

elif mode == '01':
print(
'''01) Why is it needed?\n\n'''
'''o Telegram is designed so that you cannot enter your account '''
'''without receiving a code. This code can be obtained in two ways: '''
'''by receiving the code in Telegram or on your phone. The first method '''
'''is available only if you are logged into your account from another device '''
'''(for example, the desktop version). If you are logged into your account on only '''
'''one device (or not logged at all), then if you lose access to your SIM card, you '''
'''will also lose access to your Telegram account forever.'''
)
elif mode == '02':
print(
'''02) How it works?\n\n'''
'''o Telegram has an open client API on which official clients are built. Anyone who knows '''
'''one of the many programming languages can create their own client. Tgback can be called a '''
'''very stripped-down client. This program can only log into the account and change the number. '''
'''When you log in to your account, Telegram sends you a special session token, which is used to manage '''
'''your account. This rule works on all clients, including official ones. Tgback saves this token '''
'''along with metadata (for example, your account's username or the time when the backup will be off) '''
'''and encrypts it to a file and QR. Whenever you need, you can decrypt this backup and change the phone '''
'''number (if you have lost access to the old one) or enter the TelegramDesktop. In fact, Tgback adds an '''
'''alternative login method. Your session token is not transferred anywhere and all code is open. However, '''
'''beware, the only safe sources you can get Tgback from are these:\n\n '''
'''o https://github.com/NotStatilko/tgback (bit.ly/tgback)\n o https://t.me/nontgback'''
)
elif mode == '03':
print(
'''03) Can tgback back up my messages?\n\n'''
'''o No, tgback allows you only create backups from which you can login or change your phone number. '''
'''However, session token (which tgback backups store) can allow get FULL access over your account. '''
'''So don\'t use very simple passwords, such as "qwerty" or "password1234".'''
)
elif mode == '04':
print(
'''04) What information do you store?\n\n'''
'''o Any at all. Tgback backups itself store token session, account username, account id, '''
'''time when backup will be disconnected and other data needed by tgback. Nothing will be transferred. '''
'''To get more details you can visit official GitHub page on bit.ly/tgback.'''
)
elif mode == '05':
print('05) Do you transfer any of my data?\n\no No.')

elif mode == '06':
print(
'''06) Why we are need to refresh backups?\n\n'''
'''o Because Telegram (seems to) disconnect inactive sessions. At the time of discovery this problem, '''
'''the disabled backup had not been refreshed for six months, but this has not been sufficiently researched. '''
'''At the moment, the backup needs to be refreshed every two months, and you recieve a delayed message '''
'''one week in advance as a reminder. Please note that Tgback doesn't turn off backups by itself after two '''
'''months, and you will probably still have about two more months. Disconnection of sessions is performed by the Telegram server.'''
)
elif mode == '07':
print(
'''07) Can i use tgback on my Android?\n\n'''
'''o Sure, you can use Termux which doesn\'t require root. Check out installation steps for Linux on official '''
'''tgback\'s Github page: bit.ly/tgback'''
)
elif mode == '08':
print(
'''08) What encryption is used in tgback?\n\n'''
'''o Started from 4.0 version of tgback, the AES-256 CBC with Scrypt (1 GB of RAM) as PBKDF.'''
)
elif mode == '09':
print(
'''09) What version do you prefer me to use?\n\n'''
'''o Latest which >= v4.0. Others is considered as not secure.'''
)
elif mode == '10':
print(
'''10) Passwords isn't visible. Why?\n\n'''
'''o The password is not displayed by default but you enter it. If you have any problems '''
'''with creating a backup, you can use the config-file (mode 1->2). Create an empty file and fill it with this template:\n\n'''
''' o "phone_number; telegram_password; backup_password; backup_filename"'''
)
elif mode == '11':
print(
'''11) QR features is unavailable. Why?\n\n'''
'''If you on linux then make sure that you already *installed the LibZBar package. If you are on other system, '''
'''then open issue on official tgback *repository.\n\n o sudo apt install libzbar0\n o https://github.com/NotStatilko/tgback'''
)
elif mode == '12':
print('12) Can i use tgback with TOR network?\n\no Sure, use torsocks or torify for this.')

elif mode == '13':
print(
'''13) Tell me more about backup's refreshing and disconnecting\n\n'''
'''o After backup refreshing you get new backups, but you can also use the old ones to log '''
'''into your account or change the number, they will just show the wrong time before the date when '''
'''the backup needs to be refreshed. To destroy a backup, it\'s not enough to delete only the file, you need '''
'''to disconnect your backup session. This can be done in two ways: either through the tgback itself or via Telegram. '''
'''After disconnecting the session in any way, all copies of backups associated with this session cease '''
'''to be active. Also, please note that changing the password with which you encrypted the backup only changes '''
'''the password for the backup that you opened. If the attacker somehow received the password for your backup, '''
'''immediately log in to Telegram and disconnect all sessions that you do not recognize as your own. '''
)
elif mode == '14':
print(
'''14) I found a bug or have an idea. How can i help?\n\n'''
'''o You are always welcome on tgback\'s GitHub! Open issues or send pull-requests!\n\n '''
'''o https://github.com/NotStatilko/tgback (bit.ly/tgback)'''
)
elif mode == '15':
print(
'''5) I don't trust you. Any alternatives?\n\n'''
'''o You can back up the Telegram\'s tdata folder or log in to more than one device. '''
'''You can also give a reaction to *this commit and maybe Telegram will add TOTP codes.\n\n '''
'''o https://github.com/telegramdesktop/tdesktop/issues/10253'''
)
else: continue
input('\n@ Press Enter to back ')

if selected_section == '1':
while True:
clear_terminal()
Expand Down Expand Up @@ -135,15 +277,16 @@ async def request_confirmation_code(request_coroutine, phone: str, account: Tele
else:
break
clear_terminal()
print('@ To create backup you need at least 1GB free for now.\n')
tgback_password = getpass('>> Backup password: ')
c_tgback_password = getpass('>>> Re-enter password: ')
while True:
print('@ To create backup you need at least 1GB free for now.\n')
tgback_password = getpass('> Backup password: ')
c_tgback_password = getpass('>> Re-enter password: ')

clear_terminal()
if tgback_password != c_tgback_password:
clear_terminal()
print('@: ! Password mismatch! Try again.\n')
tgback_password = getpass('> Backup password: ')
c_tgback_password = getpass('>> Re-enter password: ')
elif not tgback_password:
print('@: ! Password can\'t be empty.\n')
else:
break

Expand Down Expand Up @@ -295,9 +438,14 @@ async def request_confirmation_code(request_coroutine, phone: str, account: Tele
input(f'@: ! Can\'t find .tgback {backup_type}. Check entered path.')
await main()
else:
clear_terminal()
print('@ To decrypt backup you need at least 1GB free for now.\n')
tgback_password = getpass(f'>> Password to .tgback {backup_type}: ')
while True:
clear_terminal()
print('@ To decrypt backup you need at least 1GB free for now.\n')
tgback_password = getpass(f'>> Password to .tgback {backup_type}: ')
if not tgback_password:
clear_terminal()
input('@: ! Password can\'t be empty. Try again or press Ctrl+C.')
else: break
clear_terminal()
print('@ Creating key with your password...')
try:
Expand Down Expand Up @@ -439,10 +587,13 @@ async def request_confirmation_code(request_coroutine, phone: str, account: Tele
if new_password != c_new_password:
clear_terminal()
input('@: ! Password mismatch. Please try again.')
elif not new_password:
clear_terminal()
input('@: ! Password can\'t be empty. Try again.')
else:
clear_terminal()
print('@ Creating key with your password...')
restored[0] = TgbackAES(b'')._hash_password(new_password.encode()).digest()
restored[0] = TgbackAES(b'0')._make_scrypt_key(new_password.encode()).digest()
clear_terminal()
print('@ Refreshing...')
await account.refresh_backup(restored, path_to_tgback)
Expand Down

0 comments on commit 111adea

Please sign in to comment.