4 Invoke Method
Namhyeon, Go edited this page 2024-06-20 13:52:28 +09:00

Invoke Method

How to use

The Invoke Method feature has been supported since Caterpillar Proxy version 0.1.5.17. This feature allows you to remotely call functions defined on the server.

First, create a request in JSON format as shown below. Save it as a file named phpversion.json.

{
	"jsonrpc": "2.0",
	"method": "relay_invoke_method",
	"params": {
		"callback": "phpversion",
		"args": []
	},
	"id": ""
}

Next, use curl to perform a test to call the server's function remotely.

curl -X POST --data "@phpversion.json" -H "Content-Type: application/json" -H "User-Agent: php-httpproxy/curl" http://YOUR_HOSTNAME/

You should see the phpversion output as shown below.

{"jsonrpc":"2.0","result":{"status":200,"data":"8.2.18"},"id":""}

Here is another example:

> curl -X POST --data "{\"jsonrpc\":\"2.0\",\"method\":\"relay_invoke_method\",\"params\":{\"callback\":\"shell_exec\",\"args\":[\"whoami\"]},\"id\":\"\"}" -H "Content-Type: application/json" -H "User-Agent: php-httpproxy/curl" http://YOUR_HOSTNAME/
{"jsonrpc":"2.0","result":{"status":200,"data":"www-data\n"},"id":""}

Report abuse