• 🌙 Community Spirit

    Ramadan Mubarak! To honor this month, Crax has paused NSFW categories. Wishing you peace and growth!

Login:Pass ULP !!! SCRIPT FOR APK OBFUSCATION !!! BYPASS PLAY PROTECT (1 Viewer)

Currently reading:
 Login:Pass ULP !!! SCRIPT FOR APK OBFUSCATION !!! BYPASS PLAY PROTECT (1 Viewer)

Simple Email:Pass Combolist all domains.
URL:Login:Pass
Recently searched:

dfdsf344

Member
LV
1
Joined
Sep 5, 2025
Threads
3
Likes
3
Awards
3
Credits
1,289©
Cash
0$
this is a real world script that can be used to bypass play protect security

SCRIPT:
import os
import sys
import zipfile
import argparse
import tempfile
import shutil
import hashlib
from Crypto.Cipher import AES
from Crypto.Protocol.KDF import HKDF
from Crypto.Random import get_random_bytes
from Crypto.Hash import SHA256, SHA512
import subprocess
import json

# استيراد اختياري لمكتبة pyzipper لدعم ZipCrypto
try:
import pyzipper # type: ignore
except Exception: # pragma: no cover
pyzipper = None

class AdvancedAPKProtector:
def __init__(self):
self.temp_dir = tempfile.mkdtemp()
self.encryption_keys = []
self.obfuscation_map = {}
self.tamper_detection_seed = get_random_bytes(32)
self.anti_debug_enabled = True
self.resources_protected = False
self.key_salts = None
self.metadata = {
"dex": [],
"resources": [],
"salts": {}
}
self.zipcrypto_password = None # يمكن تعيينها من CLI لإضافة طبقة ZipCrypto
self.zipcrypto_strict = False # عند تفعيله، يطلب ZipCrypto حصراً ويخطئ إن لم يتوفر

def derive_keys(self, master_password):
"""اشتقاق مفاتيح متعددة للتشفير وتخزين الأملاح"""
salts = [get_random_bytes(32) for _ in range(3)]
self.encryption_keys = [
HKDF(master_password, 32, salts[0], SHA512, 1), # لملفات DEX
HKDF(master_password, 32, salts[1], SHA512, 1), # للموارد
HKDF(master_password, 32, salts[2], SHA512, 1) # للبيانات الوصفية
]
self.key_salts = salts
self.metadata["salts"] = {
"dex": salts[0].hex(),
"res": salts[1].hex(),
"meta": salts[2].hex(),
}
return salts

def encrypt_data(self, data, key_index=0):
"""تشفير البيانات باستخدام AES-GCM (AEAD) مع إرجاع nonce + tag + ciphertext"""
key = self.encryption_keys[key_index]
nonce = get_random_bytes(12)
cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)
ciphertext, tag = cipher.encrypt_and_digest(data)
return nonce + tag + ciphertext

def protect_dex(self, dex_path):
"""حماية ملف DEX: إنشاء نسخة مشفرة داخل assets دون حذف الأصل"""
with open(dex_path, 'rb') as f:
dex_data = f.read()

encrypted_data = self.encrypt_data(dex_data, key_index=0)

# إنشاء محمل ديناميكي (غير مدمج فعليًا هنا، فقط حفظ المرجع)
loader_class = self.generate_loader_class(os.path.basename(dex_path))

# حفظ النسخة المشفرة داخل مجلد assets/encrypted
assets_enc_dir = os.path.join(self.temp_dir, 'assets', 'encrypted')
os.makedirs(assets_enc_dir, exist_ok=True)
enc_name = os.path.basename(dex_path) + '.enc'
encrypted_path = os.path.join(assets_enc_dir, enc_name)
with open(encrypted_path, 'wb') as f:
f.write(encrypted_data)

# تسجيل في البيانات الوصفية
self.metadata["dex"].append({
"original": os.path.relpath(dex_path, self.temp_dir).replace('\\', '/'),
"encrypted_asset": f"assets/encrypted/{enc_name}"
})

return loader_class, encrypted_path

def generate_loader_class(self, dex_name):
"""إنشاء فئة جافا لتحميل DEX ديناميكياً"""
class_name = f"Loader_{hashlib.sha256(dex_name.encode()).hexdigest()[:8]}"
self.obfuscation_map[dex_name] = class_name

