0
votes

I am using the following line of code to launch a keylogger I made:

ProcessStartInfo keylogger = new ProcessStartInfo(@"C:\keylogger.exe");
keylogger.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(keylogger);

When I used this code the keylogger launches but doesn't log any keystrokes. I thought this was because of trying to hide the process window, so I changed the code to this:

ProcessStartInfo keylogger = new ProcessStartInfo(@"C:\keylogger.exe");
Process.Start(keylogger);

Still the same problem, I even tried Process.Start(@"C:\keylogger.exe"); alone and even that doesn't seem to work.

In all cases the keylogger launches but doesn't record any keystrokes to the log file. But if I double click and open the keylogger it works perfectly fine.

2
Did you check the file path? Try it with a full path. - Infinity Challenger
@Sievajet You mean the run the program as Admin or run the keylogger as admin? When I double click Admin pop up doesn't come up. - Hussain Noor Mohamed
@HwasooLee As I said the keylogger launches, I can see it in the task manager. - Hussain Noor Mohamed
It depends on the UAC settings you have, but try to run the process with admin privileges from within your code - Sievajet
How are you recording keystrokes? - Krumelur

2 Answers

1
votes

Seems like all I had to do was change the working directory..lol!

This Code worked:

ProcessStartInfo keylogger = new ProcessStartInfo(@"C:\keylogger.exe");
keylogger.WorkingDirectory = @"C:\";
keylogger.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(keylogger);
0
votes

See "To send a keystroke to a different application" on this page:

http://msdn.microsoft.com/en-us/library/ms171548.aspx

your main issue is that your key logger application is not the running application so it doesn't catch all the keystrokes...

in order to get the keystrokes of all applications you will need to hook into the system kernel, have a look on the following http://www.codeproject.com/Articles/6362/Global-System-Hooks-in-NET

keep in mind:

System hooks are powerful. And, with that power comes responsibility. When something goes wrong with system hooks, they don't just break your application. They can break every application running on your system. It is unlikely that it would actually come to that extreme. Nonetheless, you need to double and triple check your code when using system hooks.