source: titan/plugins/tithek/xvidstage.h @ 24315

Last change on this file since 24315 was 24315, checked in by obi, 10 years ago

fix

File size: 9.7 KB
Line 
1#ifndef XVIDSTAGE_H
2#define XVIDSTAGE_H
3
4char* xvidstage(char* host, char* file, char* hosterurl)
5{
6        debug(99, "in host: %s file: %s", host, file);
7        int debuglevel = getconfigint("debuglevel", NULL);
8        char* tmphost = NULL;
9        char* tmpfile = NULL;
10        char* tmpstr = NULL;
11        char* send = NULL;
12        char* ip = NULL;
13        char* streamlink = NULL;
14
15        char* cookie = NULL;           
16        char* id = NULL;
17        char* fname = NULL;
18        char* op = NULL;
19        char* hash = NULL;
20        char* hashline = NULL;
21        char* hashlen = NULL;
22        char* referer = NULL;
23        char* usr_login = NULL;
24        char* imhuman = NULL;
25        char* post = NULL;
26
27        char* b36code = NULL;
28        char* base = NULL;
29        char* search = NULL;
30
31        char* tmpstr2 = NULL;
32        char* tmpstr3 = NULL;
33        char* charlist = NULL;
34
35        unlink("/tmp/xvidstage1_get");
36        unlink("/tmp/xvidstage2_post");
37
38        if(host == NULL || file == NULL) return NULL;
39
40//      tmphost = ostrcat("www.", host, 0, 0);
41        tmphost = ostrcat(host, NULL, 0, 0);
42        tmpfile = ostrcat("/", file, 0, 0);
43        debug(99, "tmphost: %s", tmphost);
44        ip = get_ip(tmphost);
45        debug(99, "tmphost: %s", tmphost);
46        debug(99, "tmpfile: %s", tmpfile);
47        debug(99, "ip: %s", ip);
48
49        send = ostrcat(send, "GET ", 1, 0);
50        send = ostrcat(send, tmpfile, 1, 0);
51        send = ostrcat(send, " HTTP/1.1\r\nHost: ", 1, 0);     
52        send = ostrcat(send, tmphost, 1, 0);
53        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nConnection: close\r\nAccept-Encoding: gzip\r\n\r\n", 1, 0);       
54        debug(99, "send: %s", send);
55       
56        char* line = NULL;
57        char* lines = NULL;
58        char* cmd = NULL;
59
60        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
61        debug(99, "tmpstr: %s", tmpstr);
62        titheklog(debuglevel, "/tmp/xvidstage1_get", NULL, tmpstr);
63        free(send); send = NULL;
64
65        sleep(1);
66        if(tmpstr == NULL)
67        {
68                textbox(_("Message"), _("This file doesn't exist, or has been removed") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
69                goto end;
70        }
71
72        cookie = string_resub("Set-Cookie: afc=", ";", tmpstr, 0);     
73        debug(99, "cookie: %s", cookie);
74
75        //get hash from tmpstr
76        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value=");
77        fname = getxmlentry(pos1, "value=");
78        debug(99, "fname: %s", fname);
79        if(fname == NULL) goto end;
80
81        char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
82        id = getxmlentry(pos2, "value=");
83        debug(99, "id: %s", id);
84        if(id == NULL) goto end;
85
86        char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value=");
87        op = getxmlentry(pos3, "value=");
88        debug(99, "op: %s", op);
89
90        char* pos4 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"rand\" value=");
91        hashline = getxmlentry(pos4, "value=");
92        debug(99, "hashline: %s", hashline);
93
94        char* pos5 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"referer\" value=");
95        referer = getxmlentry(pos5, "value=");
96        debug(99, "referer: %s", referer);
97
98        char* pos6 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"imhuman\" value=");
99        imhuman = getxmlentry(pos6, "value=");
100        debug(99, "imhuman: %s", imhuman);
101
102        char* pos7 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"usr_login\" value=");
103        usr_login = getxmlentry(pos7, "value=");
104        debug(99, "usr_login: %s", usr_login);
105       
106        free(tmpstr); tmpstr = NULL;
107        if(op == NULL) goto end;
108
109        hash = ostrcat(hash, "hash=", 1, 0);
110        hash = ostrcat(hash, hashline, 1, 0);
111        hash = ostrcat(hash, "&imhuman=Proceed+to+video%22+id%3D%22btn_download&k=Search...%22+size%3D16+onfocus%3D%22%24%28this%29.val%28%27%27%29.css%28%27color%27%2C%27%23333%27%29%3B%22+onblur%3D%22if%28%24%28this%29.val%28%29%3D%3D%27%27%29%24%28this%29.val%28%27Search...%27%29.css%28%27color%27%2C%27%27%29%22+id%3D%22search_top", 1, 0);
112        hash = ostrcat(hash, "&usr_login=", 1, 0);     
113        hash = ostrcat(hash, usr_login, 1, 0);
114        hash = ostrcat(hash, "&referer=", 1, 0);
115        hash = ostrcat(hash, referer, 1, 0);
116        hash = ostrcat(hash, "&fname=", 1, 0);
117        hash = ostrcat(hash, fname, 1, 0);
118        hash = ostrcat(hash, "&id=", 1, 0);     
119        hash = ostrcat(hash, id, 1, 0);
120        hash = ostrcat(hash, "&op=download1", 1, 0);
121        hash = ostrcat(hash, op, 1, 0);
122        debug(99, "hash: %s", hash);
123        hashlen = oitoa(strlen(hash));
124
125        send = ostrcat(send, "POST ", 1, 0);
126        send = ostrcat(send, tmpfile, 1, 0);
127        send = ostrcat(send, " HTTP/1.1\r\nContent-Length: ", 1, 0);
128        send = ostrcat(send, hashlen, 1, 0);
129        send = ostrcat(send, "\r\nAccept-Encoding: gzip\r\nConnection: close\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.99 Safari/535.1\r\nHost: ", 1, 0);
130        send = ostrcat(send, tmphost, 1, 0);
131        send = ostrcat(send, "\r\nCookie: afc=", 1, 0);
132        send = ostrcat(send, cookie, 1, 0);
133        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
134        send = ostrcat(send, hash, 1, 0);
135        debug(99, "send: %s", send);
136
137        //send and receive answer
138        post = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
139        debug(99, "post: %s", post);
140        titheklog(debuglevel, "/tmp/xvidstage2_post", NULL, post);
141
142// hier wird nun ein captcha bild auth verlangt geht also erstmal nicht mehr
143        if(post == NULL)
144        {
145                textbox(_("Message"), _("This file doesn't exist, or has been removed") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
146                goto end;
147        }
148       
149        tmpstr = string_resub(";return p}('", ");'", post, 0);
150        titheklog(debuglevel, "/tmp/xvidstage3_tmpstr", NULL, tmpstr);
151       
152        post = string_replace_all(tmpstr, "", post, 1);
153        post = string_replace_all(";return p}(');'", "", post, 1);
154        titheklog(debuglevel, "/tmp/xvidstage4_tmpstr", NULL, post);
155
156        free(tmpstr),tmpstr = NULL;
157        free(b36code),b36code = NULL;
158        tmpstr = string_resub(";return p}('", ");'", post, 0);
159        titheklog(debuglevel, "/tmp/xvidstage5_tmpstr", NULL, tmpstr);
160
161        b36code = oregex(".*;',[0-9]{2,2},[0-9]{2,2},'(.*)'.split.*", post);
162       
163        b36code = string_replace_all("||", "| |", b36code, 1);
164        titheklog(debuglevel, "/tmp/xvidstage6_tmpstr", NULL, b36code);
165       
166        struct splitstr* ret1 = NULL;
167        int count = 0;
168        int i = 0;
169        ret1 = strsplit(b36code, "|", &count);
170
171        charlist = ostrcat(charlist, "\"", 1, 0);
172        charlist = ostrcat(charlist, "|", 1, 0);
173        charlist = ostrcat(charlist, "'", 1, 0);
174        charlist = ostrcat(charlist, "|", 1, 0);
175        charlist = ostrcat(charlist, ".", 1, 0);
176        charlist = ostrcat(charlist, "|", 1, 0);
177        charlist = ostrcat(charlist, ";", 1, 0);
178        charlist = ostrcat(charlist, "|", 1, 0);
179        charlist = ostrcat(charlist, ":", 1, 0);
180        charlist = ostrcat(charlist, "|", 1, 0);
181        charlist = ostrcat(charlist, "=", 1, 0);
182        charlist = ostrcat(charlist, "|", 1, 0);
183        charlist = ostrcat(charlist, ",", 1, 0);
184        charlist = ostrcat(charlist, "|", 1, 0);
185        charlist = ostrcat(charlist, " ", 1, 0);
186        charlist = ostrcat(charlist, "|", 1, 0);
187        charlist = ostrcat(charlist, "\\", 1, 0);
188        charlist = ostrcat(charlist, "|", 1, 0);
189        charlist = ostrcat(charlist, "/", 1, 0);
190        charlist = ostrcat(charlist, "|", 1, 0);
191        charlist = ostrcat(charlist, "(", 1, 0);
192        charlist = ostrcat(charlist, "|", 1, 0);
193        charlist = ostrcat(charlist, ")", 1, 0);
194
195        for(i = 0; i < count; i++)
196        {
197                if(ostrstr((&ret1[i])->part, " ") != NULL)
198                {
199                        printf("continue\n");
200                        continue;
201                }
202                char* x = oltostr(i, 36);
203
204                struct splitstr* ret2 = NULL;
205                int count2 = 0;
206                int i2 = 0;
207                tmpstr2 = ostrcat(charlist, NULL, 0, 0);
208                ret2 = strsplit(tmpstr2, "|", &count2);
209                for(i2 = 0; i2 < count2; i2++)
210                {
211                        struct splitstr* ret3 = NULL;
212                        int count3 = 0;
213                        int i3 = 0;
214                        tmpstr3 = ostrcat(charlist, NULL, 0, 0);
215                        ret3 = strsplit(tmpstr3, "|", &count3);
216                        for(i3 = 0; i3 < count3; i3++)
217                        {
218                                debug(99, "-----------------------------------------------");
219                                debug(99, "replace %s%s%s <> %s%s%s",(&ret2[i2])->part, x, (&ret3[i3])->part, (&ret2[i2])->part, (&ret1[i])->part, (&ret3[i3])->part);
220
221                                base = ostrcat(base, (&ret2[i2])->part, 1, 0);
222                                base = ostrcat(base, x, 1, 0);
223                                base = ostrcat(base, (&ret3[i3])->part, 1, 0);         
224                                search = ostrcat(search, (&ret2[i2])->part, 1, 0);
225                                search = ostrcat(search, (&ret1[i])->part, 1, 0);
226                                search = ostrcat(search, (&ret3[i3])->part, 1, 0);
227                                tmpstr = string_replace_all(base, search, tmpstr, 1);
228                                free(base), base = NULL;
229                                free(search), search = NULL;
230                        }
231                        free(ret3), ret3 = NULL;
232                        free(tmpstr3), tmpstr3 = NULL;
233                }
234                free(ret2), ret2 = NULL;
235                free(tmpstr2), tmpstr2 = NULL;
236                free(x);
237        }
238        free(ret1), ret1 = NULL;
239        free(b36code), b36code = NULL;
240        free(post), post = NULL;
241        free(charlist), charlist = NULL;
242
243        titheklog(debuglevel, "/tmp/xvidstage7_tmpstr_last", NULL, tmpstr);
244
245        streamlink = oregex(".*file.*(http:.*video.flv).*image.*", tmpstr);
246        if(streamlink == NULL)
247                streamlink = oregex(".*file.*(http:.*video.mp4).*image.*", tmpstr);                             
248
249        if(streamlink == NULL)
250                streamlink = oregex(".*file.*(http:.*video.mkv).*image.*", tmpstr);
251
252        if(streamlink == NULL)
253                streamlink = oregex(".*file.*(http:.*video.avi).*image.*", tmpstr);
254
255        if(streamlink == NULL)
256                streamlink = oregex(".*src=.*(http:.*video.mp4).*\".*", tmpstr);
257
258        if(streamlink == NULL)
259                streamlink = oregex(".*src=.*(http:.*video.mkv).*\".*", tmpstr);
260
261        if(streamlink == NULL)
262                streamlink = oregex(".*src=.*(http:.*video.avi).*\".*", tmpstr);
263               
264        if(streamlink == NULL)
265                streamlink = oregex(".*value=.*(http:.*video.mp4).*\".*", tmpstr);                             
266
267        if(streamlink == NULL)
268                streamlink = oregex(".*value=.*(http:.*video.mkv).*\".*", tmpstr);
269
270        if(streamlink == NULL)
271                streamlink = oregex(".*value=.*(http:.*video.avi).*\".*", tmpstr);                     
272
273        titheklog(debuglevel, "/tmp/xvidstage8_streamlink", NULL, streamlink);
274
275        free(tmpstr); tmpstr = NULL;
276
277end:
278
279        free(cookie); cookie = NULL;
280        free(hash), hash = NULL;
281        free(hashlen), hashlen = NULL;
282        free(op), op = NULL;
283        free(id), id = NULL;
284        free(fname), fname = NULL;
285               
286        free(tmphost); tmphost = NULL;
287        free(tmpfile); tmpfile = NULL;
288        free(tmpstr); tmpstr = NULL;
289        free(send); send = NULL;
290        free(ip); ip = NULL;
291
292        return streamlink;
293}
294
295#endif
Note: See TracBrowser for help on using the repository browser.