pedump 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b7032e6e832ba6c7fead77e245952396e8e28f42
4
+ data.tar.gz: 35bb50e4f1095127491dfe2cf0f902588afd8799
5
+ SHA512:
6
+ metadata.gz: 70050e12128d7068566db6aec580ebc79066134b16e38538747423bf2a52409adcb2564692463497fbe33906741e0de3d2843571ad613b17cad97d08cae5bea8
7
+ data.tar.gz: 03ad91ef9cdf5554458ffe2c50ef7ceb2ec79b6368e48e2f96b15c6f4536b82f894edafc52a01bf1b44755229ff282f6321b6db520990721901166fa0fe3541a
data/Gemfile CHANGED
@@ -1,20 +1,14 @@
1
1
  source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem "multipart-post", "~> 1.1.4"
2
+
3
+ gem "multipart-post", "~> 2.0.0"
6
4
  gem "progressbar"
7
5
  gem "awesome_print"
8
6
  gem "iostruct", ">= 0.0.4"
9
7
  gem "zhexdump", ">= 0.0.2"
10
8
 
11
- # Add dependencies to develop your gem here.
12
- # Include everything needed to run rake, tests, features, etc.
13
9
  group :development do
14
10
  gem "rspec"
15
11
  gem "bundler"
16
- gem "jeweler"
17
- # gem "rcov", ">= 0"
18
12
  gem "what_methods"
19
- # gem "looksee"
13
+ gem "rake"
20
14
  end
@@ -1,29 +1,25 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- awesome_print (1.1.0)
5
- diff-lcs (1.1.3)
6
- git (1.2.5)
4
+ awesome_print (1.7.0)
5
+ diff-lcs (1.2.5)
7
6
  iostruct (0.0.4)
8
- jeweler (1.8.4)
9
- bundler (~> 1.0)
10
- git (>= 1.2.5)
11
- rake
12
- rdoc
13
- json (1.7.5)
14
- multipart-post (1.1.5)
15
- progressbar (0.12.0)
16
- rake (10.0.4)
17
- rdoc (3.12)
18
- json (~> 1.4)
19
- rspec (2.12.0)
20
- rspec-core (~> 2.12.0)
21
- rspec-expectations (~> 2.12.0)
22
- rspec-mocks (~> 2.12.0)
23
- rspec-core (2.12.1)
24
- rspec-expectations (2.12.0)
25
- diff-lcs (~> 1.1.3)
26
- rspec-mocks (2.12.0)
7
+ multipart-post (2.0.0)
8
+ progressbar (0.21.0)
9
+ rake (10.4.2)
10
+ rspec (3.5.0)
11
+ rspec-core (~> 3.5.0)
12
+ rspec-expectations (~> 3.5.0)
13
+ rspec-mocks (~> 3.5.0)
14
+ rspec-core (3.5.3)
15
+ rspec-support (~> 3.5.0)
16
+ rspec-expectations (3.5.0)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.5.0)
19
+ rspec-mocks (3.5.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.5.0)
22
+ rspec-support (3.5.0)
27
23
  what_methods (1.0.1)
28
24
  zhexdump (0.0.2)
29
25
 
@@ -34,9 +30,12 @@ DEPENDENCIES
34
30
  awesome_print
35
31
  bundler
36
32
  iostruct (>= 0.0.4)
37
- jeweler
38
- multipart-post (~> 1.1.4)
33
+ multipart-post (~> 2.0.0)
39
34
  progressbar
35
+ rake
40
36
  rspec
41
37
  what_methods
42
38
  zhexdump (>= 0.0.2)
39
+
40
+ BUNDLED WITH
41
+ 1.12.5
data/Rakefile CHANGED
@@ -1,81 +1,12 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
1
  require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "pedump"
