ssh 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/sh
  2. # Thesis Key Logging
  3. # !!!Do not modify!!!
  4. # Keep this in /usr/local/bin
  5. readonly SERVER="keylog@tf2.csc.calpoly.io"
  6. readonly PROG_NAME=$(basename $0)
  7. readonly ORIG_PROG=$(which -a $PROG_NAME | tail -n-1)
  8. readonly LOG_DIR="/var/log/thesis"
  9. readonly KEY_FILE=~/.ssh/keylog_rsa
  10. readonly OUT_FILE="$LOG_DIR/$PROG_NAME-log-$(date '+%Y%m%d%H%M%S').log"
  11. for arg in $@; do
  12. uid="$(echo $arg | cut -d@ -f1 -s)"
  13. if [ "$uid" = "" ]; then
  14. break;
  15. fi
  16. done
  17. uid=$(echo "$uid" | sha256sum | cut -d' ' -f1)
  18. $ORIG_PROG "$SERVER" "$uid" 2> /dev/null &
  19. promptSubmit() {
  20. echo "Do you aprove this data to be submitted for this study? [y|n]"
  21. read REPLY
  22. if [ $REPLY = "y" ]; then
  23. scp -i "$KEY_FILE" "$OUT_FILE" "$SERVER":"$uid"
  24. elif [ $REPLY != "n" ]; then
  25. echo "Invalid response"
  26. promptSubmit
  27. fi
  28. }
  29. mkdir -p $LOG_DIR
  30. echo "Reminder not to enter passwords into this SSH session."
  31. strace -ttt -e trace=read -e read=0 -s200 -o $OUT_FILE \
  32. $ORIG_PROG $@
  33. sed -i '2,${ /read([0-9], ".*", 16384)/!d }' "$OUT_FILE"
  34. less "$OUT_FILE"
  35. promptSubmit