Skip to content

Commit

Permalink
feat: add --db flag to ipsw ent cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Nov 21, 2021
1 parent d9f81c9 commit 983454d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/ipsw/cmd/ent.go
Expand Up @@ -45,14 +45,15 @@ func init() {
rootCmd.AddCommand(entCmd)

entCmd.Flags().StringP("ent", "e", "", "Entitlement to search for")
entCmd.Flags().String("db", "", "Path to entitlement database to use")
entCmd.Flags().StringP("file", "f", "", "Output entitlements for file")
}

type Entitlements map[string]interface{}

// entCmd represents the ent command
var entCmd = &cobra.Command{
Use: "ent",
Use: "ent <IPSW>",
Short: "Search IPSW filesystem DMG for MachOs with a given entitlement",
Args: cobra.MinimumNArgs(1),
SilenceUsage: true,
Expand All @@ -65,6 +66,7 @@ var entCmd = &cobra.Command{
}

entitlement, _ := cmd.Flags().GetString("ent")
entDBPath, _ := cmd.Flags().GetString("db")
searchFile, _ := cmd.Flags().GetString("file")

if len(entitlement) == 0 && len(searchFile) == 0 {
Expand All @@ -76,7 +78,9 @@ var entCmd = &cobra.Command{
}

ipswPath := filepath.Clean(args[0])
entDBPath := strings.TrimSuffix(ipswPath, filepath.Ext(ipswPath)) + ".entDB"
if len(entDBPath) > 0 {
entDBPath = strings.TrimSuffix(ipswPath, filepath.Ext(ipswPath)) + ".entDB"
}

if _, err := os.Stat(entDBPath); os.IsNotExist(err) {
i, err := info.Parse(ipswPath)
Expand Down
8 changes: 8 additions & 0 deletions docs/content/docs/commands/ent.md
Expand Up @@ -100,3 +100,11 @@ Search IPSW filesystem DMG for MachOs with a given **file name** and dump it's e
</dict>
</plist>
```

Use a previously created entitlements database

```bash
❯ ipsw ent iPhone11,8,iPhone12,1_14.5_18E5199a_Restore.ipsw --ent platform-application --db /tmp/IPSW.entDB
```

> **NOTE:** When you run the `ipsw ent` command on an **IPSW** it will auto-create **IPSW.entDB** next to the **IPSW** file and it will try and use that if you run it again on the same **IPSW**.

0 comments on commit 983454d

Please sign in to comment.