Create a simple key logger in C following these instructions: 1. Include two libraries, one that will
Question:
Create a simple key logger in C following these instructions:
1. Include two libraries, one that will provide input and output functions and another that will
provide a function with an ability to execute shell commands from within your code.
2. Your code should be comprised of 1 function only, main. It is not expected to return anything
3. The keylogger will need to accept data entered at the shell prompt. Declare a variable called
kbinput of an appropriate size and type that will be used to store the data entered at the shell
prompt
4. The keylogger will be storing the key presses in a file. Declare a pointer variable called fptr
that is of type FILE
5. Open a file called keylogfile.txt for writing and assign its address to fptr
6. Echo to the screen, a copy of your shell’s default prompt
7. From the standard input device, read any data entered at the shell’s command prompt into the
variable kbinput. I suggest you use a command that reads an entire line and places it into
kbinput
8. Now you need a loop. The statements and expressions in this loop will continue to be
performed until the keylogger is stopped. For this basic version I suggest that you use a single
keyboard character that is not typically used on its own, for example the character ‘~’ to
terminate the execution of the loop and the program itself
9. Write the contents of kbinput to the file keylogfile using fptr
10. Remember that the user should be unaware that the key logger is executing. The stealthy
operation of the keylogger began by replicating the default shell prompt in step 6 above.
Whatever the user enters must still therefore be executed by the shell. Using an appropriate
command, have the shell execute what is contained in kbinput
11. Once again, echo a copy of your shell’s default prompt. This will mimick the shell completing
the execution of whatever command was executed in step 10 above
12. Repeat step 7 above. This is the last line of what should be included in the loop
13. Before terminating the keylogger, close the text file
14. Compile and run your keylogger. If you followed these steps and wrote some good code, you
will see your keylogger works and when you view the contents of keylogfile you will see all the
commands you entered in the shell between starting and ending your program. Note, on Linux,
if you try something like sudo, with this keylogger you will obtain the username entered but
not the associated password.
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill