-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyafu.sh
executable file
·130 lines (104 loc) · 2.64 KB
/
yafu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
unset CDPATH
set -u
set +o histexpand
USER_AGENT="Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0"
URL="http://pixelbanane.de/yafu"
EMAIL=""
PASSWORD=""
COMMENT=""
HIDDEN=""
FILENAME=""
EXPIRES="max"
LOGFILE="$HOME/.yafu"
while getopts ":c:p:e:hHf:l:" OPTION; do
case "$OPTION" in
'c')
COMMENT="$OPTARG"
;;
'p')
PASSWORD="$OPTARG"
;;
'e')
EMAIL="$OPTARG"
;;
'H')
HIDDEN="-F hidden=true"
;;
'f')
FILENAME="$OPTARG"
;;
'l')
LOGFILE="$OPTARG"
;;
'h')
cat << EOF
Usage: $0 [OPTIONS] FILE
OPTIONS
-c COMMENT
-p PASSWORD
-e EMAIL
-h show help
-H Hide file in public file list
-f FILENAME (use FILENAME instead of basename(FILE))
-l LOGFILENAME (write uploads into logfile: $LOGFILE)
EOF
exit 0
;;
'?')
echo "Unknown option: -$OPTARG"
exit 1
;;
':')
echo "Option -$OPTARG needs an argument"
exit 1
;;
esac
done
shift $(( OPTIND - 1 ))
if (( $# == 0 )) ; then
echo "Missing file"
exit 1
elif (( $# > 1 )) ; then
echo "Too many arguments"
exit 1
fi
UPLOAD_IDENTIFIER=$( wget -U "$USER_AGENT" -qO- "$URL" | sed -nr 's/.*name="UPLOAD_IDENTIFIER" value="([^"]+)".*/\1/p' )
FILE="$1"
if ! [[ "$FILENAME" ]] ; then
FILENAME=$(basename "$FILE")
fi
OUT=$(
curl \
-A "$USER_AGENT" \
-# \
-F "email=$EMAIL" \
-F "expires=$EXPIRES" \
-F "comment=$COMMENT" \
-F "filename=$FILENAME" \
-F "password=$PASSWORD" \
-F "upload=@$FILE" \
$HIDDEN \
"$URL/index.php"
)
ID_AND_FILE=$(sed -nr 's!.*href="/yafu/info/([0-9]+/[^"]+).*!\1!p' <<< "$OUT")
DIRECT_LINK="$URL/$ID_AND_FILE"
INFO_LINK="$URL/info/$ID_AND_FILE"
DELETION_LINK=$(sed -nr 's!.*(http://.+/delete/[^"]+).*!\1!p' <<< "$OUT")
(
echo "Download Link: $DIRECT_LINK"
echo "Info Link: $INFO_LINK"
echo "Deletion Link: $DELETION_LINK"
) | tee -a "$LOGFILE"