This repository has been archived by the owner on Nov 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for decoding encrypted backups
- Loading branch information
Showing
5 changed files
with
154 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// +build nodecrypt | ||
|
||
package main | ||
|
||
var ( | ||
decryptEnabled = false | ||
) | ||
|
||
func decrypt(backupDir string, b *backup) { | ||
b.Status = msgEncryptionDisabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// +build !nodecrypt | ||
|
||
package main | ||
|
||
import ( | ||
"bytes" | ||
|
||
plist "github.com/DHowett/go-plist" | ||
iosbackup "github.com/gwatts/ios/backup" | ||
) | ||
|
||
var ( | ||
decryptEnabled = true | ||
) | ||
|
||
func decrypt(backupDir string, b *backup) { | ||
pw := getpw() | ||
if pw == "" { | ||
b.Status = msgIsEncrypted | ||
return | ||
} | ||
encbw, err := iosbackup.Open(backupDir) | ||
if err != nil { | ||
b.Status = "Failed to open backup: " + err.Error() | ||
return | ||
} | ||
if err := encbw.SetPassword(pw); err != nil { | ||
b.Status = msgIncorrectPassword | ||
return | ||
} | ||
if err := encbw.Load(); err != nil { | ||
b.Status = err.Error() | ||
return | ||
} | ||
rec := encbw.RecordById(restrictionsPlistName) | ||
if rec == nil { | ||
b.Status = msgNoPassword | ||
return | ||
} | ||
data, err := encbw.ReadFile(*rec) | ||
if err != nil { | ||
b.Status = msgIncorrectPassword | ||
return | ||
} | ||
buf := bytes.NewReader(data) | ||
if err := plist.NewDecoder(buf).Decode(&b.Restrictions); err != nil { | ||
b.Status = msgIncorrectPassword | ||
return | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters