pb (4389B)
1 #!/bin/sh 2 # 3 # pb; a command line pastebin service helper 4 # {kopimi,CC0} MMXVIII . syntax samurai 5 # ▟▙ 6 # ▟▒░░░░░░░▜▙▜████████████████████████████████▛ 7 # ▜▒░░░░░░░▟▛▟▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▛ 8 # ▜▛ 9 # authors: 10 # xero <https://xero.nu> 11 # stark <https://git.io/stark> 12 # code: 13 # https://code.xero.nu/pb 14 # https://git.io/pb.sh 15 # greets: 16 # all the ops of these great free services <3 17 # 18 usage () { 19 cat <<EOF 20 21 █ 22 ▄▀▀▄ █▐▀▄ 23 ░ ░ ░█▐░█░█▐░█░ ░ ░ 24 █▐▄▀ ▀▄▄▀ 25 █ 26 27 pb; a command line pastebin service helper 28 29 usage: 30 pb <service> [file|stream] 31 32 services: 33 ix.io, 0x0.st, sprunge.us, p.iotek.org, 34 clbin.com, uguu.se, lewd.se, fiery.me, 35 doko.me, mixtape.moe, pomf.cat, catbox.moe, 36 asis.io, dmca.gripe, ptpb.pw, rokket.space, 37 dumpz.org, n33r.tk, w1r3.net, pastebin.com 38 39 environment variables for pastebin.com: 40 PB_API_DEV: developer api key [required] https://pastebin.com/api#1 41 PB_API_USR: user api key [optional] https://pastebin.com/api#8 42 PRIVACY: paste visibility [optional] valid values: public|0, unlisted|1, private|2 43 ANON: paste w/o a user key even if defined [optional] 44 45 examples: 46 pb ix ~/.vimrc 47 pb 0x0 <(ps aux) 48 dmesg | pb iop 49 PB_API_DEV=XXXX PRIVACY=0 pb pb /tmp/leak.txt 50 51 EOF 52 exit 0 53 } 54 55 ARG="${2:-/dev/stdin}" 56 57 case $1 in 58 ix|ix.io) 59 curl -sF 'f:1=<-' http://ix.io < $ARG 60 ;; 61 0x0|null|nullbyte|0*) 62 curl -sF 'file=@-' https://0x0.st < $ARG 63 ;; 64 sprunge|sprunge.us|s*) 65 curl -sF 'sprunge=<-' http://sprunge.us < $ARG 66 ;; 67 iotek|iopaste|p.iotek.org|iop*) 68 curl -sT- https://p.iotek.org < $ARG 69 ;; 70 w1r3|wire|w1r3.net|w*) 71 curl -sF 'upload=@-' https://w1r3.net < $ARG 72 ;; 73 clbin|clbin.com|cl*) 74 curl -sF 'clbin=<-' https://clbin.com < $ARG 75 ;; 76 uguu|uguu.se|u*) 77 curl -sF 'file=@-' https://uguu.se/api.php?d=upload-tool < $ARG 78 ;; 79 lewd|lewd.se|l*) 80 curl -sF 'file=@-' https://lewd.se/api.php?d=upload-tool < $ARG 81 ;; 82 fiery|fiery.me|f*) 83 curl -sF 'files[]=@-' https://safe.fiery.me/api/upload < $ARG | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//' 84 ;; 85 doko|doko.me|do*) 86 curl -sF 'files[]=@-' https://doko.moe/upload.php < $ARG | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//;s/[\]//g' 87 ;; 88 mixtape|mixtape.moe|m*) 89 curl -sF 'files[]=@-' https://mixtape.moe/upload.php < $ARG | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//;s/[\]//g' 90 ;; 91 pomf|pomf.cat|po*) 92 curl -sF 'files[]=@-' https://pomf.cat/upload.php < $ARG | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's!"url":"!https://a.pomf.cat/!;s/"//' 93 ;; 94 catbox|catbox.moe|cat*) 95 curl -sF 'reqtype=fileupload' -F 'fileToUpload=@-' https://catbox.moe/user/api.php < $ARG 96 ;; 97 asis|asis.io|a*) 98 curl -sF 'files[]=@-' https://up.asis.io/upload.php < $ARG | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's!"url":"!https://dl.asis.io/!;s/"//' 99 ;; 100 dmca|dmca.gripe|gripe|dm*) 101 curl -sF 'files[]=@-' http://dmca.gripe/api/upload < $ARG | grep -Po '"url":"[A-Za-z0-9]+.*?"' | sed 's/"url":"//;s/"//;s/[\]//g' 102 ;; 103 ptpb|ptpb.pw|pt*) 104 curl -sF 'c=@-' https://ptpb.pw/ < $ARG | grep "url:" | sed 's/url: //' 105 ;; 106 rokket|rokket.space|r*) 107 curl -sF 'files[]=@-' https://rokket.space/upload < $ARG | grep 'url' | sed 's/"url": "//;s/",//;s/ //g' 108 ;; 109 dumpz|dumpz.org|du*) 110 curl -s --data-binary @- https://dumpz.org < $ARG | sed 's/http/&s/;s!$!/text/!' 111 ;; 112 n33r|n33r.tk|n*) 113 curl -sF 'files[]=@-' https://n33r.tk/upload.php < $ARG | grep 'url' | sed 's/.*"url": "//;s/"//;s/[\]//g;s/[",]//;s/http/&s/' 114 ;; 115 pb|pastebin|pastebin.com) 116 [ -z ${PB_API_DEV} ] && usage 117 PRIVACY="${PRIVACY:-1}" 118 if [ -n "${PRIVACY}" ]; then 119 case ${PRIVACY} in 120 public|0) 121 PRIVACY=0 122 ;; 123 unlisted|1) 124 PRIVACY=1 125 ;; 126 private|2) 127 PRIVACY=2 128 ;; 129 *) 130 usage 131 ;; 132 esac 133 fi 134 qs="api_option=paste&api_dev_key=${PB_API_DEV}&api_paste_expire_date=N&api_paste_private=${PRIVACY}&api_paste_name=`basename ${ARG}`" 135 [ -n ${PB_API_USR} ] && [ -z ${ANON} ] && qs="${qs}&api_user_key=${PB_API_USR}" 136 curl -d "${qs}" --data-urlencode "api_paste_code=`<$ARG`" http://pastebin.com/api/api_post.php 137 ;; 138 *) 139 usage 140 ;; 141 esac 142 # vi:syntax=sh