diff --git a/cmd/ipsw/cmd/dyld/dyld_ida.go b/cmd/ipsw/cmd/dyld/dyld_ida.go index 6cb383c85..d190929f8 100644 --- a/cmd/ipsw/cmd/dyld/dyld_ida.go +++ b/cmd/ipsw/cmd/dyld/dyld_ida.go @@ -117,8 +117,8 @@ var idaCmd = &cobra.Command{ log.Warnf("will only load dependancies for first dylib (%s)", args[1]) } else if viper.IsSet("dyld.ida.diaphora-db") && !viper.IsSet("dyld.ida.script") { return fmt.Errorf("must supply '--script /path/to/diaphora.py' with '--diaphora-db /path/to/diaphora.db'") - } else if viper.IsSet("dyld.ida.diaphora-db") && viper.GetBool("dyld.ida.enable-gui") { - return fmt.Errorf("cannot use '--diaphora-db' with '--enable-gui'") + } else if (viper.IsSet("dyld.ida.diaphora-db") || strings.Contains(scriptFile, "diaphora.py")) && viper.GetBool("dyld.ida.enable-gui") { + return fmt.Errorf("diaphora analysis should be done headless and NOT with '--enable-gui'") } if viper.GetString("dyld.ida.slide") != "" { @@ -264,9 +264,13 @@ var idaCmd = &cobra.Command{ dbFile = filepath.Join(folder, fmt.Sprintf("DSC_%s_%s_%s.i64", args[1], f.Headers[f.UUID].Platform, f.Headers[f.UUID].OsVersion)) } - if viper.IsSet("dyld.ida.diaphora-db") { + if viper.IsSet("dyld.ida.diaphora-db") || strings.Contains(scriptFile, "diaphora.py") { env = append(env, "DIAPHORA_AUTO=1") - env = append(env, fmt.Sprintf("DIAPHORA_EXPORT_FILE=%s", viper.GetString("dyld.ida.diaphora-db"))) + if viper.IsSet("dyld.ida.diaphora-db") { + env = append(env, fmt.Sprintf("DIAPHORA_EXPORT_FILE=%s", viper.GetString("dyld.ida.diaphora-db"))) + } else { + env = append(env, fmt.Sprintf("DIAPHORA_EXPORT_FILE=%s", filepath.Join(folder, fmt.Sprintf("DSC_%s_%s_%s_diaphora.db", args[1], f.Headers[f.UUID].Platform, f.Headers[f.UUID].OsVersion)))) + } } if len(logFile) > 0 { diff --git a/cmd/ipsw/cmd/kernel/kernel_ida.go b/cmd/ipsw/cmd/kernel/kernel_ida.go index 2a52a1feb..45679b22c 100644 --- a/cmd/ipsw/cmd/kernel/kernel_ida.go +++ b/cmd/ipsw/cmd/kernel/kernel_ida.go @@ -112,8 +112,8 @@ var kernelIdaCmd = &cobra.Command{ return fmt.Errorf("cannot use '--temp-db' and '--delete-db'") } else if viper.IsSet("kernel.ida.diaphora-db") && !viper.IsSet("kernel.ida.script") { return fmt.Errorf("must supply '--script /path/to/diaphora.py' with '--diaphora-db /path/to/diaphora.db'") - } else if viper.IsSet("kernel.ida.diaphora-db") && viper.GetBool("kernel.ida.enable-gui") { - return fmt.Errorf("cannot use '--diaphora-db' with '--enable-gui'") + } else if (viper.IsSet("kernel.ida.diaphora-db") || strings.Contains(scriptFile, "diaphora.py")) && viper.GetBool("kernel.ida.enable-gui") { + return fmt.Errorf("diaphora analysis should be done headless and NOT with '--enable-gui'") } // if viper.GetString("kernel.ida.slide") != "" { TODO: how to set kc slide? // env = append(env, fmt.Sprintf("IDA_kernel_SHARED_CACHE_SLIDE=%s", viper.GetString("kernel.ida.slide"))) @@ -166,9 +166,13 @@ var kernelIdaCmd = &cobra.Command{ dbFile = filepath.Join(folder, fmt.Sprintf("KC_%s_%s_%s.i64", device, m.SubCPU.String(m.CPU), args[1])) } - if viper.IsSet("kernel.ida.diaphora-db") { + if viper.IsSet("kernel.ida.diaphora-db") || strings.Contains(scriptFile, "diaphora.py") { env = append(env, "DIAPHORA_AUTO=1") - env = append(env, fmt.Sprintf("DIAPHORA_EXPORT_FILE=%s", viper.GetString("kernel.ida.diaphora-db"))) + if viper.IsSet("kernel.ida.diaphora-db") { + env = append(env, fmt.Sprintf("DIAPHORA_EXPORT_FILE=%s", viper.GetString("kernel.ida.diaphora-db"))) + } else { + env = append(env, fmt.Sprintf("DIAPHORA_EXPORT_FILE=%s", filepath.Join(folder, fmt.Sprintf("KC_%s_%s_%s_diaphora.db", device, m.SubCPU.String(m.CPU), args[1])))) + } } if len(logFile) > 0 {