This file is indexed.

/usr/share/plowshare/modules/exoshare.sh is in plowshare-modules 0~git20160124.8a8190d-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# Plowshare exoshare.com module
# Copyright (c) 2011-2015 Plowshare team
#
# This file is part of Plowshare.
#
# Plowshare 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.
#
# Plowshare 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 Plowshare.  If not, see <http://www.gnu.org/licenses/>.

MODULE_EXOSHARE_REGEXP_URL='https\?://\(www\.\)\?\(exoshare\.com\|multi\.la\)/'

MODULE_EXOSHARE_UPLOAD_OPTIONS="
AUTH,a,auth,a=USER:PASSWORD,User account
INCLUDE,,include,l=LIST,Provide list of host site (comma separated)
SHORT_LINK,,short-link,,Produce short link like http://multi.la/s/XXXXXXXX
COUNT,,count,n=COUNT,Take COUNT mirrors (hosters) from the available list. Default is 12.
API,,api,,Use API to upload file
API_KEY,,api-key,s=API_KEY,Provide API key to use instead of login:pass. Can be used without --api option."
MODULE_EXOSHARE_UPLOAD_REMOTE_SUPPORT=yes

MODULE_EXOSHARE_LIST_OPTIONS=""
MODULE_EXOSHARE_LIST_HAS_SUBFOLDERS=no

# Upload a file to exoshare.com
# $1: cookie file (for account only)
# $2: input file (with full path)
# $3: remote filename
# stdout: exoshare.com download link
exoshare_upload() {
    if [ -n "$API" -o -n "$API_KEY" ]; then
        if [ -z "$AUTH" -a -z "$API_KEY" ]; then
            log_error 'API does not allow anonymous uploads.'
            return $ERR_LINK_NEED_PERMISSIONS
        fi

        if [ -n "$AUTH" -a -n "$API_KEY" ]; then
            log_error 'Cannot use --api-key and --auth at the same time.'
            return $ERR_BAD_COMMAND_LINE
        fi

        if [ -n "$COUNT" -o -n "$INCLUDE" ]; then
            log_error 'API does not support --count and --include.'
            return $ERR_BAD_COMMAND_LINE
        fi

        if match_remote_url "$FILE"; then
            log_error 'API does not support remote upload.'
            return $ERR_BAD_COMMAND_LINE
        fi

        exoshare_upload_api "$@"
    else
        if [ -n "$COUNT" -a -n "$INCLUDE" ]; then
            log_error 'Cannot use --count and --include at the same time.'
            return $ERR_BAD_COMMAND_LINE
        fi

        if (( COUNT > 12 )) || [ "${#INCLUDE[@]}" -gt 12 ]; then
            log_error 'You must select 12 hosting sites or less.'
            return $ERR_BAD_COMMAND_LINE
        fi

        exoshare_upload_regular "$@"
    fi
}

# Upload a file to exoshare.com using official API
# http://exoshare.com/api.php
# $1: cookie file (not used here)
# $2: input file (with full path)
# $3: remote filename
# stdout: exoshare.com download link
exoshare_upload_api() {
    local -r FILE=$2
    local -r DEST_FILE=$3
    local -r BASE_URL='http://www.exoshare.com'

    local PAGE FILE_LINK

    if [ -n "$API_KEY" ]; then
        PAGE=$(curl_with_log \
            -F "key=$API_KEY" \
            -F 'submit=Send' \
            -F "file_0=@$FILE;filename=$DEST_FILE" \
            "$BASE_URL/api/api.php") || return

        if match 'Wrong Key !' "$PAGE"; then
            log_error 'Wrong API key.'
            return $ERR_LOGIN_FAILED
        fi
    else
        local USER PASSWORD

        split_auth "$AUTH" USER PASSWORD || return

        PAGE=$(curl_with_log \
            -F "user=$USER" \
            -F "password=$PASSWORD" \
            -F "file_0=@$FILE;filename=$DEST_FILE" \
            "$BASE_URL/upload.php") || return

        if match 'Wrong Username/Password' "$PAGE"; then
            return $ERR_LOGIN_FAILED
        fi
    fi

    if ! match '^http://www\.exoshare\.com/download\.php?uid=[A-Z0-9]\+$' "$PAGE"; then
        log_error 'Upload failed'
        return $ERR_FATAL
    fi

    FILE_LINK="$PAGE"

    if [ -n "$SHORT_LINK" ]; then
        replace 'http://www.exoshare.com/download.php?uid=' 'http://multi.la/s/' <<< "$FILE_LINK"
    else
        echo "$FILE_LINK"
    fi
}

