
PIOF - es un marco de instrumentación dinámica y modular para PHP.
Es útil para desarrolladores, ingenieros inversos, analistas de malware e investigador de vulnerabilidades. Con Piof puedes:
Probado en:
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/martinolessio
Alessandro - Twitter.com/rhpco
git clone https://github.com/ingenuity-ninja/piof.git
cd piof
./run.sh
Se utiliza un contenedor Docker para las etapas de edificio y prueba. Use la carcasa del contenedor para interactuar con el entorno PIOF:
root@4e7b7dd9f362:/opt/piof/modules#
La extensión de PHP generada 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
Puede incluirlo en su php.ini o usarlo desde la línea de comando.
Cuando la extensión está habilitada en php.ini puede ejecutar PHP como de costumbre, por ejemplo:
root@4e7b7dd9f362:/etc# php -r "system("ls");"
adduser.conf
aliases
alternatives
apache2
apt
bash.bashrc
bindresvport.blacklist
ca-certificates
ca-certificates.conf
cron.d
[...]
Para usar el módulo en tiempo de ejecución, puede usar el siguiente comando:
php -dextension=/opt/piof/modules/piof.so -r "system("ls");"
Piof Logs In /var/log/piof*
Los módulos de enganche registran información sobre la ejecución del fregadero:
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
Todos los errores internos están registrados en /var/log/piof.error.log
Los módulos de enganche están ubicados en /opt/piof/hooks . Estos módulos están construidos y cargados dinámicamente por la extensión del núcleo PIOF, por lo que siempre deben estar disponibles con piof.so Los módulos se organizan jerárquicamente en directorios: cada directorio está asociado a un fregadero, y cada uno contiene un archivo hook.c y 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
y
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
Durante la etapa de construcción, PIOF compila todos los módulos y mueve los archivos .so generados en /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 funciones enganchadas php -dextension=/opt/piof/modules/piof.so -r "system("ls");"
Licencia BSD de 3 cláusulas (cláusula BSD-3)