
PIOF - est un cadre d'instrumentation dynamique et modulaire pour PHP.
Il est utile pour les développeurs, les ingénieurs inverses, l'analyste de logiciels malveillants et le chercheur en vulnérabilité. Avec piof vous pouvez:
Testé sur:
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies
Martino - twitter.com/martinolelessio
Alessandro - Twitter.com/rhpco
git clone https://github.com/ingenuity-ninja/piof.git
cd piof
./run.sh
Un conteneur Docker est utilisé pour les étapes de construction et de test. Utilisez le shell de conteneur pour interagir avec l'environnement PIOF:
root@4e7b7dd9f362:/opt/piof/modules#
L'extension PHP générée est disponible en /opt/piof/modules
root@4e7b7dd9f362:/opt/piof/modules# ls -lah
total 100K
drwxr-xr-x 2 root root 4.0K Feb 19 20:55 .
drwxr-xr-x 1 root root 4.0K Feb 19 20:55 ..
-rwxr-xr-x 1 root root 91K Feb 19 20:55 piof.so
Vous pouvez soit l'inclure dans votre php.ini, soit l'utiliser à partir de la ligne de commande.
Lorsque l'extension est activée dans php.ini vous pouvez exécuter PHP comme d'habitude, par exemple:
root@4e7b7dd9f362:/etc# php -r "system("ls");"
adduser.conf
aliases
alternatives
apache2
apt
bash.bashrc
bindresvport.blacklist
ca-certificates
ca-certificates.conf
cron.d
[...]
Pour utiliser le module lors de l'exécution, vous pouvez utiliser la commande suivante:
php -dextension=/opt/piof/modules/piof.so -r "system("ls");"
PIOF JOGS EN /var/log/piof*
Les modules d'accrochage enregistrent les informations sur l'exécution du puits:
root@4e7b7dd9f362:/etc# tail -f /var/log/piof.info.log
Feb 19 21:05:15 4e7b7dd9f362 piof - system - hook[155]: Arguments 1
Feb 19 21:05:15 4e7b7dd9f362 piof - system - hook[155]: Parameter ls
Feb 19 21:12:17 4e7b7dd9f362 piof - md5 - hook[160]: Arguments 1
Feb 19 21:12:17 4e7b7dd9f362 piof - md5 - hook[160]: Parameter admin
Toutes les erreurs internes sont enregistrées dans /var/log/piof.error.log
Les modules d'accrochage sont situés dans /opt/piof/hooks . Ces modules sont construits dynamiquement et chargés par l'extension PIOF Core, ils doivent donc être toujours disponibles avec piof.so Les modules sont organisés hiérarchiquement dans les répertoires: chaque répertoire est associé à un puits, et chacun contient un fichier hook.c et un fichier hook.h
root@42e0da0df931:/opt/piof/hooks# ls -lah
total 28K
drwxrwxr-x 1 root root 4.0K Feb 19 20:55 .
drwxr-xr-x 1 root root 4.0K Feb 19 20:55 ..
drwxr-xr-x 2 root root 4.0K Feb 19 20:55 build
drwxrwxr-x 2 root root 4.0K Feb 19 20:24 eval
drwxrwxr-x 2 root root 4.0K Feb 19 20:24 include
drwxrwxr-x 2 root root 4.0K Feb 19 20:24 md5
drwxrwxr-x 2 root root 4.0K Feb 19 20:24 system
et
root@42e0da0df931:/opt/piof/hooks# ls -lah include/
total 16K
drwxrwxr-x 2 root root 4.0K Feb 19 20:24 .
drwxrwxr-x 1 root root 4.0K Feb 19 20:55 ..
-rw-rw-r-- 1 root root 943 Feb 19 20:24 hook.c
-rw-rw-r-- 1 root root 356 Feb 19 20:24 hook.h
Pendant l'étape de construction, Piof compile tous les modules et déplacez les fichiers .so générés dans /opt/piof/hooks/build
root@42e0da0df931:/opt/piof/hooks/build# ls -lah
total 184K
drwxr-xr-x 2 root root 4.0K Feb 19 20:55 .
drwxrwxr-x 1 root root 4.0K Feb 19 20:55 ..
-rwxr-xr-x 1 root root 43K Feb 19 20:55 eval.so
-rwxr-xr-x 1 root root 43K Feb 19 20:55 include.so
-rwxr-xr-x 1 root root 44K Feb 19 20:55 md5.so
-rwxr-xr-x 1 root root 44K Feb 19 20:55 system.so
make clean
phpize
./configure
make
cd /opt/piof/hooks/eval/
gcc -shared -o eval.so -fPIC hook.c -g -Wall -I -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/Zend -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/include/php/20170718 -I/usr/include/php/20170718/main -I/usr/include/php/20170718/TSRM -I/usr/include/php/20170718/Zend -I/usr/include/php/20170718/ext -I/usr/include/php/20170718/ext/date/lib -I ../../
mv eval.so ../build
md5 php -dextension=/opt/piof/modules/piof.so -r "echo md5("admin");"
system de fonction accrochée php -dextension=/opt/piof/modules/piof.so -r "system("ls");"
Licence BSD 3-CLAUSE (CLAUSE BSD-3)