zsteg 0.2.13 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05bf462c6bc2696efead731d0ce3bda8cf371435cc9448b100892b7084364c64
4
- data.tar.gz: c12f610fe42706271d763620100a71572477696c07010d9323c1bb97f7440fbe
3
+ metadata.gz: 517af804bb6892894d053fe80139d31ca23746c02c42f33dd5574bf25e41f8c2
4
+ data.tar.gz: 399a3f35dc307eb44d1b3e4cb776e32887428d25f311b42a8facb33ecb8ba7f0
5
5
  SHA512:
6
- metadata.gz: 3340516e94d8248446ddb5df7a64269aed8fb4b09a1bf10057d603581b352e39adc595104ae4b75fa042d8895459532dac21c2304cc49bfe222ffc0df358fa55
7
- data.tar.gz: d4bd9eaf13356a534eeb3be2807b524c73549dc0d3fbe44f349393930f0f4a31be1430b434d4ef8fb42ea2c2eda42dd13eb013222fc37714ce9801973358ba8e
6
+ metadata.gz: cf416358da42bab09505d7f54d3e5df0b9e26cc4b29e3b6e0aa73bb13900c7367d5e941298917bb6286a6e8b5f430eca36547a4f66efd4d06b3c2a8316b17ffd
7
+ data.tar.gz: 49f2ac63384acc20790882c5542375b655c4462a6099d0ba999fe300ca91766c9d65ec08f2288f9e628c6c11b552f91490ae24be55c6ffbd96b0c94998a64002
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "zpng", ">= 0.4.5"
4
- gem "iostruct", ">= 0.0.5"
3
+ gem "zpng", ">= 0.4.6"
4
+ gem "iostruct", ">= 0.7.0"
5
5
  gem "prime"
6
6
 
7
7
  group :development do
data/Gemfile.lock CHANGED
@@ -1,13 +1,36 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.8.1)
5
- public_suffix (>= 2.0.2, < 6.0)
6
- builder (3.2.4)
4
+ activesupport (7.1.6)
5
+ base64
6
+ benchmark (>= 0.3)
7
+ bigdecimal
8
+ concurrent-ruby (~> 1.0, >= 1.0.2)
9
+ connection_pool (>= 2.2.5)
10
+ drb
11
+ i18n (>= 1.6, < 2)
12
+ logger (>= 1.4.2)
13
+ minitest (>= 5.1)
14
+ mutex_m
15
+ securerandom (>= 0.3)
16
+ tzinfo (~> 2.0)
17
+ addressable (2.8.8)
18
+ public_suffix (>= 2.0.2, < 8.0)
19
+ base64 (0.3.0)
20
+ benchmark (0.5.0)
21
+ bigdecimal (4.0.1)
22
+ builder (3.3.0)
23
+ cgi (0.5.1)
24
+ concurrent-ruby (1.3.6)
25
+ connection_pool (2.5.5)
26
+ date (3.5.1)
7
27
  descendants_tracker (0.0.4)
8
28
  thread_safe (~> 0.3, >= 0.3.1)
9
- diff-lcs (1.5.0)
10
- faraday (1.10.3)
29
+ diff-lcs (1.6.2)
30
+ drb (2.2.3)
31
+ erb (4.0.4)
32
+ cgi (>= 0.3.3)
33
+ faraday (1.10.4)
11
34
  faraday-em_http (~> 1.0)
12
35
  faraday-em_synchrony (~> 1.0)
13
36
  faraday-excon (~> 1.1)
@@ -20,19 +43,21 @@ GEM
20
43
  faraday-retry (~> 1.0)
21
44
  ruby2_keywords (>= 0.0.4)
22
45
  faraday-em_http (1.0.0)
23
- faraday-em_synchrony (1.0.0)
46
+ faraday-em_synchrony (1.0.1)
24
47
  faraday-excon (1.1.0)
25
48
  faraday-httpclient (1.0.1)
26
- faraday-multipart (1.0.4)
27
- multipart-post (~> 2)
28
- faraday-net_http (1.0.1)
49
+ faraday-multipart (1.2.0)
50
+ multipart-post (~> 2.0)
51
+ faraday-net_http (1.0.2)
29
52
  faraday-net_http_persistent (1.2.0)
