import os import shutil import subprocess from flask import Flask, request, send_file, Response app = Flask(__name__) UPLOAD_FOLDER = "uploads" OUTPUT_FOLDER = "decompiled_source" ZIP_NAME = "source_code" # Cleanup function def cleanup(): if os.path.exists(UPLOAD_FOLDER): shutil.rmtree(UPLOAD_FOLDER) if os.path.exists(OUTPUT_FOLDER): shutil.rmtree(OUTPUT_FOLDER) if os.path.exists(f"{ZIP_NAME}.zip"): os.remove(f"{ZIP_NAME}.zip") os.makedirs(UPLOAD_FOLDER, exist_ok=True) @app.route('/') def index(): return '''

🔓 APK to Source Code (Decompiler)

Upload APK & Get Java/XML Source Code Zip



''' @app.route('/decompile', methods=['POST']) def decompile(): cleanup() file = request.files['file'] if not file or file.filename == '': return "No file selected", 400 apk_path = os.path.join(UPLOAD_FOLDER, "app.apk") file.save(apk_path) # Command to run JADX # -d = output directory # --no-replace-consts = code thora saaf dikhta hai cmd = ["jadx", "-d", OUTPUT_FOLDER, apk_path] try: # Run Decompiler result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) if result.returncode == 0: # Create ZIP of the source code shutil.make_archive(ZIP_NAME, 'zip', OUTPUT_FOLDER) return send_file( f"{ZIP_NAME}.zip", as_attachment=True, download_name=f"{file.filename}_Source.zip", mimetype="application/zip" ) else: return Response(f"Decompilation Failed!\n\nLogs:\n{result.stderr}", mimetype="text/plain", status=500) except Exception as e: return f"System Error: {str(e)}", 500 if __name__ == '__main__': cleanup() app.run(host='0.0.0.0', port=7860)