nvd commited on
Commit
14305de
·
verified ·
1 Parent(s): abd1eed

Update bot.py

Browse files
Files changed (1) hide show
  1. bot.py +5 -10
bot.py CHANGED
@@ -8,7 +8,7 @@ import aiohttp
8
  import httpx
9
  import logging
10
  import tempfile
11
- import zipfile
12
  from urllib.parse import unquote
13
 
14
  # ---------- Logging ----------
@@ -189,16 +189,11 @@ async def download_file(url, dest_path):
189
  def create_password_zip(apk_path, zip_path, password="bale"):
190
  """
191
  Creates a password‑protected ZIP archive containing the APK.
192
- Uses standard library zipfile with ZipCrypto.
193
  """
194
- with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zf:
195
  arcname = os.path.basename(apk_path)
196
- # Read the APK and write it with password
197
- with open(apk_path, 'rb') as fapk:
198
- data = fapk.read()
199
- zinfo = zipfile.ZipInfo(arcname)
200
- zinfo.compress_type = zipfile.ZIP_DEFLATED
201
- zf.writestr(zinfo, data, pwd=password.encode())
202
  logger.info(f"🔐 Created password‑protected ZIP: {zip_path}")
203
 
204
  # ---------- Message / Callback handlers ----------
@@ -271,7 +266,7 @@ async def handle_callback(callback: dict):
271
  base_name = original_filename[:-4] # remove ".apk"
272
  zip_filename = base_name + ".zip"
273
  caption = "🔐 APK inside password‑protected ZIP.\nPassword: `bale`"
274
- await send_message(chat_id, f"🔐 Compressing APK into password‑protected ZIP...")
275
  else:
276
  zip_filename = None
277
  caption = "Here you go!"
 
8
  import httpx
9
  import logging
10
  import tempfile
11
+ import pyzipper
12
  from urllib.parse import unquote
13
 
14
  # ---------- Logging ----------
 
189
  def create_password_zip(apk_path, zip_path, password="bale"):
190
  """
191
  Creates a password‑protected ZIP archive containing the APK.
192
+ Uses pyzipper with AES encryption, passing password directly to write().
193
  """
194
+ with pyzipper.AESZipFile(zip_path, 'w', compression=pyzipper.ZIP_DEFLATED) as zf:
195
  arcname = os.path.basename(apk_path)
196
+ zf.write(apk_path, arcname=arcname, password=password.encode())
 
 
 
 
 
197
  logger.info(f"🔐 Created password‑protected ZIP: {zip_path}")
198
 
199
  # ---------- Message / Callback handlers ----------
 
266
  base_name = original_filename[:-4] # remove ".apk"
267
  zip_filename = base_name + ".zip"
268
  caption = "🔐 APK inside password‑protected ZIP.\nPassword: `bale`"
269
+ await send_message(chat_id, "🔐 Compressing APK into password‑protected ZIP...")
270
  else:
271
  zip_filename = None
272
  caption = "Here you go!"