storage

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 25 Imported by: 4 modules, 5 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,
	EvictionStrategy: EvictionStrategySliding,
}
View Source
var ErrCorrelationIdNotFound = errkit.New("could not get correlation-id from cache")

Functions

func AESEncrypt added in v1.0.7

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

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

func AppendMany added in v1.0.7

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

func ParseB64RSAPublicKeyFromPEM added in v1.0.7

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

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

Types

type CacheMetrics added in v0.0.5

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 EvictionStrategy added in v1.3.0

type EvictionStrategy int
const (
	EvictionStrategySliding EvictionStrategy = iota // expire-after-access
	EvictionStrategyFixed                           // expire-after-write
)

type GetInteractionsFunc added in v1.0.7

type GetInteractionsFunc func() []string

type Options added in v1.0.7

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

func (*Options) UseDisk added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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 added in v1.0.7

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

AddInteractionWithId adds an interaction data to the id bucket

func (*StorageDB) Close added in v1.0.7

func (s *StorageDB) Close() error

func (*StorageDB) GetCacheItem added in v1.0.7

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

GetCacheItem returns an item as is

func (*StorageDB) GetCacheMetrics added in v1.0.7

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

func (*StorageDB) GetInteractions added in v1.0.7

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 added in v1.0.7

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

GetInteractions returns the interactions for a id and empty the cache

func (*StorageDB) OnCacheRemovalCallback added in v1.0.7

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

func (*StorageDB) RemoveID added in v1.0.7

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

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

func (*StorageDB) SetID added in v1.0.7

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

func (*StorageDB) SetIDPublicKey added in v1.0.7

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