This file is indexed.

/usr/share/plowshare/modules/zalaa.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
# Plowshare zalaa.com module
# Copyright (c) 2012-2013 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/>.
#
# Note: This module is similar to ryushare.

MODULE_ZALAA_REGEXP_URL='https\?://\(www\.\)\?zalaa\.com/'

MODULE_ZALAA_DOWNLOAD_OPTIONS=""
MODULE_ZALAA_DOWNLOAD_RESUME=yes
MODULE_ZALAA_DOWNLOAD_FINAL_LINK_NEEDS_COOKIE=no
MODULE_ZALAA_DOWNLOAD_SUCCESSIVE_INTERVAL=

MODULE_ZALAA_UPLOAD_OPTIONS="
DESCRIPTION,d,description,S=DESCRIPTION,Set file description
LINK_PASSWORD,p,link-password,S=PASSWORD,Protect a link with a password
TOEMAIL,,email-to,e=EMAIL,<To> field for notification email"
MODULE_ZALAA_UPLOAD_REMOTE_SUPPORT=no

MODULE_ZALAA_LIST_OPTIONS=""
MODULE_ZALAA_LIST_HAS_SUBFOLDERS=yes

MODULE_ZALAA_PROBE_OPTIONS=""

# Output a zalaa file download URL
# $1: cookie file (unused here)
# $2: zalaa url
# stdout: real file download link
zalaa_download() {
    local URL=$2
    local PAGE FILE_URL JS_CODE JS_CODE2
    local FORM_HTML FORM_OP FORM_USR FORM_ID FORM_FNAME FORM_METHOD FORM_COUNT

    PAGE=$(curl -L -b 'lang=english' "$URL") || return

    # The file you were looking for could not be found, sorry for any inconvenience
    # This file has been removed due to Copyright infringement
    if match 'File Not Found\|Copyright infringement' "$PAGE"; then
        return $ERR_LINK_DEAD
    fi


    detect_javascript || return

    FORM_HTML=$(grep_form_by_name "$PAGE" frmdownload) || return
    FORM_OP=$(echo "$FORM_HTML" | parse_form_input_by_name 'op') || return
    FORM_ID=$(echo "$FORM_HTML" | parse_form_input_by_name 'id') || return
    FORM_USR=$(echo "$FORM_HTML" | parse_form_input_by_name_quiet 'usr_login')
    FORM_FNAME=$(echo "$FORM_HTML" | parse_form_input_by_name 'fname')
    FORM_METHOD=$(echo "$FORM_HTML" | parse_form_input_by_name_quiet 'method_free')
    FORM_COUNT=$(echo "$FORM_HTML" | parse_form_input_by_name 'ipcount_val')

    PAGE=$(curl -b 'lang=english' -d 'referer=' \
        -d "op=$FORM_OP" \
        -d "usr_login=$FORM_USR" \
        -d "id=$FORM_ID" \
        -d "fname=$FORM_FNAME" \
        -d "method_free=$FORM_METHOD" \
        -d "ipcount_val=$FORM_COUNT" "$URL") || return

    FILE_URL=$(echo "$PAGE" | parse_attr 'btndnlbt"' href) || return

    # Note: referer is required
    PAGE=$(curl -b 'lang=english' --referer "$URL" "$FILE_URL") || return

    # Obfuscated javascript
    JS_CODE=$(echo "$PAGE" | parse 'split(' '>\(.*\)$') || return
    JS_CODE2=$(echo "eval = function(x) { print(x); }; $JS_CODE" | javascript) || return

    FILE_URL=$(echo "$JS_CODE2" | parse 'location\.href' "f='\([^']*\)") || return

    echo "$FILE_URL"
    echo "$FORM_FNAME"
}

