RegexApps / app.py
itzraissc
oi
81c95f5
import os
import gradio as gr
from pathlib import Path
from patcher import PhantomPatcher
# PHANTOM APK AUTOMATOR v1.0 — UI Digital
# Estética Premium: Dark Mode + Cyber Gradient
CUSTOM_CSS = """
body { background-color: #0d0d0d !important; color: #e0e0e0 !important; }
.gradio-container { border: 2px solid #ff0000; border-radius: 15px; padding: 20px; box-shadow: 0 0 20px rgba(255,0,0,0.2); }
#title { text-align: center; font-size: 2.5em; font-weight: bold; color: #ff0000; text-transform: uppercase; margin-bottom: 30px; }
.gr-button { background: linear-gradient(90deg, #800000 0%, #ff0000 100%) !important; color: #fff !important; font-weight: bold !important; border: none !important; }
.gr-button:hover { background: linear-gradient(90deg, #ff0000 0%, #800000 100%) !important; transform: scale(1.02); transition: 0.2s; }
.gr-input, .gr-file { background-color: #1a1a1a !important; border: 1px solid #333 !important; border-radius: 8px !important; }
"""
def phantom_process(apk_file, regex_input, replace_input):
"""
Função principal de processamento chamada pela UI.
"""
if not apk_file:
return "Nenhum arquivo enviado.", None
# Preparar diretório de trabalho
patcher = PhantomPatcher(work_dir="phantom_workspace")
patcher.clean()
try:
# 1. Carregar RegEx
# Simples split por linha ou pipe se necessário
# Por enquanto, par único. No futuro pode ser lista.
regex_pairs = [(regex_input, replace_input)]
# 2. Processar Arquivo
input_path = Path(apk_file.name)
ready_apk = patcher.prepare_file(input_path)
# 3. Decompilar
decompiled_dir = patcher.decompile(ready_apk)
# 4. Patch
patcher.apply_patches(decompiled_dir, regex_pairs)
# 5. Rebuild & Sign
output_name = f"MOD_{ready_apk.name}"
final_apk = patcher.rebuildand_sign(decompiled_dir, output_name)
return f"Sucesso Industrial! APK Modificado: {output_name}", str(final_apk)
except Exception as e:
return f"FALHA CRÍTICA NA OPERAÇÃO: {str(e)}", None
# Construção da UI PHANTOM
with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="red", neutral_hue="slate")) as demo:
gr.HTML("<div id='title'>⬛🔴 PROJETO FANTASMA — APK AUTOMATOR ⬛🔴</div>")
with gr.Row():
file_input = gr.File(label="📦 Enviar APK, XAPK ou ZIP", file_types=[".apk", ".xapk", ".zip"])
with gr.Row():
with gr.Column():
regex_box = gr.Textbox(label="🔍 Regex Pattern (Smali)", placeholder="Ex: const/4 v0, 0x0", value="const/4 v0, 0x0")
with gr.Column():
replace_box = gr.Textbox(label="✍️ Replacement", placeholder="Ex: const/4 v0, 0x1", value="const/4 v0, 0x1")
btn = gr.Button("🚀 EXECUTAR MOD BRUTAL")
output_text = gr.Text(label="Status de Operação")
output_file = gr.File(label="📥 Baixar APK Modificado")
btn.click(fn=phantom_process, inputs=[file_input, regex_box, replace_box], outputs=[output_text, output_file])
if __name__ == "__main__":
# Iniciar no IP padrão do Hugging Face Spaces (Porta 7860)
demo.launch(server_name="0.0.0.0", server_port=7860)