loader_code = f"""
package com.secure.loader;

import android.content.Context;
import android.util.Log;

public class {class_name} {{
private static final String TAG = "{class_name}";

public static void load(Context context, byte[] encryptedData) {{
try {{
// 1. فك التشفير
byte[] dexData = Decryptor.decrypt(encryptedData);

// 2. تحميل DEX ديناميكياً
DexLoader.loadDex(context, dexData);

Log.i(TAG, "DEX loaded successfully");
}} catch (Exception e) {{
Log.e(TAG, "Failed to load DEX", e);
throw new RuntimeException(e);
}}
}}
}}
"""
return loader_code

def add_anti_reverse_techniques(self):
"""إضافة تقنيات مضادة للعكس الهندسي"""
techniques = [
"if(BuildConfig.DEBUG) { System.exit(0); }",
"checkDebugger();",
"checkEmulator();",
"checkRoot();",
"verifySignature();"
]

return "\n".join(techniques)

def process_resources(self):
"""إنشاء نسخ مشفرة اختيارية من الموارد داخل assets بدلاً من تعديل res مباشرة"""
if not self.resources_protected:
return
res_dir = os.path.join(self.temp_dir, 'res')
if os.path.exists(res_dir):
assets_res_dir = os.path.join(self.temp_dir, 'assets', 'protected_res')
os.makedirs(assets_res_dir, exist_ok=True)
for root, _, files in os.walk(res_dir):
for file in files:
if file.endswith(('.png', '.jpg', '.xml')):
file_path = os.path.join(root, file)
with open(file_path, 'rb') as f:
data = f.read()
encrypted_data = self.encrypt_data(data, key_index=1)
# استخدم اسمًا مستقرًا للملف المشفر داخل assets
rel_path = os.path.relpath(file_path, res_dir).replace('\\', '/')
enc_name = hashlib.sha256(rel_path.encode('utf-8')).hexdigest() + '.enc'
out_path = os.path.join(assets_res_dir, enc_name)
with open(out_path, 'wb') as outf:
outf.write(encrypted_data)
self.metadata["resources"].append({
"original_res": f"res/{rel_path}",
"encrypted_asset": f"assets/protected_res/{enc_name}"
})

def encrypt_resource(self, res_path):
"""تشفير ملف مورد معين"""
with open(res_path, 'rb') as f:
data = f.read()

encrypted_data = self.encrypt_data(data, key_index=1)

with open(res_path, 'wb') as f:
f.write(encrypted_data)

def modify_manifest(self):
"""تجاوز تعديل المانيفست لتجنب كسر AXML. يمكن تفعيله لاحقًا بأدوات مناسبة (apktool)."""
manifest_path = os.path.join(self.temp_dir, 'AndroidManifest.xml')
return os.path.exists(manifest_path)

def build_and_sign(self, output_path):
"""إعادة بناء APK وتوقيعه: zipalign ثم التوقيع (يفضل apksigner)."""
# إزالة توقيعات قديمة إن وُجدت
meta_inf_dir = os.path.join(self.temp_dir, 'META-INF')
if os.path.isdir(meta_inf_dir):
shutil.rmtree(meta_inf_dir, ignore_errors=True)

# إنشاء APK غير محاذى
unsigned_apk = os.path.join(self.temp_dir, 'unsigned.apk')
with zipfile.ZipFile(unsigned_apk, 'w', zipfile.ZIP_DEFLATED) as zipf:
for root, _, files in os.walk(self.temp_dir):
for file in files:
if file in ('unsigned.apk', 'unsigned-aligned.apk'):
continue
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, self.temp_dir)
zipf.write(file_path, arcname)

# محاذاة APK (مع تحمّل غياب zipalign)
aligned_apk = os.path.join(self.temp_dir, 'unsigned-aligned.apk')
zipalign = shutil.which('zipalign') if hasattr(shutil, 'which') else None
if zipalign:
subprocess.run([
zipalign,
'-f', '-v', '4',
unsigned_apk,
aligned_apk
], check=True)
else:
# إذا لم يتوفر zipalign، نواصل بدون محاذاة
shutil.copyfile(unsigned_apk, aligned_apk)

# التوقيع
keystore_path = os.path.join(os.path.dirname(__file__), 'secure.keystore')
if not os.path.exists(keystore_path):
self.generate_keystore(keystore_path)