# Upload a file to zalaa.com
# $1: cookie file (unused here)
# $2: input file (with full path)
# $3: remote filename
# stdout: download link + delete link
zalaa_upload() {
    local FILE=$2
    local DESTFILE=$3
    local BASE_URL='http://www.zalaa.com'

    local PAGE UPLOAD_ID USER_TYPE DL_URL DEL_URL
    local FORM_HTML FORM_ACTION FORM_UTYPE FORM_UHOST FORM_SESS FORM_TMP_SRV

    PAGE=$(curl -L -b 'lang=english' "$BASE_URL") || return

    FORM_HTML=$(grep_form_by_name "$PAGE" 'file') || return
    FORM_ACTION=$(parse_form_action <<< "$FORM_HTML") || return
    FORM_UTYPE=$(echo "$FORM_HTML" | parse_form_input_by_name 'upload_type')
    FORM_UHOST=$(echo "$FORM_HTML" | parse_form_input_by_name 'upload_host')
    FORM_SESS=$(echo "$FORM_HTML" | parse_form_input_by_name_quiet 'sess_id')
    FORM_TMP_SRV=$(echo "$FORM_HTML" | parse_form_input_by_name 'srv_tmp_url') || return

    UPLOAD_ID=$(random dec 12)
    USER_TYPE=anon

    PAGE=$(curl "${FORM_TMP_SRV}/status.html?${UPLOAD_ID}=filename=www.zalaa.com") || return

    # Sanity check. Avoid failure after effective upload
    if match '>404 Not Found<' "$PAGE"; then
        log_error 'upstream error (404)'
        return $ERR_FATAL
    fi

    # xupload.js
    PAGE=$(curl_with_log -F 'tos=1' \
        -H 'Expect: ' \
        -F "upload_type=$FORM_UTYPE" \
        -F "upload_host=$FORM_HOST" \
        -F "sess_id=$FORM_SESS" \
        -F "srv_tmp_url=$FORM_TMP_SRV" \
        -F "file_0=@$FILE;filename=$DESTFILE" \
        --form-string "file_0_descr=$DESCRIPTION" \
        -F "file_1=@/dev/null;filename=" \
        --form-string "link_rcpt=$TOEMAIL" \
        --form-string "link_pass=$LINK_PASSWORD" \
        "${FORM_ACTION}${UPLOAD_ID}&js_on=1&utype=${USER_TYPE}&upload_type=$FORM_UTYPE" | \
        break_html_lines) || return

    local FORM2_ACTION FORM2_FN FORM2_ST FORM2_OP
    FORM2_ACTION=$(echo "$PAGE" | parse_form_action) || return
    FORM2_FN=$(echo "$PAGE" | parse_tag 'fn.>' textarea)
    FORM2_ST=$(echo "$PAGE" | parse_tag 'st.>' textarea)
    FORM2_OP=$(echo "$PAGE" | parse_tag 'op.>' textarea)

    if [ "$FORM2_ST" = 'OK' ]; then
        PAGE=$(curl -b 'lang=english' \
            -d "fn=$FORM2_FN" -d "st=$FORM2_ST" -d "op=$FORM2_OP" \
            "$FORM2_ACTION") || return

        DL_URL=$(echo "$PAGE" | parse 'Download Link' '">\([^<]*\)' 1) || return
        DEL_URL="" # N/A

        echo "$DL_URL"
        echo "$DEL_URL"
        echo "$LINK_PASSWORD"
        return 0
    fi

    log_error "Unexpected status: $FORM2_ST"
    return $ERR_FATAL
}

# List a zalaa shared file folder URL
# $1: zalaa url
# $2: recurse subfolders (null string means not selected)
# stdout: list of links
zalaa_list() {
    local URL=$1
    local PAGE NAMES LINKS

    # check whether it looks like a folder link
    if ! match "${MODULE_ZALAA_REGEXP_URL}users/" "$URL"; then
        log_error 'This is not a directory list'
        return $ERR_FATAL
    fi

    test "$2" && log_error "Recursive flag not implemented, ignoring"

    PAGE=$(curl -L "$URL") || return

    LINKS=$(echo "$PAGE" | parse_all_quiet 'class=.file_block' 'href="\([^"]*\)' 2)
    NAMES=$(echo "$PAGE" | parse_all_quiet 'class=.file_block' '">\([^<]*\)' 2)

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

# Probe a download URL
# $1: cookie file (unused here)
# $2: zalaa url
# $3: requested capability list
# stdout: 1 capability per line
zalaa_probe() {
    local -r URL=$2
    local -r REQ_IN=$3
    local PAGE REQ_OUT FILE_SIZE

    PAGE=$(curl -L -b 'lang=english' "$URL") || return

    # The file you were looking for could not be found, sorry for any inconvenience
    # This file has been removed due to Copyright infringement
    if match 'File Not Found\|Copyright infringement' "$PAGE"; then
        return $ERR_LINK_DEAD
    fi

    REQ_OUT=c

    if [[ $REQ_IN = *f* ]]; then
        parse_form_input_by_name 'fname' <<< "$PAGE" && \
            REQ_OUT="${REQ_OUT}f"
    fi

    if [[ $REQ_IN = *s* ]]; then
        FILE_SIZE=$(echo "$PAGE" | parse '>File Size[[:space:]]*:<' \
            '^\(.*\)$' 1) && translate_size "$FILE_SIZE" && \
                REQ_OUT="${REQ_OUT}s"
    fi

    echo $REQ_OUT
}