18
- gem.homepage = "http://github.com/zed-0xff/pedump"
19
- gem.license = "MIT"
20
- gem.summary = %Q{dump win32 PE executable files with a pure ruby}
21
- gem.description = %Q{dump headers, sections, extract resources of win32 PE exe,dll,etc}
22
- gem.email = "zed.0xff@gmail.com"
23
- gem.authors = ["Andrey \"Zed\" Zaikin"]
24
- gem.executables = %w'pedump'
25
- gem.files.include "lib/**/*.rb"
26
- gem.files.include "data/*.bin"
27
- gem.files.include "data/*.txt"
28
-
29
- gem.files.exclude "samples/*", "README.md.tpl"
30
- gem.extra_rdoc_files.exclude "README.md.tpl"
31
- end
32
- Jeweler::RubygemsDotOrgTasks.new
33
-
34
- require 'rspec/core'
2
+ require 'bundler/gem_tasks'
35
3
  require 'rspec/core/rake_task'
36
- RSpec::Core::RakeTask.new(:spec) do |spec|
37
- spec.pattern = FileList['spec/**/*_spec.rb']
38
- end
39
4
 
40
- RSpec::Core::RakeTask.new(:rcov) do |spec|
41
- spec.pattern = 'spec/**/*_spec.rb'
42
- spec.rcov = true
43
- end
5
+ desc "run specs"
6
+ RSpec::Core::RakeTask.new
44
7
 
45
8
  task :default => :spec
46
9
 
47
- #require 'rake/rdoctask'
48
- #Rake::RDocTask.new do |rdoc|
49
- # version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
- #
51
- # rdoc.rdoc_dir = 'rdoc'
52
- # rdoc.title = "pedump #{version}"
53
- # rdoc.rdoc_files.include('README*')
54
- # rdoc.rdoc_files.include('lib/**/*.rb')
55
- #end
56
-
57
- class Jeweler::Commands::Version::Base
58
- alias :commit_version_old :commit_version
59
- def commit_version
60
- code = <<-EOF
61
- class PEdump
62
- module Version
63
- MAJOR = #{version_helper.major}
64
- MINOR = #{version_helper.minor}
65
- PATCH = #{version_helper.patch}
66
- BUILD = nil
67
-
68
- STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
69
- end
70
- end
71
- EOF
72
- vfile = working_subdir.join("lib/pedump/version.rb")
73
- File.open(vfile,"w"){ |f| f << code }
74
- self.repo.add vfile if self.repo
75
- commit_version_old
76
- end
77
- end
78
-
79
10
  namespace :test do
80
11
  desc "test on all files in given path"
81
12
  task :all_files do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -474,9 +474,10 @@ class PEdump
474
474
  :first_thunk
475
475
 
476
476
  class ImportedFunction < Struct.new(:hint, :name, :ordinal, :va, :module_name)
477
- # def == x
478
- # self.hint == x.hint && self.name == x.name && self.ordinal == x.ordinal
479
- # end
477
+ def == x
478
+ self.hint == x.hint && self.name == x.name && self.ordinal == x.ordinal &&
479
+ self.module_name == x.module_name
480
+ end
480
481
  # def <=> x
481
482
  # self.to_a[0..-2] <=> x.to_a[0..-2]
482
483
  # end
@@ -626,7 +627,11 @@ class PEdump
626
627
  :name, :entry_points, :names, :name_ordinals, :functions,
627
628
  :description # NE only
628
629
 
629
- ExportedFunction = Struct.new :name, :ord, :va, :file_offset
630
+ class ExportedFunction < Struct.new :name, :ord, :va, :file_offset
631
+ def ordinal
632
+ self.ord
633
+ end
634
+ end
630
635
 
631
636
  def exports f=@io
632
637
  if pe(f)
@@ -263,7 +263,7 @@ class PEdump::Loader
263
263
  @pedump.imports.each do |iid| # Image Import Descriptor
264
264
  va = iid.FirstThunk + @image_base
265
265
  (Array(iid.original_first_thunk) + Array(iid.first_thunk)).uniq.each do |func|
266
- name = func.name || "##{func.ordinal}"
266
+ name = "__imp_" + (func.name || "#{func.ordinal}")
267
267
  @names[va] = name
