// 1. Register agent commands (called when plugin loads)
function RegisterCommands(listenerType) {
// listenerType: "BeaconHTTP", "BeaconDNS", "BeaconSMB", "BeaconTCP", etc.
// Create command
let cmd_ls = ax.create_command("ls", "List files", "ls /tmp", "Task: list files");
cmd_ls.addArgString("path", false, "."); // name, required, default
let cmd_cd = ax.create_command("cd", "Change directory", "cd /tmp", "Task: change dir");
cmd_cd.addArgString("path", true);
// Command with subcommands
let cmd_ps_list = ax.create_command("list", "Show processes", "ps list");
let cmd_ps_kill = ax.create_command("kill", "Kill process", "ps kill 1234");
cmd_ps_kill.addArgInt("pid", true);
let cmd_ps = ax.create_command("ps", "Process manager");
cmd_ps.addSubCommands([cmd_ps_list, cmd_ps_kill]);
// Alias with pre-hook
let cmd_shell = ax.create_command("shell", "Execute via cmd.exe", "shell whoami");
cmd_shell.addArgString("cmd", true);
cmd_shell.setPreHook(function(id, cmdline, parsed_json) {
ax.execute_alias(id, cmdline, "ps run -o cmd.exe /c " + parsed_json["cmd"]);
});
// Commands group
let commands = ax.create_commands_group("beacon", [cmd_ls, cmd_cd, cmd_ps, cmd_shell]);
return {
commands_windows: commands, // Commands for Windows
// commands_linux: commands, // Commands for Linux (optional)
}
}
// 2. UI for payload generation (called when generation dialog opens)
function GenerateUI(listeners_type) {
// listeners_type: array of selected listener types
let labelArch = form.create_label("Arch:");
let comboArch = form.create_combo();
comboArch.addItems(["x64", "x86"]);
let labelFormat = form.create_label("Format:");
let comboFormat = form.create_combo();
comboFormat.addItems(["Exe", "DLL", "Shellcode"]);
let layout = form.create_gridlayout();
layout.addWidget(labelArch, 0, 0);
layout.addWidget(comboArch, 0, 1);
layout.addWidget(labelFormat, 1, 0);
layout.addWidget(comboFormat, 1, 1);
let container = form.create_container();
container.put("arch", comboArch);
container.put("format", comboFormat);
let panel = form.create_panel();
panel.setLayout(layout);
return {
ui_panel: panel,
ui_container: container,
ui_height: 300,
ui_width: 400
}
}