- Install android NDK
27.0.12077973 - Install golang
- Install
upx - Set environment variable
NDKto the location of your toolchain (for example/home/USERNAME/Android/Sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64) - Run
./build.sh all patch
Read IPC.md
-
Modify
build.shand temporarily remove-buildmode=pie -trimpathand-ldflags="-s -w" -
Open
pkg/proc/bininfo.goand add"android"to switch conditions
func loadBinaryInfo(bi *BinaryInfo, image *Image, path string, entryPoint uint64) error {
var wg sync.WaitGroup
defer wg.Wait()
switch bi.GOOS {
case "linux", "freebsd", "android": // append android here
return loadBinaryInfoElf(bi, image, path, entryPoint, &wg)
case "windows":
return loadBinaryInfoPE(bi, image, path, entryPoint, &wg)
case "darwin":
return loadBinaryInfoMacho(bi, image, path, entryPoint, &wg)
}
return errors.New("unsupported operating system")
}- Build dlv
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build ./cmd/dlv/-
Copy
dlvto/data/user/0/io.github.exclude0122.xivpn/files/dlvusing ADB -
Enter adb shell and execute the following commands
# Note: in order to use run-as, the app must be debuggable
run-as io.github.exclude0122.xivpn
cd /data/user/0/io.github.exclude0122.xivpn/files
# Turn on XiVPN, and then find the PID of libxivpn.so
ps -A
# Attach to libxivpn.so. Change PID to the actual PID
./dlv attach PID --headless --listen "0.0.0.0:23456"- Start ADB forward
adb forward tcp:23456 tcp:23456- Connect to dlv using vscode. An example vscode
launch.jsonis provided below:
{
"version": "0.2.0",
"configurations": [
{
"name": "Connect to server",
"type": "go",
"request": "attach",
"mode": "remote",
"port": 23456,
"host": "127.0.0.1",
"substitutePath": []
}
]
}.vscode/c_cpp_properties.json
{
"configurations": [
{
"name": "NDK",
"includePath": [
"${workspaceFolder}/**",
"/home/USERNAME/Android/Sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/**"
],
"defines": [],
"compilerPath": "/home/USERNAME/Android/Sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}.vscode/settings.json
{
"go.toolsEnvVars": {
"CGO_CFLAGS": "-target x86_64-linux-android",
"CXX": "/home/USERNAME/Android/Sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang++",
"CC": "/home/USERNAME/Android/Sdk/ndk/27.0.12077973/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android21-clang",
"TARGET": "x86_64-linux-android",
"GOARCH": "amd64",
"GOOS": "android",
"CGO_ENABLED": "1",
}
}