-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from rockbruno/deobfuscate-logs
Log deobfuscation / Plist features
- Loading branch information
Showing
33 changed files
with
1,452 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
*.profraw |
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
Binary file modified
BIN
+597 Bytes
(100%)
...ieldExample.xcworkspace/xcuserdata/bruno.rocha.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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
12 changes: 12 additions & 0 deletions
12
SwiftShieldTests/AutomaticSwiftShieldTests/MockManualOriginalFile.txt
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,12 @@ | ||
class ViewController__s: CustomVC__s { | ||
|
||
@IBAction func myMethod__s(_ sender: Any) {} | ||
public static func ++++(lhs: ViewController__s, rhs: ViewController__s) {} | ||
|
||
public var myProperty__s: MyType__s = "" | ||
|
||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
print(ViewController__s.fakeMethod__s()) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
SwiftShieldTests/AutomaticSwiftShieldTests/MockObfuscatedFile.txt
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
61 changes: 61 additions & 0 deletions
61
SwiftShieldTests/AutomaticSwiftShieldTests/MockPlist.plist
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,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UILaunchStoryboardName</key> | ||
<string>LaunchScreen</string> | ||
<key>UIMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).AClass</string> | ||
<key>WKExtensionDelegateClassName</key> | ||
<string>$(PRODUCT_MODULE_NAME).AClass</string> | ||
<key>CLKComplicationPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).AClass</string> | ||
<key>New item</key> | ||
<dict> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).AClass</string> | ||
<key>New item</key> | ||
<dict> | ||
<key>WKExtensionDelegateClassName</key> | ||
<string>$(PRODUCT_MODULE_NAME).AClass</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
61 changes: 61 additions & 0 deletions
61
SwiftShieldTests/AutomaticSwiftShieldTests/MockPlistObfuscatedPrincipalClass.plist
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,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
<key>UILaunchStoryboardName</key> | ||
<string>LaunchScreen</string> | ||
<key>UIMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>UIRequiredDeviceCapabilities</key> | ||
<array> | ||
<string>armv7</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>UISupportedInterfaceOrientations~ipad</key> | ||
<array> | ||
<string>UIInterfaceOrientationPortrait</string> | ||
<string>UIInterfaceOrientationPortraitUpsideDown</string> | ||
<string>UIInterfaceOrientationLandscapeLeft</string> | ||
<string>UIInterfaceOrientationLandscapeRight</string> | ||
</array> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).ZZZZZ</string> | ||
<key>WKExtensionDelegateClassName</key> | ||
<string>$(PRODUCT_MODULE_NAME).ZZZZZ</string> | ||
<key>CLKComplicationPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).ZZZZZ</string> | ||
<key>New item</key> | ||
<dict> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).ZZZZZ</string> | ||
<key>New item</key> | ||
<dict> | ||
<key>WKExtensionDelegateClassName</key> | ||
<string>$(PRODUCT_MODULE_NAME).ZZZZZ</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
26 changes: 26 additions & 0 deletions
26
SwiftShieldTests/DeobfuscatorTests/DeobfuscatorTests.swift
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,26 @@ | ||
// | ||
// DeobfuscatorTests.swift | ||
// SwiftShieldTests | ||
// | ||
// Created by Bruno Rocha on 9/22/18. | ||
// Copyright © 2018 Bruno Rocha. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class DeobfuscatorTests: XCTestCase { | ||
|
||
let mockObfuscatedLog = "0 vn#nfibffffffff 0x10050090c specialized 38fhdb3i.383(bvjn9fjd, argument : ksadbDs) -> GHInfa (MyFile.swift:73)" | ||
let mockDeobfuscatedLog = "0 SwiftShield 0x10050090c specialized AClass.myMethod(BClass, argument : CClass) -> DClass (MyFile.swift:73)" | ||
let mockDict: [String: String] = ["SwiftShield": "vn#nfibffffffff", "AClass": "38fhdb3i", "myMethod": "383", "BClass": "bvjn9fjd", "CClass": "ksadbDs", "DClass": "GHInfa"] | ||
|
||
func testRunner() { | ||
let mockFile = MockFile(data: mockObfuscatedLog) | ||
let obfuscationData = ObfuscationData() | ||
obfuscationData.obfuscationDict = mockDict | ||
let mapOutput = Protector.mapData(from: obfuscationData, info: "") | ||
let mockMapFile = MockFile(data: mapOutput) | ||
Deobfuscator.deobfuscate(file: mockFile, mapFile: mockMapFile) | ||
XCTAssertEqual(mockFile.writtenData, mockDeobfuscatedLog) | ||
} | ||
} |
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,19 @@ | ||
import Foundation | ||
|
||
final class MockFile: File { | ||
let data: String | ||
var writtenData: String = "" | ||
|
||
init(data: String? = nil, path: String = "") { | ||
self.data = data ?? "" | ||
super.init(filePath: path) | ||
} | ||
|
||
override func read() -> String { | ||
return data | ||
} | ||
|
||
override func write(_ text: String) { | ||
writtenData = text | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
SwiftShieldTests/ManualSwiftShieldTests/ManualSwiftShieldTests.swift
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,29 @@ | ||
// | ||
// AutomaticSwiftShieldTests.swift | ||
// SwiftShieldTests | ||
// | ||
// Created by Bruno Rocha on 9/24/18. | ||
// Copyright © 2018 Bruno Rocha. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
|
||
class ManualSwiftShieldTests: XCTestCase { | ||
func testObfuscator() { | ||
let ss = ManualSwiftShield(basePath: "abc", tag: "__s", protectedClassNameSize: 32) | ||
let obfuscationData = ObfuscationData() | ||
obfuscationData.obfuscationDict["ViewController__s"] = "AAAAA" | ||
obfuscationData.obfuscationDict["CustomVC__s"] = "BBBBBBBBBBBBBBBBBBB" | ||
obfuscationData.obfuscationDict["myProperty__s"] = "CCCCC" | ||
obfuscationData.obfuscationDict["MyType__s"] = "DDDDD" | ||
obfuscationData.obfuscationDict["fakeMethod__s"] = "EEEEE" | ||
obfuscationData.obfuscationDict["myMethod__s"] = "FFFFF" | ||
let originalFileData = loadFile("MockManualOriginalFile", ofType: "txt") | ||
let originalFile = String(data: originalFileData, encoding: .utf8)! | ||
let obfuscatedFile = ss.obfuscateReferences(fileString: originalFile, obfsData: obfuscationData) | ||
let expectedFileData = loadFile("MockObfuscatedFile", ofType: "txt") | ||
let expectedFile = String(data: expectedFileData, encoding: .utf8)! | ||
print(obfuscatedFile) | ||
XCTAssertEqual(obfuscatedFile, expectedFile) | ||
} | ||
} |
Oops, something went wrong.