I am currently making a honeypot which will record all user input once they login successfully through SSH.
Here's how it works: I have my honeypot user admin
's default shell set to a bash script:
admin:x:1001:1001::/home/admin:/home/admin/HoneyPot/spawner.sh
The spawner.sh
script will go ahead and launch an except
script and record the output using script
.
#!/bin/bash
cd /home/admin/HoneyPot/template/
pwd
script -c "./script.exp" -t 2> timing.log -a output.session #start recording session, execute except script
echo "we should not get here"
Here are the first few lines of script.exp
:
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Mon Oct 5 13:55:35
# boilerplate comments and code:
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
start of my code
set timeout -1
spawn emulator #emulator is a simh emulator executable. not a shell script.
...
interact
When I run the script using ./template.sh
as admin
using bash
, the script runs perfectly fine. However, when I login using su
, this happens:
austin@ubuntu:~$ su admin
Password:
/home/admin/HoneyPot/template
Script started, file is output.session
/home/admin/HoneyPot/template
Script started, file is output.session
/home/admin/HoneyPot/template
Script started, file is output.session
/home/admin/HoneyPot/template
Script started, file is output.session
/home/admin/HoneyPot/template
Script started, file is output.session
/home/admin/HoneyPot/template
...
Why is my bash script not working with the user's shell set to it? There are no recursive calls inside my script, and the script
command should be blocking!
And just in case anyone is worried, this machine has no outgoing network connectivity. It can only receive SSH connections. Yes, I know that a user can break out of this. This is being ran in a VM.