Module: RCS::SmsEvidence

Defined in:
lib/rcs-common/evidence/sms.rb

Overview

::SmsoldEvidence

Constant Summary collapse

SMS_VERSION =
2010050501

Instance Method Summary collapse

Instance Method Details

#additional_headerObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/rcs-common/evidence/sms.rb', line 47

def additional_header
  header = StringIO.new
  header.write [SMS_VERSION].pack("l")
  header.write [[0,1].sample].pack("l") # incoming
  time = Time.now.getutc.to_filetime
  header.write time.pack('L*')
  header.write "+39123456789".ljust(16, "\x00")
  header.write "+39987654321".ljust(16, "\x00")
  header.string
end

#contentObject



39
40
41
# File 'lib/rcs-common/evidence/sms.rb', line 39

def content
  "test sms".to_utf16le_binary_null
end

#decode_additional_header(data) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rcs-common/evidence/sms.rb', line 58

def decode_additional_header(data)
  binary = StringIO.new data

  version = binary.read(4).unpack('l').first
  raise EvidenceDeserializeError.new("invalid log version for SMS") unless version == SMS_VERSION

  ret = Hash.new
  ret[:data] = Hash.new

  ret[:data][:incoming] = binary.read(4).unpack('l').first
  low, high = binary.read(8).unpack('L2')
  # ignore this time value, it's the same as the acquired in the common header
  # Time.from_filetime high, low
  ret[:data][:from] = binary.read(16).delete("\x00")
  ret[:data][:rcpt] = binary.read(16).delete("\x00")

  return ret
end

#decode_content(common_info, chunks) {|info| ... } ⇒ Object

Yields:

  • (info)


77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rcs-common/evidence/sms.rb', line 77

def decode_content(common_info, chunks)
  info = Hash[common_info]
  info[:data] ||= Hash.new
  info[:data][:type] = :sms

  stream = StringIO.new chunks.join

  info[:data][:content] = stream.read.utf16le_to_utf8

  yield info if block_given?
  :delete_raw
end

#generate_contentObject



43
44
45
# File 'lib/rcs-common/evidence/sms.rb', line 43

def generate_content
  [ content ]
end