The Client Trojan API
Clone this wiki locally
Overview
The novahot client communicates with the trojan by POST-ing JSON to the
URI at which the trojan resides. The trojan returns a JSON response.
The Client
The POST body from the novahot client will resemble the following:
{
auth : 'the-control-password',
cwd : '/var/www/public',
cmd : 'ls',
}Whereby:
-
authis the trojan's control password -
cwdis the trojan's current working directory -
cmdis the command to pass to the trojan
Additionally, an args property may optionally be attached to the POST
body, and may contain arbitrary parameters. (args is currently used to
implement "virtual commands", but can be used to extend a trojan at-will.)
The Trojan
The trojan will return JSON resembling the following:
{
stderr : [ ],
stdout : [ 'index.html' ],
cwd : '/var/www/public',
}Whereby:
-
stderris an array of lines written tostderr -
stdoutis an array of lines written tostdout -
cwdis the trojan's current working directory
Extending the Trojans
The trojans process the data POST-ed from the client thusly:
-
If
cmdis a "payload function" (ie, a function that has been defined within the trojan), the payload function will be executed and passedargsas a parameter. -
If
cmdis not a "payload function",cmdwill be passed to a system subshell.
Only two payload functions ship with the novahot trojans by default:
payload_upload (for uploading files), and payload_download (for downloading
files).
"Payload" Mode
To extend the trojans, simply add additional payload functions to the trojan source.
It is possible to send arbitrary parameters to custom payloads using the
"payload" mode. To enter the payload mode, type .payload from within the
shell.
Once in payload mode, aribtrary payloads may be executed using the following
syntax:
payload> payload_name { "foo" : "bar" }Whereby:
-
payload_namecorresponds with the name of a payload function in the trojan -
payload_nameis (optionally) followed by parameters formatted as valid JSON.
The optional parameters will be attached to the POST body as the args
property.
Note that payload functions must return JSON formatted as specified above in order to be fully compatible with the shell.