diff --git a/root-module/customize.sh b/root-module/customize.sh index a44a181..bcc2442 100644 --- a/root-module/customize.sh +++ b/root-module/customize.sh @@ -1,67 +1,57 @@ #!/system/bin/sh # KernelSU customize.sh for Bluetooth L2CAP Patch -API_URL="https://aln.kavishdevar.me/api" TEMP_DIR="$TMPDIR/aln_patch" PATCHED_FILE_NAME="" SOURCE_FILE="" LIBRARY_NAME="" APEX_DIR=false -# Ensure temporary directory exists mkdir -p "$TEMP_DIR" -# Detect the appropriate library file +# Extract radare2 zip to /data/local/tmp/radare2 +unzip radare2.zip -d /data/local/tmp/radare2 +export LD_LIBRARY_PATH="/data/local/tmp/radare2/lib" +export PATH="/data/local/tmp/radare2/bin:$PATH" +export PREFIX="/data/local/tmp/radare2" + if [ -f "/apex/com.android.btservices/lib64/libbluetooth_jni.so" ]; then SOURCE_FILE="/apex/com.android.btservices/lib64/libbluetooth_jni.so" LIBRARY_NAME="libbluetooth_jni.so" PATCHED_FILE_NAME="libbluetooth_jni_patched.so" - ui_print "Detected library: libbluetooth_jni.so in /apex/com.android.btservices/lib64/" + ui_print "Found library: libbluetooth_jni.so in /apex/com.android.btservices/lib64/" elif [ -f "/system/lib64/libbluetooth_jni.so" ]; then SOURCE_FILE="/system/lib64/libbluetooth_jni.so" LIBRARY_NAME="libbluetooth_jni.so" PATCHED_FILE_NAME="libbluetooth_jni_patched.so" - ui_print "Detected library: libbluetooth_jni.so in /system/lib64/" + ui_print "Found library: libbluetooth_jni.so in /system/lib64/" elif [ -f "/system/lib64/libbluetooth_qti.so" ]; then SOURCE_FILE="/system/lib64/libbluetooth_qti.so" LIBRARY_NAME="libbluetooth_qti.so" PATCHED_FILE_NAME="libbluetooth_qti_patched.so" - ui_print "Detected QTI library: libbluetooth_qti.so in /system/lib64/" + ui_print "Found QTI library: libbluetooth_qti.so in /system/lib64/" elif [ -f "/system_ext/lib64/libbluetooth_qti.so" ]; then SOURCE_FILE="/system_ext/lib64/libbluetooth_qti.so" LIBRARY_NAME="libbluetooth_qti.so" PATCHED_FILE_NAME="libbluetooth_qti_patched.so" - ui_print "Detected QTI library: libbluetooth_qti.so in /system_ext/lib64/" + ui_print "Found QTI library: libbluetooth_qti.so in /system_ext/lib64/" else ui_print "No target library found. Exiting." abort "No target library found." fi -# Upload the detected library for patching -ui_print "Uploading $LIBRARY_NAME to the API for patching..." -ui_print "If you're concerned about privacy, review the source code of the API at https://github.com/kavishdevar/aln/blob/main/root-module-manual/server.py" -PATCHED_FILE_NAME="patched_$LIBRARY_NAME" +cp "$SOURCE_FILE" "$TEMP_DIR/$PATCHED_FILE_NAME" -set_perm "$MODPATH/system/bin/curl" 0 0 755 +l2c_fcr_chk_chan_modes_address=$(radare2 -q -e bin.cache=true -c 'is~l2c_fcr_chk_chan_modes' -z "$TEMP_DIR/$PATCHED_FILE_NAME" | grep -o '0x[0-9a-fA-F]\+') +radare2 -q -e bin.cache=true -w -c "s $l2c_fcr_chk_chan_modes_address; wx 20008052c0035fd6; wci" "$TEMP_DIR/$PATCHED_FILE_NAME" -CURL_CMD=$(command -v curl || echo "$MODPATH/system/bin/curl") - -if [ ! -x "$CURL_CMD" ]; then - ui_print "Error: curl is not available, and bundled binary is missing or not executable." - abort "Please ensure curl is available on your device." -fi - -$CURL_CMD -s -X POST "$API_URL" \ - -F "file=@$SOURCE_FILE" \ - -F "library_name=$LIBRARY_NAME" \ - -o "$TEMP_DIR/$PATCHED_FILE_NAME" \ - -D "$TEMP_DIR/headers.txt" +l2cu_send_peer_info_req_address=$(radare2 -q -e bin.cache=true -c 'is~l2cu_send_peer_info_req' -z "$TEMP_DIR/$PATCHED_FILE_NAME" | grep -o '0x[0-9a-fA-F]\+') +radare2 -q -e bin.cache=true -w -c "s $l2cu_send_peer_info_req_address; wx c0035fd6; wci" "$TEMP_DIR/$PATCHED_FILE_NAME" if [ -f "$TEMP_DIR/$PATCHED_FILE_NAME" ]; then ui_print "Received patched file from the API." ui_print "Installing patched file to the module's directory..." - # Determine the target directory within MODPATH if [[ "$SOURCE_FILE" == *"/system/lib64"* ]]; then TARGET_DIR="$MODPATH/system/lib64" elif [[ "$SOURCE_FILE" == *"/apex/"* ]]; then @@ -71,30 +61,22 @@ if [ -f "$TEMP_DIR/$PATCHED_FILE_NAME" ]; then TARGET_DIR="$MODPATH/system/lib" fi - # Create the target directory mkdir -p "$TARGET_DIR" - - # Copy the patched file to the target directory cp "$TEMP_DIR/$PATCHED_FILE_NAME" "$TARGET_DIR/$LIBRARY_NAME" set_perm "$TARGET_DIR/$LIBRARY_NAME" 0 0 644 ui_print "Patched file installed at $TARGET_DIR/$LIBRARY_NAME" - # Handle apex case if [ "$APEX_DIR" = true ]; then POST_DATA_FS_SCRIPT="$MODPATH/post-data-fs.sh" APEX_LIB_DIR="/apex/com.android.btservices/lib64" MOD_APEX_LIB_DIR="$MODPATH/apex/com.android.btservices/lib64" WORK_DIR="$MODPATH/apex/com.android.btservices/work" - # Create the necessary directories for apex mkdir -p "$MOD_APEX_LIB_DIR" mkdir -p "$WORK_DIR" - # Copy the patched file to the apex directory cp "$TEMP_DIR/$PATCHED_FILE_NAME" "$MOD_APEX_LIB_DIR/$LIBRARY_NAME" - set_perm "$MOD_APEX_LIB_DIR/$LIBRARY_NAME" 0 0 644 - # Create the post-data-fs.sh script cat < "$POST_DATA_FS_SCRIPT" #!/system/bin/sh mount -t overlay overlay -o lowerdir=$APEX_LIB_DIR,upperdir=$MOD_APEX_LIB_DIR,workdir=$WORK_DIR $APEX_LIB_DIR @@ -104,12 +86,11 @@ EOF ui_print "Created post-data-fs.sh script for apex library handling." fi else - ERROR_MESSAGE=$(grep -oP '(?<="error": ")[^"]+' "$TEMP_DIR/headers.txt" || echo "Unknown error") + ERROR_MESSAGE="Unknown error" ui_print "API Error: $ERROR_MESSAGE" rm -rf "$TEMP_DIR" abort "Failed to patch the library." fi -# Clean up temporary files rm -rf "$TEMP_DIR" exit 0 \ No newline at end of file diff --git a/root-module/must-work.zip b/root-module/must-work.zip new file mode 100644 index 0000000..4ae4670 Binary files /dev/null and b/root-module/must-work.zip differ diff --git a/root-module/system/bin/curl b/root-module/system/bin/curl deleted file mode 100644 index 73d22d6..0000000 Binary files a/root-module/system/bin/curl and /dev/null differ