storage

package
v0.0.0-...-a46b145 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

storage defines a storage mechanism

storage implements a encrypted memory mechanism

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	MaxSize: 2500000,
}
View Source
var ErrCorrelationIdNotFound = errors.New("could not get correlation-id from cache")

Functions

func AESEncrypt

func AESEncrypt(key []byte, message []byte) (string, error)

AESEncrypt encrypts a message using AES and puts IV at the beginning of ciphertext.

func AppendMany

func AppendMany(sep string, slices ...[]byte) []byte

func ParseB64RSAPublicKeyFromPEM

func ParseB64RSAPublicKeyFromPEM(pubPEM string) (*rsa.PublicKey, error)

ParseB64RSAPublicKeyFromPEM parses a base64 encoded rsa pem to a public key structure

Types

type CacheMetrics

type CacheMetrics struct {
	HitCount         uint64        `json:"hit-count"`
	MissCount        uint64        `json:"miss-count"`
	LoadSuccessCount uint64        `json:"load-success-count"`
	LoadErrorCount   uint64        `json:"load-error-count"`
	TotalLoadTime    time.Duration `json:"total-load-time"`
	EvictionCount    uint64        `json:"eviction-count"`
}

type CorrelationData

type CorrelationData struct {
	sync.Mutex
	// data contains data for a correlation-id in AES encrypted json format.
	Data []string `json:"data"`
	// secretkey is a secret key for original user verification
	SecretKey string `json:"-"`
	// AESKey is the AES encryption key in encrypted format.
	AESKeyEncrypted string `json:"aes-key"`
	// decrypted AES key for signing
	AESKey []byte `json:"-"`
}

CorrelationData is the data for a correlation-id.

type GetInteractionsFunc

type GetInteractionsFunc func() []string

type Options

type Options struct {
	DbPath      string
	EvictionTTL time.Duration
	MaxSize     int
}

func (*Options) UseDisk

func (options *Options) UseDisk() bool

type Storage

type Storage interface {
	GetCacheMetrics() (*CacheMetrics, error)
	SetIDPublicKey(correlationID, secretKey, publicKey string) error
	SetID(ID string) error
	AddInteraction(correlationID string, data []byte) error
	AddInteractionWithId(id string, data []byte) error
	GetInteractions(correlationID, secret string) ([]string, string, error)
	GetInteractionsWithId(id string) ([]string, error)
	RemoveID(correlationID, secret string) error
	GetCacheItem(token string) (*CorrelationData, error)
	Close() error
}

type StorageDB

type StorageDB struct {
	Options *Options
	// contains filtered or unexported fields
}

Storage is an storage for interactsh interaction data as well as correlation-id -> rsa-public-key data.

func New

func New(options *Options) (*StorageDB, error)

New creates a new storage instance for interactsh data.

func (*StorageDB) AddInteraction

func (s *StorageDB) AddInteraction(correlationID string, data []byte) error

AddInteraction adds an interaction data to the correlation ID after encrypting it with Public Key for the provided correlation ID.

func (*StorageDB) AddInteractionWithId

func (s *StorageDB) AddInteractionWithId(id string, data []byte) error

AddInteractionWithId adds an interaction data to the id bucket

func (*StorageDB) Close

func (s *StorageDB) Close() error

func (*StorageDB) GetCacheItem

func (s *StorageDB) GetCacheItem(token string) (*CorrelationData, error)

GetCacheItem returns an item as is

func (*StorageDB) GetCacheMetrics

func (s *StorageDB) GetCacheMetrics() (*CacheMetrics, error)

func (*StorageDB) GetInteractions

func (s *StorageDB) GetInteractions(correlationID, secret string) ([]string, string, error)

GetInteractions returns the interactions for a correlationID and removes it from the storage. It also returns AES Encrypted Key for the IDs.

func (*StorageDB) GetInteractionsWithId

func (s *StorageDB) GetInteractionsWithId(id string) ([]string, error)

GetInteractions returns the interactions for a id and empty the cache

func (*StorageDB) OnCacheRemovalCallback

func (s *StorageDB) OnCacheRemovalCallback(key cache.Key, value cache.Value)

func (*StorageDB) RemoveID

func (s *StorageDB) RemoveID(correlationID, secret string) error

RemoveID removes data for a correlation ID and data related to it.

func (*StorageDB) SetID

func (s *StorageDB) SetID(ID string) error

func (*StorageDB) SetIDPublicKey

func (s *StorageDB) SetIDPublicKey(correlationID, secretKey, publicKey string) error

SetIDPublicKey sets the correlation ID and publicKey into the cache for further operations.

Jump to

Keyboard shortcuts

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