30
53
  faraday-patron (1.0.0)
31
54
  faraday-rack (1.0.0)
32
55
  faraday-retry (1.0.3)
33
- forwardable (1.3.3)
34
- git (1.13.2)
56
+ forwardable (1.4.0)
57
+ git (2.3.3)
58
+ activesupport (>= 5.0)
35
59
  addressable (~> 2.8)
60
+ process_executer (~> 1.1)
36
61
  rchardet (~> 1.8)
37
62
  github_api (0.19.0)
38
63
  addressable (~> 2.4)
@@ -41,8 +66,12 @@ GEM
41
66
  hashie (~> 3.5, >= 3.5.2)
42
67
  oauth2 (~> 1.0)
43
68
  hashie (3.6.0)
44
- highline (2.1.0)
45
- iostruct (0.0.5)
69
+ highline (3.1.2)
70
+ reline
71
+ i18n (1.14.8)
72
+ concurrent-ruby (~> 1.0)
73
+ io-console (0.8.2)
74
+ iostruct (0.7.0)
46
75
  juwelier (2.4.9)
47
76
  builder
48
77
  bundler
@@ -55,15 +84,19 @@ GEM
55
84
  rake
56
85
  rdoc
57
86
  semver2
58
- jwt (2.7.0)
87
+ jwt (2.10.2)
88
+ base64
59
89
  kamelcase (0.0.2)
60
90
  semver2 (~> 3)
61
- mini_portile2 (2.8.1)
62
- multi_json (1.15.0)
91
+ logger (1.7.0)
92
+ mini_portile2 (2.8.9)
93
+ minitest (5.26.1)
94
+ multi_json (1.19.1)
63
95
  multi_xml (0.6.0)
64
- multipart-post (2.3.0)
65
- nokogiri (1.14.2)
66
- mini_portile2 (~> 2.8.0)
96
+ multipart-post (2.4.1)
97
+ mutex_m (0.3.0)
98
+ nokogiri (1.17.2)
99
+ mini_portile2 (~> 2.8.2)
67
100
  racc (~> 1.4)
68
101
  oauth2 (1.4.11)
69
102
  faraday (>= 0.17.3, < 3.0)
@@ -71,49 +104,60 @@ GEM
71
104
  multi_json (~> 1.3)
72
105
  multi_xml (~> 0.5)
73
106
  rack (>= 1.2, < 4)
74
- prime (0.1.2)
107
+ prime (0.1.4)
75
108
  forwardable
76
109
  singleton
77
- psych (5.1.0)
110
+ process_executer (1.1.2)
111
+ psych (5.3.1)
112
+ date
78
113
  stringio
79
- public_suffix (5.0.1)
80
- racc (1.6.2)
81
- rack (3.0.4.1)
114
+ public_suffix (6.0.2)
115
+ racc (1.8.1)
116
+ rack (3.2.4)
82
117
  rainbow (3.1.1)
83
- rake (13.0.6)
84
- rchardet (1.8.0)
85
- rdoc (6.5.0)
118
+ rake (13.3.1)
119
+ rchardet (1.10.0)
120
+ rdoc (7.1.0)
121
+ erb
86
122
  psych (>= 4.0.0)
87
- rspec (3.12.0)
88
- rspec-core (~> 3.12.0)
89
- rspec-expectations (~> 3.12.0)
90
- rspec-mocks (~> 3.12.0)
91
- rspec-core (3.12.1)
92
- rspec-support (~> 3.12.0)
93
- rspec-expectations (3.12.2)
123
+ tsort
124
+ reline (0.6.3)
125
+ io-console (~> 0.5)
126
+ rspec (3.13.2)
127
+ rspec-core (~> 3.13.0)
128
+ rspec-expectations (~> 3.13.0)
129
+ rspec-mocks (~> 3.13.0)
130
+ rspec-core (3.13.6)
131
+ rspec-support (~> 3.13.0)
132
+ rspec-expectations (3.13.5)
94
133
  diff-lcs (>= 1.2.0, < 2.0)
