wechat

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Common constants
	PageSize     = 4096
	KeySize      = 32
	SaltSize     = 16
	AESBlockSize = 16
	SQLiteHeader = "SQLite format 3\x00"

	// Version specific constants
	V3IterCount = 64000
	V4IterCount = 256000

	IVSize         = 16 // Same for both versions
	HmacSHA1Size   = 20 // Used in V3
	HmacSHA512Size = 64 // Used in V4
)

Constants for WeChat database decryption

View Source
const (
	StatusInit    = ""
	StatusOffline = "offline"
	StatusOnline  = "online"
)
View Source
const (
	V3ProcessName = "WeChat"
	V4ProcessName = "Weixin"
)

Variables

View Source
var (
	ErrHashVerificationFailed = errors.New("hash verification failed")
	ErrInvalidVersion         = errors.New("invalid version, must be 3 or 4")
	ErrInvalidKey             = errors.New("invalid key format")
	ErrIncorrectKey           = errors.New("incorrect decryption key")
	ErrReadFile               = errors.New("failed to read database file")
	ErrOpenFile               = errors.New("failed to open database file")
	ErrIncompleteRead         = errors.New("incomplete header read")
	ErrCreateCipher           = errors.New("failed to create cipher")
	ErrDecodeKey              = errors.New("failed to decode hex key")
	ErrWriteOutput            = errors.New("failed to write output")
	ErrSeekFile               = errors.New("failed to seek in file")
	ErrOperationCanceled      = errors.New("operation was canceled")
	ErrAlreadyDecrypted       = errors.New("file is already decrypted")
)

Error definitions

View Source
var (
	Items   []*Info
	ItemMap map[string]*Info
)

Functions

func DecryptDBFile

func DecryptDBFile(dbPath string, hexKey string, version int) ([]byte, error)

DecryptDBFile decrypts a WeChat database file and returns the decrypted content

func DecryptDBFileToFile

func DecryptDBFileToFile(dbPath, outputPath, hexKey string, version int) error

DecryptDBFileToFile decrypts a WeChat database file and saves the result to the specified output file

func Load

func Load()

func ValidateDBKey

func ValidateDBKey(dbPath string, hexKey string, version int) bool

ValidateDBKey validates if the provided key is correct for the database

Types

type Decryptor

type Decryptor struct {
	// contains filtered or unexported fields
}

Decryptor handles the decryption of WeChat database files

func NewDecryptor

func NewDecryptor(dbPath string, version int) (*Decryptor, error)

NewDecryptor creates a new Decryptor for the specified database file and version

func (*Decryptor) Decrypt

func (d *Decryptor) Decrypt(ctx context.Context, hexKey string, w io.Writer) error

Decrypt decrypts the database using the provided key and writes the result to the writer

func (*Decryptor) GetTotalPages

func (d *Decryptor) GetTotalPages() int64

GetTotalPages returns the total number of pages in the database

func (*Decryptor) Validate

func (d *Decryptor) Validate(key []byte) bool

Validate checks if the provided key is valid for this database

type Info

type Info struct {
	PID         uint32
	ExePath     string
	Version     *dllver.Info
	Status      string
	DataDir     string
	AccountName string
	Key         string
}

func NewInfo

func NewInfo(p *process.Process) (*Info, error)

func (*Info) GetKey

func (i *Info) GetKey() (string, error)

Jump to

Keyboard shortcuts

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