apksigner = shutil.which('apksigner') if hasattr(shutil, 'which') else None
if apksigner:
cmd = [
apksigner,
'sign',
'--ks', keystore_path,
'--ks-pass', 'pass:securepass',
'--key-pass', 'pass:securepass',
'--out', output_path,
aligned_apk
]
subprocess.run(cmd, check=True)
else:
# fallback إلى jarsigner (توقيع v1)
subprocess.run([
'jarsigner',
'-verbose',
'-sigalg', 'SHA256withRSA',
'-digestalg', 'SHA-256',
'-keystore', keystore_path,
'-storepass', 'securepass',
'-keypass', 'securepass',
aligned_apk,
'securekey'
], check=True)
# نسخ aligned إلى المخرج
shutil.copyfile(aligned_apk, output_path)

return True

def generate_keystore(self, path):
"""إنشاء keystore للتوقيع إذا لم يكن موجوداً"""
subprocess.run([
'keytool',
'-genkey',
'-v',
'-keystore', path,
'-alias', 'securekey',
'-keyalg', 'RSA',
'-keysize', '2048',
'-validity', '10000',
'-storepass', 'securepass',
'-keypass', 'securepass',
'-dname', 'CN=Secure, OU=Protection, O=Security, L=Internet, ST=Cyber, C=WW'
], check=True)

def protect_apk(self, input_path, output_path, password):
"""الوظيفة الرئيسية لحماية APK"""
try:
# 1. استخراج APK
with zipfile.ZipFile(input_path, 'r') as zip_ref:
zip_ref.extractall(self.temp_dir)

# 2. اشتقاق مفاتيح التشفير
self.derive_keys(password.encode('utf-8'))

# 3. معالجة ملفات DEX
dex_files = []
for root, _, files in os.walk(self.temp_dir):
for file in files:
if file.endswith('.dex'):
dex_files.append(os.path.join(root, file))

if not dex_files:
raise ValueError("No DEX files found in APK")

for dex_path in dex_files:
loader_class, encrypted_path = self.protect_dex(dex_path)
# حفظ كود المحمل في مجلد smali
self.save_loader_class(loader_class)
# لا نحذف ملفات dex الأصلية لتجنب كسر التطبيق

# 4. حماية الموارد
self.process_resources()

# 5. تعديل AndroidManifest.xml
self.modify_manifest()

# 6. إضافة كود الحماية
self.add_protection_code()

# 6.5 كتابة بيانات وصفية إلى assets
assets_dir = os.path.join(self.temp_dir, 'assets')
os.makedirs(assets_dir, exist_ok=True)
meta_path = os.path.join(assets_dir, 'secure_meta.json')
with open(meta_path, 'w', encoding='utf-8') as mf:
json.dump(self.metadata, mf, ensure_ascii=False, indent=2)

# 6.6 طبقة ZipCrypto اختيارية: تجميع الأصول المحمية داخل أرشيف مشفر
if self.zipcrypto_password:
self.apply_zipcrypto_layer(self.zipcrypto_password)

# 7. إعادة البناء والتوقيع
self.build_and_sign(output_path)

return True

except Exception as e:
print(f"Error during protection: {str(e)}")
return False
finally:
self.cleanup()

def save_loader_class(self, java_code):
"""حفظ فئة المحمل في مجلد smali"""
smali_dir = os.path.join(self.temp_dir, 'smali', 'com', 'secure', 'loader')
os.makedirs(smali_dir, exist_ok=True)

# في الواقع يجب تحويل جافا إلى smali هنا
# هذا مثال مبسط للتوضيح فقط
with open(os.path.join(smali_dir, 'SecureLoader.smali'), 'w') as f:
f.write(".class public Lcom/secure/loader/SecureLoader;")

def add_protection_code(self):
"""إضافة كود الحماية الإضافي"""
protection_dir = os.path.join(self.temp_dir, 'smali', 'com', 'secure', 'protection')
os.makedirs(protection_dir, exist_ok=True)

# إضافة فئات الحماية المختلفة
self.add_anti_debug_code(protection_dir)
self.add_tamper_check(protection_dir)
self.add_environment_checks(protection_dir)

def add_anti_debug_code(self, protection_dir):
"""قالب بسيط لفئة مضادة للتنقيح (smali placeholder)"""
path = os.path.join(protection_dir, 'AntiDebug.smali')
if not os.path.exists(path):
with open(path, 'w', encoding='utf-8') as f:
f.write(".class public Lcom/secure/protection/AntiDebug;\n.super Ljava/lang/Object;\n")