95
- rspec-support (~> 3.12.0)
96
- rspec-mocks (3.12.3)
134
+ rspec-support (~> 3.13.0)
135
+ rspec-mocks (3.13.7)
97
136
  diff-lcs (>= 1.2.0, < 2.0)
98
- rspec-support (~> 3.12.0)
99
- rspec-support (3.12.0)
137
+ rspec-support (~> 3.13.0)
138
+ rspec-support (3.13.6)
100
139
  ruby2_keywords (0.0.5)
140
+ securerandom (0.3.2)
101
141
  semver2 (3.4.2)
102
- singleton (0.1.1)
103
- stringio (3.0.5)
142
+ singleton (0.3.0)
143
+ stringio (3.2.0)
104
144
  thread_safe (0.3.6)
105
- zpng (0.4.5)
145
+ tsort (0.2.0)
146
+ tzinfo (2.0.6)
147
+ concurrent-ruby (~> 1.0)
148
+ zpng (0.4.6)
149
+ iostruct (>= 0.7.0)
106
150
  rainbow (~> 3.1.1)
107
151
 
108
152
  PLATFORMS
109
153
  ruby
110
154
 
111
155
  DEPENDENCIES
112
- iostruct (>= 0.0.5)
156
+ iostruct (>= 0.7.0)
113
157
  juwelier
114
158
  prime
115
159
  rspec
116
- zpng (>= 0.4.5)
160
+ zpng (>= 0.4.6)
117
161
 
118
162
  BUNDLED WITH
119
- 2.3.12
163
+ 2.4.22
data/TODO CHANGED
@@ -11,6 +11,8 @@
11
11
  [ ] advices on what tool to use
12
12
  [ ] SilentEye
13
13
  [ ] chunks length check, as in pngcheck
14
+ [ ] hiding data in iCCP
15
+ [ ] hiding data before/after ICC apply
14
16
 
15
17
  [ ] CLI: self-describe
16
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.13
1
+ 0.2.14
@@ -11,13 +11,13 @@ module ZSteg
11
11
  # 17 107 [bitloss] [secret size - 4 bytes] [secret type] [secret type length]
12
12
  # 17 107 1 4096 "text/plain" 10
13
13
 
14
- class Result < IOStruct.new "nCNa*", :magic, :bitloss, :secret_size, :secret_type
14
+ class Result < IOStruct.new("nCNa*", :magic, :bitloss, :secret_size, :secret_type, struct_name: 'SteganographyPNG')
15
15
  def valid?
16
16
  magic == 0x116b && (1..8).include?(bitloss)
17
17
  end
18
18
 
19
19
  def to_s
20
- super.sub('#<struct ZSteg::Checker::SteganographyPNG::Result', 'SteganographyPNG').sub(/>$/,'').bright_red
20
+ super.sub(/>$/,'').bright_red
21
21
  end
22
22
  end
23
23
 
@@ -11,7 +11,7 @@ module ZSteg
11
11
  "Rijndael", # 4
12
12
  ]
13
13
 
14
- class Result < IOStruct.new "a3a3a*", :size, :ext, :data, :even, :hdr, :enc, :mix, :controlbyte
14
+ class Result < IOStruct.new("a3a3a*", :size, :ext, :data, :even, :hdr, :enc, :mix, :controlbyte, struct_name: 'wbStego')
15
15
  attr_accessor :color
16
16
 
17
17
  def initialize *args
@@ -39,7 +39,6 @@ module ZSteg
39
39
 
40
40
  def to_s
41
41
  s = inspect.
42
- sub("#<struct #{self.class.to_s}", "<wbStego").
43
42
  gsub(/, \w+=nil/,'')
44
43
 
45
44
  color = @color
@@ -21,6 +21,7 @@ module ZSteg
21
21
  # http://blog.w3challs.com/index.php?post/2012/03/25/NDH2k12-Prequals-We-are-looking-for-a-real-hacker-Wallpaper-image
22
22
  # http://blog.w3challs.com/public/ndh2k12_prequalls/sp113.bmp
23
23
  def self.check_data data
