xref: /PHP-7.0/ext/openssl/tests/bug65538.phar (revision 0382e761)
1<?php
2
3$web = 'index.php';
4
5if (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {
6Phar::interceptFileFuncs();
7set_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());
8Phar::webPhar(null, $web);
9include 'phar://' . __FILE__ . '/' . Extract_Phar::START;
10return;
11}
12
13if (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {
14Extract_Phar::go(true);
15$mimes = array(
16'phps' => 2,
17'c' => 'text/plain',
18'cc' => 'text/plain',
19'cpp' => 'text/plain',
20'c++' => 'text/plain',
21'dtd' => 'text/plain',
22'h' => 'text/plain',
23'log' => 'text/plain',
24'rng' => 'text/plain',
25'txt' => 'text/plain',
26'xsd' => 'text/plain',
27'php' => 1,
28'inc' => 1,
29'avi' => 'video/avi',
30'bmp' => 'image/bmp',
31'css' => 'text/css',
32'gif' => 'image/gif',
33'htm' => 'text/html',
34'html' => 'text/html',
35'htmls' => 'text/html',
36'ico' => 'image/x-ico',
37'jpe' => 'image/jpeg',
38'jpg' => 'image/jpeg',
39'jpeg' => 'image/jpeg',
40'js' => 'application/x-javascript',
41'midi' => 'audio/midi',
42'mid' => 'audio/midi',
43'mod' => 'audio/mod',
44'mov' => 'movie/quicktime',
45'mp3' => 'audio/mp3',
46'mpg' => 'video/mpeg',
47'mpeg' => 'video/mpeg',
48'pdf' => 'application/pdf',
49'png' => 'image/png',
50'swf' => 'application/shockwave-flash',
51'tif' => 'image/tiff',
52'tiff' => 'image/tiff',
53'wav' => 'audio/wav',
54'xbm' => 'image/xbm',
55'xml' => 'text/xml',
56);
57
58header("Cache-Control: no-cache, must-revalidate");
59header("Pragma: no-cache");
60
61$basename = basename(__FILE__);
62if (!strpos($_SERVER['REQUEST_URI'], $basename)) {
63chdir(Extract_Phar::$temp);
64include $web;
65return;
66}
67$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));
68if (!$pt || $pt == '/') {
69$pt = $web;
70header('HTTP/1.1 301 Moved Permanently');
71header('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);
72exit;
73}
74$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);
75if (!$a || strlen(dirname($a)) < strlen(Extract_Phar::$temp)) {
76header('HTTP/1.0 404 Not Found');
77echo "<html>\n <head>\n  <title>File Not Found<title>\n </head>\n <body>\n  <h1>404 - File ", $pt, " Not Found</h1>\n </body>\n</html>";
78exit;
79}
80$b = pathinfo($a);
81if (!isset($b['extension'])) {
82header('Content-Type: text/plain');
83header('Content-Length: ' . filesize($a));
84readfile($a);
85exit;
86}
87if (isset($mimes[$b['extension']])) {
88if ($mimes[$b['extension']] === 1) {
89include $a;
90exit;
91}
92if ($mimes[$b['extension']] === 2) {
93highlight_file($a);
94exit;
95}
96header('Content-Type: ' .$mimes[$b['extension']]);
97header('Content-Length: ' . filesize($a));
98readfile($a);
99exit;
100}
101}
102
103class Extract_Phar
104{
105static $temp;
106static $origdir;
107const GZ = 0x1000;
108const BZ2 = 0x2000;
109const MASK = 0x3000;
110const START = 'index.php';
111const LEN = 6685;
112
113static function go($return = false)
114{
115$fp = fopen(__FILE__, 'rb');
116fseek($fp, self::LEN);
117$L = unpack('V', $a = (binary)fread($fp, 4));
118$m = (binary)'';
119
120do {
121$read = 8192;
122if ($L[1] - strlen($m) < 8192) {
123$read = $L[1] - strlen($m);
124}
125$last = (binary)fread($fp, $read);
126$m .= $last;
127} while (strlen($last) && strlen($m) < $L[1]);
128
129if (strlen($m) < $L[1]) {
130die('ERROR: manifest length read was "' .
131strlen($m) .'" should be "' .
132$L[1] . '"');
133}
134
135$info = self::_unpack($m);
136$f = $info['c'];
137
138if ($f & self::GZ) {
139if (!function_exists('gzinflate')) {
140die('Error: zlib extension is not enabled -' .
141' gzinflate() function needed for zlib-compressed .phars');
142}
143}
144
145if ($f & self::BZ2) {
146if (!function_exists('bzdecompress')) {
147die('Error: bzip2 extension is not enabled -' .
148' bzdecompress() function needed for bz2-compressed .phars');
149}
150}
151
152$temp = self::tmpdir();
153
154if (!$temp || !is_writable($temp)) {
155$sessionpath = session_save_path();
156if (strpos ($sessionpath, ";") !== false)
157$sessionpath = substr ($sessionpath, strpos ($sessionpath, ";")+1);
158if (!file_exists($sessionpath) || !is_dir($sessionpath)) {
159die('Could not locate temporary directory to extract phar');
160}
161$temp = $sessionpath;
162}
163
164$temp .= '/pharextract/'.basename(__FILE__, '.phar');
165self::$temp = $temp;
166self::$origdir = getcwd();
167@mkdir($temp, 0777, true);
168$temp = realpath($temp);
169
170if (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {
171self::_removeTmpFiles($temp, getcwd());
172@mkdir($temp, 0777, true);
173@file_put_contents($temp . '/' . md5_file(__FILE__), '');
174
175foreach ($info['m'] as $path => $file) {
176$a = !file_exists(dirname($temp . '/' . $path));
177@mkdir(dirname($temp . '/' . $path), 0777, true);
178clearstatcache();
179
180if ($path[strlen($path) - 1] == '/') {
181@mkdir($temp . '/' . $path, 0777);
182} else {
183file_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));
184@chmod($temp . '/' . $path, 0666);
185}
186}
187}
188
189chdir($temp);
190
191if (!$return) {
192include self::START;
193}
194}
195
196static function tmpdir()
197{
198if (strpos(PHP_OS, 'WIN') !== false) {
199if ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {
200return $var;
201}
202if (is_dir('/temp') || mkdir('/temp')) {
203return realpath('/temp');
204}
205return false;
206}
207if ($var = getenv('TMPDIR')) {
208return $var;
209}
210return realpath('/tmp');
211}
212
213static function _unpack($m)
214{
215$info = unpack('V', substr($m, 0, 4));
216 $l = unpack('V', substr($m, 10, 4));
217$m = substr($m, 14 + $l[1]);
218$s = unpack('V', substr($m, 0, 4));
219$o = 0;
220$start = 4 + $s[1];
221$ret['c'] = 0;
222
223for ($i = 0; $i < $info[1]; $i++) {
224 $len = unpack('V', substr($m, $start, 4));
225$start += 4;
226 $savepath = substr($m, $start, $len[1]);
227$start += $len[1];
228   $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));
229$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]
230& 0xffffffff);
231$ret['m'][$savepath][7] = $o;
232$o += $ret['m'][$savepath][2];
233$start += 24 + $ret['m'][$savepath][5];
234$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;
235}
236return $ret;
237}
238
239static function extractFile($path, $entry, $fp)
240{
241$data = '';
242$c = $entry[2];
243
244while ($c) {
245if ($c < 8192) {
246$data .= @fread($fp, $c);
247$c = 0;
248} else {
249$c -= 8192;
250$data .= @fread($fp, 8192);
251}
252}
253
254if ($entry[4] & self::GZ) {
255$data = gzinflate($data);
256} elseif ($entry[4] & self::BZ2) {
257$data = bzdecompress($data);
258}
259
260if (strlen($data) != $entry[0]) {
261die("Invalid internal .phar file (size error " . strlen($data) . " != " .
262$stat[7] . ")");
263}
264
265if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
266die("Invalid internal .phar file (checksum error)");
267}
268
269return $data;
270}
271
272static function _removeTmpFiles($temp, $origdir)
273{
274chdir($temp);
275
276foreach (glob('*') as $f) {
277if (file_exists($f)) {
278is_dir($f) ? @rmdir($f) : @unlink($f);
279if (file_exists($f) && is_dir($f)) {
280self::_removeTmpFiles($f, getcwd());
281}
282}
283}
284
285@rmdir($temp);
286clearstatcache();
287chdir($origdir);
288}
289}
290
291Extract_Phar::go();
292__HALT_COMPILER(); ?>e���������������������bug54992-ca.pemc���\c���5R����������bug54992.pem	���\	��Scն������-----BEGIN CERTIFICATE-----
293MIIGAzCCA+ugAwIBAgIUVL06vQzqQ1uRdJ7NAAZyylsKOpYwDQYJKoZIhvcNAQEL
294BQAwgZAxCzAJBg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tc8a4gWaYvpn6j+L
345nAajb9JpdkNeqNiBxmtfQwL7xtY+1goLd9OKtIO1b2517ZRgU9NkUfLKCTl2W2L8
346sMY7FPVs6Z1jfaXw+vIWKCJKe0thf0HMV4q11ptsqpzyIzAAjAfma1b/MM5ATHsa
3476h7Poh0yg+WMSdXurjhDWogOWrzPXSe0izUYpREkTVl1oLhzorxlEDh7vBLB2TS3
348TPAEdNxEbsIutMjoz5ql5dYxgZQGW7HARXrXhMbk6cBU8khNcGGqz1uzX1x7Vb2d
349hKs=
350-----END CERTIFICATE-----
351-----BEGIN RSA PRIVATE KEY-----
352MIICXgIBAAKBgQC1QBVApOClQ+C0U4nfDeQMkRNLjm1Z5P3qRSDU15gspb6M1sWH
353E+g8m/teF96YJqqHa1urVx1hb3TpanUv541C91NgDYhAbgRAFSWZ/IhqQ4gyw39G
354LNWQXT2+U1DBOloympO/vAHy+/BvFv2NsLZmFBQESDo8ifXx1Ky1sz0VnQIDAQAB
355AoGBALUEnHUkdgv4P7o5WJACAomedqPWSlYmgoVvpvuLmrq0ihuFAGAIvL+TlTgD
356JNfWfiejTDlSVtCSDTR1kzZVztitfXDxRkWEjGtFjMhk/DJkql3w10SUtcqCiWqw
357/XknyPHZ7A+w7Fu5KRO2LoSIze2ZLKvCfP/M/pLR2fTKGTHtAkEA2NreT1GUnvzj
358u1lb2J0nTZbSQHvEkfpEej9akl0Bc5UkskenEsiXE3cJYA1TbEGSqYCmt23x3Rd2
359FYxm6MwV6wJBANX34ZuUOllsS0FJPbkEAps3M4s59daQSFiEkQc5XjPgVB0xVV7s
360OEBlGkM3eqcCUOMnMI8L9wfBk49sELZCeJcCQQC/y/TL2q/EXo9c6I/faj+U1Exp
361VA5rvhpKtTX6NeBOxh6Kv+z5JAja4nGcTqz2FpkM6giKO+erUFDUhjWOuNK5AkEA
362xkmHnCRLxp8jRodXWeQrfigz7ixydLsVMGL5+9XgRPb5PGyBjwwePR70raH2Wls9
363FqU0zPvrnBZ6Zwlgm2cSVQJAPLYA51Z9piajbTuggpioQ5qbUEDkJjmYHbm8eJnK
364h5NW/EtCk4SBxAc+8ElPrvJjtZyOPWfm4vZF5sDKtC3Fkg==
365-----END RSA PRIVATE KEY-----
366.c{��T�U�9o������S���GBMB