# Upload a file to exoshare.com using regular site
# $1: cookie file (for account only)
# $2: input file (with full path)
# $3: remote filename
# stdout: exoshare.com download link
exoshare_upload_regular() {
    local -r COOKIE_FILE=$1
    local -r FILE=$2
    local -r DEST_FILE=$3
    local -r BASE_URL='http://www.exoshare.com'
    local SITES_COUNT=0

    local PAGE FORM_HTML SITES_ALL SITES_SEL FORM_SITES_OPT SITE UPLOAD_RND UPLOAD_ID LINK_SCRIPT UPLOAD_SCRIPT

    if [ -n "$AUTH" ]; then
        local LOGIN_DATA LOGIN_RESULT LOCATION

        LOGIN_DATA='username=$USER&pass=$PASSWORD&submit='
        LOGIN_RESULT=$(post_login "$AUTH" "$COOKIE_FILE" "$LOGIN_DATA" \
            "$BASE_URL/login.php" -i) || return

        LOCATION=$(grep_http_header_location_quiet <<< "$LOGIN_RESULT")

        if ! match 'account.php' "$LOCATION"; then
            return $ERR_LOGIN_FAILED
        fi
    fi

    PAGE=$(curl "$BASE_URL" -b "$COOKIE_FILE") || return
    PAGE=$(break_html_lines <<< "$PAGE")

    FORM_HTML=$(grep_form_by_id "$PAGE" 'form_upload') || return
    SITES_ALL=$(parse_all_attr 'type="checkbox"' 'name' <<< "$FORM_HTML") || return

    LINK_SCRIPT=$(parse 'var path_to_link_script' ' = "\([^"]\+\)' <<< "$PAGE") || return
    UPLOAD_SCRIPT=$(parse 'var path_to_upload_script' ' = "\([^"]\+\)' <<< "$PAGE") || return

    if match_remote_url "$FILE"; then
        REMOTE_FLAG='remote'
    fi

    if [ -n "$COUNT" ]; then
        for SITE in $SITES_ALL; do
            (( COUNT-- > 0 )) || break
            FORM_SITES_OPT=$FORM_SITES_OPT"-F $SITE$REMOTE_FLAG=on "
        done
    elif [ "${#INCLUDE[@]}" -gt 0 ]; then
        for SITE in "${INCLUDE[@]}"; do
            if match "$SITE" "$SITES_ALL"; then
                FORM_SITES_OPT=$FORM_SITES_OPT"-F $SITE$REMOTE_FLAG=on "
            else
                log_error "Host not supported: $SITE, ignoring"
            fi
        done
    else
        # Default hosting sites selection
        SITES_SEL=$(parse_all_attr 'checked="checked"' 'name' <<< "$FORM_HTML")
        for SITE in $SITES_SEL; do
            FORM_SITES_OPT=$FORM_SITES_OPT"-F $SITE$REMOTE_FLAG=on "
        done
    fi

    if [ -z "$FORM_SITES_OPT" ]; then
        log_error 'Empty site selection. Nowhere to upload!'
        SITES_ALL=$(replace_all $'\n' ', ' <<< "$SITES_ALL")
        log_debug "Try one of these: $SITES_ALL"
        return $ERR_FATAL
    fi

    UPLOAD_RND=$(random d 13)

    PAGE=$(curl -b "$COOKIE_FILE" \
        "$BASE_URL/$LINK_SCRIPT?rnd_id=$UPLOAD_RND")

    if match 'Error, registering for a free account is required.' "$PAGE"; then
        log_error 'Anonymous uploads limit exceeded.'
        return $ERR_FATAL
    fi

    UPLOAD_ID=$(parse 'startUpload' 'startUpload("\([^"]\+\)' <<< "$PAGE") || return

    if match_remote_url "$FILE"; then
        PAGE=$(curl_with_log \
            -b "$COOKIE_FILE" \
            -F "url=$FILE" \
            -F "newfname=$DEST_FILE" \
            $FORM_SITES_OPT \
            "$BASE_URL/remote.php") || return
    else
        PAGE=$(curl_with_log \
            -L \
            -b "$COOKIE_FILE" \
            -F 'mail=' \
            $FORM_SITES_OPT \
            -F "upfile_0=@$FILE;filename=$DEST_FILE" \
            "$BASE_URL$UPLOAD_SCRIPT?upload_id=$UPLOAD_ID") || return
    fi

    FILE_ID=$(parse 'Your download link is' '?uid=\([A-Z0-9]\+\)' <<< "$PAGE") || return

    if [ -n "$SHORT_LINK" ]; then
        echo "http://multi.la/s/$FILE_ID"
    else
        echo "http://exoshare.com/download.php?uid=$FILE_ID"
    fi

    return 0
}

# List links from a exoshare link
# $1: exoshare link
# $2: recurse subfolders (ignored here)
# stdout: list of links
exoshare_list() {
    local -r URL=$1
    local -r BASE_URL='http://www.exoshare.com'
    local PAGE LINKS NAMES NAME FILE_ID

    if match 'multi.la' "$URL"; then
        FILE_ID=$(parse . '/s/\([a-zA-Z0-9]\+\)' <<< "$URL") || return
    else
        FILE_ID=$(parse . 'uid=\([a-zA-Z0-9]\+\)' <<< "$URL") || return
    fi

    PAGE=$(curl "$URL") || return
    NAME=$(parse_tag title <<< "$PAGE")
    NAME=${NAME#Exoshare - Download - }

    PAGE=$(curl -e "$BASE_URL/download.php?uid=$FILE_ID" \
        "$BASE_URL/status.php?uid=$FILE_ID&txt=$NAME") || return

    LINKS=$(parse_all_quiet '=.himgdl.*Successv3\.png' 'href="\([^#"][^"]\+\)"' <<< "$PAGE")
    [ -n "$LINKS" ] || return $ERR_LINK_DEAD

    NAMES=$(parse_all '=.himgdl.*Successv3\.png' '/images/\(.*\)" class.*href="[^#"]' <<< "$PAGE")
    [ -n "$NAMES" ] || NAMES=$NAME

    list_submit "$LINKS" "$NAMES" || return
}