#!/bin/bash #ncat --keep-open --sh-exec bla for read line; do set -- $line command="$1" shift case "$command $*" in "rm -rf"*) command=RMDA shift ;; esac case "$command" in "open *) cd ~ echo 220 Operation successful" ;; "cd "*|"CWD "*) cd "$@" ;; ls|"ls "*|LIST|PWD) #PWD is the offical cmd ls "$@" ;; "QUIT"|"QUIT "*) #QUIT is the offical command #Disconnect break ;; "REIN"|"REIN "*) #Re initializes the connection. ;; bye|"bye "*) break ;; RMD|"RMD "*|"rm"|"rm "*|XRMD) #Remove a directory #XRMD RFC 775 Remove the directory rm "$@" ;; RMDA|"RMDA "*) #RMDA is an official comma d #Remove a directory tree #https://datatracker.ietf.org/doc/draft-peterson-streamlined-ftp-command-extensions/ #todo make sure its olay to delete directory" rm -rf "$@" :; "put *") ;; SIZE) a_file=${@[-1]} unset -v '@[-1]' if [ -f $a_file ]; then ls -1s "$@" else du -h "$@" fi ;; XCUP) #XCUP RFC 775 Change to the parent of the current working directory cd .. ;; XMKD|mkdir) #XMKD RFC 775 Make a directory mkdir "$@" ;; XPWD) #XPWD RFC 775 Print the current working directory pwd ;; esac done #Bathroom 7590 #https://tools.ietf.org/html/rfc959