frida

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: ISC Imports: 14 Imported by: 57

Documentation

Overview

Package frida provides Go bindings for frida. Some of the provided functionality includes:

* Listing devices/applications/processes * Attaching to applications/processes * Fetching information about devices/applications/processes

Example
manager := NewDeviceManager()
devices, err := manager.EnumerateDevices()
if err != nil {
	panic(err)
}

fmt.Printf("[*] Frida version: %s\n", Version())
fmt.Println("[*] Devices: ")
for _, device := range devices {
	fmt.Printf("[*] %s => %s\n", device.Name(), device.ID())
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrContextCancelled = errors.New("context cancelled")
)

Functions

func GValueToGo added in v0.8.0

func GValueToGo(val *C.GValue) any

GValueToGo is the function that is called upon unmarshalling glib values into go corresponding ones.

func PatchAndroidSELinux

func PatchAndroidSELinux()

PatchAndroidSELinux tries to patch selinux; root access is required.

func Version

func Version() string

Version returns currently used frida version

Types

type Address

type Address struct {
	Addr string
	Port uint16
}

Address represents structure returned by some specific signals.

func (*Address) String

func (a *Address) String() string

String representation of Address in format ADDR:PORT

type Application

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

Application represents the main application installed on the device

func (*Application) Clean

func (a *Application) Clean()

Clean will clean resources held by the application.

func (*Application) Identifier

func (a *Application) Identifier() string

Identifier returns application bundle identifier

func (*Application) Name

func (a *Application) Name() string

Name returns application name

func (*Application) PID

func (a *Application) PID() int

PID returns application PID or "-" if it could not be obtained when application is not running

func (*Application) Params

func (a *Application) Params() map[string]any

Params return the application parameters, like version, path etc

func (*Application) String

func (a *Application) String() string

String returns the string representation of Application printing identifier, name and pid

type AuthenticationFn

type AuthenticationFn func(string) string

AuthenticationFn is a callback function passed to the endpoint params. Function does authentication and in the case the user is authenticated, non-empty string is returned. If the user is not authenticated, empty string should be returned.

type Bus

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

Bus represent bus used to communicate with the devices.

func (*Bus) Attach

func (b *Bus) Attach() error

Attach attaches on the device bus.

func (*Bus) Clean

func (b *Bus) Clean()

Clean will clean resources held by the bus.

func (*Bus) IsDetached

func (b *Bus) IsDetached() bool

IsDetached returns whether the bus is detached from the device or not.

func (*Bus) On

func (b *Bus) On(sigName string, fn any)

On connects bus to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "detached" with callback as func() {}
  • "message" with callback as func(message string, data []byte) {}

func (*Bus) Post

func (b *Bus) Post(msg string, data []byte)

Post send(post) msg to the device.

type Certificate

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

Certificate represents the GTlsCertificate.

func (*Certificate) IssuerName added in v0.3.0

func (c *Certificate) IssuerName() string

IssuerName returns the issuer name for the certificate.

func (*Certificate) NotValidAfter added in v0.3.0

func (c *Certificate) NotValidAfter() (time.Time, error)

NotValidAfter returns the time after which certificate is not valid.

func (*Certificate) NotValidBefore added in v0.3.0

func (c *Certificate) NotValidBefore() (time.Time, error)

NotValidBefore returns the time before which certificate is not valid.

func (*Certificate) SubjectName added in v0.3.0

func (c *Certificate) SubjectName() string

SubjectName returns the subject name for the certificate.

type Child

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

Child type represents child when child gating is enabled.

func (*Child) Argv

func (f *Child) Argv() []string

Argv returns argv passed to the child.

func (*Child) Clean

func (f *Child) Clean()

Clean will clean resources held by the child.

func (*Child) Envp

func (f *Child) Envp() []string

Envp returns envp passed to the child.

func (*Child) Identifier

func (f *Child) Identifier() string

Identifier returns string identifier of the child.

func (*Child) Origin

func (f *Child) Origin() ChildOrigin

Origin returns the origin of the child.

func (*Child) PID

func (f *Child) PID() uint

PID returns the process id of the child.

func (*Child) PPID

func (f *Child) PPID() uint

PPID returns the parent process id of the child.

func (*Child) Path

func (f *Child) Path() string

Path returns the path of the child.

type ChildOrigin

type ChildOrigin int
const (
	ChildOriginFork ChildOrigin = iota
	ChildOriginExec
	ChildOriginSpawn
)

func (ChildOrigin) String

func (origin ChildOrigin) String() string

type Compiler

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

Compiler type is used to compile scripts.

func NewCompiler

func NewCompiler() *Compiler

NewCompiler creates new compiler.

func (*Compiler) Build

func (c *Compiler) Build(entrypoint string) (string, error)

Build builds the script from the entrypoint.

func (*Compiler) Clean

func (c *Compiler) Clean()

Clean will clean resources held by the compiler.

func (*Compiler) On

func (c *Compiler) On(sigName string, fn any)

On connects compiler to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "starting" with callback as func() {}
  • "finished" with callback as func() {}
  • "output" with callback as func(bundle string) {}
  • "diagnostics" with callback as func(diag string) {}
  • "file_changed" with callback as func() {}

func (*Compiler) Watch

func (c *Compiler) Watch(entrypoint string) error

Watch watches for changes at the entrypoint and sends the "output" signal.

type Crash

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

Crash represents crash of frida.

func (*Crash) Clean

func (c *Crash) Clean()

Clean will clean resources held by the crash.

func (*Crash) PID

func (c *Crash) PID() int

PID returns the process identifier oc.crashed application

func (*Crash) Params

func (c *Crash) Params() map[string]any

Params returns the parameters of the crash.

func (*Crash) ProcessName

func (c *Crash) ProcessName() string

ProcessName returns the name of the process that crashed

func (*Crash) Report

func (c *Crash) Report() string

Report returns the report of the crash

func (*Crash) String

func (c *Crash) String() string

String returns string interpretation of the crash

func (*Crash) Summary

func (c *Crash) Summary() string

Summary returns the summary of the crash

type Device

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

Device represents Device struct from frida-core

func DeviceByID added in v0.7.0

func DeviceByID(id string) (*Device, error)

DeviceByID tries to get the device by id on the default manager

func LocalDevice

func LocalDevice() *Device

LocalDevice is a wrapper around DeviceByType(DeviceTypeLocal).

func USBDevice

func USBDevice() *Device

USBDevice is a wrapper around DeviceByType(DeviceTypeUsb).

func (*Device) Attach

func (d *Device) Attach(val any, opts *SessionOptions) (*Session, error)

Attach will attach on specified process name or PID. You can pass the nil as SessionOptions or you can create it if you want the session to persist for specific timeout.

func (*Device) Bus

func (d *Device) Bus() *Bus

Bus returns device bus.

func (*Device) Clean

func (d *Device) Clean()

Clean will clean the resources held by the device.

func (*Device) DeviceIcon

func (d *Device) DeviceIcon() any

DeviceIcon will return the device icon.

func (*Device) DeviceType

func (d *Device) DeviceType() DeviceType

DeviceType returns type of the device.

func (*Device) DisableSpawnGating

func (d *Device) DisableSpawnGating() error

DisableSpawnGating will disable spawn gating on the device.

func (*Device) EnableSpawnGating

func (d *Device) EnableSpawnGating() error

EnableSpawnGating will enable spawn gating on the device.

func (*Device) EnumerateApplications

func (d *Device) EnumerateApplications(identifier string, scope Scope) ([]*Application, error)

EnumerateApplications will return slice of applications on the device

func (*Device) EnumeratePendingChildren

func (d *Device) EnumeratePendingChildren() ([]*Child, error)

EnumeratePendingChildren will return the slice of pending children.

func (*Device) EnumeratePendingSpawn

func (d *Device) EnumeratePendingSpawn() ([]*Spawn, error)

EnumeratePendingSpawn will return the slice of pending spawns.

func (*Device) EnumerateProcesses

func (d *Device) EnumerateProcesses(scope Scope) ([]*Process, error)

EnumerateProcesses will slice of processes running with scope provided

func (*Device) FindProcessByName

func (d *Device) FindProcessByName(name string, scope Scope) (*Process, error)

FindProcessByName will try to find the process with name specified.

func (*Device) FindProcessByPID

func (d *Device) FindProcessByPID(pid int, scope Scope) (*Process, error)

FindProcessByPID will try to find the process with given pid.

func (*Device) FrontmostApplication

func (d *Device) FrontmostApplication(scope Scope) (*Application, error)

FrontmostApplication will return the frontmost application or the application in focus on the device.

func (*Device) ID

func (d *Device) ID() string

ID will return the ID of the device.

func (*Device) InjectLibraryBlob

func (d *Device) InjectLibraryBlob(target any, byteData []byte, entrypoint, data string) (uint, error)

InjectLibraryBlob will inject the library in the target with byteData path. Entrypoint is the entrypoint to the library and the data is any data you need to pass to the library.

func (*Device) InjectLibraryFile

func (d *Device) InjectLibraryFile(target any, path, entrypoint, data string) (uint, error)

InjectLibraryFile will inject the library in the target with path to library specified. Entrypoint is the entrypoint to the library and the data is any data you need to pass to the library.

func (*Device) Input

func (d *Device) Input(pid int, data []byte) error

Input inputs []bytes into the process with pid specified.

func (*Device) IsLost

func (d *Device) IsLost() bool

IsLost returns boolean whether device is lost or not.

func (*Device) Kill

func (d *Device) Kill(pid int) error

Kill kills process with pid specified.

func (*Device) Manager

func (d *Device) Manager() *DeviceManager

Manager returns device manager for the device.

func (*Device) Name

func (d *Device) Name() string

Name will return the name of the device.

func (*Device) On

func (d *Device) On(sigName string, fn any)

On connects device to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "spawn_added" with callback as func(spawn *frida.Spawn) {}
  • "spawn_removed" with callback as func(spawn *frida.Spawn) {}
  • "child_added" with callback as func(child *frida.Child) {}
  • "child_removed" with callback as func(child *frida.Child) {}
  • "process_crashed" with callback as func(crash *frida.Crash) {}
  • "output" with callback as func(pid, fd int, data []byte) {}
  • "uninjected" with callback as func(id int) {}
  • "lost" with callback as func() {}

func (*Device) OpenChannel

func (d *Device) OpenChannel(address string) (*IOStream, error)

OpenChannel open channel with the address and returns the IOStream

func (*Device) OpenService added in v0.8.0

func (d *Device) OpenService(address string) (*Service, error)

func (*Device) Params

func (d *Device) Params() (map[string]any, error)

Params returns system parameters of the device

func (*Device) ProcessByName

func (d *Device) ProcessByName(name string, scope Scope) (*Process, error)

ProcessByName returns the process by passed name.

func (*Device) ProcessByPID

func (d *Device) ProcessByPID(pid int, scope Scope) (*Process, error)

ProcessByPID returns the process by passed pid.

func (*Device) Resume

func (d *Device) Resume(pid int) error

Resume will resume the process with pid.

func (*Device) Spawn

func (d *Device) Spawn(name string, opts *SpawnOptions) (int, error)

Spawn will spawn an application or binary.

type DeviceInt added in v0.7.1

type DeviceInt interface {
	ID() string
	Name() string
	DeviceIcon() any
	DeviceType() DeviceType
	Bus() *Bus
	Manager() *DeviceManager
	IsLost() bool
	Params() (map[string]any, error)
	FrontmostApplication(scope Scope) (*Application, error)
	EnumerateApplications(identifier string, scope Scope) ([]*Application, error)
	ProcessByPID(pid int, scope Scope) (*Process, error)
	ProcessByName(name string, scope Scope) (*Process, error)
	FindProcessByPID(pid int, scope Scope) (*Process, error)
	FindProcessByName(name string, scope Scope) (*Process, error)
	EnumerateProcesses(scope Scope) ([]*Process, error)
	EnableSpawnGating() error
	DisableSpawnGating() error
	EnumeratePendingSpawn() ([]*Spawn, error)
	EnumeratePendingChildren() ([]*Child, error)
	Spawn(name string, opts *SpawnOptions) (int, error)
	Input(pid int, data []byte) error
	Resume(pid int) error
	Kill(pid int) error
	Attach(val any, opts *SessionOptions) (*Session, error)
	InjectLibraryFile(target any, path, entrypoint, data string) (uint, error)
	InjectLibraryBlob(target any, byteData []byte, entrypoint, data string) (uint, error)
	OpenChannel(address string) (*IOStream, error)
	OpenService(address string) (*Service, error)
	Clean()
	On(sigName string, fn any)
}

type DeviceManager

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

DeviceManager is the main structure which holds on devices available to Frida Single instance of the DeviceManager is created when you call frida.Attach() or frida.LocalDevice().

func NewDeviceManager

func NewDeviceManager() *DeviceManager

NewDeviceManager returns new frida device manager.

func (*DeviceManager) AddRemoteDevice

func (d *DeviceManager) AddRemoteDevice(address string, remoteOpts *RemoteDeviceOptions) (DeviceInt, error)

AddRemoteDevice add a remote device from the provided address with remoteOpts populated

func (*DeviceManager) Clean

func (d *DeviceManager) Clean()

Clean will clean the resources held by the manager.

func (*DeviceManager) Close

func (d *DeviceManager) Close() error

Close method will close current manager.

func (*DeviceManager) DeviceByID

func (d *DeviceManager) DeviceByID(id string) (DeviceInt, error)

DeviceByID will return device with id passed or an error if it can't find any. Note: the caller must call EnumerateDevices() to get devices that are of type usb

func (*DeviceManager) DeviceByType

func (d *DeviceManager) DeviceByType(devType DeviceType) (DeviceInt, error)

DeviceByType will return device or an error by device type specified. Note: the caller must call EnumerateDevices() to get devices that are of type usb

func (*DeviceManager) EnumerateDevices

func (d *DeviceManager) EnumerateDevices() ([]DeviceInt, error)

EnumerateDevices will return all connected devices.

func (*DeviceManager) FindDeviceByID

func (d *DeviceManager) FindDeviceByID(id string) (DeviceInt, error)

FindDeviceByID will try to find the device by id specified Note: the caller must call EnumerateDevices() to get devices that are of type usb

func (*DeviceManager) FindDeviceByType

func (d *DeviceManager) FindDeviceByType(devType DeviceType) (DeviceInt, error)

FindDeviceByType will try to find the device by device type specified Note: the caller must call EnumerateDevices() to get devices that are of type usb

func (*DeviceManager) LocalDevice

func (d *DeviceManager) LocalDevice() (DeviceInt, error)

LocalDevice returns the device with type DeviceTypeLocal.

func (*DeviceManager) On

func (d *DeviceManager) On(sigName string, fn any)

On connects manager to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "added" with callback as func(device *frida.Device) {}
  • "removed" with callback as func(device *frida.Device) {}
  • "changed" with callback as func() {}

func (*DeviceManager) RemoteDevice

func (d *DeviceManager) RemoteDevice() (DeviceInt, error)

RemoteDevice returns the device with type DeviceTypeRemote.

func (*DeviceManager) RemoveRemoteDevice

func (d *DeviceManager) RemoveRemoteDevice(address string) error

RemoveRemoteDevice removes remote device available at address

func (*DeviceManager) USBDevice

func (d *DeviceManager) USBDevice() (DeviceInt, error)

USBDevice returns the device with type DeviceTypeUsb.

type DeviceManagerInt added in v0.7.1

type DeviceManagerInt interface {
	Close() error
	EnumerateDevices() ([]DeviceInt, error)
	LocalDevice() (DeviceInt, error)
	USBDevice() (DeviceInt, error)
	RemoteDevice() (DeviceInt, error)
	DeviceByID(id string) (DeviceInt, error)
	DeviceByType(devType DeviceType) (DeviceInt, error)
	FindDeviceByID(id string) (DeviceInt, error)
	FindDeviceByType(devType DeviceType) (DeviceInt, error)
	AddRemoteDevice(address string, remoteOpts *RemoteDeviceOptions) (DeviceInt, error)
	RemoveRemoteDevice(address string) error
	Clean()
	On(sigName string, fn any)
	// contains filtered or unexported methods
}

DeviceManagerInt is the device DeviceManagerInt interface

type DeviceType

type DeviceType int
const (
	DeviceTypeLocal DeviceType = iota
	DeviceTypeRemote
	DeviceTypeUsb
)

func (DeviceType) String

func (d DeviceType) String() string

type EParams

type EParams struct {
	Address                string
	Port                   uint16
	Certificate            string
	Origin                 string
	Token                  string
	AuthenticationCallback AuthenticationFn
	AssetRoot              string
}

EParams represent config needed to setup endpoint parameters that are used to setup Portal. Types of authentication includes:

  • no authentication (not providing Token nor AuthenticationCallback)
  • static authentication (providing token)
  • authentication using callback (providing AuthenticationCallback)

If the Token and AuthenticationCallback are passed, static authentication will be used (token based)

type EndpointParameters

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

EndpointParameters represent internal FridaEndpointParameters

func NewEndpointParameters

func NewEndpointParameters(params *EParams) (*EndpointParameters, error)

NewEndpointParameters returns *EndpointParameters needed to setup Portal by using provided EParams object.

func (*EndpointParameters) Address

func (e *EndpointParameters) Address() string

Address returns the address of the endpoint parameters.

func (*EndpointParameters) AssetRoot

func (e *EndpointParameters) AssetRoot() string

AssetRoot returns the asset root directory.

func (*EndpointParameters) Certificate

func (e *EndpointParameters) Certificate() *Certificate

Certificate returns the certificate of the endpoint parameters.

func (*EndpointParameters) Clean

func (e *EndpointParameters) Clean()

Clean will clean the resources held by the endpoint parameters.

func (*EndpointParameters) Origin

func (e *EndpointParameters) Origin() string

Origin returns the origin of the endpoint parameters.

func (*EndpointParameters) Port

func (e *EndpointParameters) Port() uint16

Port returns the port of the endpoint parameters.

func (*EndpointParameters) SetAssetRoot

func (e *EndpointParameters) SetAssetRoot(assetPath string)

SetAssetRoot sets asset root directory for the portal.

type FError

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

FError holds a pointer to GError

func (*FError) Error

func (f *FError) Error() string

Error returns string representation of FError.

type FileMonitor

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

FileMonitor type is the type responsible for monitoring file changes

func NewFileMonitor

func NewFileMonitor(path string) *FileMonitor

NewFileMonitor creates new FileMonito with the file path provided.

func (*FileMonitor) Clean

func (mon *FileMonitor) Clean()

Clean will clean the resources held by the file monitor.

func (*FileMonitor) Disable

func (mon *FileMonitor) Disable() error

Disable disables file monitoring.

func (*FileMonitor) Enable

func (mon *FileMonitor) Enable() error

Enable enables file monitoring.

func (*FileMonitor) On

func (mon *FileMonitor) On(sigName string, fn any)

On connects file monitor to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "change" with callback as func(changedFile, otherFile, changeType string) {}

func (*FileMonitor) Path

func (mon *FileMonitor) Path() string

Path returns the path of the monitored file.

type IOStream

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

IOStream type represents struct used to interact with the device using channels.

func NewIOStream

func NewIOStream(stream *C.GIOStream) *IOStream

NewIOStream creates new IOStream.

func (*IOStream) Clean

func (ios *IOStream) Clean()

Clean will clean resources held by the iostream.

func (*IOStream) Close

func (ios *IOStream) Close() error

Close closes the stream.

func (*IOStream) IsClosed

func (ios *IOStream) IsClosed() bool

IsClosed returns whether the stream is closed or not.

func (*IOStream) Read

func (ios *IOStream) Read(data *[]byte) (int, error)

Read tries to read len(data) bytes into the data from the stream.

func (*IOStream) ReadAll

func (ios *IOStream) ReadAll(count int) ([]byte, error)

ReadAll tries to read all the bytes provided with the count from the stream.

func (*IOStream) Write

func (ios *IOStream) Write(data []byte) (int, error)

Write tries to write len(data) bytes to the stream.

func (*IOStream) WriteAll

func (ios *IOStream) WriteAll(data []byte) error

WriteAll tries to write all the data provided.

type LevelType added in v0.4.0

