Skip to content

Commit

Permalink
Updating all to tgback v3.0 beta(2.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvchain committed Jul 14, 2020
1 parent 8373aca commit 9d53b79
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
7. **Minor improvements of navigation and much bugfixes!**
<br></br>

`v3.0 beta(2.0):` Initial commit
`v3.0 beta(2.0):` Initial commit

`v3.0 beta(2.1):` Fix of [**bug**](https:github.com/NotStatilko/tgback/issues/4) in `1—1` mode.

###### _Backups of the new version are not compatible with the old ones, and vice versa. You can still use beta (1.x), but if you have the opportunity, please upgrade to the latest version._
`v3.0 beta(2.2):` Issues: [#5](https://github.com/NotStatilko/tgback/issues/5), [#6](https://github.com/NotStatilko/tgback/issues/6) and [#7](https://github.com/NotStatilko/tgback/issues/7).

###### _Backups of the new version are not compatible with the old ones, and vice versa. You can still use beta(1.x), but if you have the opportunity, please upgrade to the latest version._
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TelegramBackup v3.0 beta(2.1)
# TelegramBackup v3.0 beta(2.2)
###### _Don't forget to look at [changelog](CHANGELOG.md)!_

**TelegramBackup** — console application created to backup Telegram accounts. Due to the features of Telegram, you will **not be able** to log into your account if you lose access to the phone number. **Tgback** provides the ability to create an _alternative session_ (as if you were logging in from another device) and change the number on which the account is linked.
Expand All @@ -7,7 +7,7 @@

## Download and setting
### Windows
You can download `.exe` file [**from Telegram**](https://t.me/nontgback) or [**from Google Drive**](https://drive.google.com/folderview?id=1-x6Yxp3s5-SOAHTvCHdxkAsYP011jsDz).
You can download `.exe` file [**from Telegram**](https://t.me/nontgback) or [**from Google Drive**](https://drive.google.com/folderview?id=1-x6Yxp3s5-SOAHTvCHdxkAsYP011jsDz).
### Linux
If you are outside of Windows and want to use **TelegramBackup** - you need to install all dependencies. For the program to work correctly, you need to have [Python 3.6+](https://python.org), [ZBar](http://zbar.sourceforge.net) and after that, run
```bash
Expand All @@ -20,11 +20,11 @@
To create a backup you need to select **first mode**

![main page](https://telegra.ph/file/5ba889aff30a503e32f80.png)

And choose the way you will create it.

![backup](https://telegra.ph/file/0424f7419d2cb13ceffbd.png)

You can enter everything manually, or create a special `tgback-config` file. If the first method is inconvenient for you, create a text file and fill it out using this template:
```
phone_number; telegram_password; backup_password; backup_filename
Expand All @@ -36,14 +36,14 @@
After all operations, you will receive a QR code and `.tgback` file. Please **check your backups** first for validity, since TelegramBackup is still in beta phase.

## Backup refresh and number replacement
Due to recently discovered [problem](https://github.com/NotStatilko/tgback/issues/2), which prompted me to sit down for a code rewrite, backups need to be updated periodically, so that the session doesn't turn off automatically due to inactivity. At the moment once every two months. We can probably increase it to six months, but testing is needed.
Due to recently discovered [problem](https://github.com/NotStatilko/tgback/issues/2), which prompted me to sit down for a code rewrite, backups need to be updated periodically, so that the session doesn't turn off automatically due to inactivity. At the moment once every two months. We can probably increase it to six months, but testing is needed.

**TelegramBackup** automatically creates a reminder message, so you will be notified a week before the deadline. You can refresh the backup and change the number in the mode under number **2**. After refreshing the backup, you will receive a new updated QR code and `.tgback` file. Old backups will remain working, but they will show the wrong amount of time before the expiration of the validity period.

## A bit about security
The backups you created **shouldn't** be active since the last update. If you notice something suspicious – **immediately** disconnect your backup session. After disconnecting a session, backups that are attached to it **will be destroyed**.
The backups you created **shouldn't** be active since the last update. If you notice something suspicious – **immediately** disconnect your backup session. After disconnecting a session, backups that are attached to it **will be destroyed**.

Although TelegramBackup allows you to change only the phone number, the backups themselves store **the key to the session**, upon receipt of which the attacker will receive **FULL** control over your account. You must choose complex passwords.
Although TelegramBackup allows you to change only the phone number, the backups themselves store **the key to the session**, upon receipt of which the attacker will receive **FULL** control over your account. You must choose complex passwords.

Also, no security audits have been conducted by competent people, so I **do not guarantee** complete cryptographic strength. If you have any comments, open issue. I am attaching a QR-backup of my account here, try to hack if you want!

Expand Down
37 changes: 22 additions & 15 deletions TelegramBackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,23 @@ def clear_terminal():
async def main():
try:
async def request_confirmation_code(request_coroutine, phone, rcpc=False) -> tuple:
request_code = True
while True:
clear_terminal()
print('@ Requesting confirmation code...')
if request_code:
print('@ Requesting confirmation code...')

if rcpc:
code_hash = await request_coroutine(phone)
else:
code_hash = await request_coroutine()

# code_hash is for request_change_phone_code (rcpc)
if rcpc:
code_hash = await request_coroutine(phone)
else:
code_hash = await request_coroutine()

clear_terminal()
request_time = f'{strftime("%H:%M:%S")} ({strftime("%I:%M:%S %p")})'
# code_hash is for request_change_phone_code (rcpc)
clear_terminal()

print(f'@ Please wait for message or call with code ({phone})')
print(f'@ Last request sended at {strftime("%H:%M:%S")}\n')
print(f'@ Last request sended at {request_time}\n')
print('> 1) I received the code')
print('>> 2) I haven\'t recieved code')
print('>>> 3) Return to main page')
Expand All @@ -64,9 +66,15 @@ async def request_confirmation_code(request_coroutine, phone, rcpc=False) -> tup
code = input('> Confirmation Code: ')
break

elif mode == '2':
request_code = True

elif mode == '3':
await main()

else:
request_code = False

clear_terminal()
return (code, code_hash)

Expand Down Expand Up @@ -116,7 +124,6 @@ async def request_confirmation_code(request_coroutine, phone, rcpc=False) -> tup
print('@ Trying to connect with Telegram...')
await account.login(password,code)


while True:
clear_terminal()
tgback_filename = input('> Backup filename: ')
Expand All @@ -143,7 +150,7 @@ async def request_confirmation_code(request_coroutine, phone, rcpc=False) -> tup
filename = await account.backup(tgback_password, tgback_filename)

clear_terminal()
input(f'@ Successfully encrypted and backuped! ({filename})')
input(f'@ Successfully encrypted and backuped! ("{filename})"')
await main()

except (KeyboardInterrupt, EOFError):
Expand All @@ -166,9 +173,9 @@ async def request_confirmation_code(request_coroutine, phone, rcpc=False) -> tup
except KeyboardInterrupt:
await main()

except PhoneNumberInvalidError:
except (PhoneNumberInvalidError, TypeError):
clear_terminal()
input(f'@: ! The provided number ({phone}) is invalid')
input(f'@: ! The provided number ("{phone}") is invalid. Try again.')
await main()

elif selected_section == '2': # Config file
Expand Down Expand Up @@ -238,9 +245,9 @@ async def request_confirmation_code(request_coroutine, phone, rcpc=False) -> tup
print(f'@ Password is hashing, please wait {HASHING_TIME}...')

filename = await account.backup(config[2],config[3])

clear_terminal()
input(f'@ Successfully encrypted and backuped! ({filename})')
input(f'@ Successfully encrypted and backuped! ("{filename})"')

return_to_main = True; break

Expand Down
15 changes: 5 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
pillow==7.1.2

pyaes==1.6.1

reedsolo==1.5.3

pyzbar==0.1.8

telethon==1.14.0

pillow==7.1.2
pyaes==1.6.1
reedsolo==1.5.3
pyzbar==0.1.8
telethon==1.14.0
qrcode==6.1
12 changes: 6 additions & 6 deletions tgback_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
hash_functions.sort(key=repr)
hash_functions *= 20

VERSION = 'v3.0 beta(2.1)'
VERSION = 'v3.0 beta(2.2)'
TelegramClient.__version__ = VERSION

RSC = RSCodec(222)
Expand Down Expand Up @@ -187,7 +187,7 @@ async def backup(self, password: bytes, filename: str=None) -> str:
await self._TelegramClient.send_file('me',
open(filename + '.png','rb'),
caption=self.__notify.format(
'created', filename, 'Created', ctime(),
'created', filename, 'Created', ctime(),
ctime(backup_death_at),'new ', VERSION
)
)
Expand Down Expand Up @@ -218,18 +218,18 @@ async def refresh_backup(self, decoded_restored: list, tgback_file_path: str) ->
'updated', tgback_file_path, 'Updated',
ctime(), ctime(backup_death_at),'', VERSION
)
)
)
backup_name = path_split(tgback_file_path)[-1]
await self._TelegramClient.send_message('me',
f'Hello! Please, update your backup `{backup_name}`\n\n**One week left!!**',
schedule=timedelta(seconds=4_752_000)
)
def dump(encoded_restored: list, tgback_file_path: str):
encrypted = encrypt_restored(encoded_restored)
ext = '.png' if not tgback_file_path[-4:] == '.png' else ''

ext = '.png' if not tgback_file_path[-4:] == '.png' else ''
makeqrcode(encrypted).save(tgback_file_path + ext)

tgback_file_path = tgback_file_path[:-4] if not ext else tgback_file_path
with open(tgback_file_path,'wb') as f:
f.write(reedsolo_encode(encrypted))
Expand Down

0 comments on commit 9d53b79

Please sign in to comment.