yserx

package
v1.3.0-sp3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TC_OBJECT         byte = 0x73 // s
	TC_CLASS          byte = 0x76 // v
	TC_ARRAY          byte = 0x75 // u
	TC_STRING         byte = 0x74 // t
	TC_LONGSTRING     byte = 0x7c // |
	TC_ENUM           byte = 0x7e // ~
	TC_CLASSDESC      byte = 0x72 // r
	TC_PROXYCLASSDESC byte = 0x7d // }
	TC_EXCEPTION      byte = 0x7b // { - ignore
	TC_RESET          byte = 0x79 // y - ignore
	TC_REFERENCE      byte = 0x71 // q
	TC_NULL           byte = 0x70 // p
	TC_BLOCKDATA      byte = 0x77 // w
	TC_BLOCKDATALONG  byte = 0x7a // z
	TC_ENDBLOCKDATA   byte = 0x78 // x
	TC_UNKNOWN        byte = 0    // 0x00
	X_CLASSDESC       byte = 0
	X_CLASSFIELD      byte = 0
	X_CLASSFIELDS     byte = 0
	X_CLASSDATA       byte = 0
	X_FIELDVALUE      byte = 0
)

first class

View Source
const (
	JT_BYTE   byte = 'B'
	JT_CHAR   byte = 'C'
	JT_DOUBLE byte = 'D'
	JT_FLOAT  byte = 'F'
	JT_INT    byte = 'I'
	JT_LONG   byte = 'J'
	JT_SHORT  byte = 'S'
	JT_BOOL   byte = 'Z'
	JT_ARRAY  byte = '['
	JT_OBJECT byte = 'L'
)
View Source
const INDENT = "  "

Variables

View Source
var Exports = map[string]interface{}{
	"ToJson":                   ToJson,
	"FromJson":                 FromJson,
	"ParseHexJavaObjectStream": ParseHexJavaSerialized,
	"ParseJavaObjectStream":    ParseJavaSerialized,

	"NewJavaNull":             NewJavaNull,
	"NewJavaClass":            NewJavaClass,
	"NewJavaClassFields":      NewJavaClassFields,
	"NewJavaClassField":       NewJavaClassField,
	"NewJavaClassData":        NewJavaClassData,
	"NewJavaClassDesc":        NewJavaClassDesc,
	"NewJavaClassDetails":     NewJavaClassDetails,
	"NewJavaEnum":             NewJavaEnum,
	"NewJavaArray":            NewJavaArray,
	"NewJavaString":           NewJavaString,
	"NewJavaLongString":       NewJavaLongString,
	"NewJavaFieldArrayValue":  NewJavaFieldArrayValue,
	"NewJavaFieldByteValue":   NewJavaFieldByteValue,
	"NewJavaFieldBoolValue":   NewJavaFieldBoolValue,
	"NewJavaFieldCharValue":   NewJavaFieldCharValue,
	"NewJavaFieldDoubleValue": NewJavaFieldDoubleValue,
	"NewJavaFieldFloatValue":  NewJavaFieldFloatValue,
	"NewJavaFieldIntValue":    NewJavaFieldIntValue,
	"NewJavaFieldLongValue":   NewJavaFieldLongValue,
	"NewJavaFieldObjectValue": NewJavaFieldObjectValue,
	"NewJavaFieldShortValue":  NewJavaFieldShortValue,
	"NewJavaFieldValue":       NewJavaFieldValue,
	"NewJavaEndBlockData":     NewJavaEndBlockData,
	"NewJavaBlockDataBytes":   NewJavaBlockDataBytes,
	"NewJavaObject":           NewJavaObject,
	"NewJavaReference":        NewJavaReference,
	"MarshalJavaObjects":      MarshalJavaObjects,
}
View Source
var MAGIC_BANNER = []byte{0xac, 0xed}

Functions

func Float32To4Byte

func Float32To4Byte(float float32) []byte

func Float64To8Byte

func Float64To8Byte(float float64) []byte

func IntTo2Bytes

func IntTo2Bytes(i int) []byte

func IntTo4Bytes

func IntTo4Bytes(i int) []byte

func IntToByte

func IntToByte(i int) []byte

func JavaSerializedDumper

func JavaSerializedDumper(raw []byte) string

func MarshalJavaObjects

func MarshalJavaObjects(res ...JavaSerializable) []byte

func Read2ByteToInt

func Read2ByteToInt(r io.Reader) (int, error)

func Read4ByteToInt

func Read4ByteToInt(r io.Reader) (int, error)

func Read4ByteToUint64

func Read4ByteToUint64(r io.Reader) (uint64, error)

func Read8BytesToUint64

func Read8BytesToUint64(r io.Reader) (uint64, error)

func ReadByte added in v1.3.0

