This commit is contained in:
parent
84ae0f6994
commit
1d36961a7c
16 changed files with 734 additions and 48 deletions
58
apps/pkg/proxy/embed.go
Normal file
58
apps/pkg/proxy/embed.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package proxy
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"drmdecryption/adb"
|
||||
"drmdecryption/repo"
|
||||
)
|
||||
|
||||
//go:embed embedded/tproxy_iptables.sh
|
||||
var embeddedTProxyScript []byte
|
||||
|
||||
// ensureTProxyScript pushes the iptables helper to the phone.
|
||||
// Prefers the source-tree copy; falls back to the copy embedded in drm.exe
|
||||
// so a portable release zip does not need apps/proxy/device/.
|
||||
func ensureTProxyScript(c *adb.Client) error {
|
||||
candidates := []string{
|
||||
filepath.Join(repo.Root(), "apps", "proxy", "device", "tproxy_iptables.sh"),
|
||||
}
|
||||
if exe, err := os.Executable(); err == nil {
|
||||
dir := filepath.Dir(exe)
|
||||
candidates = append(candidates,
|
||||
filepath.Join(dir, "tproxy_iptables.sh"),
|
||||
filepath.Join(dir, "apps", "proxy", "device", "tproxy_iptables.sh"),
|
||||
)
|
||||
}
|
||||
var local string
|
||||
for _, p := range candidates {
|
||||
if st, err := os.Stat(p); err == nil && !st.IsDir() {
|
||||
local = p
|
||||
break
|
||||
}
|
||||
}
|
||||
tmp := filepath.Join(os.TempDir(), "tproxy_iptables.sh")
|
||||
if local != "" {
|
||||
data, err := os.ReadFile(local)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(tmp, data, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := os.WriteFile(tmp, embeddedTProxyScript, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("[*] Using embedded tproxy_iptables.sh")
|
||||
}
|
||||
defer os.Remove(tmp)
|
||||
if err := c.Push(tmp, RemoteTProxyScript); err != nil {
|
||||
return err
|
||||
}
|
||||
_, _ = c.Shell("chmod", "755", RemoteTProxyScript)
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue