testsupport

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustSingleCall

func MustSingleCall[T any](t testing.TB, h *Harness, method string) (T, metadata.MD)

func MustSingleSessionEvent

func MustSingleSessionEvent(t testing.TB, h *Harness) (*clientpb.Event, metadata.MD)

func RequireCallee

func RequireCallee(t testing.TB, md metadata.MD, want string)

func RequireNoPrimaryCalls

func RequireNoPrimaryCalls(t testing.TB, h *Harness)

func RequireNoSessionEvents

func RequireNoSessionEvents(t testing.TB, h *Harness)

func RequireSessionID

func RequireSessionID(t testing.TB, md metadata.MD, want string)

func RunCases

func RunCases(t *testing.T, cases []CommandCase)

func RunClientCases

func RunClientCases(t *testing.T, cases []CommandCase)

func SessionClone

func SessionClone(session *iomclient.Session) *clientpb.Session

func SessionRaw

func SessionRaw(rawID uint32) []byte

Types

type CommandCase

type CommandCase struct {
	Name    string
	Argv    []string
	Setup   func(testing.TB, *Harness)
	WantErr string
	Assert  func(testing.TB, *Harness, error)
}

type Harness

type Harness struct {
	Console  *core.Console
	Recorder *RecorderRPC
	Session  *iomclient.Session
}

func NewClientHarness

func NewClientHarness(t testing.TB) *Harness

func NewHarness

func NewHarness(t testing.TB) *Harness

func (*Harness) AddSession

func (h *Harness) AddSession(t testing.TB, sessionID string) *iomclient.Session

func (*Harness) AddTCPPipeline

func (h *Harness) AddTCPPipeline(name, host string, port uint32)

func (*Harness) Execute

func (h *Harness) Execute(argv ...string) error

func (*Harness) ExecuteClient

func (h *Harness) ExecuteClient(argv ...string) error

func (*Harness) SetSessionResponse

func (h *Harness) SetSessionResponse(session *clientpb.Session)

type RecordedCall

type RecordedCall struct {
	Method   string
	Request  any
	Metadata metadata.MD
}

type RecorderRPC

type RecorderRPC struct {
	clientrpc.MaliceRPCClient
	listenerrpc.ListenerRPCClient
	// contains filtered or unexported fields
}

func NewRecorderRPC

func NewRecorderRPC() *RecorderRPC

func (*RecorderRPC) AddContext

func (r *RecorderRPC) AddContext(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) AddCredential

func (r *RecorderRPC) AddCredential(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) AddDownload

func (r *RecorderRPC) AddDownload(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) AddKeylogger

func (r *RecorderRPC) AddKeylogger(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) AddPort

func (r *RecorderRPC) AddPort(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) AddScreenShot

func (r *RecorderRPC) AddScreenShot(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) AddUpload

func (r *RecorderRPC) AddUpload(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Broadcast

func (r *RecorderRPC) Broadcast(ctx context.Context, in *clientpb.Event, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Build

func (*RecorderRPC) Bypass

func (*RecorderRPC) Calls

func (r *RecorderRPC) Calls() []RecordedCall

func (*RecorderRPC) CancelTask

func (r *RecorderRPC) CancelTask(ctx context.Context, in *implantpb.TaskCtrl, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Cat

func (r *RecorderRPC) Cat(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Cd

func (*RecorderRPC) CheckSource

func (r *RecorderRPC) CheckSource(ctx context.Context, in *clientpb.BuildConfig, opts ...grpc.CallOption) (*clientpb.BuildConfig, error)

func (*RecorderRPC) Clear

func (r *RecorderRPC) Clear(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Cp

func (*RecorderRPC) DeleteCertificate

func (r *RecorderRPC) DeleteCertificate(ctx context.Context, in *clientpb.Cert, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) DeleteContext

func (r *RecorderRPC) DeleteContext(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) DeletePipeline

func (r *RecorderRPC) DeletePipeline(ctx context.Context, in *clientpb.CtrlPipeline, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Download

func (*RecorderRPC) DownloadArtifact

func (r *RecorderRPC) DownloadArtifact(ctx context.Context, in *clientpb.Artifact, opts ...grpc.CallOption) (*clientpb.Artifact, error)

func (*RecorderRPC) DownloadCertificate

func (r *RecorderRPC) DownloadCertificate(ctx context.Context, in *clientpb.Cert, opts ...grpc.CallOption) (*clientpb.TLS, error)

func (*RecorderRPC) DownloadDir

func (r *RecorderRPC) DownloadDir(ctx context.Context, in *implantpb.DownloadRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) EnumDrivers

func (r *RecorderRPC) EnumDrivers(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Env

func (r *RecorderRPC) Env(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Execute

func (r *RecorderRPC) Execute(ctx context.Context, in *implantpb.ExecRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ExecuteAddon

func (r *RecorderRPC) ExecuteAddon(ctx context.Context, in *implantpb.ExecuteAddon, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ExecuteModule

func (r *RecorderRPC) ExecuteModule(ctx context.Context, in *implantpb.ExecuteModuleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) GenerateSelfCert

func (r *RecorderRPC) GenerateSelfCert(ctx context.Context, in *clientpb.Pipeline, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) GetAcmeConfig

func (r *RecorderRPC) GetAcmeConfig(ctx context.Context, in *clientpb.Empty, opts ...grpc.CallOption) (*clientpb.AcmeConfig, error)

func (*RecorderRPC) GetAllCertificates

func (r *RecorderRPC) GetAllCertificates(ctx context.Context, in *clientpb.Empty, opts ...grpc.CallOption) (*clientpb.Certs, error)

func (*RecorderRPC) GetAllTaskContent

func (r *RecorderRPC) GetAllTaskContent(ctx context.Context, in *clientpb.Task, opts ...grpc.CallOption) (*clientpb.TaskContexts, error)

func (*RecorderRPC) GetBasic

func (r *RecorderRPC) GetBasic(ctx context.Context, in *clientpb.Empty, opts ...grpc.CallOption) (*clientpb.Basic, error)

func (*RecorderRPC) GetContexts

func (r *RecorderRPC) GetContexts(ctx context.Context, in *clientpb.Context, opts ...grpc.CallOption) (*clientpb.Contexts, error)

func (*RecorderRPC) GetLicenseInfo

func (r *RecorderRPC) GetLicenseInfo(ctx context.Context, in *clientpb.Empty, opts ...grpc.CallOption) (*clientpb.LicenseInfo, error)

func (*RecorderRPC) GetListeners

func (r *RecorderRPC) GetListeners(ctx context.Context, in *clientpb.Empty, opts ...grpc.CallOption) (*clientpb.Listeners, error)

func (*RecorderRPC) GetSession

func (r *RecorderRPC) GetSession(ctx context.Context, in *clientpb.SessionRequest, opts ...grpc.CallOption) (*clientpb.Session, error)

func (*RecorderRPC) GetSystem

func (r *RecorderRPC) GetSystem(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) GetTasks

func (r *RecorderRPC) GetTasks(ctx context.Context, in *clientpb.TaskRequest, opts ...grpc.CallOption) (*clientpb.Tasks, error)

func (*RecorderRPC) Info

func (r *RecorderRPC) Info(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) InitBindSession

func (r *RecorderRPC) InitBindSession(ctx context.Context, in *implantpb.Init, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Keepalive

func (r *RecorderRPC) Keepalive(ctx context.Context, in *implantpb.CommonBody, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Kill

func (r *RecorderRPC) Kill(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ListAddon

func (r *RecorderRPC) ListAddon(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ListJobs

func (r *RecorderRPC) ListJobs(ctx context.Context, in *clientpb.Empty, opts ...grpc.CallOption) (*clientpb.Pipelines, error)

func (*RecorderRPC) ListModule

func (r *RecorderRPC) ListModule(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ListTasks

func (r *RecorderRPC) ListTasks(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) LoadAddon

func (r *RecorderRPC) LoadAddon(ctx context.Context, in *implantpb.LoadAddon, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) LoadModule

func (r *RecorderRPC) LoadModule(ctx context.Context, in *implantpb.LoadModule, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Ls

func (*RecorderRPC) Mkdir

func (r *RecorderRPC) Mkdir(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Mv

func (*RecorderRPC) Netstat

func (r *RecorderRPC) Netstat(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Notify

func (r *RecorderRPC) Notify(ctx context.Context, in *clientpb.Event, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) ObtainAcmeCert

func (r *RecorderRPC) ObtainAcmeCert(ctx context.Context, in *clientpb.AcmeRequest, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) OnAcmeConfig

func (r *RecorderRPC) OnAcmeConfig(method string, fn func(context.Context, any) (*clientpb.AcmeConfig, error))

func (*RecorderRPC) OnArtifact

func (r *RecorderRPC) OnArtifact(method string, fn func(context.Context, any) (*clientpb.Artifact, error))

func (*RecorderRPC) OnBasic

func (r *RecorderRPC) OnBasic(method string, fn func(context.Context, any) (*clientpb.Basic, error))

func (*RecorderRPC) OnBuildConfig

func (r *RecorderRPC) OnBuildConfig(method string, fn func(context.Context, any) (*clientpb.BuildConfig, error))

func (*RecorderRPC) OnCerts

func (r *RecorderRPC) OnCerts(method string, fn func(context.Context, any) (*clientpb.Certs, error))

func (*RecorderRPC) OnContext

func (r *RecorderRPC) OnContext(method string, fn func(context.Context, any) (*clientpb.Context, error))

func (*RecorderRPC) OnContexts

func (r *RecorderRPC) OnContexts(method string, fn func(context.Context, any) (*clientpb.Contexts, error))

func (*RecorderRPC) OnEmpty

func (r *RecorderRPC) OnEmpty(method string, fn func(context.Context, any) (*clientpb.Empty, error))

func (*RecorderRPC) OnLicenseInfo

func (r *RecorderRPC) OnLicenseInfo(method string, fn func(context.Context, any) (*clientpb.LicenseInfo, error))

func (*RecorderRPC) OnListeners

func (r *RecorderRPC) OnListeners(method string, fn func(context.Context, any) (*clientpb.Listeners, error))

func (*RecorderRPC) OnPipelines

func (r *RecorderRPC) OnPipelines(method string, fn func(context.Context, any) (*clientpb.Pipelines, error))

func (*RecorderRPC) OnSession

func (r *RecorderRPC) OnSession(method string, fn func(context.Context, any) (*clientpb.Session, error))

func (*RecorderRPC) OnTLS

func (r *RecorderRPC) OnTLS(method string, fn func(context.Context, any) (*clientpb.TLS, error))

func (*RecorderRPC) OnTask

func (r *RecorderRPC) OnTask(method string, fn func(context.Context, any) (*clientpb.Task, error))

func (*RecorderRPC) OnTaskContext

func (r *RecorderRPC) OnTaskContext(method string, fn func(context.Context, any) (*clientpb.TaskContext, error))

func (*RecorderRPC) OnTaskContexts

func (r *RecorderRPC) OnTaskContexts(method string, fn func(context.Context, any) (*clientpb.TaskContexts, error))

func (*RecorderRPC) OnTasks

func (r *RecorderRPC) OnTasks(method string, fn func(context.Context, any) (*clientpb.Tasks, error))

func (*RecorderRPC) Ping

func (r *RecorderRPC) Ping(ctx context.Context, in *implantpb.Ping, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Polling

func (r *RecorderRPC) Polling(ctx context.Context, in *clientpb.Polling, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Privs

func (r *RecorderRPC) Privs(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Ps

func (*RecorderRPC) Pwd

func (r *RecorderRPC) Pwd(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) QueryTask

func (r *RecorderRPC) QueryTask(ctx context.Context, in *implantpb.TaskCtrl, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) RefreshModule

func (r *RecorderRPC) RefreshModule(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) RegAdd

func (*RecorderRPC) RegDelete

func (r *RecorderRPC) RegDelete(ctx context.Context, in *implantpb.RegistryRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) RegListKey

func (r *RecorderRPC) RegListKey(ctx context.Context, in *implantpb.RegistryRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) RegListValue

func (r *RecorderRPC) RegListValue(ctx context.Context, in *implantpb.RegistryRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) RegQuery

func (*RecorderRPC) Rev2Self

func (r *RecorderRPC) Rev2Self(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Rm

func (*RecorderRPC) Runas

func (*RecorderRPC) ServiceCreate

func (r *RecorderRPC) ServiceCreate(ctx context.Context, in *implantpb.ServiceRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ServiceDelete

func (r *RecorderRPC) ServiceDelete(ctx context.Context, in *implantpb.ServiceRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ServiceList

func (r *RecorderRPC) ServiceList(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ServiceQuery

func (r *RecorderRPC) ServiceQuery(ctx context.Context, in *implantpb.ServiceRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ServiceStart

func (r *RecorderRPC) ServiceStart(ctx context.Context, in *implantpb.ServiceRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) ServiceStop

func (r *RecorderRPC) ServiceStop(ctx context.Context, in *implantpb.ServiceRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) SessionEvent

func (r *RecorderRPC) SessionEvent(ctx context.Context, in *clientpb.Event, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) SessionEvents

func (r *RecorderRPC) SessionEvents() []RecordedCall

func (*RecorderRPC) SetEnv

func (r *RecorderRPC) SetEnv(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) SetSession

func (r *RecorderRPC) SetSession(session *clientpb.Session)

func (*RecorderRPC) Sleep

func (r *RecorderRPC) Sleep(ctx context.Context, in *implantpb.Timer, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) StartPipeline

func (r *RecorderRPC) StartPipeline(ctx context.Context, in *clientpb.CtrlPipeline, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) StopPipeline

func (r *RecorderRPC) StopPipeline(ctx context.Context, in *clientpb.CtrlPipeline, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Suicide

func (r *RecorderRPC) Suicide(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Switch

func (r *RecorderRPC) Switch(ctx context.Context, in *implantpb.Switch, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Sync

func (r *RecorderRPC) Sync(ctx context.Context, in *clientpb.Sync, opts ...grpc.CallOption) (*clientpb.Context, error)

func (*RecorderRPC) SyncBuild

func (r *RecorderRPC) SyncBuild(ctx context.Context, in *clientpb.BuildConfig, opts ...grpc.CallOption) (*clientpb.Artifact, error)

func (*RecorderRPC) TaskSchdCreate

func (r *RecorderRPC) TaskSchdCreate(ctx context.Context, in *implantpb.TaskScheduleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) TaskSchdDelete

func (r *RecorderRPC) TaskSchdDelete(ctx context.Context, in *implantpb.TaskScheduleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) TaskSchdList

func (r *RecorderRPC) TaskSchdList(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) TaskSchdQuery

func (r *RecorderRPC) TaskSchdQuery(ctx context.Context, in *implantpb.TaskScheduleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) TaskSchdRun

func (r *RecorderRPC) TaskSchdRun(ctx context.Context, in *implantpb.TaskScheduleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) TaskSchdStart

func (r *RecorderRPC) TaskSchdStart(ctx context.Context, in *implantpb.TaskScheduleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) TaskSchdStop

func (r *RecorderRPC) TaskSchdStop(ctx context.Context, in *implantpb.TaskScheduleRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) Touch

func (r *RecorderRPC) Touch(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) UnloadModule

func (r *RecorderRPC) UnloadModule(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) UnsetEnv

func (r *RecorderRPC) UnsetEnv(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) UpdateAcmeConfig

func (r *RecorderRPC) UpdateAcmeConfig(ctx context.Context, in *clientpb.AcmeConfig, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) UpdateCertificate

func (r *RecorderRPC) UpdateCertificate(ctx context.Context, in *clientpb.TLS, opts ...grpc.CallOption) (*clientpb.Empty, error)

func (*RecorderRPC) Upload

func (*RecorderRPC) WaitTaskFinish

func (r *RecorderRPC) WaitTaskFinish(ctx context.Context, in *clientpb.Task, opts ...grpc.CallOption) (*clientpb.TaskContext, error)

func (*RecorderRPC) Whoami

func (r *RecorderRPC) Whoami(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) WmiExecute

func (r *RecorderRPC) WmiExecute(ctx context.Context, in *implantpb.WmiMethodRequest, opts ...grpc.CallOption) (*clientpb.Task, error)

func (*RecorderRPC) WmiQuery

Jump to

Keyboard shortcuts

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