def add_tamper_check(self, protection_dir):
"""قالب بسيط لفحص العبث (smali placeholder)"""
path = os.path.join(protection_dir, 'TamperCheck.smali')
if not os.path.exists(path):
with open(path, 'w', encoding='utf-8') as f:
f.write(".class public Lcom/secure/protection/TamperCheck;\n.super Ljava/lang/Object;\n")

def add_environment_checks(self, protection_dir):
"""قالب بسيط لفحوصات البيئة (smali placeholder)"""
path = os.path.join(protection_dir, 'EnvironmentChecks.smali')
if not os.path.exists(path):
with open(path, 'w', encoding='utf-8') as f:
f.write(".class public Lcom/secure/protection/EnvironmentChecks;\n.super Ljava/lang/Object;\n")

def apply_zipcrypto_layer(self, password: str):
"""تجميع الأصول المشفرة داخل assets/protected.zip.
- Strict: إن كان pyzipper لا يدعم ZipCrypto، نستخدم 7-Zip بوسيط -mem=ZipCrypto.
- Non-strict: نستخدم AES عبر pyzipper إن توفر، وإلا ZipCrypto إن أمكن.
"""

assets_dir = os.path.join(self.temp_dir, 'assets')
enc_dir = os.path.join(assets_dir, 'encrypted')
res_dir = os.path.join(assets_dir, 'protected_res')
meta_file = os.path.join(assets_dir, 'secure_meta.json')
out_zip = os.path.join(assets_dir, 'protected.zip')

# إذا كان النمط صارمًا ونحتاج ZipCrypto تحديدًا
if self.zipcrypto_strict:
# محاولة pyzipper بصرامة ZipCrypto
if pyzipper is not None and hasattr(pyzipper, 'ZIP_CRYPTO'):
ZipClass = pyzipper.ZipFile
with ZipClass(out_zip, 'w', compression=zipfile.ZIP_DEFLATED, encryption=pyzipper.ZIP_CRYPTO) as zf:
zf.setpassword(password.encode('utf-8'))
if hasattr(zf, 'setencryption'):
zf.setencryption(pyzipper.ZIP_CRYPTO)
# dex
if os.path.isdir(enc_dir):
for root, _, files in os.walk(enc_dir):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, assets_dir).replace('\\', '/')
zf.write(file_path, arcname)
# res
if os.path.isdir(res_dir):
for root, _, files in os.walk(res_dir):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, assets_dir).replace('\\', '/')
zf.write(file_path, arcname)
# meta
if os.path.isfile(meta_file):
zf.write(meta_file, 'secure_meta.json')
else:
# محاولة استخدام 7-Zip
sevenz = shutil.which('7z') or shutil.which('7z.exe')
if sevenz is None:
# مسارات شائعة على ويندوز
common_paths = [
r"C:\\Program Files\\7-Zip\\7z.exe",
r"C:\\Program Files (x86)\\7-Zip\\7z.exe",
]
for p in common_paths:
if os.path.isfile(p):
sevenz = p
break
if sevenz is None:
raise RuntimeError(
"That encryption method is not supported: لا يتوفر ZipCrypto بالبايثون، و7-Zip غير مثبت"
)

# نبني قائمة العناصر المراد أرشفتها من داخل مجلد assets
args = [sevenz, 'a', '-tzip', f'-p{password}', '-mem=ZipCrypto', 'protected.zip']
candidates = []
if os.path.isdir(enc_dir):
candidates.append('encrypted')
if os.path.isdir(res_dir):
candidates.append('protected_res')
if os.path.isfile(meta_file):
candidates.append('secure_meta.json')
if not candidates:
# لا يوجد شيء لنضعه في الأرشيف
return
args.extend(candidates)

subprocess.run(args, check=True, cwd=assets_dir)

else:
# غير صارم: استخدم AES إن توفر، وإلا ZipCrypto إن أمكن، وإلا 7-Zip
if pyzipper is None:
raise RuntimeError("pyzipper غير مثبت. رجاءً ثبّته: pip install pyzipper")

