zsteg 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 68101c2a1131eef8343b68bc8176274d0d8d0a3e
4
- data.tar.gz: 090dabdfd430f5ef61dd2f70c84610842bdfffea
3
+ metadata.gz: 9c404bfeb56a154e348ab6b9317d39f2ed111909
4
+ data.tar.gz: 4757c7c83b8cc4b7ed7ce818df237846784c9e72
5
5
  SHA512:
6
- metadata.gz: fa1a8dd3e81074ce70c3019d08f27d33a31b245b0f2ca12b7f28c2824a08fac1c0740b3bdcdcd86f83e38888267c6f0524a590b3dc1511ea62702468a308a76e
7
- data.tar.gz: c0f4e62456de78b373695f2cbd0f8ae4ea1e9c13f959a5554f0472eb7d35847c039331a5c5ea724fcbcfed1c80db09903f17c6428bb08bafd7ad0b224d8eb202
6
+ metadata.gz: 5bedebed7ee62ad32d4eebdcd881ede8ac8750d85c39107138ce5ddd3532947afd7114876017191c274ae34398243f9cacaf9b949d3304d5f326ae029cd4b6d1
7
+ data.tar.gz: 90f91286daabad120e67ba8f1eb15c531c8f17fbc1e85e79fda39841d8ef265fac7ac5067acc23521ac016ef139bc829474427afcdb1957b266b64e6a8cc544a
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'zpng', ">= 0.2.3"
3
+ gem 'zpng', ">= 0.2.5"
4
4
  gem "iostruct"
5
5
 
6
6
  group :development do
@@ -4,7 +4,7 @@ GEM
4
4
  addressable (2.3.5)
5
5
  builder (3.2.2)
6
6
  diff-lcs (1.1.3)
7
- faraday (0.8.8)
7
+ faraday (0.8.9)
8
8
  multipart-post (~> 1.2.0)
9
9
  git (1.2.6)
10
10
  github_api (0.10.1)
@@ -15,10 +15,9 @@ GEM
15
15
  nokogiri (~> 1.5.2)
16
16
  oauth2
17
17
  hashie (2.0.5)
18
- highline (1.6.19)
19
- httpauth (0.2.0)
18
+ highline (1.6.21)
20
19
  iostruct (0.0.1)
21
- jeweler (1.8.7)
20
+ jeweler (1.8.8)
22
21
  builder
23
22
  bundler (~> 1.0)
24
23
  git (>= 1.2.5)
@@ -27,24 +26,23 @@ GEM
27
26
  nokogiri (= 1.5.10)
28
27
  rake
29
28
  rdoc
30
- json (1.8.0)
31
- jwt (0.1.8)
29
+ json (1.8.1)
30
+ jwt (0.1.11)
32
31
  multi_json (>= 1.5)
33
- multi_json (1.8.0)
32
+ multi_json (1.8.4)
34
33
  multi_xml (0.5.5)
35
34
  multipart-post (1.2.0)
36
35
  nokogiri (1.5.10)
37
- oauth2 (0.9.2)
38
- faraday (~> 0.8)
39
- httpauth (~> 0.2)
40
- jwt (~> 0.1.4)
41
- multi_json (~> 1.0)
36
+ oauth2 (0.9.3)
37
+ faraday (>= 0.8, < 0.10)
38
+ jwt (~> 0.1.8)
39
+ multi_json (~> 1.3)
42
40
  multi_xml (~> 0.5)
43
41
  rack (~> 1.2)
44
42
  rack (1.5.2)
45
- rainbow (1.1.4)
46
- rake (10.1.0)
47
- rdoc (4.0.1)
43
+ rainbow (2.0.0)
44
+ rake (10.1.1)
45
+ rdoc (4.1.1)
48
46
  json (~> 1.4)
49
47
  rspec (2.12.0)
50
48
  rspec-core (~> 2.12.0)
@@ -54,7 +52,7 @@ GEM
54
52
  rspec-expectations (2.12.1)
55
53
  diff-lcs (~> 1.1.3)
56
54
  rspec-mocks (2.12.1)
57
- zpng (0.2.3)
55
+ zpng (0.2.5)
58
56
  rainbow
59
57
 
60
58
  PLATFORMS
@@ -65,4 +63,4 @@ DEPENDENCIES
65
63
  iostruct
66
64
  jeweler (~> 1.8.4)
67
65
  rspec (>= 2.8.0)
68
- zpng (>= 0.2.3)
66
+ zpng (>= 0.2.5)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -310,6 +310,8 @@ module ZSteg
310
310
  show_result result, params
311
311
  end
