Skip to content

Commit

Permalink
fix: ipsw img4 dec cmd if not --output given
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jun 1, 2024
1 parent 7c22c05 commit 91d50e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cmd/ipsw/cmd/img4/img4_dec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"crypto/aes"
"encoding/hex"
"fmt"
"path/filepath"

"github.com/apex/log"
icmd "github.com/blacktop/ipsw/internal/commands/img4"
Expand Down Expand Up @@ -68,6 +69,12 @@ var decImg4Cmd = &cobra.Command{
return fmt.Errorf("must specify either --iv-key OR --iv/--key")
}

infile := filepath.Clean(args[0])

if len(outputFile) == 0 {
outputFile = infile + ".dec"
}

var iv []byte
var key []byte

Expand All @@ -90,6 +97,6 @@ var decImg4Cmd = &cobra.Command{
}
}
utils.Indent(log.Info, 2)(fmt.Sprintf("Decrypting file to %s", outputFile))
return icmd.DecryptPayload(args[0], outputFile, iv, key)
return icmd.DecryptPayload(infile, outputFile, iv, key)
},
}

0 comments on commit 91d50e9

Please sign in to comment.