if hasattr(pyzipper, 'AESZipFile') and hasattr(pyzipper, 'WZ_AES'):
with pyzipper.AESZipFile(out_zip, 'w', compression=zipfile.ZIP_DEFLATED, encryption=pyzipper.WZ_AES) as zf:
zf.setpassword(password.encode('utf-8'))
if hasattr(zf, 'setencryption'):
zf.setencryption(pyzipper.WZ_AES)
if os.path.isdir(enc_dir):
for root, _, files in os.walk(enc_dir):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, assets_dir).replace('\\', '/')
zf.write(file_path, arcname)
if os.path.isdir(res_dir):
for root, _, files in os.walk(res_dir):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, assets_dir).replace('\\', '/')
zf.write(file_path, arcname)
if os.path.isfile(meta_file):
zf.write(meta_file, 'secure_meta.json')
elif hasattr(pyzipper, 'ZIP_CRYPTO'):
with pyzipper.ZipFile(out_zip, 'w', compression=zipfile.ZIP_DEFLATED, encryption=pyzipper.ZIP_CRYPTO) as zf:
zf.setpassword(password.encode('utf-8'))
if hasattr(zf, 'setencryption'):
zf.setencryption(pyzipper.ZIP_CRYPTO)
if os.path.isdir(enc_dir):
for root, _, files in os.walk(enc_dir):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, assets_dir).replace('\\', '/')
zf.write(file_path, arcname)
if os.path.isdir(res_dir):
for root, _, files in os.walk(res_dir):
for file in files:
file_path = os.path.join(root, file)
arcname = os.path.relpath(file_path, assets_dir).replace('\\', '/')
zf.write(file_path, arcname)
if os.path.isfile(meta_file):
zf.write(meta_file, 'secure_meta.json')
else:
# 7-Zip كحل أخير
sevenz = shutil.which('7z') or shutil.which('7z.exe')
if sevenz is None:
raise RuntimeError("لا يتوفر AES ولا ZipCrypto عبر pyzipper، و7-Zip غير مثبت")
args = [sevenz, 'a', '-tzip', f'-p{password}', '-mem=ZipCrypto', 'protected.zip']
if os.path.isdir(enc_dir):
args.append('encrypted')
if os.path.isdir(res_dir):
args.append('protected_res')
if os.path.isfile(meta_file):
args.append('secure_meta.json')
subprocess.run(args, check=True, cwd=assets_dir)

# بعد إنشاء الأرشيف، إزالة العناصر الأصلية من assets والاكتفاء بـ protected.zip
if os.path.isdir(enc_dir):
shutil.rmtree(enc_dir, ignore_errors=True)
if os.path.isdir(res_dir):
shutil.rmtree(res_dir, ignore_errors=True)
if os.path.isfile(meta_file):
os.remove(meta_file)

def cleanup(self):
"""تنظيف الملفات المؤقتة"""
shutil.rmtree(self.temp_dir, ignore_errors=True)

def main():
parser = argparse.ArgumentParser(description='Advanced APK Protection Tool')
parser.add_argument('input', help='Input APK file path')
parser.add_argument('output', help='Output protected APK path')
parser.add_argument('password', help='Encryption password')
parser.add_argument('--obfuscate', action='store_true', help='Enable advanced obfuscation')
parser.add_argument('--protect-resources', action='store_true', help='Encrypt resources')
parser.add_argument('--zipcrypto-password', default=None, help='Optional password to wrap protected assets into assets/protected.zip using ZipCrypto (pyzipper)')
parser.add_argument('--zipcrypto-strict', action='store_true', help='Require ZipCrypto exactly and fail if unavailable (no fallback)')

args = parser.parse_args()

protector = AdvancedAPKProtector()
protector.anti_debug_enabled = True
protector.resources_protected = args.protect_resources
protector.zipcrypto_password = args.zipcrypto_password
protector.zipcrypto_strict = args.zipcrypto_strict

if protector.protect_apk(args.input, args.output, args.password):
print(f"APK protected successfully. Output: {args.output}")
print("Protection features applied:")
print("- Multi-layer DEX encryption")
print("- Signature preservation")
print("- Anti-debugging techniques")
print("- Tamper detection")
if args.obfuscate:
print("- Advanced code obfuscation")
if args.protect_resources:
print("- Resources protection")
else:
print("Failed to protect APK")

if __name__ == '__main__':
main()


AND HERE IS THE USAGE]
python3 apk_encryptor.py basic.apk protected.apk "My$ecureP@ssw0rd2023" --protect-resources --zipcrypto-password 123456 --zipcrypto-strict



 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Tips
Recently searched:

Users who are viewing this thread

Top Bottom