312
312
  if data.size > 0 && !result.is_a?(Result::OneChar) && !result.is_a?(Result::WholeText)
313
+ # newline if no results and want hexdump
314
+ puts if !result || result == []
313
315
  limit = (params[:limit] || @params[:limit]).to_i
314
316
  t = limit > 0 ? data[0,limit] : data
315
317
  print ZPNG::Hexdump.dump(t){ |x| x.prepend(" "*4) }
@@ -383,7 +385,7 @@ module ZSteg
383
385
  # t = data.
384
386
  # encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').
385
387
  # encode!('UTF-8', 'UTF-16')
386
- # r = t.scan(/\p{Word}{#{MIN_TEXT_LENGTH},}/)
388
+ # r = t.scan(/\p{Word}{#{DEFAULT_MIN_STR_LEN},}/)
387
389
  # r if r.any?
388
390
  # rescue
389
391
  # end
@@ -112,6 +112,10 @@ module ZSteg
112
112
  @options[:min_str_len] = x
113
113
  end
114
114
 
115
+ opts.on "--shift N", Integer, "prepend N zero bits" do |x|
116
+ @options[:shift] = x
117
+ end
118
+
115
119
  opts.separator ""
116
120
  opts.on "-v", "--verbose", "Run verbosely (can be used multiple times)" do |v|
117
121
  @options[:verbose] += 1
@@ -42,10 +42,14 @@ module ZSteg
42
42
 
43
43
  opts.separator ""
44
44
 
45
- opts.on "-a", "--all", "try all possible sizes (default)" do
45
+ opts.on "-a", "--all", "try all possible sizes" do
46
46
  @options[:try_all] = true
47
47
  end
48
48
 
49
+ opts.on "-r", "--rewrite", "just rewrite the header, keeping imagedata as-is" do
50
+ @options[:rewrite] = true
51
+ end
52
+
49
53
  opts.separator ""
50
54
 
51
55
  opts.on "-O", "--outfile FILENAME", "output single result to specified file" do |x|
@@ -150,12 +154,21 @@ module ZSteg
150
154
  h = @image.width*@image.height/w
151
155
  _reflow w,h
152
156
  end
153
- else
157
+ elsif @options[:try_all]
154
158
  # enum all
155
159
  2.upto(@image.width*@image.height/2) do |w|
156
160
  h = @image.width*@image.height/w
157
161
  _reflow w,h
158
162
  end
163
+ else
164
+ # smart all
165
+ w = 4
166
+ loop do
167
+ h = @image.width*@image.height/w
168
+ break if h < 4
169
+ _reflow w,h
170
+ w += 1
171
+ end
159
172
  end
160
173
  end
161
174
 
@@ -202,37 +215,41 @@ module ZSteg
202
215
  data = fi.read(4+4+4)
203
216
  fo.write(data[0,4] + [w,h].pack("V2")) # write new size
204
217
 
205
- # copy remaining header bytes
206
- fo.write fi.read(imagedata_offset-fi.tell)
207
-
208
- # FIXME: if scanline sizes differ in BITS, not bytes...
209
-
210
- # scanline padding needs to be respected...
211
- imagedata = StringIO.new
212
- @image.height.times do
213
- data = fi.read @old_total_sl_bytes
214
- imagedata << data[0, @old_significant_sl_bytes]
215
- #p data[@old_significant_sl_bytes..-1]
216
- end
217
- imagedata << fi.read # read extradata, if any
218
-
219
- imagedata.rewind
220
- imagedata_start = fo.tell
221
- h.times do
222
- fo << imagedata.read(new_significant_sl_bytes)
223
- fo << padding
218
+ if @options[:rewrite]
219
+ IO.copy_stream fi, fo
220
+ else
221
+ # copy remaining header bytes
222
+ fo.write fi.read(imagedata_offset-fi.tell)
223
+
224
+ # FIXME: if scanline sizes differ in BITS, not bytes...
225
+
226
+ # scanline padding needs to be respected...
227
+ imagedata = StringIO.new
228
+ @image.height.times do
229
+ data = fi.read @old_total_sl_bytes
230
+ imagedata << data[0, @old_significant_sl_bytes]
231
+ #p data[@old_significant_sl_bytes..-1]
232
+ end
233
+ imagedata << fi.read # read extradata, if any
234
+
235
+ imagedata.rewind
236
+ imagedata_start = fo.tell
237
+ h.times do
238
+ fo << imagedata.read(new_significant_sl_bytes)
239
+ fo << padding
240
+ end
241
+ file_size = fo.tell
242
+ imagedata_size = fo.tell - imagedata_start
243
+ fo << imagedata.read # write extradata, if any
244
+
245
+ # write new BITMAPFILEHEADER.bfSize
246
+ fo.seek 2
247
+ fo.write [file_size].pack('V')
248
+
249
+ # write new BITMAPINFOHEADER.biSizeImage
250
+ fo.seek 14+20 # BITMAPFILEHEADER::SIZE + 20
251
+ fo.write [imagedata_size].pack('V')
224
252
  end
