source: titan/plugins/tithek/filenuke.h @ 24319

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

[tithek] update and add hoster movshare

File size: 9.7 KB
Line 
1#ifndef FILENUKE_H
2#define FILENUKE_H
3
4char* filenuke(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, *error = NULL, *tmpfile = NULL, *tmpstr = NULL, *send = NULL, *id = NULL, *fname = NULL, *op = NULL, *hash = NULL, *hashlen = NULL, *ip = NULL;
9        char* b36code = NULL, *base = NULL, *search = NULL, *post = NULL, *streamlink = NULL, *tmpstr2 = NULL, *tmpstr3 = NULL, *charlist = NULL;
10//      char* cmd = NULL;
11       
12        if(host == NULL || file == NULL) return NULL;
13
14        unlink("/tmp/filenuke1_get");
15        unlink("/tmp/filenuke2_post");
16        unlink("/tmp/filenuke3_tmpstr1");
17        unlink("/tmp/filenuke4_post2");
18        unlink("/tmp/filenuke5_tmpstr2");
19        unlink("/tmp/filenuke6_b36code2");
20        unlink("/tmp/filenuke7_tmpstr_last");
21        unlink("/tmp/filenuke8_streamlink");
22
23        tmphost = ostrcat("www.", host, 0, 0);
24        tmpfile = ostrcat("/", file, 0, 0);
25        debug(99, "tmphost: %s", tmphost);
26        ip = get_ip(tmphost);
27        debug(99, "ip: %s", ip);
28        debug(99, "test host only: %s", get_ip(host));
29        debug(99, "tmpfile: %s", tmpfile);
30
31        send = ostrcat(send, "GET ", 1, 0);
32        send = ostrcat(send, tmpfile, 1, 0);
33        send = ostrcat(send, " HTTP/1.1\r\nAccept-Encoding: identity\r\n", 1, 0);
34        send = ostrcat(send, "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4\r\n", 1, 0);
35        send = ostrcat(send, "Host: ", 1, 0);
36        send = ostrcat(send, tmphost, 1, 0);
37        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de-DE; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3\r\n", 1, 0);
38        send = ostrcat(send, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n", 1, 0);
39        send = ostrcat(send, "Connection: close\r\nCookie: xxx2=ok;\r\n\r\n", 1, 0);
40        debug(99, "send: %s", send);
41
42        tmpstr = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
43        free(send), send = NULL;
44        debug(99, "tmpstr: %s", tmpstr);
45        titheklog(debuglevel, "/tmp/filenuke1_get", NULL, tmpstr);
46
47        if(tmpstr == NULL)
48        {
49                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
50                goto end;
51        }
52
53//      sleep(2);
54
55        if(tmpstr == NULL || ostrstr(tmpstr, "<title>The page is temporarily unavailable</title>") != NULL)
56        {
57                error = string_resub("<td align=\"center\" valign=\"middle\">", "</td>", tmpstr, 0);
58                string_deltags(error);
59                stringreplacechar(error, '|', '\0');
60                error = strstrip(error);
61                if(error == NULL || strlen(error) == 0)
62                        error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1);
63                textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
64                goto end;
65        }
66
67        if(ostrstr(tmpstr, "<title>Direct IP access not allowed") != NULL)
68        {
69                error = string_resub("<title>", "</title>", tmpstr, 0);
70                string_deltags(error);
71                stringreplacechar(error, '|', '\0');
72                error = strstrip(error);
73                if(error == NULL || strlen(error) == 0)
74                        error = ostrcat(_("The page is temporarily unavailable"), error, 0, 1);
75                textbox(_("Message"), error, _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 400, 0, 0);
76                goto end;
77        }
78
79        //get hash from tmpstr
80        char* pos1 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"fname\" value=");
81        fname = getxmlentry(pos1, "value=");
82        debug(99, "fname: %s", fname);
83        if(fname == NULL) goto end;
84
85        char* pos2 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"id\" value=");
86        id = getxmlentry(pos2, "value=");
87        debug(99, "id: %s", id);
88        if(id == NULL) goto end;
89
90        char* pos3 = ostrstr(tmpstr, "<input type=\"hidden\" name=\"op\" value=");
91        op = getxmlentry(pos3, "value=");
92        free(tmpstr); tmpstr = NULL;
93        debug(99, "op: %s", op);
94        if(op == NULL) goto end;
95
96        hash = ostrcat(hash, "id=", 1, 0);     
97        hash = ostrcat(hash, id, 1, 0);
98        hash = ostrcat(hash, "&referer=&fname=", 1, 0);
99        hash = ostrcat(hash, fname, 1, 0);
100        hash = ostrcat(hash, "&method_free=Free&usr_login=&op=", 1, 0);
101        hash = ostrcat(hash, op, 1, 0);
102        debug(99, "hash: %s", hash);
103
104        hashlen = oitoa(strlen(hash));
105       
106        //create send string
107        send = ostrcat(send, "POST /", 1, 0);
108        send = ostrcat(send, id, 1, 0);
109        send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0);
110        send = ostrcat(send, hashlen, 1, 0);
111        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);
112        send = ostrcat(send, tmphost, 1, 0);
113        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n", 1, 0);
114        send = ostrcat(send, hash, 1, 0);
115        debug(99, "send: %s", send);
116
117//      sleep(5);
118       
119        post = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
120        free(send), send = NULL;
121        debug(99, "post: %s", post);
122        titheklog(debuglevel, "/tmp/filenuke2_post", NULL, tmpstr);
123
124        if(post == NULL)
125        {
126                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
127                goto end;
128        }
129
130        free(tmpstr),tmpstr = NULL;
131        tmpstr = string_resub(";return p}('", ");'", post, 0);
132        debug(99, "tmpstr: %s", tmpstr);
133        titheklog(debuglevel, "/tmp/filenuke3_tmpstr1", NULL, tmpstr);
134       
135        post = string_replace_all(tmpstr, "", post, 1);
136        post = string_replace_all(";return p}(');'", "", post, 1);
137        debug(99, "post: %s", post);
138        titheklog(debuglevel, "/tmp/filenuke4_post2", NULL, post);
139
140        free(tmpstr),tmpstr = NULL;
141        free(b36code),b36code = NULL;
142        tmpstr = string_resub(";return p}('", ");'", post, 0);
143        debug(99, "tmpstr: %s", tmpstr);
144        titheklog(debuglevel, "/tmp/filenuke5_tmpstr2", NULL, tmpstr);
145
146        b36code = oregex(".*;',[0-9]{2,2},[0-9]{2,2},'(.*)'.split.*", post);
147       
148        b36code = string_replace_all("||", "| |", b36code, 1);
149        debug(99, "b36code: %s", b36code);
150        titheklog(debuglevel, "/tmp/filenuke6_b36code2", NULL, b36code);
151       
152        struct splitstr* ret1 = NULL;
153        int count = 0;
154        int i = 0;
155        ret1 = strsplit(b36code, "|", &count);
156
157        charlist = ostrcat(charlist, "\"", 1, 0);
158        charlist = ostrcat(charlist, "|", 1, 0);
159        charlist = ostrcat(charlist, "'", 1, 0);
160        charlist = ostrcat(charlist, "|", 1, 0);
161        charlist = ostrcat(charlist, ".", 1, 0);
162        charlist = ostrcat(charlist, "|", 1, 0);
163        charlist = ostrcat(charlist, ";", 1, 0);
164        charlist = ostrcat(charlist, "|", 1, 0);
165        charlist = ostrcat(charlist, ":", 1, 0);
166        charlist = ostrcat(charlist, "|", 1, 0);
167        charlist = ostrcat(charlist, "=", 1, 0);
168        charlist = ostrcat(charlist, "|", 1, 0);
169        charlist = ostrcat(charlist, ",", 1, 0);
170        charlist = ostrcat(charlist, "|", 1, 0);
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
181        for(i = 0; i < count; i++)
182        {
183                if(ostrstr((&ret1[i])->part, " ") != NULL)
184                {
185                        printf("continue\n");
186                        continue;
187                }
188                char* x = oltostr(i, 36);
189
190                struct splitstr* ret2 = NULL;
191                int count2 = 0;
192                int i2 = 0;
193                tmpstr2 = ostrcat(charlist, NULL, 0, 0);
194                ret2 = strsplit(tmpstr2, "|", &count2);
195                for(i2 = 0; i2 < count2; i2++)
196                {
197                        struct splitstr* ret3 = NULL;
198                        int count3 = 0;
199                        int i3 = 0;
200                        tmpstr3 = ostrcat(charlist, NULL, 0, 0);
201                        ret3 = strsplit(tmpstr3, "|", &count3);
202                        for(i3 = 0; i3 < count3; i3++)
203                        {
204                                debug(99, "-----------------------------------------------");
205                                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);
206
207                                base = ostrcat(base, (&ret2[i2])->part, 1, 0);
208                                base = ostrcat(base, x, 1, 0);
209                                base = ostrcat(base, (&ret3[i3])->part, 1, 0);         
210                                search = ostrcat(search, (&ret2[i2])->part, 1, 0);
211                                search = ostrcat(search, (&ret1[i])->part, 1, 0);
212                                search = ostrcat(search, (&ret3[i3])->part, 1, 0);
213                                tmpstr = string_replace_all(base, search, tmpstr, 1);
214                                free(base), base = NULL;
215                                free(search), search = NULL;
216                        }
217                        free(ret3), ret3 = NULL;
218                        free(tmpstr3), tmpstr3 = NULL;
219                }
220                free(ret2), ret2 = NULL;
221                free(tmpstr2), tmpstr2 = NULL;
222                free(x);
223        }
224        free(ret1), ret1 = NULL;
225        free(b36code), b36code = NULL;
226        free(post), post = NULL;
227        free(charlist), charlist = NULL;
228
229        titheklog(debuglevel, "/tmp/filenuke7_tmpstr_last", NULL, tmpstr);
230
231        streamlink = oregex(".*file.*(http:.*video.flv).*image.*", tmpstr);
232        if(streamlink == NULL)
233                streamlink = oregex(".*file.*(http:.*video.mp4).*image.*", tmpstr);                             
234
235        if(streamlink == NULL)
236                streamlink = oregex(".*file.*(http:.*video.mkv).*image.*", tmpstr);
237
238        if(streamlink == NULL)
239                streamlink = oregex(".*file.*(http:.*video.avi).*image.*", tmpstr);
240
241        if(streamlink == NULL)
242                streamlink = oregex(".*src=.*(http:.*video.mp4).*\".*", tmpstr);
243
244        if(streamlink == NULL)
245                streamlink = oregex(".*src=.*(http:.*video.mkv).*\".*", tmpstr);
246
247        if(streamlink == NULL)
248                streamlink = oregex(".*src=.*(http:.*video.avi).*\".*", tmpstr);
249               
250        if(streamlink == NULL)
251                streamlink = oregex(".*value=.*(http:.*video.mp4).*\".*", tmpstr);                             
252
253        if(streamlink == NULL)
254                streamlink = oregex(".*value=.*(http:.*video.mkv).*\".*", tmpstr);
255
256        if(streamlink == NULL)
257                streamlink = oregex(".*value=.*(http:.*video.avi).*\".*", tmpstr);                     
258
259        titheklog(debuglevel, "/tmp/filenuke8_streamlink", NULL, streamlink);
260
261        free(tmpstr); tmpstr = NULL;
262
263end:
264
265        free(error); error = NULL;
266        free(tmphost); tmphost = NULL;
267        free(tmpfile); tmpfile = NULL;
268        free(tmpstr); tmpstr = NULL;
269        free(send); send = NULL;
270        free(hash), hash = NULL;
271        free(hashlen), hashlen = NULL;
272        free(op), op = NULL;
273        free(id), id = NULL;
274        free(fname), fname = NULL;
275        free(ip); ip = NULL;
276
277        return streamlink;
278}
279
280#endif
Note: See TracBrowser for help on using the repository browser.