device

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const RemoteRoot = "/var/mobile/Media/ipadecrypt"

Variables

View Source
var ErrSudoPasswordRejected = errors.New("sudo password rejected")

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Connect

func Connect(ctx context.Context, dev config.Device) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Download

func (c *Client) Download(src string, dst io.Writer) error

Download streams the remote file at src into dst. Caller owns dst (open, close, atomic rename if needed). Wrap dst for progress.

func (*Client) EnsureHelper

func (c *Client) EnsureHelper() (string, error)

func (*Client) Exists

func (c *Client) Exists(path string) bool

func (*Client) FindInstalledByBundleID added in v0.5.0

func (c *Client) FindInstalledByBundleID(bundleID string) (string, string, error)

FindInstalledByBundleID returns the .app path and canonical CFBundleIdentifier matching bundleID case-insensitively. grep is a prefilter; each hit is parsed to confirm (binary plists embed bundle ids as URL-scheme substrings).

func (*Client) HashFile added in v0.3.0

func (c *Client) HashFile(target string) (string, error)

HashFile computes the sha256 of a path on-device. Installed bundles under /var/containers are readable only by root + _installd, hence sudo. Relies on a `shasum` binary being on PATH (procursus/dopamine/palera1n all ship it at /var/jb/usr/bin/shasum).

func (*Client) Install

func (c *Client) Install(appinstPath, ipaRemote string) error

func (*Client) InstalledVersion added in v0.4.0

func (c *Client) InstalledVersion(bundlePath string) (string, error)

InstalledVersion reads CFBundleShortVersionString (falling back to CFBundleVersion) from an installed app bundle's Info.plist.

func (*Client) LocateAppSync

func (c *Client) LocateAppSync() (string, error)

func (*Client) LocateAppinst

func (c *Client) LocateAppinst() (string, error)

func (*Client) Mkdir

func (c *Client) Mkdir(path string) error

func (*Client) Probe

func (c *Client) Probe() (ProbeResult, error)

func (*Client) Remove

func (c *Client) Remove(path string) error

func (*Client) Run

func (c *Client) Run(cmd string) (string, string, int, error)

func (*Client) RunHelper

func (c *Client) RunHelper(helperPath, bundleID, bundlePath string,
	verbose, skipAppex bool, onEvent EventHandler, ipaW io.Writer) (int, error)

RunHelper spawns the on-device helper for a bundle and streams the decrypted IPA bytes into ipaW. bundleID goes to the SpringBoard SBS SPI (only accepted for the main app; empty string skips the main-app pass and just decrypts PlugIns/*.appex + Extensions/*.appex). When skipAppex is true the helper passes --skip-appex, leaving extensions encrypted.

In this mode the helper writes IPA bytes to stdout and event lines to stderr; we tee stderr through the event splitter while ipaW receives the binary stream - no on-device output file, no sftp pull.

func (*Client) RunHelperExecs added in v0.7.0

func (c *Client) RunHelperExecs(helperPath, bundleID, bundlePath string,
	verbose, skipAppex bool, onEvent EventHandler, onFrame FrameHandler) (int, error)

RunHelperExecs runs the helper in --execs-only mode: the helper streams framed Mach-O records on stdout, events on stderr. onFrame is called once per record. Use this when the host has the source IPA and will assemble the output by substituting the helper-provided execs.

func (*Client) RunSudo

func (c *Client) RunSudo(cmd string) (string, string, int, error)

func (*Client) RunSudoStream

func (c *Client) RunSudoStream(cmd string, stdoutW, stderrW io.Writer) (string, string, int, error)

func (*Client) Stat added in v0.5.2

func (c *Client) Stat(p string) (os.FileInfo, error)

func (*Client) Uninstall

func (c *Client) Uninstall(bundlePath string) error

Uninstall removes an installed app. Two steps wrapped in a single `sudo sh -c '…'` so both commands run as root (sudo only elevates the first command in a `cmd1; cmd2` chain, otherwise rm runs as mobile and hits the _installd-owned files with EACCES). Order matters:

  1. uicache -u <bundlePath> - unregister from LSApplicationWorkspace so SpringBoard drops the icon and the LS registry forgets the bundle.
  2. rm -rf <UUID-dir> - remove the bundle dir under /var/containers/Bundle/Application/.

The data container at /var/mobile/Containers/Data/Application/<other-UUID>/ is left behind finding it would require scanning every container's metadata plist for the bundle id, and the next install spins a fresh one regardless.

func (*Client) Upload

func (c *Client) Upload(src io.Reader, dst string, mode os.FileMode) error

func (*Client) VerifyHelper

func (c *Client) VerifyHelper(helperPath string) error

VerifyHelper is a best-effort sanity: invoke the helper with no args; it should exit 2 with a usage string we can recognize. Catches common issues (binary not executable, sudo denied, missing codesign).

type Event

type Event struct {
	Name  string
	Attrs map[string]string
}

func ParseEvent

func ParseEvent(line string) (Event, bool)

ParseEvent parses "@evt event=foo key=value ..." lines. Values may be double-quoted to allow spaces. Returns (_, false) for non-event lines.

func (Event) Attr

func (e Event) Attr(key string) string

type EventHandler

type EventHandler func(Event)

type FrameHandler added in v0.7.0

type FrameHandler func(path string, size int64, r io.Reader) error

FrameHandler is invoked once per Mach-O record the helper streams in --execs-only mode. path is the IPA-relative bundle path ("Payload/AppName.app/Frameworks/X.framework/X"). r yields exactly size bytes; the handler must read them fully before returning, or the next frame will deserialize garbage.

type ProbeResult

type ProbeResult struct {
	IOSVersion string
	Arch       string // "arm64" or "arm64e"
	Model      string // "iPhone10,2", "iPad7,3", …
	// DeviceFamily mirrors UIDeviceFamily values from Info.plist:
	// 1 = iPhone/iPod, 2 = iPad. 0 if unknown.
	DeviceFamily int
	// Jailbreak is the detected jailbreak: "Dopamine", "palera1n",
	// "checkra1n", "rootless?" (rootless but brand unknown) or "unknown".
	Jailbreak string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址