type LevelType string

LevelType represents possible levels when Message.Type == MessageTypeLog

const (
	LevelTypeLog   LevelType = "info"
	LevelTypeWarn  LevelType = "warning"
	LevelTypeError LevelType = "error"
)

type Message added in v0.4.0

type Message struct {
	Type         MessageType `json:"type"`
	Level        LevelType   `json:"level,omitempty"`        // populated when type==MessageTypeLog
	Description  string      `json:"description,omitempty"`  // populated when type==MessageTypeError
	Stack        string      `json:"stack,omitempty"`        // populated when type==MessageTypeError
	Filename     string      `json:"fileName,omitempty"`     // populated when type==MessageTypeError
	LineNumber   int         `json:"lineNumber,omitempty"`   // populated when type==MessageTypeError
	ColumnNumber int         `json:"columnNumber,omitempty"` // populated when type==MessageTypeError
	Payload      any         `json:"payload,omitempty"`
	IsPayloadMap bool
}

Message represents the data returned inside the message parameter in on_message script callback

func ScriptMessageToMessage added in v0.4.0

func ScriptMessageToMessage(message string) (*Message, error)

ScriptMessageToMessage returns the parsed Message from the message strign received in script.On("message", func(msg string, data []byte) {}) callback.

type MessageType added in v0.4.0

type MessageType string

MessageType represents all possible message types populated in the first argument of the on_message callback.

const (
	MessageTypeLog   MessageType = "log"
	MessageTypeError MessageType = "error"
	MessageTypeSend  MessageType = "send"
)

type PeerOptions

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

PeerOptions type represents struct used to setup p2p connection.

func NewPeerOptions

func NewPeerOptions() *PeerOptions

NewPeerOptions creates new empty peer options.

func (*PeerOptions) AddRelay

func (p *PeerOptions) AddRelay(relay *Relay)

AddRelay adds new relay to use for peer options.

func (*PeerOptions) Clean

func (p *PeerOptions) Clean()

Clean will clean the resources held by the peer options.

func (*PeerOptions) ClearRelays

func (p *PeerOptions) ClearRelays()

ClearRelays removes previously added relays.

func (*PeerOptions) SetStunServer

func (p *PeerOptions) SetStunServer(stunServer string)

SetStunServer sets the stun server for peer options.

func (*PeerOptions) StunServer

func (p *PeerOptions) StunServer() string

StunServer returns the stun server for peer options.

type Portal

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

Portal represents portal to collect exposed gadgets and sessions.

func NewPortal

func NewPortal(clusterParams, controlParams *EndpointParameters) *Portal

NewPortal creates new Portal from the EndpointParameters provided.

func (*Portal) Broadcast

func (p *Portal) Broadcast(json string, data []byte)

Broadcast sends the message to all controllers.

func (*Portal) Clean

func (p *Portal) Clean()

Clean will clean the resources held by the frida.

func (*Portal) ClusterParams

func (p *Portal) ClusterParams() *EndpointParameters

ClusterParams returns the cluster parameters for the portal.

func (*Portal) ControlParams

func (p *Portal) ControlParams() *EndpointParameters

ControlParams returns the control parameters for the portal.

func (*Portal) Device

func (p *Portal) Device() DeviceInt

Device returns portal device.

func (*Portal) EnumerateTags

func (p *Portal) EnumerateTags(connectionID uint) []string

EnumerateTags returns all the tags that connection with connectionID is tagged with.

func (*Portal) Kick

func (p *Portal) Kick(connectionID uint)

Kick kicks the connection with connectionID provided.

func (*Portal) Narrowcast

func (p *Portal) Narrowcast(tag, json string, data []byte)

Narrowcast sends the message to all controllers tagged with the tag.

func (*Portal) On

func (p *Portal) On(sigName string, fn any)

On connects portal to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "node_connected" with callback as func(connId uint, addr *frida.Address) {}
  • "node_joined" with callback as func(connId uint, app *frida.Application) {}
  • "node_left" with callback as func(connId uint, app *frida.Application) {}
  • "node_disconnected" with callback as func(connId uint, addr *frida.Address) {}
  • "controller_connected" with callback as func(connId uint, addr *frida.Address) {}
  • "controller_disconnected" with callback as func(connId uint, addr *frida.Address) {}
  • "authenticated" with callback as func(connId uint, sessionInfo string) {}
  • "subscribe" with callback as func(connId uint) {}
  • "message" with callback as func(connId uint, jsonData string, data []byte) {}

func (*Portal) Post

func (p *Portal) Post(connectionID uint, json string, data []byte)

Post posts the message to the connectionID with json string or bytes.

func (*Portal) Start

func (p *Portal) Start() error

Start stars the portal.

func (*Portal) Stop

func (p *Portal) Stop() error

Stop stops the portal.

func (*Portal) TagConnection

func (p *Portal) TagConnection(connectionID uint, tag string)

TagConnection tags the connection with connectionID with the tag provided.

func (*Portal) UntagConnection

func (p *Portal) UntagConnection(connectionID uint, tag string)

UntagConnection untags the connection with connectionID with the tag provided.

type PortalMembership

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

PortalMembership type is used to join portal with session.

