API 2.0 Documentation
Decode PHP scripts in bulk.
Overview
The API expect a multi-part HTTP POST request to http://www.unphp.net/api/v2/post. The following parameters are required:
Parameter | Description |
---|---|
api_key | An API key for your application. You can request one automatically for free. |
file | The content of the PHP file to decode. The file should be multipart-encoded. |
Python Example
Using the API in Python with the help of the Requests module is a cinch:
import requests
test_file = 'mysample.php'
data = {
'api_key' : '1c2755023f354893ed17c99182d44464',
}
files = {'file' : open(test_file, 'rb')}
r = requests.post('http://www.unphp.net/api/v2/post', files=files, data=data)
PHP Example
You can easily do the same thing in PHP with Curl.
<?php
$post = array(
"file"=>"@a.php",
"api_key"=>"1c2755023f354893ed17c99182d44464",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.unphp.net/api/v2/post');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
echo curl_exec($ch);
echo curl_error($ch);
curl_close($ch);
?>
CURL Example
You can also decode files from the command line using the 'curl' command:
$ curl -i -F api_key=1c2755023f354893ed17c99182d44464 -F [email protected] http://www.unphp.net/api/v2/post
Bash Command Line Example
Using bash scripting you can also call the UnPHP API from the command line. Just replace the API key below with yours and then you can call it as a bash function.
$ unphp(){ curl -LF "api_key=1c2755023f354893ed17c99182d44464" -F "file=@$*" 'http://www.unphp.net/api/v2/post'|python2.7 -c'import sys,json;j=json.loads(sys.stdin.read());print j["output"] if j["result"]=="success" else False'|sed 's,api/v2,decode,';};
$ unphp mysample.php
Sample Response
All calls to the API will return an JSON object. If successful, the JSON object will contain metadata about the decoding process as well as a URL to the decoded script (available in the 'decoded' field).
{
"functions": {
"get_option": 1,
"base64_decode": 1,
"gzinflate": 1,
"stripslashes": 1
},
"if_chain": [],
"variables": {},
"emails": [],
"eval_count": 1,
"result": "success",
"urls": ["http://www.freethemelayouts.com/", "http://www.iwebsitetemplate.com"],
"output": "http://www.unphp.net/api/v2/27c3fafda955160b98536e9dc194a785/decoded?api_key=1c2755023f354893ed17c99182d44464",
"md5": "27c3fafda955160b98536e9dc194a785",
"function_chain": ["base64_decode", "gzinflate", "stripslashes", "get_option"],
"final_exception": "PHP function get_option() not defined",
"size": 625
}
Sample Error Message
If there was a problem with the decoding process the 'result' field will equal 'error'. You can get additional information about the error in the 'message' field.
{
"message": "Not all parameters specified",
"result": "error"
}