func ReadByte(r io.Reader) ([]byte, error)

func ReadByteToInt

func ReadByteToInt(r io.Reader) (int, error)

func ReadBytesLength

func ReadBytesLength(r io.Reader, length uint64) ([]byte, error)

utils method

func ReadBytesLengthInt

func ReadBytesLengthInt(r io.Reader, length int) ([]byte, error)

func ToJson

func ToJson(i interface{}) ([]byte, error)

func Uint64To4Bytes

func Uint64To4Bytes(i uint64) []byte

func Uint64To8Bytes

func Uint64To8Bytes(i uint64) []byte

Types

type JavaArray

type JavaArray struct {
	Type        byte              `json:"type"`
	TypeVerbose string            `json:"type_verbose"`
	ClassDesc   JavaSerializable  `json:"class_desc"`
	Size        int               `json:"size"`
	Values      []*JavaFieldValue `json:"values"`
	Handle      uint64            `json:"handle"`
	Bytescode   bool              `json:"bytescode,omitempty"`
	Bytes       []byte            `json:"bytes,omitempty"`
}

func NewJavaArray

func NewJavaArray(j *JavaClassDesc, values ...*JavaFieldValue) *JavaArray

func (*JavaArray) Marshal

func (j *JavaArray) Marshal() []byte

type JavaBlockData

type JavaBlockData struct {
	Type        byte   `json:"type"`
	TypeVerbose string `json:"type_verbose"`
	IsLong      bool   `json:"is_long"`
	Size        uint64 `json:"size"`
	Contents    []byte `json:"contents"`
}

func NewJavaBlockDataBytes

func NewJavaBlockDataBytes(raw []byte) *JavaBlockData

func (*JavaBlockData) Marshal

func (j *JavaBlockData) Marshal() []byte

type JavaClass

type JavaClass struct {
	Type        byte             `json:"type"`
	TypeVerbose string           `json:"type_verbose"`
	Desc        JavaSerializable `json:"class_desc"`
	Handle      uint64           `json:"handle"`
}

func NewJavaClass

func NewJavaClass(j *JavaClassDesc) *JavaClass

func (*JavaClass) Marshal

func (j *JavaClass) Marshal() []byte

type JavaClassData

type JavaClassData struct {
	Type        byte               `json:"type"`
	TypeVerbose string             `json:"type_verbose"`
	Fields      []JavaSerializable `json:"fields"`
	BlockData   []JavaSerializable `json:"block_data"`
}

func NewJavaClassData

func NewJavaClassData(fields []JavaSerializable, blockData []JavaSerializable) *JavaClassData

func (*JavaClassData) Marshal

func (d *JavaClassData) Marshal() []byte

type JavaClassDesc

type JavaClassDesc struct {
	Type        byte              `json:"type"`
	TypeVerbose string            `json:"type_verbose"`
	Detail      *JavaClassDetails `json:"detail"`
	//LastDetails  *JavaClassDetails            `json:"-"`
	Map map[uint64]*JavaClassDetails `json:"-"`
}

group

func NewJavaClassDesc

func NewJavaClassDesc(
	className string,
	serialVersionUID []byte,
	flag byte,
	fields *JavaClassFields,
	annotations []JavaSerializable,
	superClass *JavaClassDetails,
) *JavaClassDesc

func (*JavaClassDesc) Marshal

func (j *JavaClassDesc) Marshal() []byte

func (*JavaClassDesc) SetDetails

func (g *JavaClassDesc) SetDetails(d *JavaClassDetails)

type JavaClassDetails

type JavaClassDetails struct {
	Type          byte               `json:"type"`
	TypeVerbose   string             `json:"type_verbose"`
	IsNull        bool               `json:"is_null"`
	ClassName     string             `json:"class_name"`
	SerialVersion []byte             `json:"serial_version"`
	Handle        uint64             `json:"handle"`
	DescFlag      byte               `json:"desc_flag"`
	Fields        *JavaClassFields   `json:"fields"`
	Annotations   []JavaSerializable `json:"annotations"`
	SuperClass    JavaSerializable   `json:"super_class"`

	// proxy class
	DynamicProxyClass               bool               `json:"dynamic_proxy_class"`
	DynamicProxyClassInterfaceCount int                `json:"dynamic_proxy_class_interface_count"`
	DynamicProxyAnnotation          []JavaSerializable `json:"dynamic_proxy_annotation"`
	DynamicProxyClassInterfaceNames []string           `json:"dynamic_proxy_class_interface_names"`
}

func NewJavaClassDetails

func NewJavaClassDetails(
	className string,
	serialVersionUID []byte,
	Flag byte,
	Fields *JavaClassFields,
	Annotations []JavaSerializable,
	SuperClass *JavaClassDetails,
) *JavaClassDetails

