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

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

clean up

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