puffgo

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: LGPL-3.0 Imports: 5 Imported by: 1

README

puffgo

A simple go package implementing a simple logic-bomb

❗ Warning ❗

This project is strictly for educational/research purposes, any malicious activities that involve use of this repository is not the responsibility of the owner. ⚡ Ignore at your own risk! ⚡.

Usage:

To use the types and functions within, simply import:

import "github.com/ARaChn3/puffgo"

Run the following command in shell to get the module for your package:

$ go get github.com/ARaChn3/puffgo

More info about the library, including docs, usage reference and examples, can be found on the project's wiki

License 📜

This project is licensed under the GPL-3.0 License. Please see License File for more information.


Credit to the free-gophers-pack project for the gopher in the logo.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventListener

type EventListener struct {

	// TriggerChannel is to detect if the event has occured.
	// When it does, a boolean true is passed into it.
	TriggerChannel chan bool

	// [Interval] specifies the delay between each check of for the event.
	Interval *time.Duration

	// [TriggerFunction] specifies the function which will be
	// used to check when the event has occured.
	//
	// The function will return a boolean, and will be executed
	// on intervals of [Interval] (type: *time.Duration).
	// If Interval is nil, it performs checks every 500ms.
	//
	// When the event occurs, true is passed into [TriggerChannel],
	// which can be used as a detection mechanism.
	TriggerFunction func() bool

	// [TerminationChannel] acts as stopping mechanism for the mainloop.
	// If a boolean true is passed into it, the mainloop is terminated.
	TerminationChannel chan bool

	// PID specifies the process-id of the persistent mainloop.
	// It holds nil until the mainloop of the event-listner is started.
	PID *int
}

EventListener implements an event-listener that performs checks for occuerence of an event in the system. The said checks are preformed on the basis of the TriggerFunction field. Check the docs for more info.

func NewListener

func NewListener(interval *time.Duration, tfunc func() bool) *EventListener

NewListener creates a new instance of EventListener and returns a pointer to it.

func (*EventListener) GetPID

func (e *EventListener) GetPID() int

GetPID returns the PID for the EventListener's process.

func (*EventListener) Mainloop

func (e *EventListener) Mainloop()

Mainloop starts an infinite loop which checks for the event's occurence until terminated.

func (*EventListener) Terminate

func (e *EventListener) Terminate()

Terminate terminates the mainloop checking for the event.

type LogicBomb

type LogicBomb struct {

	// Listener represents an event-listner defined in this library.
	Listener *EventListener

	// ExecutionFunction specifies the function
	// which will be executed when the bomb is triggered and it goes off
	ExecutionFunction func()

	// BombId specifies a random hex string used to identify the bomb.
	BombID string

	// PID specifies the process-id of the persistent logic-bomb program running.
	// It holds nil until the mainloop of the event-listner is started.
	PID *int
}

LogicBomb: type implementing a logic-bomb for UNIX/Linux based systems.

func NewBomb

func NewBomb(listener EventListener, execFunc func()) *LogicBomb

NewBomb returns an instance of LogicBomb, which can be implanted by Implant(), to be triggered when conditions for it to do so are met.

func (*LogicBomb) Arm

func (lb *LogicBomb) Arm()

Arm() allows the activation of the bomb. If a bomb is not armed, it won't be triggered even if the event defined in Listener occurs.

func (*LogicBomb) Disarm

func (lb *LogicBomb) Disarm()

Disarm() allows the deactivation of the bomb. It passes a true into the TerminationChannel of Listener, thereby terminating the listener's mainloop.

Jump to

Keyboard shortcuts

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