func (*JavaClassDetails) IsJavaNull

func (j *JavaClassDetails) IsJavaNull() bool

func (*JavaClassDetails) Is_SC_BLOCKDATA

func (j *JavaClassDetails) Is_SC_BLOCKDATA() bool

func (*JavaClassDetails) Is_SC_EXTERNALIZABLE

func (j *JavaClassDetails) Is_SC_EXTERNALIZABLE() bool

func (*JavaClassDetails) Is_SC_SERIALIZABLE

func (j *JavaClassDetails) Is_SC_SERIALIZABLE() bool

func (*JavaClassDetails) Is_SC_WRITE_METHOD

func (j *JavaClassDetails) Is_SC_WRITE_METHOD() bool

func (*JavaClassDetails) Marshal

func (j *JavaClassDetails) Marshal() []byte

type JavaClassField

type JavaClassField struct {
	Type             byte             `json:"type"`
	TypeVerbose      string           `json:"type_verbose"`
	Name             string           `json:"name"`
	FieldType        byte             `json:"field_type"`
	FieldTypeVerbose string           `json:"field_type_verbose"`
	ClassName1       JavaSerializable `json:"class_name_1"`
}

func NewJavaClassField

func NewJavaClassField(name string, jType byte, className JavaSerializable) *JavaClassField

func (*JavaClassField) Marshal

func (f *JavaClassField) Marshal() []byte

type JavaClassFields

type JavaClassFields struct {
	Type        byte              `json:"type"`
	TypeVerbose string            `json:"type_verbose"`
	FieldCount  int               `json:"field_count"`
	Fields      []*JavaClassField `json:"fields"`
}

func NewJavaClassFields

func NewJavaClassFields(fields ...*JavaClassField) *JavaClassFields

func (*JavaClassFields) Marshal

func (fs *JavaClassFields) Marshal() []byte

type JavaEndBlockData

type JavaEndBlockData struct {
	Type        byte   `json:"type"`
	TypeVerbose string `json:"type_verbose"`
	IsEmpty     bool   `json:"is_empty,omitempty"`
}

func NewJavaEndBlockData

func NewJavaEndBlockData() *JavaEndBlockData

func (*JavaEndBlockData) Marshal

func (j *JavaEndBlockData) Marshal() []byte

type JavaEnumDesc

type JavaEnumDesc struct {
	Type          byte             `json:"type"`
	TypeVerbose   string           `json:"type_verbose"`
	TypeClassDesc JavaSerializable `json:"type_class_desc"`
	ConstantName  JavaSerializable `json:"constant_name"`
	Handle        uint64           `json:"handle"`
}

func NewJavaEnum

func NewJavaEnum(i *JavaClassDesc, constantName *JavaString) *JavaEnumDesc

func (*JavaEnumDesc) Marshal

func (desc *JavaEnumDesc) Marshal() []byte

type JavaFieldValue

type JavaFieldValue struct {
	Type        byte   `json:"type"`
	TypeVerbose string `json:"type_verbose"`

	FieldType        byte   `json:"field_type"`
	FieldTypeVerbose string `json:"field_type_verbose"`

	Bytes []byte `json:"bytes,omitempty"`

	// for array / object
	Object JavaSerializable `json:"object,omitempty"`
}

func NewJavaFieldArrayValue

func NewJavaFieldArrayValue(i JavaSerializable) *JavaFieldValue

func NewJavaFieldBoolValue

func NewJavaFieldBoolValue(b bool) *JavaFieldValue

func NewJavaFieldByteValue

func NewJavaFieldByteValue(b byte) *JavaFieldValue

func NewJavaFieldBytes

func NewJavaFieldBytes(rawStr string) *JavaFieldValue

func NewJavaFieldCharValue

func NewJavaFieldCharValue(i int) *JavaFieldValue

func NewJavaFieldDoubleValue

func NewJavaFieldDoubleValue(i float64) *JavaFieldValue

func NewJavaFieldFloatValue

func NewJavaFieldFloatValue(i float32) *JavaFieldValue

func NewJavaFieldIntValue

func NewJavaFieldIntValue(i uint64) *JavaFieldValue

func NewJavaFieldLongValue

func NewJavaFieldLongValue(i uint64) *JavaFieldValue

func NewJavaFieldObjectValue

func NewJavaFieldObjectValue(i JavaSerializable) *JavaFieldValue

func NewJavaFieldShortValue

func NewJavaFieldShortValue(i int) *JavaFieldValue

func NewJavaFieldValue

func NewJavaFieldValue(t byte, raw []byte) *JavaFieldValue

func (*JavaFieldValue) Marshal

func (v *JavaFieldValue) Marshal() []byte

