ahoj ..
lide pouzivajici irc a developeri komunikujici s ostatnimi jiste oceni ..
napsal jsem si takovy skript na upload veci primo z cmdlajny na pastebin.ca a mam nejake drobne problemy, se kteryma mi muze pomoci snad jedine starenka, neb je chytra a zna webove technologie ..
ostatni se mohou snazit taky ..
a) obsah souboru se pri pastu zatipne na '<' a '>' a mozna na jinych znacich. je to nejaka vlastnost toho http. asi je potreba ty znaky nejak escapovat, ale nevim jak (<, > nefunguje .. dal nevim, jsem dutej ..) .. viz napr.
cat `which pastebin.sh` | pastebin.sh .. vyreseno diky Velkemu Vezirovib) viz priloha zpravy!, chtel bych do skryptu dodelat opsny na type textu aka (bash, plaintext, c/c++ source apod ..). classes jsou v priloze, nevim, jak je dostat do hlavicky .. starenko !help .. vyreseno.c) obcas to rozhodi formatovani .. pri normalnim pastu pres webovy rozhrani to funguje normalne.
Dela to i pri manualnim uploadu souboru na pastabin, jde to nejak osetrit?
$ cat /proc/cpuinfo | pastebin.sh
http://pastebin.ca/1308289 d) kdyz me zkuseny perlista ukaze jak udelat tohle ::
wget -O - --tries=5 --timeout=60 --post-file=/tmp/pastebin.sh.tmpx \
http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &> /tmp/pastebin.sh.tmpy
.. v perlu, tak to jednoduse prekoduju do nej ..
nesnasim pouzivat system() a evel() .. ciste perlovou metodu ..
#!/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;
fi
if 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";;
esac
exit;
}
## check for help request ..
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
usage --base;
fi
PASTEBINKEY="bU5WOzg358e+D6pSAHRvuTJj/YUhY+zk";
PLINES="0";
PFORC="";
## default values
PTYPE="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.tmpx
while IFS= read -r line; do
echo "$line" >> /tmp/pastebin.sh.tmpx;
PLINES=$(($PLINES + 1));
done
## exit if only whitspaces are input
if test -z "$(sed '1d;/^$/d' /tmp/pastebin.sh.tmpx)"; then
usage --base;
fi
## exit when input less then 5 lines and -f option omitted
if [ $PLINES -lt "5" ] && [ "$PFORC" != 'true' ]; then
echo "input is less then 5 lines, use -f option to force exploit pastebin.ca";
exit;
fi
## DEBUG
sed -i '2,$s/%/%25/g' /tmp/pastebin.sh.tmpx
sed -i '2,$s/&/%26/g' /tmp/pastebin.sh.tmpx
sed -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.tmpy
echo `sed '/SUCCESS:/!d;s/^.*:\([0-9][0-9]*\).*$/http:\/\/pastebin.ca\/\1/' /tmp/pastebin.sh.tmpy`;
## DEBUG
#cat /tmp/pastebin.sh.tmpy
## cleanup
rm /tmp/pastebin.sh.tmp*;
exit 0;
diky a regards by ntz

[attachment deleted by admin]