Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1736 #1737

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions implant/sliver/ps/ps_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,9 @@ func getArgvFromPid(pid int) ([]string, error) {
errStr := unix.ErrnoName(errno)
return []string{""}, fmt.Errorf("%s", errStr)
}
buffer := bytes.NewBuffer(processArgs)
numberOfArgs, err := binary.ReadUvarint(buffer)
if err != nil {
return []string{""}, err
}
buffer.Next(3) // skip sizeof(int32), the number of args
buffer := bytes.NewBuffer(processArgs[0:size])
numberOfArgsBytes := buffer.Next(4)
numberOfArgs := binary.LittleEndian.Uint32(numberOfArgsBytes)
argv := make([]string, numberOfArgs+1) // executable name is present twice

// There's probably a way to optimize that loop.
Expand All @@ -248,7 +245,7 @@ func getArgvFromPid(pid int) ([]string, error) {
for {
arg, err := buffer.ReadString(0x00)
if err != nil {
continue
break
}
if strings.ReplaceAll(arg, "\x00", "") != "" {
argv[i] = arg
Expand Down
Loading