Skip to content

Commit 24e0506

Browse files
committed
Update index.php
1 parent 9a6b68c commit 24e0506

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

assets/php/index.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
* Updated at: 2024-11-26
1010
*/
1111

12-
define("PHP_HTTPPROXY_VERSION", "0.1.6.4");
12+
define("PHP_HTTPPROXY_VERSION", "0.1.6.5");
1313
define("DEFAULT_SOCKET_TIMEOUT", 1);
1414
define("STATEFUL_SOCKET_TIMEOUT", 30);
1515
define("MAX_EXECUTION_TIME", 0);
16+
define("ALLOW_INVOKE_INSECURE_METHOD", false);
17+
define("ALLOW_LOAD_INSECURE_SCRIPT", true);
1618
define("DEFAULT_USER_AGENT", 'php-httpproxy/' . PHP_HTTPPROXY_VERSION . ' (Server; PHP ' . phpversion() . '; Caterpillar; [email protected])');
1719

1820
error_reporting(E_ALL);
@@ -88,6 +90,10 @@ function fatal_handler() {
8890

8991
function load_script($data) {
9092
$loaded_script = false;
93+
94+
if (!ALLOW_LOAD_INSECURE_SCRIPT) {
95+
return $loaded_script;
96+
}
9197

9298
$fh = tmpfile();
9399
if ($fh !== false) {
@@ -514,7 +520,21 @@ function relay_invoke_method($params) {
514520
$callback = $params['callback'];
515521
$requires = jsonrpc2_cast_to_array($params['requires']);
516522
$args = jsonrpc2_cast_to_array($params['args']);
517-
523+
524+
if (!ALLOW_INVOKE_INSECURE_METHOD) {
525+
$allow_callbacks = array("idn_to_ascii", "idn_to_utf8", "load_script");
526+
if (!in_array($callback, $allow_callbacks)) {
527+
return array(
528+
"success" => false,
529+
"error" => array(
530+
"status" => 403,
531+
"code" => -1,
532+
"message" => $callback . " is not allowed"
533+
)
534+
);
535+
}
536+
}
537+
518538
foreach($requires as $required_url) {
519539
try {
520540
$result = relay_fetch_url(array(

0 commit comments

Comments
 (0)