source: titan/plugins/tithek/promptfile.h @ 32084

Last change on this file since 32084 was 32084, checked in by obi, 8 years ago

tithek add hoster promptfile and update filenuke

File size: 5.4 KB
Line 
1#ifndef PROMPTFILE_H
2#define PROMPTFILE_H
3
4char* promptfile(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* post = NULL, *streamlink = NULL;
10//      char* cmd = NULL;
11
12        if(link == NULL) return NULL;
13
14        unlink("/tmp/promptfile1_get");
15        unlink("/tmp/promptfile2_post");
16        unlink("/tmp/promptfile3_tmpstr1");
17        unlink("/tmp/promptfile4_post2");
18        unlink("/tmp/promptfile5_tmpstr2");
19        unlink("/tmp/promptfile6_b36code2");
20        unlink("/tmp/promptfile7_tmpstr_last");
21        unlink("/tmp/promptfile8_streamlink");
22
23/////////////
24        char* tmplink = NULL, *pos = NULL, *path = NULL;
25
26        tmplink = ostrcat(link, NULL, 0, 0);
27
28        debug(99, "tmplink: %s", tmplink);
29
30        char* referer = NULL;
31//      htmldecode(referer, tmplink);
32        referer = htmlencode(tmplink);
33        referer = string_replace_all("/", "%2F", referer, 1);
34        debug(99, "referer: %s", referer);
35       
36       
37        if(ostrstr(link, "/Out/?s=") != NULL)
38        {
39                tmplink = string_replace("/Out/?s=", "", tmplink, 1);
40                debug(99, "remove out string: %s", tmplink);
41        }
42       
43
44        if(tmplink == NULL || ostrncmp("http://", tmplink, 7))
45        {
46                textbox(_("Message"), _("Hoster Url not http://") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
47                goto end;
48        }
49
50        tmphost = string_replace("http://", "", tmplink, 0);
51        free(tmplink) , tmplink = NULL;
52
53        if(tmphost != NULL)
54                pos = strchr(tmphost, '/');
55        if(pos != NULL)
56        {
57                pos[0] = '\0';
58                path = pos + 1;
59        }
60
61        tmppath = ostrcat("/", path, 0, 0);
62//      free(path), path = NULL;
63
64/////////////
65
66/*
67        tmphost = ostrcat("www.", host, 0, 0);
68        tmppath = ostrcat("/", file, 0, 0);
69        debug(99, "tmphost: %s", tmphost);
70        ip = get_ip(tmphost);
71        debug(99, "ip: %s", ip);
72        debug(99, "test host only: %s", get_ip(host));
73        debug(99, "tmppath: %s", tmppath);
74*/
75
76        send = ostrcat(send, "GET ", 1, 0);
77        send = ostrcat(send, tmppath, 1, 0);
78        send = ostrcat(send, " HTTP/1.0", 1, 0);
79        send = ostrcat(send, "\r\nHost: ", 1, 0);
80        send = ostrcat(send, tmphost, 1, 0);
81        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", 1, 0);
82        send = ostrcat(send, "\r\nConnection: close", 1, 0);
83        send = ostrcat(send, "\r\nAccept-Encoding: gzip", 1, 0);       
84        send = ostrcat(send, "\r\n\r\n", 1, 0);
85        debug(99, "send: %s", send);
86
87        tmpstr = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 1);
88        free(send), send = NULL;
89        debug(99, "tmpstr: %s", tmpstr);
90        titheklog(debuglevel, "/tmp/promptfile1_get", NULL, NULL, NULL, tmpstr);
91
92        if(tmpstr == NULL)
93        {
94                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
95                goto end;
96        }
97
98        char* chash = string_resub("name=\"chash\" value=\"", "\"", tmpstr, 0);
99        hash = ostrcat(hash, "chash=", 1, 0);
100        hash = ostrcat(hash, chash, 1, 0);
101        debug(99, "hash: %s", hash);
102
103        hashlen = oitoa(strlen(hash));
104
105        char* cokkie = string_resub("Set-Cookie: ", ";", tmpstr, 0);
106
107        //create send string
108        send = ostrcat(send, "POST ", 1, 0);
109        send = ostrcat(send, tmppath, 1, 0);
110
111        send = ostrcat(send, " HTTP/1.0\r\nContent-Length: ", 1, 0);
112        send = ostrcat(send, hashlen, 1, 0);
113        send = ostrcat(send, "\r\nAccept-Encoding: gzip", 1, 0);       
114        send = ostrcat(send, "\r\nHost: ", 1, 0);
115        send = ostrcat(send, tmphost, 1, 0);
116        send = ostrcat(send, "\r\nUser-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:30.0) Gecko/20100101 Firefox/30.0", 1, 0);
117        send = ostrcat(send, "\r\nConnection: close", 1, 0);
118        send = ostrcat(send, "\r\nReferer: ", 1, 0);
119        send = ostrcat(send, link, 1, 0);
120        send = ostrcat(send, "\r\nCookie: ", 1, 0);
121        send = ostrcat(send, cokkie, 1, 0);
122        send = ostrcat(send, "\r\nContent-Type: application/x-www-form-urlencoded", 1, 0);
123        send = ostrcat(send, "\r\n\r\n", 1, 0);
124        send = ostrcat(send, hash, 1, 0);
125        debug(99, "send: %s", send);
126
127        free(cokkie), cokkie = NULL;
128       
129        post = gethttpreal(tmphost, tmppath, 80, NULL, NULL, NULL, 0, send, NULL, 5000, 0);
130        free(send), send = NULL;
131        debug(99, "post: %s", post);
132        titheklog(debuglevel, "/tmp/promptfile2_post", NULL, NULL, NULL, tmpstr);
133
134        if(post == NULL)
135        {
136                textbox(_("Message"), _("The page is temporarily unavailable") , _("OK"), getrcconfigint("rcok", NULL), _("EXIT"), getrcconfigint("rcexit", NULL), NULL, 0, NULL, 0, 1200, 200, 0, 0);
137                goto end;
138        }
139
140        free(tmpstr),tmpstr = NULL;
141        tmpstr = string_resub(";return p}('", ");'", post, 0);
142        debug(99, "tmpstr: %s", tmpstr);
143        titheklog(debuglevel, "/tmp/promptfile3_tmpstr1", NULL, NULL, NULL, tmpstr);
144       
145        post = string_replace_all(tmpstr, "", post, 1);
146        post = string_replace_all(";return p}(');'", "", post, 1);
147        debug(99, "post: %s", post);
148        titheklog(debuglevel, "/tmp/promptfile4_post2", NULL, NULL, NULL, post);
149
150        streamlink = string_resub("url: '", "',", post, 0);
151
152        titheklog(debuglevel, "/tmp/promptfile8_streamlink", NULL, NULL, NULL, streamlink);
153
154        free(tmpstr); tmpstr = NULL;
155
156end:
157
158        free(error); error = NULL;
159        free(tmphost); tmphost = NULL;
160        free(tmppath); tmppath = NULL;
161        free(tmpstr); tmpstr = NULL;
162        free(send); send = NULL;
163        free(hash), hash = NULL;
164        free(hashlen), hashlen = NULL;
165        free(op), op = NULL;
166        free(id), id = NULL;
167        free(fname), fname = NULL;
168        free(ip); ip = NULL;
169
170        return streamlink;
171}
172
173#endif
Note: See TracBrowser for help on using the repository browser.