pedump 0.7.4 → 0.7.5
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 +4 -4
- data/Gemfile +7 -12
- data/Gemfile.lock +12 -151
- data/README.md +1 -0
- data/Rakefile +73 -105
- data/data/jc-userdb.txt +2 -6
- data/data/sig.bin +0 -0
- data/lib/pedump/cli.rb +21 -7
- data/lib/pedump/colors.rb +29 -0
- data/lib/pedump/comparer.rb +12 -9
- data/lib/pedump/logger.rb +4 -2
- data/lib/pedump/multipart.rb +56 -0
- data/lib/pedump/sig_parser.rb +11 -55
- data/lib/pedump/unpacker/aspack.rb +1 -1
- data/lib/pedump/version.rb +3 -5
- data/lib/pedump.rb +1 -1
- data/pedump.gemspec +29 -88
- metadata +6 -88
- data/VERSION +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d422e0cae0fcfb5090f13cdbe0e9fe8635463ba9cfccee49a110f766a962be9f
|
|
4
|
+
data.tar.gz: cbffb2114ff2b8195ffeb2ed5b92a2cadf4dadd35303802c30d6386c91041b2d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d4d9ca21d96b9ac64339da6208fa049d364384e505ff6e9d2a5232aa2cd711c3bd8b37a5fb1141b601df1f7ef82cc70c6a0a5389d03a2ffc4ab76d1c8b7ea3e
|
|
7
|
+
data.tar.gz: 8468e35a72ff9d84e475092aee3b8f0e0e0e0b5927197f0a3d6cc2d99d68552d98cb7cbc096f7de6439d5df1a981710f4f53389974d43f5dcc2ac8d5d0f7f5fd
|
data/Gemfile
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
#gemspec
|
|
1
|
+
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
gem "awesome_print"
|
|
6
|
-
gem "iostruct", ">= 0.7.0"
|
|
7
|
-
gem "multipart-post", ">= 2.0.0"
|
|
8
|
-
gem "zhexdump", ">= 0.0.2"
|
|
3
|
+
source 'https://rubygems.org'
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
gem
|
|
14
|
-
gem
|
|
5
|
+
gemspec
|
|
6
|
+
|
|
7
|
+
group :development, :test do
|
|
8
|
+
gem 'rspec'
|
|
9
|
+
gem 'rspec-its'
|
|
15
10
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,136 +1,17 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
pedump (0.7.4)
|
|
5
|
+
iostruct (>= 0.7.0)
|
|
6
|
+
logger
|
|
7
|
+
zhexdump (>= 0.0.2)
|
|
8
|
+
|
|
1
9
|
GEM
|
|
2
10
|
remote: https://rubygems.org/
|
|
3
11
|
specs:
|
|
4
|
-
activesupport (8.1.2)
|
|
5
|
-
base64
|
|
6
|
-
bigdecimal
|
|
7
|
-
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
8
|
-
connection_pool (>= 2.2.5)
|
|
9
|
-
drb
|
|
10
|
-
i18n (>= 1.6, < 2)
|
|
11
|
-
json
|
|
12
|
-
logger (>= 1.4.2)
|
|
13
|
-
minitest (>= 5.1)
|
|
14
|
-
securerandom (>= 0.3)
|
|
15
|
-
tzinfo (~> 2.0, >= 2.0.5)
|
|
16
|
-
uri (>= 0.13.1)
|
|
17
|
-
addressable (2.8.8)
|
|
18
|
-
public_suffix (>= 2.0.2, < 8.0)
|
|
19
|
-
awesome_print (1.9.2)
|
|
20
|
-
base64 (0.3.0)
|
|
21
|
-
bigdecimal (4.0.1)
|
|
22
|
-
builder (3.3.0)
|
|
23
|
-
concurrent-ruby (1.3.6)
|
|
24
|
-
connection_pool (3.0.2)
|
|
25
|
-
date (3.5.1)
|
|
26
|
-
descendants_tracker (0.0.4)
|
|
27
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
|
28
12
|
diff-lcs (1.6.2)
|
|
29
|
-
drb (2.2.3)
|
|
30
|
-
erb (6.0.1)
|
|
31
|
-
faraday (1.10.4)
|
|
32
|
-
faraday-em_http (~> 1.0)
|
|
33
|
-
faraday-em_synchrony (~> 1.0)
|
|
34
|
-
faraday-excon (~> 1.1)
|
|
35
|
-
faraday-httpclient (~> 1.0)
|
|
36
|
-
faraday-multipart (~> 1.0)
|
|
37
|
-
faraday-net_http (~> 1.0)
|
|
38
|
-
faraday-net_http_persistent (~> 1.0)
|
|
39
|
-
faraday-patron (~> 1.0)
|
|
40
|
-
faraday-rack (~> 1.0)
|
|
41
|
-
faraday-retry (~> 1.0)
|
|
42
|
-
ruby2_keywords (>= 0.0.4)
|
|
43
|
-
faraday-em_http (1.0.0)
|
|
44
|
-
faraday-em_synchrony (1.0.1)
|
|
45
|
-
faraday-excon (1.1.0)
|
|
46
|
-
faraday-httpclient (1.0.1)
|
|
47
|
-
faraday-multipart (1.2.0)
|
|
48
|
-
multipart-post (~> 2.0)
|
|
49
|
-
faraday-net_http (1.0.2)
|
|
50
|
-
faraday-net_http_persistent (1.2.0)
|
|
51
|
-
faraday-patron (1.0.0)
|
|
52
|
-
faraday-rack (1.0.0)
|
|
53
|
-
faraday-retry (1.0.3)
|
|
54
|
-
git (4.3.0)
|
|
55
|
-
activesupport (>= 5.0)
|
|
56
|
-
addressable (~> 2.8)
|
|
57
|
-
process_executer (~> 4.0)
|
|
58
|
-
rchardet (~> 1.9)
|
|
59
|
-
github_api (0.19.0)
|
|
60
|
-
addressable (~> 2.4)
|
|
61
|
-
descendants_tracker (~> 0.0.4)
|
|
62
|
-
faraday (>= 0.8, < 2)
|
|
63
|
-
hashie (~> 3.5, >= 3.5.2)
|
|
64
|
-
oauth2 (~> 1.0)
|
|
65
|
-
hashie (3.6.0)
|
|
66
|
-
highline (3.1.2)
|
|
67
|
-
reline
|
|
68
|
-
i18n (1.14.8)
|
|
69
|
-
concurrent-ruby (~> 1.0)
|
|
70
|
-
io-console (0.8.2)
|
|
71
13
|
iostruct (0.7.0)
|
|
72
|
-
json (2.18.0)
|
|
73
|
-
juwelier (2.4.9)
|
|
74
|
-
builder
|
|
75
|
-
bundler
|
|
76
|
-
git
|
|
77
|
-
github_api
|
|
78
|
-
highline
|
|
79
|
-
kamelcase (~> 0)
|
|
80
|
-
nokogiri
|
|
81
|
-
psych
|
|
82
|
-
rake
|
|
83
|
-
rdoc
|
|
84
|
-
semver2
|
|
85
|
-
jwt (2.10.2)
|
|
86
|
-
base64
|
|
87
|
-
kamelcase (0.0.2)
|
|
88
|
-
semver2 (~> 3)
|
|
89
14
|
logger (1.7.0)
|
|
90
|
-
mini_portile2 (2.8.9)
|
|
91
|
-
minitest (6.0.1)
|
|
92
|
-
prism (~> 1.5)
|
|
93
|
-
multi_json (1.19.1)
|
|
94
|
-
multi_xml (0.8.1)
|
|
95
|
-
bigdecimal (>= 3.1, < 5)
|
|
96
|
-
multipart-post (2.4.1)
|
|
97
|
-
nokogiri (1.19.0)
|
|
98
|
-
mini_portile2 (~> 2.8.2)
|
|
99
|
-
racc (~> 1.4)
|
|
100
|
-
nokogiri (1.19.0-aarch64-linux-gnu)
|
|
101
|
-
racc (~> 1.4)
|
|
102
|
-
nokogiri (1.19.0-arm-linux-gnu)
|
|
103
|
-
racc (~> 1.4)
|
|
104
|
-
nokogiri (1.19.0-arm64-darwin)
|
|
105
|
-
racc (~> 1.4)
|
|
106
|
-
nokogiri (1.19.0-x86_64-darwin)
|
|
107
|
-
racc (~> 1.4)
|
|
108
|
-
nokogiri (1.19.0-x86_64-linux-gnu)
|
|
109
|
-
racc (~> 1.4)
|
|
110
|
-
oauth2 (1.4.11)
|
|
111
|
-
faraday (>= 0.17.3, < 3.0)
|
|
112
|
-
jwt (>= 1.0, < 3.0)
|
|
113
|
-
multi_json (~> 1.3)
|
|
114
|
-
multi_xml (~> 0.5)
|
|
115
|
-
rack (>= 1.2, < 4)
|
|
116
|
-
prism (1.9.0)
|
|
117
|
-
process_executer (4.0.2)
|
|
118
|
-
track_open_instances (~> 0.1)
|
|
119
|
-
psych (5.3.1)
|
|
120
|
-
date
|
|
121
|
-
stringio
|
|
122
|
-
public_suffix (7.0.2)
|
|
123
|
-
racc (1.8.1)
|
|
124
|
-
rack (3.2.4)
|
|
125
|
-
rainbow (3.1.1)
|
|
126
|
-
rake (13.3.1)
|
|
127
|
-
rchardet (1.10.0)
|
|
128
|
-
rdoc (7.1.0)
|
|
129
|
-
erb
|
|
130
|
-
psych (>= 4.0.0)
|
|
131
|
-
tsort
|
|
132
|
-
reline (0.6.3)
|
|
133
|
-
io-console (~> 0.5)
|
|
134
15
|
rspec (3.13.2)
|
|
135
16
|
rspec-core (~> 3.13.0)
|
|
136
17
|
rspec-expectations (~> 3.13.0)
|
|
@@ -147,36 +28,16 @@ GEM
|
|
|
147
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
148
29
|
rspec-support (~> 3.13.0)
|
|
149
30
|
rspec-support (3.13.6)
|
|
150
|
-
ruby2_keywords (0.0.5)
|
|
151
|
-
securerandom (0.4.1)
|
|
152
|
-
semver2 (3.4.2)
|
|
153
|
-
stringio (3.2.0)
|
|
154
|
-
thread_safe (0.3.6)
|
|
155
|
-
track_open_instances (0.1.15)
|
|
156
|
-
tsort (0.2.0)
|
|
157
|
-
tzinfo (2.0.6)
|
|
158
|
-
concurrent-ruby (~> 1.0)
|
|
159
|
-
uri (1.1.1)
|
|
160
31
|
zhexdump (0.3.0)
|
|
161
32
|
|
|
162
33
|
PLATFORMS
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
arm64-darwin
|
|
166
|
-
x86-linux
|
|
167
|
-
x86_64-darwin
|
|
168
|
-
x86_64-linux
|
|
34
|
+
arm64-darwin-24
|
|
35
|
+
ruby
|
|
169
36
|
|
|
170
37
|
DEPENDENCIES
|
|
171
|
-
|
|
172
|
-
bundler
|
|
173
|
-
iostruct (>= 0.7.0)
|
|
174
|
-
juwelier
|
|
175
|
-
multipart-post (>= 2.0.0)
|
|
176
|
-
rainbow
|
|
38
|
+
pedump!
|
|
177
39
|
rspec
|
|
178
40
|
rspec-its
|
|
179
|
-
zhexdump (>= 0.0.2)
|
|
180
41
|
|
|
181
42
|
BUNDLED WITH
|
|
182
|
-
2.
|
|
43
|
+
2.6.9
|
data/README.md
CHANGED
|
@@ -4,6 +4,7 @@ pedump [
|
|
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 'juwelier'
|
|
15
|
-
Juwelier::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.exclude %w'samples/**/* spec/**/* tmp/**/* tmp/.keep .* README.md.tpl .github/**/*'
|
|
27
|
-
gem.extra_rdoc_files.exclude 'README.md.tpl'
|
|
28
|
-
# dependencies defined in Gemfile
|
|
29
|
-
end
|
|
30
|
-
Juwelier::RubygemsDotOrgTasks.new
|
|
1
|
+
# frozen_string_literal: true
|
|
31
2
|
|
|
32
|
-
require '
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
33
4
|
require 'rspec/core/rake_task'
|
|
34
5
|
|
|
35
|
-
desc
|
|
6
|
+
desc 'run specs'
|
|
36
7
|
RSpec::Core::RakeTask.new
|
|
37
8
|
|
|
38
|
-
task :
|
|
9
|
+
task default: %i[spec readme]
|
|
39
10
|
|
|
40
11
|
task :init do
|
|
41
12
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
@@ -44,9 +15,9 @@ task :init do
|
|
|
44
15
|
end
|
|
45
16
|
|
|
46
17
|
namespace :test do
|
|
47
|
-
desc
|
|
48
|
-
task :
|
|
49
|
-
path = ENV['path'] || raise(
|
|
18
|
+
desc 'test on all files in given path'
|
|
19
|
+
task all_files: :init do
|
|
20
|
+
path = ENV['path'] || raise('run me with path=...')
|
|
50
21
|
`find #{path} -type f`.split("\n").each do |fname|
|
|
51
22
|
puts "\n### #{fname}\n"
|
|
52
23
|
PEdump::CLI.new(fname).run
|
|
@@ -54,33 +25,33 @@ namespace :test do
|
|
|
54
25
|
end
|
|
55
26
|
|
|
56
27
|
namespace :all_files do
|
|
57
|
-
desc
|
|
58
|
-
task :
|
|
59
|
-
path = ENV['path'] || raise(
|
|
28
|
+
desc 'output file name to stderr, use with stdout redirection'
|
|
29
|
+
task stderr: :init do
|
|
30
|
+
path = ENV['path'] || raise('run me with path=...')
|
|
60
31
|
`find #{path} -type f`.split("\n").each do |fname|
|
|
61
|
-
|
|
32
|
+
warn "\n### #{fname}\n"
|
|
62
33
|
PEdump::CLI.new(fname).run
|
|
63
34
|
end
|
|
64
35
|
end
|
|
65
36
|
end
|
|
66
37
|
|
|
67
|
-
desc
|
|
68
|
-
task :
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
38
|
+
desc 'test on corkami binaries'
|
|
39
|
+
task corkami: :init do
|
|
40
|
+
path = 'samples/corkami'
|
|
41
|
+
`find #{path} -type f`.split("\n").each do |fname|
|
|
42
|
+
warn "\n### #{fname}\n"
|
|
43
|
+
PEdump::CLI.new(fname).run
|
|
44
|
+
end
|
|
74
45
|
end
|
|
75
46
|
end
|
|
76
47
|
|
|
77
|
-
def check_file
|
|
48
|
+
def check_file(url, params = {})
|
|
78
49
|
require 'digest/md5'
|
|
79
50
|
require 'open-uri'
|
|
80
51
|
|
|
81
52
|
params[:min_size] ||= 80_000
|
|
82
53
|
|
|
83
|
-
|
|
54
|
+
$stdout.sync = true
|
|
84
55
|
prefix = params[:prefix]
|
|
85
56
|
fname = File.join 'data', (prefix ? "#{prefix}-" : '') + File.basename(url)
|
|
86
57
|
existing_md5 = File.exist?(fname) ? Digest::MD5.file(fname).hexdigest : ''
|
|
@@ -88,127 +59,124 @@ def check_file url, params = {}
|
|
|
88
59
|
remote_data = URI.open(url).read.force_encoding('cp1252').encode('utf-8')
|
|
89
60
|
puts "#{remote_data.size} bytes"
|
|
90
61
|
raise "too small remote data (#{remote_data.size})" if remote_data.size < params[:min_size]
|
|
91
|
-
|
|
62
|
+
|
|
63
|
+
remote_md5 = Digest::MD5.hexdigest(remote_data)
|
|
92
64
|
if remote_md5 == existing_md5
|
|
93
|
-
puts
|
|
65
|
+
puts '[.] same as local'
|
|
94
66
|
else
|
|
95
67
|
existing_size = File.exist?(fname) ? File.size(fname) : 0
|
|
96
|
-
File.
|
|
68
|
+
File.write(fname, remote_data, mode: 'wb')
|
|
97
69
|
puts "[*] updated: #{existing_size} -> #{remote_data.size}"
|
|
98
70
|
end
|
|
99
71
|
end
|
|
100
72
|
|
|
101
|
-
RICH_IDS_URL =
|
|
73
|
+
RICH_IDS_URL = 'https://raw.githubusercontent.com/dishather/richprint/master/comp_id.txt'
|
|
102
74
|
|
|
103
75
|
namespace :rich do
|
|
104
|
-
desc
|
|
76
|
+
desc 'update rich comp_id db from net'
|
|
105
77
|
task :update do
|
|
106
|
-
check_file RICH_IDS_URL, :
|
|
78
|
+
check_file RICH_IDS_URL, min_size: 30_000
|
|
107
79
|
end
|
|
108
80
|
|
|
109
|
-
desc
|
|
81
|
+
desc 'convert'
|
|
110
82
|
task :convert do
|
|
111
83
|
result = [
|
|
112
|
-
|
|
84
|
+
'class PEdump',
|
|
113
85
|
" # data from #{RICH_IDS_URL}",
|
|
114
|
-
|
|
86
|
+
' RICH_IDS = {'
|
|
115
87
|
]
|
|
116
88
|
n = 0
|
|
117
89
|
t0 = Time.now
|
|
118
|
-
File.readlines(File.join(
|
|
90
|
+
File.readlines(File.join('data', File.basename(RICH_IDS_URL))).each do |line|
|
|
119
91
|
line.strip!
|
|
120
92
|
next if line.empty? || line[0] == '#'
|
|
93
|
+
|
|
121
94
|
comp_id, desc = line.split(nil, 2)
|
|
122
95
|
raise unless comp_id =~ /\A[0-9a-fA-F]+\Z/
|
|
96
|
+
|
|
123
97
|
result << " 0x#{comp_id} => #{desc.inspect},"
|
|
124
98
|
n += 1
|
|
125
99
|
end
|
|
126
|
-
result <<
|
|
127
|
-
result <<
|
|
128
|
-
printf "[.] parsed %d definitions in %6.3fs\n", n, Time.now-t0
|
|
129
|
-
File.write(
|
|
100
|
+
result << ' }'
|
|
101
|
+
result << 'end'
|
|
102
|
+
printf "[.] parsed %d definitions in %6.3fs\n", n, Time.now - t0
|
|
103
|
+
File.write('lib/pedump/rich.rb', result.join("\n") + "\n")
|
|
130
104
|
end
|
|
131
105
|
end
|
|
132
106
|
|
|
133
107
|
namespace :sigs do
|
|
134
|
-
desc
|
|
135
|
-
task :
|
|
136
|
-
require './lib/pedump/packer'
|
|
137
|
-
check_file "http://research.pandasecurity.com/blogs/images/userdb.txt"
|
|
138
|
-
check_file "http://fuu.googlecode.com/svn/trunk/src/x86/Tools/Signaturesdb/signatures.txt"
|
|
139
|
-
check_file "http://handlers.sans.edu/jclausing/userdb.txt", :prefix => "jc"
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
desc "convert txt2bin"
|
|
143
|
-
task :convert do
|
|
108
|
+
desc 'convert txt2bin'
|
|
109
|
+
task convert: :init do
|
|
144
110
|
require './lib/pedump/packer'
|
|
145
111
|
t0 = Time.now
|
|
146
|
-
sigs = PEdump::SigParser.parse
|
|
147
|
-
printf "[.] parsed %d definitions in %6.3fs\n", sigs.size, Time.now-t0
|
|
148
|
-
File.open(PEdump::Packer::BIN_SIGS_FILE,
|
|
112
|
+
sigs = PEdump::SigParser.parse optimize: true
|
|
113
|
+
printf "[.] parsed %d definitions in %6.3fs\n", sigs.size, Time.now - t0
|
|
114
|
+
File.open(PEdump::Packer::BIN_SIGS_FILE, 'wb') { |f| Marshal.dump(sigs, f) }
|
|
149
115
|
end
|
|
150
116
|
|
|
151
|
-
desc
|
|
152
|
-
task :
|
|
117
|
+
desc 'dump'
|
|
118
|
+
task dump: :init do
|
|
153
119
|
require './lib/pedump/packer'
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
end
|
|
120
|
+
PEdump::Packer.all
|
|
121
|
+
.group_by(&:name)
|
|
122
|
+
.sort_by { |name, _sigs| name }
|
|
123
|
+
.each do |name, sigs|
|
|
124
|
+
next if sigs.size == 1
|
|
125
|
+
|
|
126
|
+
puts name
|
|
127
|
+
sigs.each do |sig|
|
|
128
|
+
printf " %-5s %s\n", sig.ep_only, sig.re.source.inspect
|
|
164
129
|
end
|
|
130
|
+
end
|
|
165
131
|
end
|
|
166
132
|
end
|
|
167
133
|
|
|
168
|
-
desc
|
|
134
|
+
desc 'build readme'
|
|
169
135
|
task :readme do
|
|
170
136
|
require 'erb'
|
|
171
137
|
tpl = File.read('README.md.tpl').gsub(/^%\s+(.+)/) do |x|
|
|
172
|
-
x.sub!
|
|
138
|
+
x.sub!(/^%/, '')
|
|
173
139
|
"<%= run(\"#{x}\") %>"
|
|
174
140
|
end
|
|
175
|
-
def run
|
|
141
|
+
def run(cmd)
|
|
176
142
|
cmd.strip!
|
|
177
143
|
puts "[.] #{cmd} ..."
|
|
178
144
|
r = " # #{cmd}\n\n"
|
|
179
|
-
cmd.sub!
|
|
180
|
-
lines = `#{cmd}`.sub(/\A\n+/m,'').sub(/\s+\Z/,'').split("\n")
|
|
181
|
-
lines = lines[0,25] + ['...'] if lines.size > 50 && cmd.split.last != '-h'
|
|
182
|
-
r << lines.map{|x| " #{x}"}.join("\n")
|
|
145
|
+
cmd.sub!(/^pedump/, '../bin/pedump')
|
|
146
|
+
lines = `#{cmd}`.sub(/\A\n+/m, '').sub(/\s+\Z/, '').split("\n")
|
|
147
|
+
lines = lines[0, 25] + ['...'] if lines.size > 50 && cmd.split.last != '-h'
|
|
148
|
+
r << lines.map { |x| " #{x}" }.join("\n")
|
|
183
149
|
r << "\n"
|
|
184
150
|
end
|
|
185
151
|
Dir.chdir 'samples'
|
|
186
152
|
result = ERB.new(tpl, trim_mode: '%>').result
|
|
187
153
|
Dir.chdir '..'
|
|
188
|
-
File.
|
|
154
|
+
File.write('README.md', result)
|
|
189
155
|
end
|
|
190
156
|
|
|
191
157
|
namespace :console do
|
|
192
|
-
desc
|
|
158
|
+
desc 'start console with PEdump::Loader with loaded file'
|
|
193
159
|
task :load do
|
|
194
|
-
raise
|
|
160
|
+
raise 'gimme a fname' unless (fname = ENV['fname'])
|
|
161
|
+
|
|
195
162
|
require './lib/pedump'
|
|
196
163
|
require './lib/pedump/loader'
|
|
197
164
|
require 'pp'
|
|
198
|
-
File.open(fname,
|
|
165
|
+
File.open(fname, 'rb') do |f|
|
|
199
166
|
@ldr = PEdump::Loader.new f
|
|
200
|
-
puts
|
|
167
|
+
puts '[.] loader is at @ldr'
|
|
201
168
|
pp @ldr.sections
|
|
202
|
-
Rake::Task[
|
|
169
|
+
Rake::Task['console'].execute
|
|
203
170
|
end
|
|
204
171
|
end
|
|
205
172
|
end
|
|
206
173
|
|
|
207
|
-
desc
|
|
174
|
+
desc 'compare two PE files'
|
|
208
175
|
task :cmp do
|
|
209
|
-
raise
|
|
210
|
-
raise
|
|
176
|
+
raise 'gimme a f1' unless (f1 = ENV['f1'])
|
|
177
|
+
raise 'gimme a f2' unless (f2 = ENV['f2'])
|
|
178
|
+
|
|
211
179
|
require './lib/pedump'
|
|
212
180
|
require './lib/pedump/comparer'
|
|
213
|
-
PEdump::Comparer.cmp(f1,f2)
|
|
181
|
+
PEdump::Comparer.cmp(f1, f2)
|
|
214
182
|
end
|
data/data/jc-userdb.txt
CHANGED
|
@@ -4301,13 +4301,9 @@ signature = 68 ?? ?? ?? ?? 64 A1 00 00 00 00 50 8B 44 24 10 89 6C 24 10 8D 6C 24
|
|
|
4301
4301
|
ep_only = false
|
|
4302
4302
|
|
|
4303
4303
|
[Microsoft Visual C++ 6.0 - 8.0]
|
|
4304
|
-
signature = 68 ?? ?? ?? ?? 64 A1 00 00 00 00 50 8B 44 24 10 89 6C 24 10 8D 6C 24 10 2B E0 53 56 57 8B 45 F8 89 65 E8 50 8B 45 FC C7 45 FC FF FF FF FF 89 45 F8 8D 45 F0 64 A3 00 00 00 00 C3 8B 4D F0 64 89 0D 00 00 00 00 59 5F 5E 5B C9 51 C3
|
|
4304
|
+
signature = 68 ?? ?? ?? ?? 64 A1 00 00 00 00 50 8B 44 24 10 89 6C 24 10 8D 6C 24 10 2B E0 53 56 57 8B 45 F8 89 65 E8 50 8B 45 FC C7 45 FC FF FF FF FF 89 45 F8 8D 45 F0 64 A3 00 00 00 00 C3 8B 4D F0 64 89 0D 00 00 00 00 59 5F 5E 5B C9 51 C3
|
|
4305
4305
|
ep_only = true
|
|
4306
4306
|
|
|
4307
|
-
[Microsoft Visual C++ 6.0 - 8.0]
|
|
4308
|
-
signature = 68 ?? ?? ?? ?? 64 A1 00 00 00 00 50 8B 44 24 10 89 6C 24 10 8D 6C 24 10 2B E0 53 56 57 8B 45 F8 89 65 E8 50 8B 45 FC C7 45 FC FF FF FF FF 89 45 F8 8D 45 F0 64 A3 00 00 00 00 C3 8B 4D F0 64 89 0D 00 00 00 00 59 5F 5E 5B C9 51 C3 (TRUNCATED HERE)
|
|
4309
|
-
ep_only = false
|
|
4310
|
-
|
|
4311
4307
|
[Microsoft Visual C++ 6.0 - 8.0]
|
|
4312
4308
|
signature = 8B 44 24 08 85 C0 0F 84 ?? ?? ?? ?? 83 F8 01 8B 0D ?? ?? ?? ?? 8B 09 89 0D ?? ?? ?? ?? 0F 85 ?? ?? ?? ?? 68 80 00 00 00 FF 15 ?? ?? ?? ?? 85 C0 59 A3 ?? ?? ?? ?? 0F 84 ?? ?? ?? ?? 83 20 00 A1 ?? ?? ?? ?? 68 ?? ?? ?? ?? 68 ?? ?? ?? ?? A3 ?? ?? ?? ?? E8
|
|
4313
4309
|
ep_only = false
|
|
@@ -9946,7 +9942,7 @@ signature = E8 00 00 00 00 5E 83 C6 14 AD 89 C7 AD 89 C1 AD 30 07 47 E2 FB AD FF
|
|
|
9946
9942
|
ep_only = true
|
|
9947
9943
|
|
|
9948
9944
|
[UPX-Shit v0.1 -> 500mhz]
|
|
9949
|
-
signature = E8 00 00 00 00 5E 83 C6 14 AD 89 C7 AD 89 C1 AD 30 07 47 E2 FB AD FF E0 C3 00 ?? ?? 00 ?? ?? ?? 00 ?? ?? ??
|
|
9945
|
+
signature = E8 00 00 00 00 5E 83 C6 14 AD 89 C7 AD 89 C1 AD 30 07 47 E2 FB AD FF E0 C3 00 ?? ?? 00 ?? ?? ?? 00 ?? ?? ?? 01 ?? ?? ?? 00 55 50 58 2D 53 68 69 74 20 76 30 2E 31 20 2D 20 77 77 77 2E 62 6C 61 63 6B 6C 6F 67 69 63 2E 6E 65 74 20 2D 20 63 6F 64 65 20 62 79 20 5B 35 30 30 6D 68 7A 5D
|
|
9950
9946
|
ep_only = true
|
|
9951
9947
|
|
|
9952
9948
|
[UPX-Shit v0.1 -> 500mhz]
|
data/data/sig.bin
CHANGED
|
Binary file
|
data/lib/pedump/cli.rb
CHANGED
|
@@ -293,7 +293,7 @@ class PEdump::CLI
|
|
|
293
293
|
require 'digest/md5'
|
|
294
294
|
require 'open-uri'
|
|
295
295
|
require 'net/http'
|
|
296
|
-
require '
|
|
296
|
+
require 'pedump/multipart'
|
|
297
297
|
|
|
298
298
|
stdout_sync = $stdout.sync
|
|
299
299
|
$stdout.sync = true
|
|
@@ -320,12 +320,26 @@ class PEdump::CLI
|
|
|
320
320
|
|
|
321
321
|
f.rewind
|
|
322
322
|
|
|
323
|
-
# upload with progress
|
|
323
|
+
# upload with progress using manual multipart POST
|
|
324
324
|
post_url = URI.parse(URL_BASE+'/upload')
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
boundary = MultipartBody.generate_boundary
|
|
326
|
+
filename = File.basename(f.path)
|
|
327
|
+
|
|
328
|
+
# Build multipart body parts
|
|
329
|
+
header_part = "--#{boundary}\r\n" \
|
|
330
|
+
"Content-Disposition: form-data; name=\"file\"; filename=\"#{filename}\"\r\n" \
|
|
331
|
+
"Content-Type: application/octet-stream\r\n\r\n"
|
|
332
|
+
footer_part = "\r\n--#{boundary}--\r\n"
|
|
333
|
+
|
|
334
|
+
content_length = header_part.bytesize + f.size + footer_part.bytesize
|
|
335
|
+
|
|
336
|
+
req = Net::HTTP::Post.new(post_url.path)
|
|
337
|
+
req['Content-Type'] = "multipart/form-data; boundary=#{boundary}"
|
|
338
|
+
req['Content-Length'] = content_length
|
|
339
|
+
|
|
340
|
+
ppx = ProgressProxy.new(f)
|
|
341
|
+
req.body_stream = MultipartBody.new(header_part, ppx, footer_part, content_length)
|
|
342
|
+
|
|
329
343
|
res = Net::HTTP.start(post_url.host, post_url.port, use_ssl: (post_url.scheme == 'https')) do |http|
|
|
330
344
|
http.request(req)
|
|
331
345
|
end
|
|
@@ -361,7 +375,7 @@ class PEdump::CLI
|
|
|
361
375
|
end
|
|
362
376
|
end
|
|
363
377
|
|
|
364
|
-
puts "[.] ldr = PEdump::Loader.new(open(#{f.path.inspect}))"
|
|
378
|
+
puts "[.] ldr = PEdump::Loader.new(open(#{f.path.inspect}))"
|
|
365
379
|
IRB.start
|
|
366
380
|
end
|
|
367
381
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module PEdump::Colors
|
|
2
|
+
def gray(str)
|
|
3
|
+
"\e[1;30m#{str}\e[0m"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def red(str)
|
|
7
|
+
"\e[1;31m#{str}\e[0m"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def green(str)
|
|
11
|
+
"\e[1;32m#{str}\e[0m"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def yellow(str)
|
|
15
|
+
"\e[1;33m#{str}\e[0m"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def redish(str)
|
|
19
|
+
"\e[0;31m#{str}\e[0m"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def greenish(str)
|
|
23
|
+
"\e[0;32m#{str}\e[0m"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def yellowish(str)
|
|
27
|
+
"\e[0;33m#{str}\e[0m"
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/pedump/comparer.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'pedump'
|
|
2
|
+
require 'pedump/colors'
|
|
2
3
|
require 'pedump/loader'
|
|
3
4
|
|
|
4
5
|
########################################################################
|
|
@@ -9,6 +10,8 @@ class PEdump::Comparer
|
|
|
9
10
|
attr_accessor :verbose
|
|
10
11
|
attr_accessor :ignored_data_dirs, :ignored_sections
|
|
11
12
|
|
|
13
|
+
include PEdump::Colors
|
|
14
|
+
|
|
12
15
|
METHODS = [:sections, :data_dirs, :imports, :resources, :pe_hdr]
|
|
13
16
|
|
|
14
17
|
def initialize ldr1, ldr2
|
|
@@ -53,12 +56,12 @@ class PEdump::Comparer
|
|
|
53
56
|
|
|
54
57
|
if !s2
|
|
55
58
|
r = false
|
|
56
|
-
printf "[!] extra section %-12s in %s\n"
|
|
59
|
+
printf red("[!] extra section %-12s in %s\n"), s1.name.inspect, f1
|
|
57
60
|
elsif s1.data == s2.data
|
|
58
|
-
printf "[.] section: %s == %s\n"
|
|
61
|
+
printf green("[.] section: %s == %s\n"), s1.name, s2.name if @verbose
|
|
59
62
|
else
|
|
60
63
|
r = false
|
|
61
|
-
printf "[!] section: %s != %s\n"
|
|
64
|
+
printf red("[!] section: %s != %s\n"), s1.name, s2.name
|
|
62
65
|
self.class.cmp_ios *[s1,s2].map{ |section| StringIO.new(section.data) }
|
|
63
66
|
end
|
|
64
67
|
end
|
|
@@ -81,14 +84,14 @@ class PEdump::Comparer
|
|
|
81
84
|
|
|
82
85
|
if d1.va != d2.va && d1.size != d2.size
|
|
83
86
|
r = false
|
|
84
|
-
printf "[!] data_dir: %-12s: SIZE & VA: %6x %6x | %6x %6x\n"
|
|
87
|
+
printf red("[!] data_dir: %-12s: SIZE & VA: %6x %6x | %6x %6x\n"), d1.type,
|
|
85
88
|
d1.va, d1.size, d2.va, d2.size
|
|
86
89
|
elsif d1.va != d2.va
|
|
87
90
|
r = false
|
|
88
|
-
printf "[!] data_dir: %-12s: VA : %x != %x\n"
|
|
91
|
+
printf red("[!] data_dir: %-12s: VA : %x != %x\n"), d1.type, d1.va, d2.va
|
|
89
92
|
elsif d1.size != d2.size
|
|
90
93
|
r = false
|
|
91
|
-
printf "[!] data_dir: %-12s: SIZE : %x != %x\n"
|
|
94
|
+
printf red("[!] data_dir: %-12s: SIZE : %x != %x\n"), d1.type, d1.size, d2.size
|
|
92
95
|
end
|
|
93
96
|
end
|
|
94
97
|
r
|
|
@@ -98,7 +101,7 @@ class PEdump::Comparer
|
|
|
98
101
|
@ldr1.pedump.imports.each_with_index do |iid1,idx|
|
|
99
102
|
iid2 = @ldr2.pedump.imports[idx]
|
|
100
103
|
if iid1 != iid2
|
|
101
|
-
puts "[!] diff imports"
|
|
104
|
+
puts red("[!] diff imports")
|
|
102
105
|
return false
|
|
103
106
|
end
|
|
104
107
|
end
|
|
@@ -133,9 +136,9 @@ class PEdump::Comparer
|
|
|
133
136
|
bytes = ios.map(&:readbyte)
|
|
134
137
|
if bytes.uniq.size > 1
|
|
135
138
|
ndiff += 1
|
|
136
|
-
printf
|
|
139
|
+
printf(yellow("\t%08x:"+" %02x"*ios.size)+"\n", ios[0].pos-1, *bytes)
|
|
137
140
|
if ndiff >= 5
|
|
138
|
-
puts "\t..."
|
|
141
|
+
puts yellow("\t...")
|
|
139
142
|
break
|
|
140
143
|
end
|
|
141
144
|
end
|
data/lib/pedump/logger.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'pedump/colors'
|
|
2
2
|
|
|
3
3
|
class PEdump
|
|
4
4
|
class Logger < ::Logger
|
|
@@ -39,6 +39,8 @@ class PEdump
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
class ColoredLogger < ::Logger
|
|
42
|
+
include PEdump::Colors
|
|
43
|
+
|
|
42
44
|
def initialize *args
|
|
43
45
|
super
|
|
44
46
|
@formatter = proc do |severity,_,_,msg|
|
|
@@ -58,7 +60,7 @@ class PEdump
|
|
|
58
60
|
when 'DEBUG'
|
|
59
61
|
:gray
|
|
60
62
|
end
|
|
61
|
-
"#{color ?
|
|
63
|
+
"#{color ? send(color, msg) : msg}\n"
|
|
62
64
|
end
|
|
63
65
|
end
|
|
64
66
|
@level = WARN
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class PEdump
|
|
4
|
+
class CLI
|
|
5
|
+
# Streaming multipart body for file uploads
|
|
6
|
+
class MultipartBody
|
|
7
|
+
BOUNDARY_CHARS = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
|
|
8
|
+
|
|
9
|
+
def self.generate_boundary
|
|
10
|
+
"----PEdumpUpload#{Array.new(32) { BOUNDARY_CHARS.sample }.join}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def initialize(header, file_io, footer, total_size)
|
|
14
|
+
@parts = [
|
|
15
|
+
StringIO.new(header),
|
|
16
|
+
file_io,
|
|
17
|
+
StringIO.new(footer)
|
|
18
|
+
]
|
|
19
|
+
@part_index = 0
|
|
20
|
+
@size = total_size
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
attr_reader :size
|
|
24
|
+
|
|
25
|
+
def read(length = nil, outbuf = nil)
|
|
26
|
+
outbuf ||= String.new
|
|
27
|
+
outbuf.clear
|
|
28
|
+
outbuf.force_encoding(Encoding::BINARY)
|
|
29
|
+
|
|
30
|
+
return nil if @part_index >= @parts.length
|
|
31
|
+
|
|
32
|
+
while @part_index < @parts.length
|
|
33
|
+
chunk = if length
|
|
34
|
+
@parts[@part_index].read(length - outbuf.bytesize)
|
|
35
|
+
else
|
|
36
|
+
@parts[@part_index].read
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if chunk
|
|
40
|
+
outbuf << chunk
|
|
41
|
+
break if length && outbuf.bytesize >= length
|
|
42
|
+
else
|
|
43
|
+
@part_index += 1
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
outbuf.empty? && length ? nil : outbuf
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def rewind
|
|
51
|
+
@parts.each(&:rewind)
|
|
52
|
+
@part_index = 0
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/lib/pedump/sig_parser.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
#coding: binary
|
|
2
|
+
|
|
1
3
|
class PEdump
|
|
2
4
|
module SigParser
|
|
3
5
|
|
|
@@ -47,8 +49,6 @@ class PEdump
|
|
|
47
49
|
puts "[=] #{sigs.size-n0} sigs from #{File.basename(fname)}\n\n" if args[:verbose]
|
|
48
50
|
end
|
|
49
51
|
|
|
50
|
-
bins = Hash.new{ |k,v| k[v] = ''.force_encoding('binary') }
|
|
51
|
-
|
|
52
52
|
# convert strings to Regexps
|
|
53
53
|
sigs = sigs.values
|
|
54
54
|
sigs.each_with_index do |sig,idx|
|
|
@@ -57,16 +57,14 @@ class PEdump
|
|
|
57
57
|
sig.size = a.size
|
|
58
58
|
end.map do |x|
|
|
59
59
|
case x
|
|
60
|
-
when /\A\?\?\
|
|
61
|
-
bins[sig] << '.'
|
|
62
|
-
'.'
|
|
63
|
-
when /\A.\?/,/\?.\Z/
|
|
64
|
-
puts "[?] #{x.inspect} -> \"??\" in #{sig.name}" if args[:verbose]
|
|
65
|
-
bins[sig] << '.'
|
|
60
|
+
when /\A\?\?\z/
|
|
66
61
|
'.'
|
|
67
|
-
when /\A
|
|
62
|
+
when /\A\h\?\z/ # 'f?'
|
|
63
|
+
"[\\x#{x[0]}0-\\x#{x[0]}f]"
|
|
64
|
+
when /\A\?\h\z/ # '?4'
|
|
65
|
+
'[' + (0..15).map{ |i| "\\x#{i.to_s(16)}#{x[1]}" }.join + ']'
|
|
66
|
+
when /\A[a-f0-9]{2}\z/i
|
|
68
67
|
x = x.to_i(16).chr
|
|
69
|
-
bins[sig] << x
|
|
70
68
|
if args[:raw]
|
|
71
69
|
x
|
|
72
70
|
elsif args[:raword]
|
|
@@ -89,34 +87,6 @@ class PEdump
|
|
|
89
87
|
sigs.delete_if{ |sig| !sig.re || sig.re.index('BAD_RE') }
|
|
90
88
|
return sigs if args[:raw] || args[:raword]
|
|
91
89
|
|
|
92
|
-
# require 'awesome_print'
|
|
93
|
-
# bins.each do |bin_sig, bin|
|
|
94
|
-
# next if bin.size < 5
|
|
95
|
-
# #next unless bin_sig.name['UPX']
|
|
96
|
-
#
|
|
97
|
-
# bin_re = Regexp.new(bin_sig.re.join, Regexp::MULTILINE)
|
|
98
|
-
# was = false
|
|
99
|
-
# sigs.each do |sig|
|
|
100
|
-
# next if sig.size < 5 || sig == bin_sig
|
|
101
|
-
# #next unless sig.name['UPX']
|
|
102
|
-
#
|
|
103
|
-
# re = Regexp.new(sig.re.join, Regexp::MULTILINE)
|
|
104
|
-
# if bin.index(re) == 0
|
|
105
|
-
# rd = _re_diff(bin_re.source, re.source)
|
|
106
|
-
# if rd.any? && rd.size <= 4
|
|
107
|
-
# #if sig.name.split.first.upcase != bin_sig.name.split.first.upcase
|
|
108
|
-
# puts "\n[.] #{bin_sig.name.yellow}\n#{bin_re.source.inspect.red}" unless was
|
|
109
|
-
# puts "[=] #{sig.name}"
|
|
110
|
-
# puts re.source.inspect.green
|
|
111
|
-
# p rd
|
|
112
|
-
# was = true
|
|
113
|
-
# #end
|
|
114
|
-
# end
|
|
115
|
-
# end
|
|
116
|
-
# end
|
|
117
|
-
# end
|
|
118
|
-
|
|
119
|
-
|
|
120
90
|
optimize sigs if args[:optimize]
|
|
121
91
|
|
|
122
92
|
# convert re-arrays to Regexps
|
|
@@ -141,6 +111,7 @@ class PEdump
|
|
|
141
111
|
return if sig.name == "JAR Archive"
|
|
142
112
|
return if sig.name == "Turbo / Borland Pascal v7.x Unit"
|
|
143
113
|
return if sig.re == "54 68 69 73 20 70 72 6F 67 72 61 6D 20 63 61 6E 6E 6F 74 20 62 65 20 72 75 6E 20 69 6E 20 44 4F 53 20 6D 6F" # dos stub
|
|
114
|
+
return if sig.re =~ /T RU E/
|
|
144
115
|
|
|
145
116
|
sig.name.sub!(/^\*\s+/, '')
|
|
146
117
|
sig.name.sub!(/\s+\(h\)$/, '')
|
|
@@ -172,8 +143,8 @@ class PEdump
|
|
|
172
143
|
|
|
173
144
|
# too short signatures
|
|
174
145
|
if sig.re.split.delete_if{ |x| x['?'] }.size < 3
|
|
175
|
-
|
|
176
|
-
|
|
146
|
+
puts "[?] too short signature: #{sig.inspect}" if args[:verbose]
|
|
147
|
+
return
|
|
177
148
|
end
|
|
178
149
|
|
|
179
150
|
# fs.txt contains a lot of signatures that copied from other sources
|
|
@@ -223,12 +194,6 @@ class PEdump
|
|
|
223
194
|
return if d.all?(&:empty?) # no different words => can keep ANY name
|
|
224
195
|
|
|
225
196
|
|
|
226
|
-
# if name1 =~ /pecompact/i
|
|
227
|
-
# require 'awesome_print'
|
|
228
|
-
# puts "[d] #{name1}".yellow
|
|
229
|
-
# puts "[d] #{name2}".yellow
|
|
230
|
-
# end
|
|
231
|
-
|
|
232
197
|
# [["v1.14/v1.20"], ["v1.14,", "v1.20"]]]
|
|
233
198
|
# [["EXEShield", "v0.3b/v0.3", "v0.6"], ["Shield", "v0.3b,", "v0.3"]]]
|
|
234
199
|
2.times do |i|
|
|
@@ -241,9 +206,6 @@ class PEdump
|
|
|
241
206
|
end
|
|
242
207
|
end
|
|
243
208
|
|
|
244
|
-
# require 'awesome_print'
|
|
245
|
-
# puts "[d] #{name1.yellow} #{name2.green}"
|
|
246
|
-
|
|
247
209
|
a = name1.split
|
|
248
210
|
b = name2.split
|
|
249
211
|
|
|
@@ -282,12 +244,6 @@ class PEdump
|
|
|
282
244
|
new_name = new_name_head
|
|
283
245
|
new_name << [a.join(' '), b.join(' ')].delete_if{|x| x.empty?}.join(' / ')
|
|
284
246
|
new_name += new_name_tail
|
|
285
|
-
# if name1 =~ /pecompact/i
|
|
286
|
-
# p a
|
|
287
|
-
# p b
|
|
288
|
-
# p new_name_tail
|
|
289
|
-
# puts "[=] #{new_name.inspect}".red
|
|
290
|
-
# end
|
|
291
247
|
new_name = new_name.join(' ')
|
|
292
248
|
end
|
|
293
249
|
|
|
@@ -840,7 +840,7 @@ if __FILE__ == $0
|
|
|
840
840
|
next unless packer = Array(pedump.packer(f)).first
|
|
841
841
|
next unless packer.name =~ /aspack/i
|
|
842
842
|
|
|
843
|
-
STDERR.puts "\n=== #{fname}"
|
|
843
|
+
STDERR.puts "\n=== #{fname}"
|
|
844
844
|
|
|
845
845
|
f.rewind
|
|
846
846
|
unpacker = PEdump::Unpacker::ASPack.new(f,
|
data/lib/pedump/version.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class PEdump
|
|
2
|
-
|
|
3
|
-
STRING = File.read(File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'VERSION')).strip
|
|
4
|
-
MAJOR, MINOR, PATCH = STRING.split('.').map(&:to_i)
|
|
5
|
-
BUILD = nil
|
|
6
|
-
end
|
|
4
|
+
VERSION = '0.7.5'
|
|
7
5
|
end
|
data/lib/pedump.rb
CHANGED
|
@@ -9,6 +9,7 @@ unless Object.new.respond_to?(:try) && nil.respond_to?(:try)
|
|
|
9
9
|
require 'pedump/core_ext/try'
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
require 'pedump/version'
|
|
12
13
|
require 'pedump/core'
|
|
13
14
|
require 'pedump/ordlookup'
|
|
14
15
|
require 'pedump/pe'
|
|
@@ -30,7 +31,6 @@ require 'pedump/clr'
|
|
|
30
31
|
class PEdump
|
|
31
32
|
attr_accessor :fname, :logger, :force, :io
|
|
32
33
|
|
|
33
|
-
VERSION = Version::STRING
|
|
34
34
|
MAX_ERRORS = 100
|
|
35
35
|
MAX_IMAGE_IMPORT_DESCRIPTORS = 1000
|
|
36
36
|
MAX_EXPORT_NUMBER_OF_NAMES = 16384 # got 7977 in https://pedump.me/03ad7400080678c6b1984f995d36fd04
|
data/pedump.gemspec
CHANGED
|
@@ -1,94 +1,35 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'English'
|
|
4
|
+
lib = File.expand_path('lib', __dir__)
|
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
6
|
+
require 'pedump/version'
|
|
6
7
|
|
|
7
8
|
Gem::Specification.new do |s|
|
|
8
|
-
s.name
|
|
9
|
-
s.version
|
|
9
|
+
s.name = 'pedump'
|
|
10
|
+
s.version = PEdump::VERSION
|
|
11
|
+
s.authors = ['Andrey "Zed" Zaikin']
|
|
12
|
+
s.email = 'zed.0xff@gmail.com'
|
|
13
|
+
s.homepage = 'http://github.com/zed-0xff/pedump'
|
|
14
|
+
s.license = 'MIT'
|
|
15
|
+
s.summary = 'dump win32 PE executable files with a pure ruby'
|
|
16
|
+
s.description = 'dump headers, sections, extract resources of win32 PE exe,dll,etc'
|
|
10
17
|
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(
|
|
12
|
-
s.require_paths = [
|
|
13
|
-
s.authors = ["Andrey \"Zed\" Zaikin".freeze]
|
|
14
|
-
s.date = "1980-01-02"
|
|
15
|
-
s.description = "dump headers, sections, extract resources of win32 PE exe,dll,etc".freeze
|
|
16
|
-
s.email = "zed.0xff@gmail.com".freeze
|
|
17
|
-
s.executables = ["pedump".freeze]
|
|
18
|
-
s.extra_rdoc_files = [
|
|
19
|
-
"LICENSE.txt",
|
|
20
|
-
"README.md"
|
|
21
|
-
]
|
|
22
|
-
s.files = [
|
|
23
|
-
"CODE_OF_CONDUCT.md",
|
|
24
|
-
"Gemfile",
|
|
25
|
-
"Gemfile.lock",
|
|
26
|
-
"LICENSE.txt",
|
|
27
|
-
"README.md",
|
|
28
|
-
"Rakefile",
|
|
29
|
-
"VERSION",
|
|
30
|
-
"bin/pedump",
|
|
31
|
-
"data/comp_id.txt",
|
|
32
|
-
"data/fs.txt",
|
|
33
|
-
"data/jc-userdb.txt",
|
|
34
|
-
"data/ordlookup/oleaut32.dll.yml",
|
|
35
|
-
"data/ordlookup/pefile2json.py",
|
|
36
|
-
"data/ordlookup/ws2_32.dll.yml",
|
|
37
|
-
"data/ordlookup/wsock32.dll.yml",
|
|
38
|
-
"data/sig.bin",
|
|
39
|
-
"data/signatures.txt",
|
|
40
|
-
"data/userdb.txt",
|
|
41
|
-
"lib/pedump.rb",
|
|
42
|
-
"lib/pedump/cli.rb",
|
|
43
|
-
"lib/pedump/clr.rb",
|
|
44
|
-
"lib/pedump/clr/readytorun.rb",
|
|
45
|
-
"lib/pedump/clr/signature.rb",
|
|
46
|
-
"lib/pedump/comparer.rb",
|
|
47
|
-
"lib/pedump/composite_io.rb",
|
|
48
|
-
"lib/pedump/core.rb",
|
|
49
|
-
"lib/pedump/core_ext/try.rb",
|
|
50
|
-
"lib/pedump/loader.rb",
|
|
51
|
-
"lib/pedump/loader/minidump.rb",
|
|
52
|
-
"lib/pedump/loader/section.rb",
|
|
53
|
-
"lib/pedump/logger.rb",
|
|
54
|
-
"lib/pedump/ne.rb",
|
|
55
|
-
"lib/pedump/ne/version_info.rb",
|
|
56
|
-
"lib/pedump/ordlookup.rb",
|
|
57
|
-
"lib/pedump/packer.rb",
|
|
58
|
-
"lib/pedump/pe.rb",
|
|
59
|
-
"lib/pedump/resources.rb",
|
|
60
|
-
"lib/pedump/rich.rb",
|
|
61
|
-
"lib/pedump/security.rb",
|
|
62
|
-
"lib/pedump/sig_parser.rb",
|
|
63
|
-
"lib/pedump/te.rb",
|
|
64
|
-
"lib/pedump/tls.rb",
|
|
65
|
-
"lib/pedump/unpacker.rb",
|
|
66
|
-
"lib/pedump/unpacker/aspack.rb",
|
|
67
|
-
"lib/pedump/unpacker/upx.rb",
|
|
68
|
-
"lib/pedump/version.rb",
|
|
69
|
-
"lib/pedump/version_info.rb",
|
|
70
|
-
"misc/aspack/Makefile",
|
|
71
|
-
"misc/aspack/aspack_unlzx.c",
|
|
72
|
-
"misc/aspack/lzxdec.c",
|
|
73
|
-
"misc/aspack/lzxdec.h",
|
|
74
|
-
"misc/nedump.c",
|
|
75
|
-
"pedump.gemspec"
|
|
76
|
-
]
|
|
77
|
-
s.homepage = "http://github.com/zed-0xff/pedump".freeze
|
|
78
|
-
s.licenses = ["MIT".freeze]
|
|
79
|
-
s.rubygems_version = "3.6.9".freeze
|
|
80
|
-
s.summary = "dump win32 PE executable files with a pure ruby".freeze
|
|
18
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
|
19
|
+
s.require_paths = ['lib']
|
|
81
20
|
|
|
82
|
-
s.
|
|
21
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
22
|
+
f.match(%r{^(samples|spec|tmp)/}) ||
|
|
23
|
+
f.match(/^\./) ||
|
|
24
|
+
f == 'README.md.tpl'
|
|
25
|
+
end
|
|
26
|
+
s.executables = ['pedump']
|
|
83
27
|
|
|
84
|
-
s.
|
|
85
|
-
s.add_runtime_dependency(%q<awesome_print>.freeze, [">= 0".freeze])
|
|
86
|
-
s.add_runtime_dependency(%q<iostruct>.freeze, [">= 0.7.0".freeze])
|
|
87
|
-
s.add_runtime_dependency(%q<multipart-post>.freeze, [">= 2.0.0".freeze])
|
|
88
|
-
s.add_runtime_dependency(%q<zhexdump>.freeze, [">= 0.0.2".freeze])
|
|
89
|
-
s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
|
|
90
|
-
s.add_development_dependency(%q<rspec-its>.freeze, [">= 0".freeze])
|
|
91
|
-
s.add_development_dependency(%q<bundler>.freeze, [">= 0".freeze])
|
|
92
|
-
s.add_development_dependency(%q<juwelier>.freeze, [">= 0".freeze])
|
|
93
|
-
end
|
|
28
|
+
s.extra_rdoc_files = ['LICENSE.txt', 'README.md']
|
|
94
29
|
|
|
30
|
+
s.add_runtime_dependency 'logger'
|
|
31
|
+
s.add_runtime_dependency 'iostruct', '>= 0.7.0'
|
|
32
|
+
s.add_runtime_dependency 'zhexdump', '>= 0.0.2'
|
|
33
|
+
|
|
34
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pedump
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrey "Zed" Zaikin
|
|
@@ -10,21 +10,7 @@ cert_chain: []
|
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
|
-
name:
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - ">="
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '0'
|
|
19
|
-
type: :runtime
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - ">="
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '0'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: awesome_print
|
|
13
|
+
name: logger
|
|
28
14
|
requirement: !ruby/object:Gem::Requirement
|
|
29
15
|
requirements:
|
|
30
16
|
- - ">="
|
|
@@ -51,20 +37,6 @@ dependencies:
|
|
|
51
37
|
- - ">="
|
|
52
38
|
- !ruby/object:Gem::Version
|
|
53
39
|
version: 0.7.0
|
|
54
|
-
- !ruby/object:Gem::Dependency
|
|
55
|
-
name: multipart-post
|
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - ">="
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: 2.0.0
|
|
61
|
-
type: :runtime
|
|
62
|
-
prerelease: false
|
|
63
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
-
requirements:
|
|
65
|
-
- - ">="
|
|
66
|
-
- !ruby/object:Gem::Version
|
|
67
|
-
version: 2.0.0
|
|
68
40
|
- !ruby/object:Gem::Dependency
|
|
69
41
|
name: zhexdump
|
|
70
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -79,62 +51,6 @@ dependencies:
|
|
|
79
51
|
- - ">="
|
|
80
52
|
- !ruby/object:Gem::Version
|
|
81
53
|
version: 0.0.2
|
|
82
|
-
- !ruby/object:Gem::Dependency
|
|
83
|
-
name: rspec
|
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - ">="
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '0'
|
|
89
|
-
type: :development
|
|
90
|
-
prerelease: false
|
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - ">="
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '0'
|
|
96
|
-
- !ruby/object:Gem::Dependency
|
|
97
|
-
name: rspec-its
|
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - ">="
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '0'
|
|
103
|
-
type: :development
|
|
104
|
-
prerelease: false
|
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - ">="
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '0'
|
|
110
|
-
- !ruby/object:Gem::Dependency
|
|
111
|
-
name: bundler
|
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - ">="
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '0'
|
|
117
|
-
type: :development
|
|
118
|
-
prerelease: false
|
|
119
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - ">="
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '0'
|
|
124
|
-
- !ruby/object:Gem::Dependency
|
|
125
|
-
name: juwelier
|
|
126
|
-
requirement: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - ">="
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '0'
|
|
131
|
-
type: :development
|
|
132
|
-
prerelease: false
|
|
133
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
-
requirements:
|
|
135
|
-
- - ">="
|
|
136
|
-
- !ruby/object:Gem::Version
|
|
137
|
-
version: '0'
|
|
138
54
|
description: dump headers, sections, extract resources of win32 PE exe,dll,etc
|
|
139
55
|
email: zed.0xff@gmail.com
|
|
140
56
|
executables:
|
|
@@ -150,7 +66,6 @@ files:
|
|
|
150
66
|
- LICENSE.txt
|
|
151
67
|
- README.md
|
|
152
68
|
- Rakefile
|
|
153
|
-
- VERSION
|
|
154
69
|
- bin/pedump
|
|
155
70
|
- data/comp_id.txt
|
|
156
71
|
- data/fs.txt
|
|
@@ -167,6 +82,7 @@ files:
|
|
|
167
82
|
- lib/pedump/clr.rb
|
|
168
83
|
- lib/pedump/clr/readytorun.rb
|
|
169
84
|
- lib/pedump/clr/signature.rb
|
|
85
|
+
- lib/pedump/colors.rb
|
|
170
86
|
- lib/pedump/comparer.rb
|
|
171
87
|
- lib/pedump/composite_io.rb
|
|
172
88
|
- lib/pedump/core.rb
|
|
@@ -175,6 +91,7 @@ files:
|
|
|
175
91
|
- lib/pedump/loader/minidump.rb
|
|
176
92
|
- lib/pedump/loader/section.rb
|
|
177
93
|
- lib/pedump/logger.rb
|
|
94
|
+
- lib/pedump/multipart.rb
|
|
178
95
|
- lib/pedump/ne.rb
|
|
179
96
|
- lib/pedump/ne/version_info.rb
|
|
180
97
|
- lib/pedump/ordlookup.rb
|
|
@@ -200,7 +117,8 @@ files:
|
|
|
200
117
|
homepage: http://github.com/zed-0xff/pedump
|
|
201
118
|
licenses:
|
|
202
119
|
- MIT
|
|
203
|
-
metadata:
|
|
120
|
+
metadata:
|
|
121
|
+
rubygems_mfa_required: 'true'
|
|
204
122
|
rdoc_options: []
|
|
205
123
|
require_paths:
|
|
206
124
|
- lib
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.7.4
|