24
+ data = data.force_encoding('ASCII-8BIT')
24
25
  return unless idx = data.index(/\x78[\x9c\xda\x01]/n)
25
26
 
26
27
  zi = ::Zlib::Inflate.new
data/lib/zsteg/checker.rb CHANGED
@@ -76,6 +76,7 @@ module ZSteg
76
76
  check_extradata
77
77
  check_metadata
78
78
  check_imagedata
79
+ check_chunks
79
80
  end
80
81
 
81
82
  if @image.format == :bmp
@@ -143,6 +144,16 @@ module ZSteg
143
144
  process_result @image.imagedata, h
144
145
  end
145
146
 
147
+ def check_chunks
148
+ @image.chunks.each_with_index do |chunk, idx|
149
+ next unless chunk.respond_to?(:size) && chunk.respond_to?(:data)
150
+ next unless chunk.size && chunk.data
151
+ next if chunk.size < 5 || chunk.is_a?(ZPNG::TextChunk) || chunk.is_a?(ZPNG::Chunk::IDAT)
152
+ h = { :title => "chunk:#{idx}:#{chunk.type}", :show_title => true }
153
+ process_result chunk.data, h
154
+ end
155
+ end
156
+
146
157
  def check_extradata
147
158
  # accessing imagedata implicitly unpacks zlib stream
148
159
  # zlib stream may contain extradata
data/lib/zsteg/cli/cli.rb CHANGED
@@ -244,6 +244,17 @@ module ZSteg
244
244
  @img.extradata[$1.to_i]
245
245
  when /imagedata/
246
246
  @img.imagedata
247
+ when /\Achunk:(\d+):(.+)\Z/
248
+ # chunk with type check
249
+ idx, type = $1.to_i, $2
250
+ chunk = @img.chunks[idx]
251
+ raise "chunk ##{idx}: expected #{type} type, but got #{chunk.type}" if chunk.type != type
252
+ chunk.data
253
+ when /\Achunk:(\d+)\Z/
254
+ # chunk without type check
255
+ idx, type = $1.to_i, $2
256
+ chunk = @img.chunks[idx]
257
+ chunk.data
247
258
  else
248
259
  h = decode_param_string name
249
260
  h[:limit] = @options[:limit] if @options[:limit] != Checker::DEFAULT_LIMIT
data/lib/zsteg/result.rb CHANGED
@@ -8,8 +8,9 @@ module ZSteg
8
8
  end
9
9
  end
10
10
 
11
- class OpenStego < IOStruct.new "CVCCCC",
12
- :version, :data_len, :channel_bits, :fname_len, :compress, :encrypt, :fname
11
+ class OpenStego < IOStruct.new("CVCCCC",
12
+ :version, :data_len, :channel_bits, :fname_len, :compress, :encrypt, :fname,
13
+ struct_name: 'OpenStego')
13
14
 
14
15
  def self.read io
15
16
  super.tap do |r|
@@ -18,7 +19,7 @@ module ZSteg
18
19
  end
19
20
 
20
21
  def to_s
21
- super.sub(/^<Result::/,'').sub(/>$/,'').bright_red
22
+ super.sub(/>$/,'').bright_red
22
23
  end
23
24
  end
24
25
 
data/spec/plte_spec.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe "samples/plte1.png" do
4
+ subject{ cli(sample("plte1.png")) }
5
+ it { should include("Zip archive data") }
6
+
7
+ describe "--extract" do
8
+ it "should extract zip file from PLTE with type check" do
9
+ r = cli(sample("plte1.png"), "--extract", "chunk:1:PLTE")
10
+ md5(r).should == 'e125f0f322fd1e99050dba688968385c'
11
+ end
12
+ it "should extract zip file from PLTE without type check" do
13
+ r = cli(sample("plte1.png"), "--extract", "chunk:1")
14
+ md5(r).should == 'e125f0f322fd1e99050dba688968385c'
15
+ end
16
+ end
17
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,14 @@
1
1
  #coding: binary
2
2
  $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
3
3
  require 'zsteg'
4
+ require 'digest/md5'
4
5
 
5
6
  SAMPLES_DIR = File.expand_path("../samples", File.dirname(__FILE__))
6
7
 