func (*PortalMembership) Clean

func (p *PortalMembership) Clean()

Clean will clean the resources held by the portal membership.

func (*PortalMembership) ID

func (p *PortalMembership) ID() uint

ID returns the ID of the membership

func (*PortalMembership) Terminate

func (p *PortalMembership) Terminate() error

Terminate terminates the session membership

type PortalOptions

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

PortalOptions type represents struct used to connect to the portal.

func NewPortalOptions

func NewPortalOptions() *PortalOptions

NewPortalOptions creates new portal options.

func (*PortalOptions) ACL

func (p *PortalOptions) ACL() []string

ACL returns the acls for the portal.

func (*PortalOptions) Certificate

func (p *PortalOptions) Certificate() *Certificate

Certificate returns the tls certificate for portal options.

func (*PortalOptions) Clean

func (p *PortalOptions) Clean()

Clean will clean the resources held by the portal options.

func (*PortalOptions) SetACL

func (p *PortalOptions) SetACL(acls []string)

SetACL sets the acls from the string slice provided.

func (*PortalOptions) SetCertificate

func (p *PortalOptions) SetCertificate(certPath string) error

SetCertificate sets the certificate for the portal.

func (*PortalOptions) SetToken

func (p *PortalOptions) SetToken(token string)

SetToken sets the token for the authentication.

func (*PortalOptions) Token

func (p *PortalOptions) Token() string

Token returns the token for the portal.

type Process

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

Process represents process on the device.

func (*Process) Clean

func (p *Process) Clean()

Clean will clean the resources held by the process.

func (*Process) Name

func (p *Process) Name() string

Name returns the name of the process.

func (*Process) PID

func (p *Process) PID() int

PID returns the PID of the process.

func (*Process) Params

func (p *Process) Params() map[string]any

Params returns the parameters of the process.

type Realm

type Realm int
const (
	RealmNative Realm = iota
	RealmEmulated
)

func (Realm) String

func (r Realm) String() string

type Relay

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

Relay type represents relay for setting up p2p.

func NewRelay

func NewRelay(address, username, password string, kind RelayKind) *Relay

NewRelay creates the new relay with the credentials provided.

func (*Relay) Address

func (relay *Relay) Address() string

Address returns the address of the relay.

func (*Relay) Clean

func (relay *Relay) Clean()

Clean will clean the resources held by the relay.

func (*Relay) Password

func (relay *Relay) Password() string

Password returns the password for the relay.

func (*Relay) RelayKind

func (relay *Relay) RelayKind() RelayKind

RelayKind returns the kind of relay.

func (*Relay) Username

func (relay *Relay) Username() string

Username returns the username for the relay.

type RelayKind

type RelayKind int
const (
	RelayKindTurnUDP RelayKind = iota
	RelayKindTurnTCP
	RelayKindTurnTLS
)

func (RelayKind) String

func (kind RelayKind) String() string

type RemoteDeviceOptions

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

RemoteDeviceOptions type is used to configure the remote device.

func NewRemoteDeviceOptions

func NewRemoteDeviceOptions() *RemoteDeviceOptions

NewRemoteDeviceOptions returns the new remote device options.

func (*RemoteDeviceOptions) Certificate

func (r *RemoteDeviceOptions) Certificate() *Certificate

Certificate returns the certificate for the remote device options.

func (*RemoteDeviceOptions) Clean

func (r *RemoteDeviceOptions) Clean()

Clean will clean the resources held by the remote device options.

func (*RemoteDeviceOptions) KeepAliveInterval

func (r *RemoteDeviceOptions) KeepAliveInterval() int

KeepAliveInterval returns the keepalive interval for the remote device options.

func (*RemoteDeviceOptions) Origin

func (r *RemoteDeviceOptions) Origin() string

Origin returns the origin for the remote device options.

func (*RemoteDeviceOptions) SetCertificate

func (r *RemoteDeviceOptions) SetCertificate(certPath string) error

SetCertificate sets the certificate for the remote device.

func (*RemoteDeviceOptions) SetKeepAlive

func (r *RemoteDeviceOptions) SetKeepAlive(interval int)

SetKeepAlive sets keepalive interval for the remote device options.

func (*RemoteDeviceOptions) SetOrigin

func (r *RemoteDeviceOptions) SetOrigin(origin string)

SetOrigin sets the origin for the remote device options.

func (*RemoteDeviceOptions) SetToken

func (r *RemoteDeviceOptions) SetToken(token string)

SetToken sets the token for the remote device options.

func (*RemoteDeviceOptions) Token

func (r *RemoteDeviceOptions) Token() string

Token returns the token for the remote device options.

type Runtime

type Runtime int
const (
	RuntimeDefault Runtime = iota
	RuntimeQJS
	RuntimeV8
)

func (Runtime) String

func (r Runtime) String() string

type Scope

type Scope int
const (
	ScopeMinimal Scope = iota
	ScopeMetadata
	ScopeFull
)

func (Scope) String

func (s Scope) String() string

type Script

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

Script represents loaded string in the memory.

func (*Script) Clean

func (s *Script) Clean()

Clean will clean the resources held by the script.

func (*Script) DisableDebugger

