storage

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

storage defines a storage mechanism

storage implements a encrypted memory mechanism

Index

Constants

View Source
const YYYYMMDD = "2006-01-02"

Variables

View Source
var DefaultOptions = Options{
	MaxSize: 2500000,
}

Functions

func AESEncrypt added in v1.0.8

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.8

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

func ParseB64RSAPublicKeyFromPEM added in v1.0.8

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

type GetInteractionsFunc func() []string

type Options added in v1.0.8

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

func (*Options) UseDisk added in v1.0.8

func (options *Options) UseDisk() bool

type PersistentEntry

type PersistentEntry struct {

	//Description of the connection
	Description string
	// contains filtered or unexported fields
}

type Storage

type Storage interface {
	GetCacheMetrics() (*CacheMetrics, error)
	SetIDPublicKey(correlationID, secretKey, publicKey, description 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
	GetDescription(correlationID string) (string, error)
	GetAllDescriptions() []*communication.DescriptionEntry
	SetDescription(correlationID string, description string) error
	GetPersistentInteractions(correlationID string) ([]string, error)
	GetRegisteredSessions(activeOnly bool, from, to time.Time, desc, layout string) ([]*communication.SessionEntry, error)
}

type StorageDB added in v1.0.8

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.8

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.8

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.8

func (s *StorageDB) Close() error

func (*StorageDB) GetAllDescriptions added in v1.0.8

func (s *StorageDB) GetAllDescriptions() []*communication.DescriptionEntry

GetAllDescriptions returns all descriptions

func (*StorageDB) GetCacheItem added in v1.0.8

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

GetCacheItem returns an item as is

func (*StorageDB) GetCacheMetrics added in v1.0.8

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

func (*StorageDB) GetDescription added in v1.0.8

func (s *StorageDB) GetDescription(correlationID string) (string, error)

GetDescription returns the description for a correlationID

func (*StorageDB) GetInteractions added in v1.0.8

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.8

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

GetInteractions returns the interactions for a id and empty the cache

func (*StorageDB) GetPersistentInteractions added in v1.0.8

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

GetPersistentInteractions returns the interactions for a correlationID. It also returns AES Encrypted Key for the IDs.

func (*StorageDB) GetRegisteredSessions added in v1.0.8

func (s *StorageDB) GetRegisteredSessions(activeOnly bool, from, to time.Time, desc, layout string) ([]*communication.SessionEntry, error)

func (*StorageDB) OnCacheRemovalCallback added in v1.0.8

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

func (*StorageDB) RemoveID added in v1.0.8

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

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

func (*StorageDB) SetDescription added in v1.0.8

func (s *StorageDB) SetDescription(correlationID string, description string) error

SetDescription sets the description of an associated ID

func (*StorageDB) SetID added in v1.0.8

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

func (*StorageDB) SetIDPublicKey added in v1.0.8

func (s *StorageDB) SetIDPublicKey(correlationID, secretKey, publicKey string, description 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