8
+ def md5 data
9
+ Digest::MD5.hexdigest(data)
10
+ end
11
+
7
12
  def each_sample glob="*.png"
8
13
  Dir[File.join(SAMPLES_DIR, glob)].each do |fname|
9
14
  yield fname.sub(Dir.pwd+'/','')
data/zsteg.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: zsteg 0.2.13 ruby lib
5
+ # stub: zsteg 0.2.14 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "zsteg".freeze
9
- s.version = "0.2.13"
9
+ s.version = "0.2.14"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Andrey \"Zed\" Zaikin".freeze]
14
- s.date = "2023-02-19"
14
+ s.date = "2026-01-28"
15
15
  s.email = "zed.0xff@gmail.com".freeze
16
16
  s.executables = ["zsteg".freeze, "zsteg-mask".freeze, "zsteg-reflow".freeze]
17
17
  s.extra_rdoc_files = [
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
59
59
  "spec/mask_spec.rb",
60
60
  "spec/newbiecontest_spec.rb",
61
61
  "spec/openstego_spec.rb",
62
+ "spec/plte_spec.rb",
62
63
  "spec/polictf2012_spec.rb",
63
64
  "spec/prime_spec.rb",
64
65
  "spec/r3g2b3_spec.rb",
@@ -75,7 +76,7 @@ Gem::Specification.new do |s|
75
76
  ]
76
77
  s.homepage = "http://github.com/zed-0xff/zsteg".freeze
77
78
  s.licenses = ["MIT".freeze]
78
- s.rubygems_version = "3.3.7".freeze
79
+ s.rubygems_version = "3.2.33".freeze
79
80
  s.summary = "Detect stegano-hidden data in PNG & BMP files.".freeze
80
81
 
81
82
  if s.respond_to? :specification_version then
@@ -83,14 +84,14 @@ Gem::Specification.new do |s|
83
84
  end
84
85
 
85
86
  if s.respond_to? :add_runtime_dependency then
86
- s.add_runtime_dependency(%q<zpng>.freeze, [">= 0.4.5"])
87
- s.add_runtime_dependency(%q<iostruct>.freeze, [">= 0.0.5"])
87
+ s.add_runtime_dependency(%q<zpng>.freeze, [">= 0.4.6"])
88
+ s.add_runtime_dependency(%q<iostruct>.freeze, [">= 0.7.0"])
88
89
  s.add_runtime_dependency(%q<prime>.freeze, [">= 0"])
89
90
  s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
90
91
  s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
91
92
  else
92
- s.add_dependency(%q<zpng>.freeze, [">= 0.4.5"])
93
- s.add_dependency(%q<iostruct>.freeze, [">= 0.0.5"])
93
+ s.add_dependency(%q<zpng>.freeze, [">= 0.4.6"])
94
+ s.add_dependency(%q<iostruct>.freeze, [">= 0.7.0"])
94
95
  s.add_dependency(%q<prime>.freeze, [">= 0"])
95
96
  s.add_dependency(%q<rspec>.freeze, [">= 0"])
96
97
  s.add_dependency(%q<juwelier>.freeze, [">= 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.2.13
4
+ version: 0.2.14
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: 2023-02-19 00:00:00.000000000 Z
11
+ date: 2026-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zpng
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.5
19
+ version: 0.4.6
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.4.5
26
+ version: 0.4.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: iostruct
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.5
33
+ version: 0.7.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.5
40
+ version: 0.7.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: prime
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ files:
131
131
  - spec/mask_spec.rb
132
132
  - spec/newbiecontest_spec.rb
133
133
  - spec/openstego_spec.rb
134
+ - spec/plte_spec.rb
134
135
  - spec/polictf2012_spec.rb
135
136
  - spec/prime_spec.rb
136
137
  - spec/r3g2b3_spec.rb
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  - !ruby/object:Gem::Version
164
165
  version: '0'
165
166
  requirements: []
166
- rubygems_version: 3.3.7
167
+ rubygems_version: 3.2.33
167
168
  signing_key:
168
169
  specification_version: 4
169
170
  summary: Detect stegano-hidden data in PNG & BMP files.