268
268
  va += 4
269
269
  end
@@ -53,6 +53,24 @@ class PEdump
53
53
  end
54
54
  end
55
55
 
56
+ MINIDUMP_MEMORY_DESCRIPTOR = IOStruct.new 'QLL',
57
+ :StartOfMemoryRange,
58
+ :DataSize,
59
+ :Rva
60
+
61
+ class MINIDUMP_MEMORY_LIST < IOStruct.new 'L',
62
+ :NumberOfMemoryRanges,
63
+ :MemoryRanges
64
+
65
+ def self.read io
66
+ r = super
67
+ r.MemoryRanges = r.NumberOfMemoryRanges.times.map{ MINIDUMP_MEMORY_DESCRIPTOR.read(io) }
68
+ r
69
+ end
70
+
71
+ def entries; self.MemoryRanges; end
72
+ end
73
+
56
74
  MINIDUMP_MEMORY_DESCRIPTOR64 = IOStruct.new 'QQ',
57
75
  :StartOfMemoryRange,
58
76
  :DataSize
@@ -78,7 +96,7 @@ class PEdump
78
96
  2 => :ReservedStream1,
79
97
  3 => :ThreadListStream,
80
98
  4 => :ModuleListStream,
81
- 5 => :MemoryListStream,
99
+ 5 => :MemoryListStream, # MINIDUMP_MEMORY_LIST
82
100
  6 => :ExceptionStream,
83
101
  7 => :SystemInfoStream,
84
102
  8 => :ThreadExListStream,
@@ -125,6 +143,14 @@ class PEdump
125
143
  end
126
144
 
127
145
  def memory_list
146
+ # MINIDUMP_MEMORY_LIST
147
+ stream = streams.find{ |s| s.StreamType == 5 }
148
+ return nil unless stream
149
+ io.seek stream.Location.Rva
150
+ MINIDUMP_MEMORY_LIST.read io
151
+ end
152
+
153
+ def memory64_list
128
154
  # MINIDUMP_MEMORY64_LIST
129
155
  stream = streams.find{ |s| s.StreamType == 9 }
130
156
  return nil unless stream
@@ -136,27 +162,50 @@ class PEdump
136
162
 
137
163
  # set options[:merge] = true to merge adjacent memory ranges
138
164
  def memory_ranges options = {}
139
- ml = memory_list
140
- file_offset = ml.BaseRva
141
- r = []
142
- if options[:merge]
143
- ml.entries.each do |x|
144
- if r.last && r.last.va + r.last.size == x.StartOfMemoryRange
145
- # if section VA == prev_section.VA + prev_section.SIZE
146
- # then just increase the size of previous section
147
- r.last.size += x.DataSize
148
- else
165
+ if memory64_list
166
+ ml = memory64_list
167
+ file_offset = ml.BaseRva
168
+ r = []
169
+ if options[:merge]
170
+ ml.entries.each do |x|
171
+ if r.last && r.last.va + r.last.size == x.StartOfMemoryRange
172
+ # if section VA == prev_section.VA + prev_section.SIZE
173
+ # then just increase the size of previous section
174
+ r.last.size += x.DataSize
175
+ else
176
+ r << MemoryRange.new( file_offset, x.StartOfMemoryRange, x.DataSize )
177
+ end
178
+ file_offset += x.DataSize
179
+ end
180
+ else
181
+ ml.entries.each do |x|
149
182
  r << MemoryRange.new( file_offset, x.StartOfMemoryRange, x.DataSize )
183
+ file_offset += x.DataSize
150
184
  end
151
- file_offset += x.DataSize
152
185
  end
153
- else
154
- ml.entries.each do |x|
155
- r << MemoryRange.new( file_offset, x.StartOfMemoryRange, x.DataSize )
156
- file_offset += x.DataSize
186
+ return r
187
+ elsif memory_list
188
+ ml = memory_list
189
+ r = []
190
+ if options[:merge]
191
+ ml.entries.each do |x|
192
+ if r.last && r.last.va + r.last.size == x.StartOfMemoryRange
193
+ # if section VA == prev_section.VA + prev_section.SIZE
194
+ # then just increase the size of previous section
195
+ r.last.size += x.DataSize
196
+ else
197
+ r << MemoryRange.new( x.Rva, x.StartOfMemoryRange, x.DataSize )
198
+ end
199
+ end
200
+ else
201
+ ml.entries.each do |x|
202
+ r << MemoryRange.new( x.Rva, x.StartOfMemoryRange, x.DataSize )
203
+ end
157
204
  end
205
+ return r
206
+ else
207
+ raise "Could not find memory ranges"
158
208
  end
159
- r
160
209
  end
161
210
 
162
211
  end # class Minidump
@@ -2,7 +2,7 @@ class PEdump
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 5
5
- PATCH = 0
5
+ PATCH = 1
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -1,137 +1,27 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pedump/version'
5
5
 
6
- Gem::Specification.new do |s|
7
- s.name = "pedump"
8
- s.version = "0.5.0"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pedump"
8
+ spec.version = PEdump::Version::STRING
9
+ spec.authors = ["Andrey \"Zed\" Zaikin"]
10
+ spec.email = ["zed.0xff@gmail.com"]
9
11
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Andrey \"Zed\" Zaikin"]
12
- s.date = "2013-04-20"
13
- s.description = "dump headers, sections, extract resources of win32 PE exe,dll,etc"
14
- s.email = "zed.0xff@gmail.com"
15
- s.executables = ["pedump"]
16
- s.extra_rdoc_files = [
17
- "LICENSE.txt",
18
- "README.md"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".rspec",
23
- ".travis.yml",
24
- "Gemfile",
25
- "Gemfile.lock",
26
- "LICENSE.txt",
27
- "README.md",
28
- "Rakefile",
29
- "VERSION",
30
- "bin/pedump",
31
- "data/fs.txt",
32
- "data/jc-userdb.txt",
33
- "data/sig.bin",
34
- "data/signatures.txt",
35
- "data/userdb.txt",
36
- "lib/pedump.rb",
37
- "lib/pedump/cli.rb",
38
- "lib/pedump/comparer.rb",
39
- "lib/pedump/composite_io.rb",
40
- "lib/pedump/core.rb",
41
- "lib/pedump/core_ext/try.rb",
42
- "lib/pedump/loader.rb",
43
- "lib/pedump/loader/minidump.rb",
44
- "lib/pedump/loader/section.rb",
45
- "lib/pedump/logger.rb",
46
- "lib/pedump/ne.rb",
47
- "lib/pedump/ne/version_info.rb",
48
- "lib/pedump/packer.rb",
49
- "lib/pedump/pe.rb",
50
- "lib/pedump/resources.rb",
51
- "lib/pedump/security.rb",
52
- "lib/pedump/sig_parser.rb",
53
- "lib/pedump/tls.rb",
54
- "lib/pedump/unpacker.rb",
55
- "lib/pedump/unpacker/aspack.rb",
56
- "lib/pedump/unpacker/upx.rb",
57
- "lib/pedump/version.rb",
58
- "lib/pedump/version_info.rb",
59
- "misc/aspack/Makefile",
60
- "misc/aspack/aspack_unlzx.c",
61
- "misc/aspack/lzxdec.c",
62
- "misc/aspack/lzxdec.h",
63
- "misc/nedump.c",
64
- "pedump.gemspec",
65
- "samples/bad/68.exe",
66
- "samples/bad/data_dir_15_entries.exe",
67
- "spec/65535sects_spec.rb",
68
- "spec/bad_imports_spec.rb",
69
- "spec/bad_samples_spec.rb",
70
- "spec/composite_io_spec.rb",
71
- "spec/data/calc.exe_sections.yml",
72
- "spec/data/data_dir_15_entries.exe_sections.yml",
73
- "spec/dllord_spec.rb",
74
- "spec/foldedhdr_spec.rb",
75
- "spec/imports_badterm_spec.rb",
76
- "spec/imports_vterm_spec.rb",
77
- "spec/loader/names_spec.rb",
78
- "spec/loader/va_spec.rb",
79
- "spec/manyimportsW7_spec.rb",
80
- "spec/ne_spec.rb",
81
- "spec/packer_spec.rb",
82
- "spec/pe_spec.rb",
83
- "spec/pedump_spec.rb",
84
- "spec/resource_spec.rb",
85
- "spec/sections_spec.rb",
86
- "spec/sig_all_packers_spec.rb",
87
- "spec/sig_spec.rb",
88
- "spec/spec_helper.rb",
89
- "spec/support/samples.rb",
90
- "spec/unpackers/aspack_spec.rb",
91
- "spec/unpackers/find_spec.rb",
92
- "spec/virtsectblXP_spec.rb",
93
- "tmp/.keep"
94
- ]
95
- s.homepage = "http://github.com/zed-0xff/pedump"
96
- s.licenses = ["MIT"]
97
- s.require_paths = ["lib"]
98
- s.rubygems_version = "1.8.24"
99
- s.summary = "dump win32 PE executable files with a pure ruby"
12
+ spec.summary = "dump win32 PE executable files with a pure ruby"
13
+ spec.description = "dump headers, sections, extract resources of win32 PE exe,dll,etc"
14
+ spec.homepage = "http://github.com/zed-0xff/pedump"
15
+ spec.license = "MIT"
100
16
 
101
- if s.respond_to? :specification_version then
102
- s.specification_version = 3
17
+ spec.files = `git ls-files -z`.split("\x0").
18
+ reject { |f| f.match(%r{^(test|spec|features|samples|tmp|\.)/}) || f.start_with?('.') || f == "README.md.tpl" }
103
19
 
104
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
105
- s.add_runtime_dependency(%q<multipart-post>, ["~> 1.1.4"])
106
- s.add_runtime_dependency(%q<progressbar>, [">= 0"])
107
- s.add_runtime_dependency(%q<awesome_print>, [">= 0"])
108
- s.add_runtime_dependency(%q<iostruct>, [">= 0.0.4"])
109
- s.add_runtime_dependency(%q<zhexdump>, [">= 0.0.2"])
110
- s.add_development_dependency(%q<rspec>, [">= 0"])
111
- s.add_development_dependency(%q<bundler>, [">= 0"])
112
- s.add_development_dependency(%q<jeweler>, [">= 0"])
113
- s.add_development_dependency(%q<what_methods>, [">= 0"])
114
- else
115
- s.add_dependency(%q<multipart-post>, ["~> 1.1.4"])
116
- s.add_dependency(%q<progressbar>, [">= 0"])
117
- s.add_dependency(%q<awesome_print>, [">= 0"])
118
- s.add_dependency(%q<iostruct>, [">= 0.0.4"])
119
- s.add_dependency(%q<zhexdump>, [">= 0.0.2"])
120
- s.add_dependency(%q<rspec>, [">= 0"])
121
- s.add_dependency(%q<bundler>, [">= 0"])
122
- s.add_dependency(%q<jeweler>, [">= 0"])
123
- s.add_dependency(%q<what_methods>, [">= 0"])
124
- end
125
- else
126
- s.add_dependency(%q<multipart-post>, ["~> 1.1.4"])
127
- s.add_dependency(%q<progressbar>, [">= 0"])
128
- s.add_dependency(%q<awesome_print>, [">= 0"])
129
- s.add_dependency(%q<iostruct>, [">= 0.0.4"])
130
- s.add_dependency(%q<zhexdump>, [">= 0.0.2"])
131
- s.add_dependency(%q<rspec>, [">= 0"])
132
- s.add_dependency(%q<bundler>, [">= 0"])
133
- s.add_dependency(%q<jeweler>, [">= 0"])
134
- s.add_dependency(%q<what_methods>, [">= 0"])
135
- end
136
- end
20
+ spec.bindir = "bin"
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
137
23
 
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end