• STATISTIQUES
  • Il y a eu un total de 1 membres et 4290 visiteurs sur le site dans les dernières 24h pour un total de 4 291 personnes!


    Membres: 2 604
    Discussions: 3 579
    Messages: 32 816
    Tutoriels: 78
    Téléchargements: 38
    Sites dans l'annuaire: 58


  • ANNUAIRE
  • [EN] Big-Daddy
    Big-Daddy est site internet communautaire avec un effectif diversifié, y compris des artistes, des programmeur...
    Hacking
    [EN] Exploit-db
    Une base de données d'exploits triés par genre (GHDB, Remote, Local, Web, DOS, ShellCode) à ...
    Vulnérabilités
    [FR] PHP Débutant
    Apprendre le PHP par l'exemple, facilement et simplement. Réservé d'abord aux débutants....
    Programmation
    [EN] PHPFreaks
    PHPFreaks est un site dédié à l'apprentissage et l'enseignement du PHP. Ici vous trouver...
    Programmation
    [EN] social-engineer
    Site dédié au Social Engineering en général.
    Hacking
    [EN] This is legal
    Basic: 10, Realistic: 5, Programming: 1, Bonus: 11, SQL: 2, Encryption: 6, Application: 4, User Contributed: 3
    Challenges
    [EN] SecurityFocus
    SecurityFocus a été conçu pour faciliter la discussion sur des sujets liés la sécu...
    Vulnérabilités

  • DONATION
  • Si vous avez trouvé ce site internet utile, nous vous invitons à nous faire un don du montant de votre choix via Paypal. Ce don servira à financer notre hébergement.

    MERCI!




Introduction au Cracking sur Linux

Hola

Voici mon premier tuto pour le site N-PN

Nous allons voir Les méthodes de Reverse sous Linux, Le crackme et dispo ici*: http://www.reversing.be/easyfile/file.ph...2180927229


Donc on récupère notre crackme small et on va voir à quoi on à faire .


Code :
systemprog@n-pn:~/Bureau$ file ./small

./small: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped

systemprog@n-pn:~/Bureau$


Ok c'est un ELF 32 bit, on continu

Code :
systemprog@n-pn:~/Bureau$ ls -al
-rwxr-xr-x  1 noshell noshell  11263 2004-10-16 21:02 small

systemprog@n-pn:~/Bureau$


Ok tout va bien on peut l'exécuter.

Si on avait pas les droits pour l'exécuter, un simple ' $ chmod 777 small ' et c'est réglé.

Allez c'est parti on l'exécute voir ce que ça donne*:


Code :
systemprog@n-pn:~/Bureau$ ./small
-> Small crackme for Stingduk <-

Give me your name (max 50 chars):[color=RoyalBlue] systemprog[/color]

Pass me the serial (max 50 chars): [color=RoyalBlue]123[/color]

[color=Red]No luck here mate :([/color]

systemprog@n-pn:~/Bureau$


On vois qu'il nous demande un nom et un passe, donc le but va être de trouver le bon passe pour notre nom. :-)


Regardons un peut les strings s'il n'y a pas quelque chose d'intéressant*:


Code :
systemprog@n-pn:~/Bureau$ strings small
…......
…......

libc.so.6

__cxa_atexit

strcmp

_IO_stdin_used

__libc_start_main

GLIBC_2.1.3

GLIBC_2.0

CXXABI_1.2

GLIBCPP_3.2

PTRh

-> Small crackme for Stingduk <-

Give me your name (max 50 chars):

Pass me the serial (max 50 chars):

Great work!

No luck here mate :(

systemprog@n-pn:~/Bureau$


Juste un strcmp qui doit servir pour comparer notre passe.


Bon maintenant on va essayer de tracer le crackme avec la commande ltrace


Code :
systemprog@n-pn:~/Bureau$  ltrace ./small

__libc_start_main(0x80487bc, 1, 0xffa64ec4, 0x80489a0, 0x8048a00 <unfinished ...>

_ZNSt8ios_base4InitC1Ev(0x8049edc, 0xf7764918, 0xf761fff4, 0xffa64dc8, 0xf74f6cb5) = 3

__cxa_atexit(0x8048966, 0, 0x8049be0, 0xffa64dc8, 0xf74f6cb5) = 0

_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(0x8049db8, 0x8048ae0, 0x8048504, 0xf74cadf0, 0xf776146c) = 0x8049db8

_ZNSolsEPFRSoS_E(0x8049db8, 0x80486d8, 0xf7720810, 0xf74d37d0, 0x3df6174 <unfinished ...>

_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(0x8049db8, 0xf7764918, 0xffa64e18, 0x80487f2, 0x8049db8-> Small crackme for Stingduk <-

) = 0x8049db8

<... _ZNSolsEPFRSoS_E resumed> )                 = 0x8049db8

_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(0x8049db8, 0x8048b20, 0xf7720810, 0xf74d37d0, 0x3df6174) = 0x8049db8

_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(0x8049e48, 0xffa64dd0, 0xf7720810, 0xf74d37d0, 0x3df6174Give me your name (max 50 chars): [color=Red]systemprog[/color]

) = 0x8049e48

_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(0x8049db8, 0x8048b60, 0xf7720810, 0xf74d37d0, 0x3df6174) = 0x8049db8

_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_(0x8049e48, 0xffa64d90, 0xf7720810, 0xf74d37d0, 0x3df6174Pass me the serial (max 50 chars): [color=Red]123[/color]

) = 0x8049e48

[color=Red]strcmp("5156192413", "123")[/color]                      = 1

_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(0x8049db8, 0x8048b90, 8, 0x80488cb, 0xffa64d50) = 0x8049db8

_ZNSolsEPFRSoS_E(0x8049db8, 0x80486d8, 0xf7720810, 0xf74d37d0, 0x3df6174 <unfinished ...>

_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(0x8049db8, 0x8048b90, 0xffa64e18, 0x804891d, 0x8049db8No luck here mate :(

) = 0x8049db8

<... _ZNSolsEPFRSoS_E resumed> )                 = 0x8049db8

_ZNSt8ios_base4InitD1Ev(0x8049edc, 0, 0x8049be0, 0xffa64dc8, 0xf74f6cb5) = 0xf77188b0

+++ exited (status 0) +++
systemprog@n-pn:~/Bureau$


Bingo , on vois bien le strcmp qui compare notre pass 123 avec 5156192413
On test*:


Code :
systemprog@n-pn:~/Bureau$ ./small
-> Small crackme for Stingduk <-

Give me your name (max 50 chars):[COLOR="RoyalBlue"] systemprog
[/COLOR]
Pass me the serial (max 50 chars):[color=RoyalBlue] 5156192413[/color]

[color=Red]Great work![/color]

systemprog@n-pn:~/Bureau$


Maintenant on va voir une autre méthode avec GDB *( pourquoi faire simple quand on peut faire compliqué) :

Donc on ouvre le crackme avec GDB et on va le désassembler avec la commande disass de GDB.

On peut aussi récupérer le code asm avec la commande objdump et rediriger la sortie dans un fichié txt.

Exemple*:

Code :
systemprog@n-pn:~/Bureau$  objdump -D small >> small.txt

systemprog@n-pn:~/Bureau$


Et voilà on a notre code dans small.txt


bon allez on ouvre le crackme avec GDB

Code :
systemprog@n-pn:~/Bureau$  gdb -q ./small
Reading symbols from /systemprog/Bureau/small...done.

(gdb) disass main
…..
…...
   0x080488b5 <+249>:    lea    -0x88(%ebp),%eax

   0x080488bb <+255>:    lea    -0xc8(%ebp),%edx

   0x080488c1 <+261>:    sub    $0x8,%esp

   0x080488c4 <+264>:    push   %eax

   0x080488c5 <+265>:    push   %edx

   [color=Red]0x080488c6 <+266>:    call   0x8048668 <strcmp@plt>[/color]

   0x080488cb <+271>:    add    $0x10,%esp

   0x080488ce <+274>:    test   %eax,%eax

   0x080488d0 <+276>:    jne    0x80488fa <main+318>

   0x080488d2 <+278>:    sub    $0x8,%esp

   0x080488d5 <+281>:    push   $0x80486d8

   0x080488da <+286>:    sub    $0xc,%esp

   0x080488dd <+289>:    push   $0x8048b84

   0x080488e2 <+294>:    push   $0x8049db8

   0x080488e7 <+299>:    call   0x8048698
….....
….....
(gdb)


On retrouve notre strcmp, on va poser un breakpoint en 0x080488c6, lancer le crackme avec
r (run), et on va regarder un peut ce qui se passe dans les registres avec i r (info registre).


Code :
(gdb) b * 0x080488c6
Breakpoint 1 at 0x80488c6
(gdb) r
Starting program: /systemprog/Bureau/small

-> Small crackme for Stingduk <-

Give me your name (max 50 chars): [color=RoyalBlue]systemprog[/color]

Pass me the serial (max 50 chars): [color=RoyalBlue]123[/color]



Breakpoint 1, 0x080488c6 in main ()

(gdb) i r
eax            0xffffd310    -11504

ecx            0xffffd2d9    -11559

edx            0xffffd2d0    -11568

ebx            0xf7eb8ff4    -135557132

esp            0xffffd2a0    0xffffd2a0

ebp            0xffffd398    0xffffd398

esi            0x0    0

edi            0x0    0

eip            0x80488c6    0x80488c6 <main+266>

eflags         0x292    [ AF SF IF ]

cs             0x23    35

ss             0x2b    43

ds             0x2b    43

es             0x2b    43

fs             0x0    0

gs             0x63    99

(gdb)


On peut voir que EAX contient notre passe qui et comparé à EDX qui lui contient le bon passe.

Code :
(gdb) x/s 0xffffd2d0

0xffffd2d0:    [color=Red] "5156192413"[/color]

(gdb) x/s 0xffffd310

0xffffd310:    [color=Red] "123"[/color]

(gdb)


Si on remonte un peut le code au dessus du strcmp, on vois que la routine de génération du passe se trouve entre 8048854 et 80488a4, pour ceux qui veulent là tracer Wink .


Code ASM :


 8048854:   8d 45 b8                lea    -0x48(%ebp),%eax
 8048857:   03 85 34 ff ff ff       add    -0xcc(%ebp),%eax
 804885d:   80 38 00                cmpb   $0x0,(%eax)
 8048860:   75 02                   jne    8048864 <main+0xa8>
 8048862:   eb 42                   jmp    80488a6 <main+0xea>
 8048864:   8d 85 38 ff ff ff       lea    -0xc8(%ebp),%eax
 804886a:   89 c1                   mov    %eax,%ecx
 804886c:   03 8d 34 ff ff ff       add    -0xcc(%ebp),%ecx
 8048872:   8d 45 b8                lea    -0x48(%ebp),%eax
 8048875:   03 85 34 ff ff ff       add    -0xcc(%ebp),%eax
 804887b:   8a 00                   mov    (%eax),%al
 804887d:   66 0f be d0             movsbw %al,%dx
 8048881:   66 c7 85 26 ff ff ff    movw   $0xa,-0xda(%ebp)
 8048888:   0a 00
 804888a:   89 d0                   mov    %edx,%eax
 804888c:   66 99                   cwtd  
 804888e:   66 f7 bd 26 ff ff ff    idivw  -0xda(%ebp)
 8048895:   88 d0                   mov    %dl,%al
 8048897:   83 c0 30                add    $0x30,%eax
 804889a:   88 01                   mov    %al,(%ecx)
 804889c:   8d 85 34 ff ff ff       lea    -0xcc(%ebp),%eax
 80488a2:   ff 00                   incl   (%eax)
 80488a4:   eb ae                   jmp    8048854 <main+0x98>
 80488a6:   8d 85 38 ff ff ff       lea    -0xc8(%ebp),%eax
 80488ac:   03 85 34 ff ff ff       add    -0xcc(%ebp),%eax
 80488b2:   c6 00 00                movb   $0x0,(%eax)
 80488b5:   8d 85 78 ff ff ff       lea    -0x88(%ebp),%eax
 80488bb:   8d 95 38 ff ff ff       lea    -0xc8(%ebp),%edx
 80488c1:   83 ec 08                sub    $0x8,%esp
 80488c4:   50                      push   %eax
 80488c5:   52                      push   %edx
 80488c6:   e8 9d fd ff ff          call   8048668 <strcmp@plt>
 80488cb:   83 c4 10                add    $0x10,%esp
 80488ce:   85 c0                   test   %eax,%eax

 



Un petit résumé des commandes de GDB*:

- run // pour lancer l'exécution
- quit // pour quiter le programme
- step // pour avancer pas a pas
- info registre // pour voir les registres
- breakpoint // pose un point d'arret
- continu // continu au prochain point d'arret
- clear // enlève un point d'arret
- disass // pour désassembler
- print // pour afficher la valeur d'une variable
- backtrace // pour afficher la pile d'exécution
- watch // surveille une variable si elle est modiffié


Voila pour mon premier tuto, j'espère avoir était assez clair.
26-10-2011, 23h02
Message : #1
CyberSee Hors ligne
Admin fondateur de N-PN
*******



Messages : 1,721
Sujets : 287
Points: 157
Inscription : Jan 2012
Introduction au Cracking sur Linux
Très bon tuto merci de ta contribution ;-)

New Project News White Hat Hacker V2.3
Accueil | Challenges | Tutoriels | Téléchargements | Forum