Skip to content

Commit

Permalink
feat: add un-private logging to debugserver cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Mar 28, 2021
1 parent 8d590c0 commit 0f6d0d0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
64 changes: 63 additions & 1 deletion cmd/ipsw/cmd/debugserver.go
Expand Up @@ -22,6 +22,7 @@ THE SOFTWARE.
package cmd

import (
"bytes"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -123,7 +124,7 @@ var debugserverCmd = &cobra.Command{
if len(imagePath) == 0 {
choice := 0
prompt := &survey.Select{
Message: fmt.Sprintf("Select the DeveloperDiskImage you want to extract the debugserver from:"),
Message: "Select the DeveloperDiskImage you want to extract the debugserver from:",
Options: images,
}
survey.AskOne(prompt, &choice)
Expand Down Expand Up @@ -256,6 +257,67 @@ var debugserverCmd = &cobra.Command{
return
}

// CREDIT: https://github.com/EthanArbuckle/unredact-private-os_logs
loggingPlist, err := statikFS.Open("/com.apple.system.logging.plist")
if err != nil {
log.Error(err.Error())
return
}
loggingData, err := ioutil.ReadAll(loggingPlist)
if err != nil {
log.Error(err.Error())
return
}

sessionLogSCP, err := client.NewSession()
if err != nil {
log.Fatalf("failed to create scp session: %s", err)
}
defer sessionLogSCP.Close()

go func() error {
w, _ := sessionLogSCP.StdinPipe()
defer w.Close()

count, err := io.Copy(w, bytes.NewReader(loggingData))
if err != nil {
log.Error(err.Error())
return err
}
if count == 0 {
return fmt.Errorf("%d bytes copied to device", count)
}

return nil
}()

if err := sessionLogSCP.Start("cat > /Library/Preferences/Logging/com.apple.system.logging.plist"); err != nil {
log.Error(err.Error())
return
}

if err := sessionLogSCP.Wait(); err != nil {
log.Error(err.Error())
return
}

/*
* killall logd
*/
sessionKillAll, err := client.NewSession()
if err != nil {
log.Fatalf("failed to create killall session: %s", err)
}
defer sessionKillAll.Close()
if err := sessionKillAll.Start("killall logd"); err != nil {
log.Error(err.Error())
return
}
if err := sessionKillAll.Wait(); err != nil {
log.Error(err.Error())
return
}

} else {
log.Warn("debugserver already on device")
}
Expand Down
9 changes: 9 additions & 0 deletions hack/logging_profiles/NOTES.md
@@ -0,0 +1,9 @@
# NOTES

## credit

- <https://github.com/EthanArbuckle/unredact-private-os_logs/pull/1>

### Usuage

Place profiles into the `/Library/Preferences/Logging/Subsystems` folder
Binary file added hack/logging_profiles/profiles.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/statik/statik.go

Large diffs are not rendered by default.

0 comments on commit 0f6d0d0

Please sign in to comment.