func (s *Script) DisableDebugger() error

DisableDebugger function disables debugging

func (*Script) EnableDebugger

func (s *Script) EnableDebugger(port uint16) error

EnableDebugger function enables debugging on the port specified

func (*Script) Eternalize

func (s *Script) Eternalize() error

Eternalize function will keep the script loaded even after deataching from the process

func (*Script) ExportsCall

func (s *Script) ExportsCall(fn string, args ...any) any

ExportsCall will try to call fn from the rpc.exports with args provided

func (*Script) ExportsCallWithContext added in v0.6.0

func (s *Script) ExportsCallWithContext(ctx context.Context, fn string, args ...any) any

ExportsCallWithContext will try to call fn from the rpc.exports with args provided using context provided.

func (*Script) IsDestroyed

func (s *Script) IsDestroyed() bool

IsDestroyed function returns whether the script previously loaded is destroyed (could be caused by unload)

func (*Script) Load

func (s *Script) Load() error

Load function loads the script into the process.

func (*Script) On

func (s *Script) On(sigName string, fn any)

On connects script to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "destroyed" with callback as func() {}
  • "message" with callback as func(message string, data []byte) {}

func (*Script) Post

func (s *Script) Post(jsonString string, data []byte)

Post sends post to the script.

func (*Script) Unload

func (s *Script) Unload() error

Unload function unload previously loaded script

type ScriptOptions

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

ScriptOptions type represents options passed to the session to create script.

func NewScriptOptions

func NewScriptOptions(name string) *ScriptOptions

NewScriptOptions creates new script options with the script name provided.

func (*ScriptOptions) Clean

func (s *ScriptOptions) Clean()

Clean will clean the resources held by the script options.

func (*ScriptOptions) Name

func (s *ScriptOptions) Name() string

Name returns the name for the script.

func (*ScriptOptions) SetName

func (s *ScriptOptions) SetName(name string)

SetName sets the name of the script.

func (*ScriptOptions) SetRuntime

func (s *ScriptOptions) SetRuntime(rt ScriptRuntime)

SetRuntime sets the runtime for the script.

func (*ScriptOptions) SetSnapshot

func (s *ScriptOptions) SetSnapshot(value []byte)

SetSnapshot sets the snapshot for the script.

func (*ScriptOptions) SetSnapshotTransport

func (s *ScriptOptions) SetSnapshotTransport(tr SnapshotTransport)

SetSnapshotTransport sets the transport for the snapshot

func (*ScriptOptions) Snapshot

func (s *ScriptOptions) Snapshot() []byte

Snapshot returns the snapshot for the script.

func (*ScriptOptions) SnapshotTransport

func (s *ScriptOptions) SnapshotTransport() SnapshotTransport

SnapshotTransport returns the transport for the script.

type ScriptRuntime

type ScriptRuntime int
const (
	ScriptRuntimeDefault ScriptRuntime = iota
	ScriptRuntimeQJS
	ScriptRuntimeV8
)

func (ScriptRuntime) String

func (s ScriptRuntime) String() string

type Service added in v0.8.0

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

Service represents Service from frida-core

func (*Service) Activate added in v0.9.0

func (s *Service) Activate() error

func (*Service) Cancel added in v0.9.0

func (s *Service) Cancel() error

func (*Service) IsClosed added in v0.9.0

func (s *Service) IsClosed() bool

func (*Service) Request added in v0.8.0

func (s *Service) Request(req any) (any, error)

type ServiceInt added in v0.8.0

type ServiceInt interface {
}

type Session

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

Session type represents the session with the device.

func Attach

func Attach(val any) (*Session, error)

Attach attaches at val(string or int pid) using local device.

func (*Session) Clean

func (s *Session) Clean()

Clean will clean the resources held by the session.

func (*Session) CompileScript

func (s *Session) CompileScript(script string, opts *ScriptOptions) ([]byte, error)

CompileScript compiles the script from the script as string provided.

func (*Session) CreateScript

func (s *Session) CreateScript(script string) (*Script, error)

CreateScript creates new string from the string provided.

func (*Session) CreateScriptBytes

func (s *Session) CreateScriptBytes(script []byte, opts *ScriptOptions) (*Script, error)

CreateScriptBytes is a wrapper around CreateScript(script string)

func (*Session) CreateScriptWithOptions

func (s *Session) CreateScriptWithOptions(script string, opts *ScriptOptions) (*Script, error)

CreateScriptWithOptions creates the script with the script options provided. Useful in cases where you previously created the snapshot.

func (*Session) CreateScriptWithSnapshot

func (s *Session) CreateScriptWithSnapshot(script string, snapshot []byte) (*Script, error)

func (*Session) Detach

func (s *Session) Detach() error

Detach detaches the current session.

func (*Session) DisableChildGating

func (s *Session) DisableChildGating() error

DisableChildGating disables child gating on the session.

func (*Session) EnableChildGating

func (s *Session) EnableChildGating() error

EnableChildGating enables child gating on the session.

func (*Session) IsDetached

func (s *Session) IsDetached() bool

IsDetached returns bool whether session is detached or not.

func (*Session) JoinPortal

func (s *Session) JoinPortal(address string, opts *PortalOptions) (*PortalMembership, error)