225
- file_size = fo.tell
226
- imagedata_size = fo.tell - imagedata_start
227
- fo << imagedata.read # write extradata, if any
228
-
229
- # write new BITMAPFILEHEADER.bfSize
230
- fo.seek 2
231
- fo.write [file_size].pack('V')
232
-
233
- # write new BITMAPINFOHEADER.biSizeImage
234
- fo.seek 14+20 # BITMAPFILEHEADER::SIZE + 20
235
- fo.write [imagedata_size].pack('V')
236
253
  end
237
254
  end
238
255
  end
@@ -15,7 +15,7 @@ module ZSteg
15
15
  end
16
16
 
17
17
  data = ''.force_encoding('binary')
18
- a = []
18
+ a = [0]*params[:shift].to_i # prepend :shift zero bits
19
19
  byte_iterator(params) do |x,y|
20
20
  sl = @image.scanlines[y]
21
21
 
@@ -35,8 +35,7 @@ module ZSteg
35
35
  end
36
36
 
37
37
  data = ''.force_encoding('binary')
38
- a = []
39
- #puts
38
+ a = [0]*params[:shift].to_i # prepend :shift zero bits
40
39
  catch :limit do
41
40
  coord_iterator(params) do |x,y|
42
41
  color = @image[x,y]
@@ -94,7 +94,7 @@ module ZSteg
94
94
  rescue
95
95
  t = data.force_encoding('binary')
96
96
  end
97
- if t.size >= Checker::MIN_TEXT_LENGTH
97
+ if t.size >= Checker::DEFAULT_MIN_STR_LEN
98
98
  ZSteg::Result::UnicodeText.new(t,0)
99
99
  end
100
100
  else
@@ -2,15 +2,14 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: zsteg 0.1.1 ruby lib
6
5
 
7
6
  Gem::Specification.new do |s|
8
7
  s.name = "zsteg"
9
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
10
9
 
11
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
11
  s.authors = ["Andrey \"Zed\" Zaikin"]
13
- s.date = "2013-09-20"
12
+ s.date = "2014-03-01"
14
13
  s.email = "zed.0xff@gmail.com"
15
14
  s.executables = ["zsteg", "zsteg-mask", "zsteg-reflow"]
16
15
  s.extra_rdoc_files = [
@@ -103,27 +102,27 @@ Gem::Specification.new do |s|
103
102
  s.homepage = "http://github.com/zed-0xff/zsteg"
104
103
  s.licenses = ["MIT"]
105
104
  s.require_paths = ["lib"]
106
- s.rubygems_version = "2.1.4"
105
+ s.rubygems_version = "2.0.3"
107
106
  s.summary = "Detect stegano-hidden data in PNG & BMP files."
108
107
 
109
108
  if s.respond_to? :specification_version then
110
109
  s.specification_version = 4
111
110
 
112
111
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
113
- s.add_runtime_dependency(%q<zpng>, [">= 0.2.3"])
112
+ s.add_runtime_dependency(%q<zpng>, [">= 0.2.5"])
114
113
  s.add_runtime_dependency(%q<iostruct>, [">= 0"])
115
114
  s.add_development_dependency(%q<rspec>, [">= 2.8.0"])
116
115
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
117
116
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
118
117
  else
119
- s.add_dependency(%q<zpng>, [">= 0.2.3"])
118
+ s.add_dependency(%q<zpng>, [">= 0.2.5"])
120
119
  s.add_dependency(%q<iostruct>, [">= 0"])
121
120
  s.add_dependency(%q<rspec>, [">= 2.8.0"])
122
121
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
123
122
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
124
123
  end
125
124
  else
126
- s.add_dependency(%q<zpng>, [">= 0.2.3"])
125
+ s.add_dependency(%q<zpng>, [">= 0.2.5"])
127
126
  s.add_dependency(%q<iostruct>, [">= 0"])
128
127
  s.add_dependency(%q<rspec>, [">= 2.8.0"])
129
128
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zsteg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey "Zed" Zaikin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-20 00:00:00.000000000 Z
11
+ date: 2014-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zpng
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.3
19
+ version: 0.2.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.3
26
+ version: 0.2.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: iostruct
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.1.4
195
+ rubygems_version: 2.0.3
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: Detect stegano-hidden data in PNG & BMP files.