type JavaNull

type JavaNull struct {
	Type        byte   `json:"type"`
	TypeVerbose string `json:"type_verbose"`
	IsEmpty     bool   `json:"is_empty,omitempty"`
}

func NewJavaNull

func NewJavaNull() *JavaNull

func (*JavaNull) Marshal

func (s *JavaNull) Marshal() []byte

type JavaObject

type JavaObject struct {
	Type        byte               `json:"type"`
	TypeVerbose string             `json:"type_verbose"`
	Class       JavaSerializable   `json:"class_desc"`
	ClassData   []JavaSerializable `json:"class_data"`
	Handle      uint64             `json:"handle"`
}

func NewJavaObject

func NewJavaObject(class *JavaClassDesc, classData ...*JavaClassData) *JavaObject

func ParseFromBytes

func ParseFromBytes(raw []byte) (*JavaObject, error)

func (*JavaObject) Bytes

func (j *JavaObject) Bytes() []byte

func (*JavaObject) Json

func (j *JavaObject) Json() (string, error)

func (*JavaObject) Marshal

func (j *JavaObject) Marshal() []byte

type JavaReference

type JavaReference struct {
	Type        byte   `json:"type"`
	TypeVerbose string `json:"type_verbose"`
	Value       []byte `json:"value"`
	Handle      uint64 `json:"handle"`
}

func NewJavaReference

func NewJavaReference(handle uint64) *JavaReference

func (*JavaReference) GetHandle

func (j *JavaReference) GetHandle() uint64

func (*JavaReference) Marshal

func (j *JavaReference) Marshal() []byte

type JavaSerializable

type JavaSerializable interface {
	//String() string
	//SDumper(indent int) string
	Marshal() []byte
}

func FromJson

func FromJson(raw []byte) ([]JavaSerializable, error)

func ParseHexJavaSerialized

func ParseHexJavaSerialized(raw string) ([]JavaSerializable, error)

func ParseJavaSerialized

func ParseJavaSerialized(raw []byte) ([]JavaSerializable, error)

func ParseJavaSerializedEx

func ParseJavaSerializedEx(r io.Reader, writer io.Writer, callback ...func(j JavaSerializable)) ([]JavaSerializable, error)

func ParseJavaSerializedFromReader

func ParseJavaSerializedFromReader(r io.Reader, callback ...func(serializable JavaSerializable)) ([]JavaSerializable, error)

func ParseMultiJavaSerializedEx added in v1.3.0

func ParseMultiJavaSerializedEx(r io.Reader, writer io.Writer, n int, callback ...func(j JavaSerializable)) ([]JavaSerializable, error)

func ParseSingleJavaSerializedFromReader added in v1.3.0

func ParseSingleJavaSerializedFromReader(r io.Reader, callback ...func(serializable JavaSerializable)) ([]JavaSerializable, error)

type JavaSerializationParser

type JavaSerializationParser struct {
	MagicBanner       []byte
	JavaSerialVersion []byte
	ClassDetails      map[uint64]JavaSerializable
	ClassDescriptions []*JavaClassDesc
	// contains filtered or unexported fields
}

func (*JavaSerializationParser) ShowBool

func (p *JavaSerializationParser) ShowBool(raw []byte)

func (*JavaSerializationParser) ShowByte

func (p *JavaSerializationParser) ShowByte(raw []byte)

func (*JavaSerializationParser) ShowChar

func (p *JavaSerializationParser) ShowChar(raw []byte)

func (*JavaSerializationParser) ShowDouble

func (p *JavaSerializationParser) ShowDouble(raw []byte)

func (*JavaSerializationParser) ShowFloat

func (p *JavaSerializationParser) ShowFloat(raw []byte)

func (*JavaSerializationParser) ShowInt

func (p *JavaSerializationParser) ShowInt(raw []byte)

func (*JavaSerializationParser) ShowLong

func (p *JavaSerializationParser) ShowLong(raw []byte)

func (*JavaSerializationParser) ShowShort

func (p *JavaSerializationParser) ShowShort(raw []byte)

type JavaSerializationStreamer

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

func NewJavaSerializationStreamer

func NewJavaSerializationStreamer() *JavaSerializationStreamer

type JavaString

type JavaString struct {
	Type        byte   `json:"type"`
	TypeVerbose string `json:"type_verbose"`
	IsLong      bool   `json:"is_long"`
	Size        uint64 `json:"size"`
	Raw         []byte `json:"raw"`
	Value       string `json:"value"`
	Handle      uint64 `json:"handle"`
}

func NewJavaLongString

func NewJavaLongString(raw string) *JavaString

func NewJavaString

func NewJavaString(raw string) *JavaString

func (*JavaString) Marshal

func (s *JavaString) Marshal() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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