JoinPortal joins portal at the address with portal options provided.

func (*Session) On

func (s *Session) On(sigName string, fn any)

On connects session to specific signals. Once sigName is triggered, fn callback will be called with parameters populated.

Signals available are:

  • "detached" with callback as func(reason frida.SessionDetachReason, crash *frida.Crash) {}

func (*Session) Resume

func (s *Session) Resume() error

Resume resumes the current session.

func (*Session) SetupPeerConnection

func (s *Session) SetupPeerConnection(opts *PeerOptions) error

SetupPeerConnection sets up peer (p2p) connection with peer options provided.

func (*Session) SnapshotScript

func (s *Session) SnapshotScript(embedScript string, snapshotOpts *SnapshotOptions) ([]byte, error)

SnapshotScript creates snapshot from the script.

type SessionDetachReason

type SessionDetachReason int
const (
	SessionDetachReasonApplicationRequested SessionDetachReason = iota + 1
	SessionDetachReasonProcessReplaced
	SessionDetachReasonProcessTerminated
	SessionDetachReasonServerTerminated
	SessionDetachReasonDeviceLost
)

func (SessionDetachReason) String

func (reason SessionDetachReason) String() string

type SessionOptions

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

SessionOptions type is used to configure session

func NewSessionOptions

func NewSessionOptions(realm Realm, persistTimeout uint) *SessionOptions

NewSessionOptions create new SessionOptions with the realm and timeout to persist provided

func (*SessionOptions) Clean

func (s *SessionOptions) Clean()

Clean will clean the resources held by the session options.

func (*SessionOptions) PersistTimeout

func (s *SessionOptions) PersistTimeout() int

PersistTimeout returns the persist timeout of the script.s

func (*SessionOptions) Realm

func (s *SessionOptions) Realm() Realm

Realm returns the realm of the options

type SnapshotOptions

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

func NewSnapshotOptions

func NewSnapshotOptions(warmupScript string, rt ScriptRuntime) *SnapshotOptions

NewSnapshotOptions creates new snapshot options with warmup script and script runtime provided.

func (*SnapshotOptions) Clean

func (s *SnapshotOptions) Clean()

Clean will clean the resources held by the snapshot options.

func (*SnapshotOptions) Runtime

func (s *SnapshotOptions) Runtime() ScriptRuntime

Runtime returns the runtime used to create the script options.

func (*SnapshotOptions) WarmupScript

func (s *SnapshotOptions) WarmupScript() string

WarmupScript returns the warmup script used to create the script options.

type SnapshotTransport

type SnapshotTransport int
const (
	SnapshotTransportInline SnapshotTransport = iota
	SnapshotTransportSharedMemory
)

type Spawn

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

Spawn represents spawn of the device.

func (*Spawn) Clean

func (s *Spawn) Clean()

Clean will clean the resources held by the spawn.

func (*Spawn) Identifier

func (s *Spawn) Identifier() string

Identifier returns identifier of the spawn.

func (*Spawn) PID

func (s *Spawn) PID() int

PID returns process id of the spawn.

type SpawnOptions

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

SpawnOptions struct is responsible for setting/getting argv, envp etc

func NewSpawnOptions

func NewSpawnOptions() *SpawnOptions

NewSpawnOptions create new instance of SpawnOptions.

func (*SpawnOptions) Argv

func (s *SpawnOptions) Argv() []string

Argv returns argv of the spawn.

func (*SpawnOptions) Aux

func (s *SpawnOptions) Aux() map[string]any

Aux returns aux of the spawn.

func (*SpawnOptions) Clean

func (s *SpawnOptions) Clean()

Clean will clean the resources held by the spawn options.

func (*SpawnOptions) Cwd

func (s *SpawnOptions) Cwd() string

Cwd returns current working directory (CWD) of the spawn.

func (*SpawnOptions) Env

func (s *SpawnOptions) Env() []string

Env returns env of the spawn.

func (*SpawnOptions) Envp

func (s *SpawnOptions) Envp() []string

Envp returns envp of the spawn.

func (*SpawnOptions) SetArgv

func (s *SpawnOptions) SetArgv(argv []string)

SetArgv set spawns argv with the argv provided.

func (*SpawnOptions) SetCwd

func (s *SpawnOptions) SetCwd(cwd string)

SetCwd sets current working directory (CWD) for the spawn.

func (*SpawnOptions) SetEnv

func (s *SpawnOptions) SetEnv(env map[string]string)

SetEnv set spawns env with the env provided.

func (*SpawnOptions) SetEnvp

func (s *SpawnOptions) SetEnvp(envp map[string]string)

SetEnvp set spawns envp with the envp provided.

func (*SpawnOptions) SetStdio

func (s *SpawnOptions) SetStdio(stdio Stdio)

SetStdio sets standard input/output of the spawn with the stdio provided.

func (*SpawnOptions) Stdio

func (s *SpawnOptions) Stdio() Stdio

Stdio returns spawns stdio.

type Stdio

type Stdio int
const (
	StdioInherit Stdio = iota
	StdioPipe
)

func (Stdio) String

func (s Stdio) String() string

Jump to

Keyboard shortcuts

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