Documentation
¶
Index ¶
Constants ¶
const ( CharsetASCII = "3" CharsetUTF8 = "106" )
Character sets as specified by IANA.
const ( MMSSendReq uint64 = iota + 128 // 128 MMSSendConf // 129 MMSNotificationInd // 130 MMSNotifyResponseInd // 131 MMSRetrieveConf // 132 MMSAckknowledgeInd // 133 MMSDeliveryInd // 134 MMSReadRecInd // 135 MMSReadOrigInd // 136 MMSForwardReq // 137 MMSForwardConf // 138 MMSMBoxStoreReq // 139 MMSMBoxStoreConf // 140 MMSMBoxViewReq // 141 MMSMBoxViewConf // 142 MMSMBoxUploadReq // 143 MMSMBoxUploadConf // 144 MMSMBoxDeleteReq // 145 MMSMBoxDeleteConf // 146 MMSMBoxDescr // 147 )
MMS message types as defined by the MMS Encapsulation Protocol. See: http://www.openmobilealliance.org/release/MMS/V1_2-20050429-A/OMA-MMS-ENC-V1_2-20050301-A.pdf
const ATTACHMENT_BUFFER_SIZE = 8192
ATTACHMENT_BUFFER_SIZE is the size of the buffer in bytes used for decrypting attachments. Larger values of this will consume more memory, but may decrease the overall time taken to decrypt an attachment.
Variables ¶
var ( SMSCSVHeaders = []string{ "ID", "THREAD_ID", "ADDRESS", "ADDRESS_DEVICE_ID", "PERSON", "DATE_RECEIVED", "DATE_SENT", "PROTOCOL", "READ", "STATUS", "TYPE", "REPLY_PATH_PRESENT", "DELIVERY_RECEIPT_COUNT", "SUBJECT", "BODY", "MISMATCHED_IDENTITIES", "SERVICE_CENTER", "SUBSCRIPTION_ID", "EXPIRES_IN", "EXPIRE_STARTED", "NOTIFIED", "READ_RECEIPT_COUNT", "UNIDENTIFIED", } MMSCSVHeaders = []string{ "ID", "THREAD_ID", "DATE_SENT", "DATE_RECEIVED", "MESSAGE_BOX", "READ", "m_id", "sub", "sub_cs", "BODY", "PART_COUNT", "ct_t", "CONTENT_LOCATION", "ADDRESS", "ADDRESS_DEVICE_ID", "EXPIRY", "m_cls", "MESSAGE_TYPE", "v", "MESSAGE_SIZE", "pri", "rr", "rpt_a", "resp_st", "STATUS", "TRANSACTION_ID", "retr_st", "retr_txt", "retr_txt_cs", "read_status", "ct_cls", "resp_txt", "d_tm", "DELIVERY_RECEIPT_COUNT", "MISMATCHED_IDENTITIES", "NETWORK_FAILURE", "d_rpt", "SUBSCRIPTION_ID", "EXPIRES_IN", "EXPIRE_STARTED", "NOTIFIED", "READ_RECEIPT_COUNT", "QUOTE_ID", "QUOTE_AUTHOR", "QUOTE_ATTACHMENT", "QUOTE_MISSING", "SHARED_CONTACTS", "UNIDENTIFIED", } SMSPartCSVHeaders = []string{ "ROW_ID", "MMS_ID", "seq", "CONTENT_TYPE", "NAME", "chset", "CONTENT_DISPOSITION", "fn", "cid", "CONTENT_LOCATION", "ctt_s", "ctt_t", "encrypted", "TRANSFER_STATE", "DATA", "SIZE", "FILE_NAME", "THUMBNAIL", "THUMBNAIL_ASPECT_RATIO", "UNIQUE_ID", "DIGEST", "FAST_PREFLIGHT_ID", "VOICE_NOTE", "DATA_RANDOM", "THUMBNAIL_RANDOM", "QUOTE", "WIDTH", "HEIGHT", "CAPTION", } )
CSV column headers.
var ProtoCommitHash = "d6610f0"
ProtoCommitHash is the commit hash of the Signal Protobuf spec.
Functions ¶
func SetMMSMessageType ¶
func StatementToStringArray ¶
func StatementToStringArray(sql *signal.SqlStatement) []string
StatementToStringArray formats a SqlStatement fairly literally as an array. Null parameters are left empty.
Types ¶
type BackupFile ¶
type BackupFile struct {
FileSize int64
CipherKey []byte
MacKey []byte
Mac hash.Hash
IV []byte
Counter uint32
// contains filtered or unexported fields
}
BackupFile stores information about a given backup file.
Decrypting a backup is done by consuming the underlying file buffer. Attemtping to read from a BackupFile after it is consumed will return an error.
Closing the underlying file handle is the responsibilty of the programmer if implementing the iteration manually, or is done as part of the Consume method.
func NewBackupFile ¶
func NewBackupFile(path, password string) (*BackupFile, error)
NewBackupFile initialises a backup file for reading using the provided path and password.
func (*BackupFile) Close ¶
func (bf *BackupFile) Close() error
func (*BackupFile) Consume ¶
func (bf *BackupFile) Consume(fns ConsumeFuncs) error
Consume iterates over the backup file using the fields in the provided ConsumeFuncs. When a BackupFrame is encountered, the matching function will run.
If any image-related functions are nil (e.g., AttachmentFunc) the default will be to discard the next *n* bytes, where n is the Attachment.Length.
The underlying file is closed at the end of the method, and the backup file should be considered spent.
func (*BackupFile) DecryptAttachment ¶
func (bf *BackupFile) DecryptAttachment(length uint32, out io.Writer) error
DecryptAttachment reads the attachment immediately next in the file's bytes, using a streaming intermediate buffer of size ATTACHMENT_BUFFER_SIZE.
func (*BackupFile) Frame ¶
func (bf *BackupFile) Frame() (*signal.BackupFrame, error)
Frame returns the next frame in the file.
func (*BackupFile) Slurp ¶
func (bf *BackupFile) Slurp() ([]*signal.BackupFrame, error)
Slurp consumes the entire BackupFile and returns a list of all frames contained in the file. Note that after calling this function, the underlying file buffer will be empty and the file should be considered dropped. Calling any function on the backup file after calling Slurp will fail.
Note that any attachments in the backup file will not be handled.
Closes the underlying file handler afterwards. The backup file should be considered exhausted.
type ConsumeFuncs ¶
type ConsumeFuncs struct {
AttachmentFunc func(*signal.Attachment) error
AvatarFunc func(*signal.Avatar) error
StatementFunc func(*signal.SqlStatement) error
}
ConsumeFuncs stores parameters for a Consume operation.
func DiscardConsumeFuncs ¶
func DiscardConsumeFuncs(bf *BackupFile) ConsumeFuncs
type MMS ¶
type MMS struct {
XMLName xml.Name `xml:"mms"`
Parts []MMSPart `xml:"parts"`
Body *string `xml:"-"`
TextOnly uint64 `xml:"text_only,attr"` // optional
Sub string `xml:"sub,attr"` // optional
RetrSt string `xml:"retr_st,attr"` // required
Date uint64 `xml:"date,attr"` // required
CtCls string `xml:"ct_cls,attr"` // required
SubCs string `xml:"sub_cs,attr"` // required
Read uint64 `xml:"read,attr"` // required
CtL string `xml:"ct_l,attr"` // required
TrID string `xml:"tr_id,attr"` // required
St string `xml:"st,attr"` // required
MsgBox uint64 `xml:"msg_box,attr"` // required
Address string `xml:"address,attr"` // required
MCls string `xml:"m_cls,attr"` // required
DTm string `xml:"d_tm,attr"` // required
ReadStatus string `xml:"read_status,attr"` // required
CtT string `xml:"ct_t,attr"` // required
RetrTxtCs string `xml:"retr_txt_cs,attr"` // required
DRpt uint64 `xml:"d_rpt,attr"` // required
MId string `xml:"m_id,attr"` // required
DateSent uint64 `xml:"date_sent,attr"` // required
Seen uint64 `xml:"seen,attr"` // required
MType *uint64 `xml:"m_type,attr"` // required
V uint64 `xml:"v,attr"` // required
Exp string `xml:"exp,attr"` // required
Pri uint64 `xml:"pri,attr"` // required
Rr uint64 `xml:"rr,attr"` // required
RespTxt string `xml:"resp_txt,attr"` // required
RptA string `xml:"rpt_a,attr"` // required
Locked uint64 `xml:"locked,attr"` // required
RetrTxt string `xml:"retr_txt,attr"` // required
RespSt uint64 `xml:"resp_st,attr"` // required
MSize *uint64 `xml:"m_size,attr"` // required
ReadableDate string `xml:"readable_date,attr"` // optional
ContactName *string `xml:"contact_name,attr"` // optional
}
MMS represents a Multimedia Messaging Service record.
func NewMMSFromStatement ¶
func NewMMSFromStatement(stmt *signal.SqlStatement) (uint64, *MMS, error)
type MMSPart ¶
type MMSPart struct {
XMLName xml.Name `xml:"part"`
UniqueID uint64 `xml:"-"`
Seq uint64 `xml:"seq,attr"` // required
Ct string `xml:"ct,attr"` // required
Name string `xml:"name,attr"` // required
ChSet string `xml:"chset,attr"` // required
Cd string `xml:"cd,attr"` // required
Fn string `xml:"fn,attr"` // required
CID string `xml:"cid,attr"` // required
Cl string `xml:"cl,attr"` // required
CttS string `xml:"ctt_s,attr"` // required
CttT string `xml:"ctt_t,attr"` // required
Text string `xml:"text,attr"` // required
Data *string `xml:"data,attr"` // optional
}
MMSPart holds a data blob for an MMS.
func NewPartFromStatement ¶
func NewPartFromStatement(stmt *signal.SqlStatement) (uint64, *MMSPart, error)
type MultiWriter ¶
MultiWriter is a convenience wrapper around an io.Writer to allow multiple consecutive (safe) writes.
func NewMultiWriter ¶
func NewMultiWriter(w io.Writer) *MultiWriter
NewMultiWriter returns a new instance of a multi writer.
func (*MultiWriter) Error ¶
func (w *MultiWriter) Error() error
Error returns the final error message of the writer.
func (*MultiWriter) W ¶
func (w *MultiWriter) W(p []byte)
W writes a slice of bytes to the underlying writer, or silently fails if there was a previous error.
type SMS ¶
type SMS struct {
XMLName xml.Name `xml:"sms"`
Protocol *uint64 `xml:"protocol,attr"` // optional
Address string `xml:"address,attr"` // required
Date string `xml:"date,attr"` // required
Type SMSType `xml:"type,attr"` // required
Subject *string `xml:"subject,attr"` // optional
Body string `xml:"body,attr"` // required
TOA *string `xml:"toa,attr"` // optional
SCTOA *string `xml:"sc_toa,attr"` // optional
ServiceCenter *string `xml:"service_center,attr"` // optional
Read uint64 `xml:"read,attr"` // required
Status int64 `xml:"status,attr"` // required
Locked *uint64 `xml:"locked,attr"` // optional
DateSent *uint64 `xml:"date_sent,attr"` // optional
ReadableDate *string `xml:"readable_date,attr"` // optional
ContactName *uint64 `xml:"contact_name,attr"` // optional
}
SMS represents a Short Message Service record.
func NewSMSFromStatement ¶
func NewSMSFromStatement(stmt *signal.SqlStatement) (*SMS, error)
NewSMSFromStatement constructs an XML SMS struct from a SQL statement.
type SMSes ¶
type SMSes struct {
XMLName xml.Name `xml:"smses"`
Count int `xml:"count,attr"`
MMS []MMS `xml:"mms"`
SMS []SMS `xml:"sms"`
}
SMSes holds a set of MMS or SMS records.
type SQLMMS ¶
type SQLMMS struct {
ID uint64
ThreadID *uint64
DateSent *uint64
DateReceived *uint64
MessageBox *uint64
Read uint64 // default 0
MID *string
Sub *string
SubCs *uint64
Body *string
PartCount *uint64
CtT *string
ContentLocation *string
Address *string
AddressDeviceID *uint64
Expiry *uint64
MCls *string
MessageType *uint64
V *uint64
MessageSize *uint64
Pri *uint64
Rr *uint64
RptA *uint64
RespSt *uint64
Status *uint64
TransactionID *string
RetrSt *uint64
RetrTxt *string
RetrTxtCs *uint64
ReadStatus *uint64
CtCls *uint64
RespTxt *string
DTm *uint64
DeliveryReceiptCount uint64 // default 0
MismatchedIdentities *string // default null
NetworkFailure *string // default null
DRpt *uint64
SubscriptionID uint64 // default -1
ExpiresIn uint64 // default 0
ExpireStarted uint64 // default 0
Notified uint64 // default 0
ReadReceiptCount uint64 // default 0
QuoteID uint64 // default 0
QuoteAuthor *string
QuoteBody *string
QuoteAttachment uint64 // default -1
QuoteMissing uint64 // default 0
Unidentified uint64 // default 0
}
SQLMMS info
func ParametersToMMS ¶
func ParametersToMMS(ps []*signal.SqlStatement_SqlParameter) *SQLMMS
ParametersToMMS converts a set of SQL parameters to a single MMS.
func StatementToMMS ¶
func StatementToMMS(sql *signal.SqlStatement) *SQLMMS
StatementToMMS converts a of SQL statement to a single MMS.
type SQLPart ¶
type SQLPart struct {
RowID uint64 // primary
MmsID *uint64
Seq uint64 // default 0
ContentType *string
Name *string
Chset *uint64
ContentDisposition *string
Fn *string
Cid *string
ContentLocation *string
CttS *uint64
CttT *string
TransferState *uint64
Data *string
Size *uint64
FileName *string
Thumbnail *string
ThumbnailAspectRatio *float64
UniqueID uint64 // not null
Digest []byte
FastPreflightID *string
VoiceNote uint64 // default 0
DataRandom []byte
ThumbnailRandom []byte
Quote uint64 // default 0
Width uint64 // default 0
Height uint64 // default 0
Caption *string //default null
// contains filtered or unexported fields
}
SQLPart info
func ParametersToPart ¶
func ParametersToPart(ps []*signal.SqlStatement_SqlParameter) *SQLPart
ParametersToPart converts a set of SQL parameters to a single part.
func StatementToPart ¶
func StatementToPart(sql *signal.SqlStatement) *SQLPart
StatementToPart converts a of SQL statement to a single part.
type SQLSMS ¶
type SQLSMS struct {
ID uint64
ThreadID *uint64
Address *string
AddressDeviceID uint64 // default 1
Person *uint64
DateReceived *uint64
DateSent *uint64
Protocol uint64 // effectively default 0
Read uint64 // default 0
Status uint64 // default -1
Type *uint64
ReplyPathPresent *uint64
DeliveryReceiptCount uint64 // default 0
Subject *string
Body *string
MismatchedIdentities *string // default null
ServiceCenter *string
SubscriptionID uint64 // default -1
ExpiresIn uint64 // default 0
ExpireStarted uint64 // default 0
Notified uint64 // default 0
ReadReceiptCount uint64 // default 0
Unidentified uint64 // default 0
}
SQLSMS info
func ParametersToSMS ¶
func ParametersToSMS(ps []*signal.SqlStatement_SqlParameter) *SQLSMS
ParametersToSMS converts a set of SQL parameters to a single SMS.
func StatementToSMS ¶
func StatementToSMS(sql *signal.SqlStatement) *SQLSMS
StatementToSMS converts a of SQL statement to a single SMS.