rendered paste body#!/bin/bash## paste output of commands directly to pastebin.ca# regards by dpecka alias nettezzaumana## check for wget availability and if is able to upload files ..if test ! -x "$(which wget 2>/dev/null)"; then echo "can't find executable wget .. it's over"; exit;fiif test -z "$(wget --help | grep 'post-file=')"; then echo "seems like your wget can't upload files .. it's over"; exit;fi## When passed section above, all should be then ok ..usage() {case $1 in --base ) echo "Usage: foo | pastebin.sh [-f] [-t type] [-d description] [-n name]"; echo -e "-f\texploit pastebin.ca even if input have less then 5 lines"; echo -e "-t\ttry 'help' for list of available syntax highlight types"; echo -e "-d\tshort paste description" echo -e "-n\talternate nick, default is your USERNAME"; echo -e "\nescape white characters in name and description string ..";; --types ) echo -e "action ada apache asm asp asterisk bash c c# c++ css delphi diff html java javascript lisp lua mirc nasm net objc pascal perl php pli python raw ruby scheme sql vbs xml";;esacexit;}## check for help request ..if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then usage --base;fiPASTEBINKEY="bU5WOzg358e+D6pSAHRvuTJj/YUhY+zk";PLINES="0";PFORC="";## default valuesPTYPE="33";PDESC="";PUSER="$USER";if [ "$#" -ge "8" ]; then usage --base;fi# superb resolution of bash getopt ..for((x=1;x<$#+1;x++)) { case "${!x}" in -f ) PFORC="true";; -t ) x=$(($x + 1)); PTYPE="${!x}"; case $PTYPE in raw ) PTYPE="1";; asterisk ) PTYPE="2";; c | C ) PTYPE="3";; 'c++' | 'C++' ) PTYPE="4";; php ) PTYPE="5";; perl | Perl ) PTYPE="6";; java | Java ) PTYPE="7";; vbs | Vbs | VBS ) PTYPE="8";; 'c#' | 'C#' ) PTYPE="9";; ruby | Ruby ) PTYPE="10";; python | Python ) PTYPE="11";; pascal | Pascal ) PTYPE="12";; mirc | mIRC ) PTYPE="13";; pli ) PTYPE="14";; xml | Xml | XML ) PTYPE="15";; sql | Sql | SQL ) PTYPE="16";; scheme | Scheme ) PTYPE="17";; action | Action ) PTYPE="18";; ada | Ada | ADA ) PTYPE="19";; apache | Apache ) PTYPE="20";; nasm | NASM ) PTYPE="21";; asp | Asp | ASP ) PTYPE="22";; bash | Bash ) PTYPE="23";; css | Css | CSS ) PTYPE="24";; delphi | Delphi ) PTYPE="25";; html | HTML ) PTYPE="26";; javascript ) PTYPE="27";; lisp | Lisp ) PTYPE="28";; lua | Lua | LUA ) PTYPE="29";; asm | ASM ) PTYPE="30";; objc | OBJC ) PTYPE="31";; net | Net | NET ) PTYPE="32";; diff | patch ) PTYPE="34";; * ) usage --types;; esac;; -d ) x=$(($x + 1)); PDESC="$(echo ${!x} | sed 's/\s/+/g')";; -n ) x=$(($x + 1)); PUSER="$(echo ${!x} | sed 's/\s/+/g')";; * ) usage --base;; esac}## build tempfile to upload ..echo "name=$PUSER&type=$PTYPE&description=$PDESC&expiry=&s=Submit+Post&content=" > /tmp/pastebin.sh.tmpxwhile IFS= read -r line; do echo "$line" >> /tmp/pastebin.sh.tmpx; PLINES=$(($PLINES + 1));done## exit if only whitspaces are inputif test -z "$(sed '1d;/^$/d' /tmp/pastebin.sh.tmpx)"; then usage --base;fi## exit when input less then 5 lines and -f option omittedif [ $PLINES -lt "5" ] && [ "$PFORC" != 'true' ]; then echo "input is less then 5 lines, use -f option to force exploit pastebin.ca"; exit;fi## DEBUGsed -i '2,$s/%/%25/g' /tmp/pastebin.sh.tmpxsed -i '2,$s/&/%26/g' /tmp/pastebin.sh.tmpxsed -i '2,$s/+/%2B/g' /tmp/pastebin.sh.tmpx## post tempfile and print url of post ..wget -O - --tries=5 --timeout=60 --post-file=/tmp/pastebin.sh.tmpx \ http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &> /tmp/pastebin.sh.tmpyecho `sed '/SUCCESS:/!d;s/^.*:\([0-9][0-9]*\).*$/http:\/\/pastebin.ca\/\1/' /tmp/pastebin.sh.tmpy`;## DEBUG#cat /tmp/pastebin.sh.tmpy## cleanuprm /tmp/pastebin.sh.tmp*;exit 0;