rex-exploitation 0.1.41 → 0.1.43
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/.github/workflows/verify.yml +2 -41
- data/lib/rex/exploitation/vbsobfuscate.rb +141 -0
- data/lib/rex/exploitation/version.rb +1 -1
- data/rex-exploitation.gemspec +8 -0
- metadata +36 -33
- checksums.yaml.gz.sig +0 -4
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57ee0a86e51281389fe57ae6bdef8d5a05973ddf9159ab084d61a494e9f525f
|
4
|
+
data.tar.gz: e77944b1b5b69f1fe584923a31005957af5f8e773f4c9335616fd288f1825524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c479681a255e5faab29066c3fe06ebabc3d3b868572a0e99aa9c5400b50c691ef451a1c1d6cf3de5d188fcaa03b2b67276b015d9bbb4b8381f5209083f0ff66b
|
7
|
+
data.tar.gz: 798d4dd5d42818fa41d86d6a835716f7631516d8dd56605eae15125e6b50a9de7aac35a085d02a9f8d4a9443f2878a5de889c3ed266b81fea25c7b07caa30bc5
|
@@ -9,44 +9,5 @@ on:
|
|
9
9
|
- '*'
|
10
10
|
|
11
11
|
jobs:
|
12
|
-
|
13
|
-
|
14
|
-
timeout-minutes: 40
|
15
|
-
|
16
|
-
strategy:
|
17
|
-
fail-fast: true
|
18
|
-
matrix:
|
19
|
-
ruby:
|
20
|
-
- '2.7'
|
21
|
-
- '3.0'
|
22
|
-
- '3.1'
|
23
|
-
- '3.2'
|
24
|
-
os:
|
25
|
-
- ubuntu-20.04
|
26
|
-
- ubuntu-latest
|
27
|
-
exclude:
|
28
|
-
- { os: ubuntu-latest, ruby: '2.7' }
|
29
|
-
- { os: ubuntu-latest, ruby: '3.0' }
|
30
|
-
test_cmd:
|
31
|
-
- bundle exec rspec
|
32
|
-
|
33
|
-
env:
|
34
|
-
RAILS_ENV: test
|
35
|
-
|
36
|
-
name: ${{ matrix.os }} - Ruby ${{ matrix.ruby }} - ${{ matrix.test_cmd }}
|
37
|
-
steps:
|
38
|
-
- name: Checkout code
|
39
|
-
uses: actions/checkout@v4
|
40
|
-
|
41
|
-
- name: Setup Ruby
|
42
|
-
uses: ruby/setup-ruby@v1
|
43
|
-
with:
|
44
|
-
ruby-version: ${{ matrix.ruby }}
|
45
|
-
bundler-cache: true
|
46
|
-
|
47
|
-
- name: ${{ matrix.test_cmd }}
|
48
|
-
run: |
|
49
|
-
echo "${CMD}"
|
50
|
-
bash -c "${CMD}"
|
51
|
-
env:
|
52
|
-
CMD: ${{ matrix.test_cmd }}
|
12
|
+
build:
|
13
|
+
uses: rapid7/metasploit-framework/.github/workflows/shared_gem_verify.yml@master
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# -*- coding: binary -*-
|
2
|
+
|
3
|
+
module Rex
|
4
|
+
module Exploitation
|
5
|
+
#
|
6
|
+
# VBScript obfuscation library
|
7
|
+
#
|
8
|
+
class VBSObfuscate
|
9
|
+
# The VBScript code that this obfuscator will transform
|
10
|
+
attr_accessor :code
|
11
|
+
|
12
|
+
# Saves +code+ for later obfuscation with #obfuscate!
|
13
|
+
#
|
14
|
+
# @param code [#to_s] the code to obfuscate
|
15
|
+
# @param opts [Hash] an options hash
|
16
|
+
def initialize(code = nil, _opts = {})
|
17
|
+
self.code = code
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [String] the (possibly obfuscated) code
|
21
|
+
def to_s
|
22
|
+
@code
|
23
|
+
end
|
24
|
+
|
25
|
+
# Append +str+ to the (possibly obfuscated) code
|
26
|
+
def <<(str)
|
27
|
+
@code << str
|
28
|
+
end
|
29
|
+
|
30
|
+
# Obfuscate VBScript code.
|
31
|
+
#
|
32
|
+
# @option iterations [Integer] number of times to run the obfuscator on this code (1)
|
33
|
+
# @option normalize_whitespace [Boolean] normalize line endings and strip leading/trailing whitespace from each line (true)
|
34
|
+
# @option dynamic_execution [Boolean] dynamically execute obfuscated code with Execute (true)
|
35
|
+
#
|
36
|
+
# @return [self]
|
37
|
+
def obfuscate!(iterations: 1, normalize_whitespace: true, dynamic_execution: true)
|
38
|
+
raise(ArgumentError, 'code must be present') if @code.nil?
|
39
|
+
raise(ArgumentError, 'iterations must be a positive integer') unless iterations.integer? && iterations.positive?
|
40
|
+
|
41
|
+
obfuscated = @code.dup
|
42
|
+
|
43
|
+
iterations.times do
|
44
|
+
# Normalize line endings and strip leading/trailing whitespace
|
45
|
+
if normalize_whitespace
|
46
|
+
obfuscated.gsub!(/\r\n/, "\n")
|
47
|
+
obfuscated = obfuscated.lines.map(&:strip).reject(&:empty?).join("\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Convert all VBScript to a string to be dynamically executed with Execute()
|
51
|
+
if dynamic_execution
|
52
|
+
obfuscated = 'Execute ' + vbscript_string_for_execute(obfuscated)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Obfuscate strings
|
56
|
+
obfuscated = chunk_vbscript_strings(obfuscated)
|
57
|
+
obfuscated.gsub!(/"((?:[^"]|"")*)"/) do
|
58
|
+
raw = ::Regexp.last_match(1).gsub('""', '"')
|
59
|
+
raw.chars.map { |c| "chr(#{generate_number_expression(c.ord)})" }.join('&')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Obfuscate integers
|
63
|
+
obfuscated.gsub!(/\b\d+\b/) do |num|
|
64
|
+
generate_number_expression(num.to_i)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
@code = obfuscated
|
69
|
+
|
70
|
+
self
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
# Converts all VBScript in +vbscript+ to a string for dynamic execution
|
76
|
+
# with Execute().
|
77
|
+
#
|
78
|
+
# @param vbscript [String] VBScript code
|
79
|
+
#
|
80
|
+
# @return [String] obfuscated VBScript code for use with Execute()
|
81
|
+
def vbscript_string_for_execute(vbscript)
|
82
|
+
lines = vbscript.lines.map(&:chomp).map do |line|
|
83
|
+
escaped_line = line.gsub('"', '""')
|
84
|
+
"\"#{escaped_line}\""
|
85
|
+
end
|
86
|
+
lines.join('&vbCrLf&')
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns a random math expression evaluating to input +int+
|
90
|
+
#
|
91
|
+
# @param int [Integer] input integer
|
92
|
+
#
|
93
|
+
# @return [String] math expression evaluating to input +int+
|
94
|
+
def generate_number_expression(int)
|
95
|
+
case rand(4)
|
96
|
+
when 0 # Sum
|
97
|
+
a = rand(0..int)
|
98
|
+
b = int - a
|
99
|
+
"(#{a}+#{b})"
|
100
|
+
when 1 # Difference
|
101
|
+
r1 = int + rand(1..10)
|
102
|
+
r2 = r1 - int
|
103
|
+
"(#{r1}-#{r2})"
|
104
|
+
when 2 # Product (only if divisible)
|
105
|
+
divisors = (1..int).select { |d| (int % d).zero? }
|
106
|
+
if divisors.size > 1
|
107
|
+
d = divisors.sample
|
108
|
+
"(#{d}*#{int / d})"
|
109
|
+
else
|
110
|
+
"(#{int}+0)"
|
111
|
+
end
|
112
|
+
when 3 # Quotient
|
113
|
+
r2 = rand(1..10)
|
114
|
+
r1 = int * r2
|
115
|
+
"(#{r1}/#{r2})"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# Return VBScript code with all strings split into chunks and concatenated
|
120
|
+
#
|
121
|
+
# @param vbscript [String] VBScript code
|
122
|
+
#
|
123
|
+
# @return [String] VBScript code with chunked strings
|
124
|
+
def chunk_vbscript_strings(vbscript)
|
125
|
+
vbscript.gsub(/"([^"]+)"/) do
|
126
|
+
original = Regexp.last_match(1)
|
127
|
+
chunks = []
|
128
|
+
|
129
|
+
i = 0
|
130
|
+
while i < original.length
|
131
|
+
chunk_size = rand(1..5)
|
132
|
+
chunks << "\"#{original[i, chunk_size]}\""
|
133
|
+
i += chunk_size
|
134
|
+
end
|
135
|
+
|
136
|
+
chunks.join('&')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/rex-exploitation.gemspec
CHANGED
@@ -34,4 +34,12 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_runtime_dependency 'metasm'
|
35
35
|
# Needed for Javascript obfuscation
|
36
36
|
spec.add_runtime_dependency 'jsobfu'
|
37
|
+
|
38
|
+
# bigdecimal and racc are not part of the default gems starting from Ruby 3.4.0: https://www.ruby-lang.org/en/news/2023/12/25/ruby-3-3-0-released/
|
39
|
+
%w[
|
40
|
+
bigdecimal
|
41
|
+
racc
|
42
|
+
].each do |library|
|
43
|
+
spec.add_runtime_dependency library
|
44
|
+
end
|
37
45
|
end
|
metadata
CHANGED
@@ -1,40 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rex-exploitation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Metasploit Hackers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
|
-
cert_chain:
|
11
|
-
-
|
12
|
-
-----BEGIN CERTIFICATE-----
|
13
|
-
MIIERDCCAqygAwIBAgIBATANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDDBttc2Zk
|
14
|
-
ZXYvREM9bWV0YXNwbG9pdC9EQz1jb20wHhcNMjMxMDMwMTYwNDI1WhcNMjUxMDI5
|
15
|
-
MTYwNDI1WjAmMSQwIgYDVQQDDBttc2ZkZXYvREM9bWV0YXNwbG9pdC9EQz1jb20w
|
16
|
-
ggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDZN/EKv+yVjwiKWvjAVhjF
|
17
|
-
aWNYI0E9bJ5d1qKd29omRYX9a+OOKBCu5+394fyF5RjwU4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cuq+d3YhAyU7NI4+Ja8EwazOnB+07sWhKpg7z
|
33
|
-
yuQ1mWYPmZfVQpoSVv1CvXsoqJYXVPBBLOacKKSj8ArVG6pPn9Bej7IOQdblaFjl
|
34
|
-
DgscAao7wB3xW2BWEp1KnaDWkf1x9ttgoBEYyuYwU7uatB67kBQG1PKvLt79wHvz
|
35
|
-
Dxs+KOjGbBRfMnPgVGYkORKVrZIwlaboHbDKxcVW5xv+oZc7KYXWGg==
|
36
|
-
-----END CERTIFICATE-----
|
37
|
-
date: 2025-02-13 00:00:00.000000000 Z
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-09-24 00:00:00.000000000 Z
|
38
12
|
dependencies:
|
39
13
|
- !ruby/object:Gem::Dependency
|
40
14
|
name: rake
|
@@ -148,6 +122,34 @@ dependencies:
|
|
148
122
|
- - ">="
|
149
123
|
- !ruby/object:Gem::Version
|
150
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bigdecimal
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: racc
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
151
153
|
description: |-
|
152
154
|
This gem contains various helper mechanisms for creating exploits.
|
153
155
|
This includes SEH Overwrite helpers, egghunters, command stagers and more.
|
@@ -227,12 +229,13 @@ files:
|
|
227
229
|
- lib/rex/exploitation/opcodedb.rb
|
228
230
|
- lib/rex/exploitation/ropdb.rb
|
229
231
|
- lib/rex/exploitation/seh.rb
|
232
|
+
- lib/rex/exploitation/vbsobfuscate.rb
|
230
233
|
- lib/rex/exploitation/version.rb
|
231
234
|
- rex-exploitation.gemspec
|
232
235
|
homepage: https://github.com/rapid7/rex-exploitation
|
233
236
|
licenses: []
|
234
237
|
metadata: {}
|
235
|
-
post_install_message:
|
238
|
+
post_install_message:
|
236
239
|
rdoc_options: []
|
237
240
|
require_paths:
|
238
241
|
- lib
|
@@ -247,8 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
250
|
- !ruby/object:Gem::Version
|
248
251
|
version: '0'
|
249
252
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
251
|
-
signing_key:
|
253
|
+
rubygems_version: 3.4.19
|
254
|
+
signing_key:
|
252
255
|
specification_version: 4
|
253
256
|
summary: Ruby Exploitation(Rex) library for various exploitation helpers
|
254
257
|
test_files: []
|
checksums.yaml.gz.sig
DELETED
data.tar.gz.sig
DELETED
Binary file
|
metadata.gz.sig
DELETED