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

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

tithek update filenuke

File size: 9.0 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        debug(99, "tmpstr: %s", tmpstr);
36        titheklog(debuglevel, "/tmp/filenuke1_get", NULL, tmpstr);
37
38//      sleep(2);
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        post = gethttpreal(tmphost, tmpfile, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
105        free(send), send = NULL;
106        debug(99, "post: %s", post);
107        titheklog(debuglevel, "/tmp/filenuke2_post", NULL, tmpstr);
108
109        free(tmpstr),tmpstr = NULL;
110        tmpstr = string_resub(";return p}('", ");'", post, 0);
111        debug(99, "tmpstr: %s", tmpstr);
112        titheklog(debuglevel, "/tmp/filenuke3_tmpstr1", NULL, tmpstr);
113       
114        post = string_replace_all(tmpstr, "", post, 1);
115        post = string_replace_all(";return p}(');'", "", post, 1);
116        debug(99, "post: %s", post);
117        titheklog(debuglevel, "/tmp/filenuke4_post2", NULL, post);
118
119        free(tmpstr),tmpstr = NULL;
120        free(b36code),b36code = NULL;
121        tmpstr = string_resub(";return p}('", ");'", post, 0);
122        debug(99, "tmpstr: %s", tmpstr);
123        titheklog(debuglevel, "/tmp/filenuke5_tmpstr2", NULL, tmpstr);
124
125        b36code = oregex(".*;',[0-9]{2,2},[0-9]{2,2},'(.*)'.split.*", post);
126       
127        b36code = string_replace_all("||", "| |", b36code, 1);
128        debug(99, "b36code: %s", b36code);
129        titheklog(debuglevel, "/tmp/filenuke6_b36code2", NULL, b36code);
130       
131        struct splitstr* ret1 = NULL;
132        int count = 0;
133        int i = 0;
134        ret1 = strsplit(b36code, "|", &count);
135
136        charlist = ostrcat(charlist, "\"", 1, 0);
137        charlist = ostrcat(charlist, "|", 1, 0);
138        charlist = ostrcat(charlist, "'", 1, 0);
139        charlist = ostrcat(charlist, "|", 1, 0);
140        charlist = ostrcat(charlist, ".", 1, 0);
141        charlist = ostrcat(charlist, "|", 1, 0);
142        charlist = ostrcat(charlist, ";", 1, 0);
143        charlist = ostrcat(charlist, "|", 1, 0);
144        charlist = ostrcat(charlist, ":", 1, 0);
145        charlist = ostrcat(charlist, "|", 1, 0);
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
160        for(i = 0; i < count; i++)
161        {
162                if(ostrstr((&ret1[i])->part, " ") != NULL)
163                {
164                        printf("continue\n");
165                        continue;
166                }
167                char* x = oltostr(i, 36);
168
169                struct splitstr* ret2 = NULL;
170                int count2 = 0;
171                int i2 = 0;
172                tmpstr2 = ostrcat(charlist, NULL, 0, 0);
173                ret2 = strsplit(tmpstr2, "|", &count2);
174                for(i2 = 0; i2 < count2; i2++)
175                {
176                        struct splitstr* ret3 = NULL;
177                        int count3 = 0;
178                        int i3 = 0;
179                        tmpstr3 = ostrcat(charlist, NULL, 0, 0);
180                        ret3 = strsplit(tmpstr3, "|", &count3);
181                        for(i3 = 0; i3 < count3; i3++)
182                        {
183                                debug(99, "-----------------------------------------------");
184                                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);
185
186                                base = ostrcat(base, (&ret2[i2])->part, 1, 0);
187                                base = ostrcat(base, x, 1, 0);
188                                base = ostrcat(base, (&ret3[i3])->part, 1, 0);         
189                                search = ostrcat(search, (&ret2[i2])->part, 1, 0);
190                                search = ostrcat(search, (&ret1[i])->part, 1, 0);
191                                search = ostrcat(search, (&ret3[i3])->part, 1, 0);
192                                tmpstr = string_replace_all(base, search, tmpstr, 1);
193                                free(base), base = NULL;
194                                free(search), search = NULL;
195                        }
196                        free(ret3), ret3 = NULL;
197                        free(tmpstr3), tmpstr3 = NULL;
198                }
199                free(ret2), ret2 = NULL;
200                free(tmpstr2), tmpstr2 = NULL;
201                free(x);
202        }
203        free(ret1), ret1 = NULL;
204        free(b36code), b36code = NULL;
205        free(post), post = NULL;
206        free(charlist), charlist = NULL;
207
208        titheklog(debuglevel, "/tmp/filenuke7_tmpstr_last", NULL, tmpstr);
209
210        streamlink = oregex(".*file.*(http:.*video.flv).*image.*", tmpstr);
211        if(streamlink == NULL)
212                streamlink = oregex(".*file.*(http:.*video.mp4).*image.*", tmpstr);                             
213
214        if(streamlink == NULL)
215                streamlink = oregex(".*file.*(http:.*video.mkv).*image.*", tmpstr);
216
217        if(streamlink == NULL)
218                streamlink = oregex(".*file.*(http:.*video.avi).*image.*", tmpstr);
219
220        if(streamlink == NULL)
221                streamlink = oregex(".*src=.*(http:.*video.mp4).*\".*", tmpstr);
222
223        if(streamlink == NULL)
224                streamlink = oregex(".*src=.*(http:.*video.mkv).*\".*", tmpstr);
225
226        if(streamlink == NULL)
227                streamlink = oregex(".*src=.*(http:.*video.avi).*\".*", tmpstr);
228               
229        if(streamlink == NULL)
230                streamlink = oregex(".*value=.*(http:.*video.mp4).*\".*", tmpstr);                             
231
232        if(streamlink == NULL)
233                streamlink = oregex(".*value=.*(http:.*video.mkv).*\".*", tmpstr);
234
235        if(streamlink == NULL)
236                streamlink = oregex(".*value=.*(http:.*video.avi).*\".*", tmpstr);                     
237
238        titheklog(debuglevel, "/tmp/filenuke8_streamlink", NULL, streamlink);
239
240        free(tmpstr); tmpstr = NULL;
241
242end:
243
244        free(error); error = NULL;
245        free(tmphost); tmphost = NULL;
246        free(tmpfile); tmpfile = NULL;
247        free(tmpstr); tmpstr = NULL;
248        free(send); send = NULL;
249        free(hash), hash = NULL;
250        free(hashlen), hashlen = NULL;
251        free(op), op = NULL;
252        free(id), id = NULL;
253        free(fname), fname = NULL;
254        free(ip); ip = NULL;
255
256        return streamlink;
257}
258
259#endif
Note: See TracBrowser for help on using the repository browser.