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

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

[tithek] add filenuke not allowed msg and fix solarmovie

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