BASH   55
sshd sh
Guest on 14th August 2022 01:08:52 AM


  1. #!/bin/bash
  2. #
  3. # This is the server script. Install as a cgi script on a webserver.
  4. #
  5. # Robert McKay <robert@mckay.com>
  6. #
  7. # Requires: nc
  8. #
  9.  
  10.  
  11. # Proxies sometimes virus scan content. this means they won't allow streaming
  12. # however they often exempt certain common mime-types from scanning in order
  13. # to allow streaming media to work. We need streaming in order for this to work
  14. # so set a mime type that works. Try them all.. try different ones.. try
  15. # making one up.
  16.  
  17. pretend_content=video/avi
  18. pretend_content=video/x-ms-asf
  19. pretend_content=video/x-ms-wm
  20. pretend_content=video/x-ms-wmx
  21. pretend_content=video/msvideo
  22. pretend_content=video-x-msvideo
  23. pretend_content=video/xmpg2
  24. pretend_content=application/x-troff-msvideo
  25. pretend_content=audio/avi
  26. pretend_content=audio/asf
  27. pretend_content=audio/vnd.rn-realaudio
  28. padding=1
  29.  
  30. if [ "${REQUEST_METHOD}" == "POST" ];
  31. then
  32. # If the request is a POST then it's the RX mode
  33.  
  34.         hashkey=`echo "${QUERY_STRING}" | cut -f2 -d"="`
  35.  
  36.         sessionkey=`echo "${hashkey}" | md5sum - | cut -f1 -d" "`
  37.         pipe="/tmp/outpipe.${sessionkey}"
  38.  
  39.         if [ -p "${pipe}" ];
  40.         then
  41.                 head -1 >/dev/null
  42.                 cat > "${pipe}"
  43.         else
  44.                 echo -en "Content-Type: text/plain\n\n"
  45.                 echo "Session not found."
  46.                 exit 0
  47.         fi
  48.  
  49.         echo -en "Content-Type: application/octet-stream\n\n"
  50.         echo "End of script"
  51.  
  52. else
  53. # If it's a GET then we're the TX
  54.  
  55.         host=`echo "${QUERY_STRING}" | cut -f2 -d"="`
  56.         : ${host:=localhost} # default to localhost
  57.  
  58.         echo -en "Content-Type: ${pretend_content}\n"
  59.         echo -en "Cache-Control: no-cache\n"
  60.         echo -en "Pragma: no-cache\n"
  61.         echo -en "\r\n"
  62.  
  63.         echo -en "Padding proxy cache..."
  64.  
  65.         c=0
  66.         while [ $c -lt "$padding" ];
  67.         do
  68.                 echo -en "."
  69.                 ((c++))
  70.         done
  71.         echo "done"
  72.  
  73.         hashkey=`head -c 1024 /dev/urandom | md5sum - | cut -f1 -d" "`
  74.  
  75.         sessionkey=`echo "${hashkey}" | md5sum - | cut -f1 -d" "`
  76.         pipe="/tmp/outpipe.${sessionkey}"
  77.  
  78.         mknod "${pipe}" p
  79.  
  80.         #nc "${host}" 22 < "${pipe}" &
  81.         sudo sshd -i < "${pipe}" &
  82.         echo "Key:"${hashkey}
  83.         wait
  84.  
  85.  
  86. fi
  87.  
  88. rm -rf "${pipe}"

Raw Paste

Login or Register to edit or fork this paste. It's free.