Précédent   Forum du club des développeurs et IT Pro > Autres langages > Assembleur > Contribuez
Contribuez Contribuez à la FAQ Assembleur ou partagez vos sources
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 14/02/2011, 10h59   #1
edfed
Membre chevronné
 
Avatar de edfed
 
être humain
Inscription : décembre 2007
Messages : 471
Détails du profil
Informations professionnelles :
Activité : être humain

Informations forums :
Inscription : décembre 2007
Messages : 471
Points : 619
Points : 619
Par défaut [WIN32] appeler le shell

Trois manières d'appeler le shell sous windows avec FASM
1: la méthode pur assembleur, sans invoke ni import
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
format PE GUI
entry start
 
section '.text' code readable executable
start:
        push    5
        push    0
        push    0
        push    _site
        push    0
        push    0
        call   [ShellExecute]
        push    0
        call   [ExitProcess]
 
 
 _site db 'http://www.google.com',0
 
section '.idata' import data readable writeable
 
  dd 0,0,0,RVA kernel,RVA kernel_table
  dd 0,0,0,RVA shell,RVA shell_table
  dd 0,0,0,0,0
 
  kernel_table:
    ExitProcess dd RVA _ExitProcess
    dd 0
  shell_table:
    ShellExecute dd RVA _ShellExecute
    dd 0
 
  kernel db 'kernel32.dll',0
  shell  db 'shell32.DLL',0
  _ExitProcess dw 0
               db 'ExitProcess',0
  _ShellExecute dw 0
                db 'ShellExecuteA'
2: avec imports, mais toujours sans invoke, on gagne pas mal en lisibilité sur la fin du fichier.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
format PE GUI
entry start
include 'win32a.inc'
 
section '.text' code readable executable
start:
        push    5
        push    0
        push    0
        push    _site
        push    0
        push    0
        call   [ShellExecute]
        push    0
        call   [ExitProcess]
 
 _site db 'http://www.google.com',0
 
 section '.idata' import data readable writeable
 
    library kernel,'kernel32.dll',\
          shell,'shell32.dll'
 
     import kernel,ExitProcess,'ExitProcess'
     import shell,ShellExecute,'ShellExecuteA'
3: la méthode avec invoke, ça prend moins de place, et ça fait exactement la même chose, ajout d'une section data pour contenir la ligne de commande
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 
format PE GUI
entry start
include 'win32a.inc'
 
section '.text' code readable executable
start:
        invoke ShellExecute,0,0,_site,0,0,5
        invoke ExitProcess,0
 
 
 section '.data' data readable writeable
 
 _site db 'http://www.google.com',0
 
 section '.idata' import data readable writeable
 
    library kernel,'kernel32.dll',\
          shell,'shell32.dll'
 
     import kernel,ExitProcess,'ExitProcess'
     import shell,ShellExecute,'ShellExecuteA'
ce code permet de créer un petit programme qui fera office de raccourci vers la ressource décrite dans la chaine _web.

il est aussi possible de lancer des commandes complexe, du batch, des programmes, et même, le programme lui même, ce qui mène evidement en un depassement de capacité.
edfed est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 21h05.


 
 
 
 
Partenaires

Hébergement Web