Advertisement
s243a

bashftp

Dec 22nd, 2020
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.35 KB | None | 0 0
  1. #!/bin/bash
  2. #ncat --keep-open --sh-exec bla
  3. for read line; do
  4.  set -- $line
  5.  command="$1"
  6.  shift
  7.  case  "$command $*" in
  8.  "rm -rf"*)
  9.    command=RMDA
  10.    shift
  11.    ;;
  12.  esac
  13.  case "$command" in
  14.   "open *)
  15.    cd ~
  16.    echo 220 Operation successful"
  17.   ;;
  18.   "cd "*|"CWD "*)
  19.    cd "$@"
  20.    ;;
  21.   ls|"ls "*|LIST|PWD) #PWD is the offical cmd
  22.     ls "$@"
  23.   ;;
  24.   "QUIT"|"QUIT "*) #QUIT is the offical command
  25.   #Disconnect
  26.     break
  27.     ;;
  28.   "REIN"|"REIN "*)
  29.    #Re initializes the connection.
  30.   ;;
  31.   bye|"bye "*)
  32.     break
  33.     ;;
  34.   RMD|"RMD "*|"rm"|"rm "*|XRMD)
  35.   #Remove a directory
  36.   #XRMD RFC 775 Remove the directory
  37.   rm "$@"
  38.   ;;
  39.   RMDA|"RMDA "*) #RMDA is an official comma d
  40.   #Remove a directory tree
  41.   #https://datatracker.ietf.org/doc/draft-peterson-streamlined-ftp-command-extensions/
  42.   #todo make sure its olay to delete directory"
  43.   rm -rf "$@"
  44.   :;
  45.   "put *")
  46.    ;;
  47.   SIZE)
  48.    a_file=${@[-1]}
  49.    unset -v '@[-1]'
  50.     if [ -f $a_file ]; then
  51.       ls -1s "$@"
  52.     else
  53.       du -h "$@"
  54.     fi
  55.     ;;
  56.   XCUP)
  57.     #XCUP RFC 775 Change to the parent of the current working directory
  58.     cd ..
  59.     ;;
  60.   XMKD|mkdir)
  61.     #XMKD RFC 775 Make a directory
  62.     mkdir "$@"
  63.     ;;
  64.   XPWD)
  65.     #XPWD RFC 775 Print the current working directory
  66.    pwd
  67.    ;;
  68.   esac
  69. done
  70.    #Bathroom 7590
  71.  
  72. #https://tools.ietf.org/html/rfc959
  73.  
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement