- #!/bin/bash
- #
- # This is the server script. Install as a cgi script on a webserver.
- #
- # Robert McKay <robert@mckay.com>
- #
- # Requires: nc
- #
- # Proxies sometimes virus scan content. this means they won't allow streaming
- # however they often exempt certain common mime-types from scanning in order
- # to allow streaming media to work. We need streaming in order for this to work
- # so set a mime type that works. Try them all.. try different ones.. try
- # making one up.
- pretend_content=video/avi
- pretend_content=video/x-ms-asf
- pretend_content=video/x-ms-wm
- pretend_content=video/x-ms-wmx
- pretend_content=video/msvideo
- pretend_content=video-x-msvideo
- pretend_content=video/xmpg2
- pretend_content=application/x-troff-msvideo
- pretend_content=audio/avi
- pretend_content=audio/asf
- pretend_content=audio/vnd.rn-realaudio
- padding=1
- if [ "${REQUEST_METHOD}" == "POST" ];
- then
- # If the request is a POST then it's the RX mode
- hashkey=`echo "${QUERY_STRING}" | cut -f2 -d"="`
- sessionkey=`echo "${hashkey}" | md5sum - | cut -f1 -d" "`
- pipe="/tmp/outpipe.${sessionkey}"
- if [ -p "${pipe}" ];
- then
- head -1 >/dev/null
- cat > "${pipe}"
- else
- echo -en "Content-Type: text/plain\n\n"
- echo "Session not found."
- exit 0
- fi
- echo -en "Content-Type: application/octet-stream\n\n"
- echo "End of script"
- else
- # If it's a GET then we're the TX
- host=`echo "${QUERY_STRING}" | cut -f2 -d"="`
- : ${host:=localhost} # default to localhost
- echo -en "Content-Type: ${pretend_content}\n"
- echo -en "Cache-Control: no-cache\n"
- echo -en "Pragma: no-cache\n"
- echo -en "\r\n"
- echo -en "Padding proxy cache..."
- c=0
- while [ $c -lt "$padding" ];
- do
- echo -en "."
- ((c++))
- done
- echo "done"
- hashkey=`head -c 1024 /dev/urandom | md5sum - | cut -f1 -d" "`
- sessionkey=`echo "${hashkey}" | md5sum - | cut -f1 -d" "`
- pipe="/tmp/outpipe.${sessionkey}"
- mknod "${pipe}" p
- #nc "${host}" 22 < "${pipe}" &
- sudo sshd -i < "${pipe}" &
- echo "Key:"${hashkey}
- wait
- fi
- rm -rf "${pipe}"
Raw Paste