Skip to content

Commit

Permalink
Merge pull request kam800#40 from kjamroz-bt/add-dry-run-option
Browse files Browse the repository at this point in the history
Add dry run option
  • Loading branch information
kam800 authored Jul 18, 2019
2 parents 8f3078a + a3c9806 commit 16c47ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions MachObfuscator/Controller/Obfuscator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Obfuscator {
var image: Image = try! loader.load(forURL: obfuscableImage)
image.replaceSymbols(withMap: manglingMap, paths: paths)
// TODO: add option
// TODO: what is the difference between eraseSymtab and last operation in replaceSymbols?
image.eraseSymtab()
if options.swiftReflectionObfuscation {
image.eraseSwiftReflectiveSections()
Expand All @@ -72,9 +73,13 @@ class Obfuscator {
savable.append(nib)
}

LOGGER.info("Saving all the files in place...")
savable.forEach {
$0.save()
if options.dryrun {
LOGGER.warn("Running in dry run mode - will not update files")
} else {
LOGGER.info("Saving all the files in place...")
savable.forEach {
$0.save()
}
}

LOGGER.info("BYE")
Expand Down
6 changes: 6 additions & 0 deletions MachObfuscator/Options/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation

struct Options {
var help = false
var dryrun = false
var quiet = false
var verbose = false
var debug = false
Expand Down Expand Up @@ -48,11 +49,13 @@ extension Options {
case skipFramework
case skipAllFrameworks
case skipSymbolsFromSources
case dryrun
}

let longopts: [option] = [
option(name: Options.newCCharPtrFromStaticString("help"), has_arg: no_argument, flag: nil, val: OptLongChars.help),
option(name: Options.newCCharPtrFromStaticString("verbose"), has_arg: no_argument, flag: nil, val: OptLongChars.verbose),
option(name: Options.newCCharPtrFromStaticString("dry-run"), has_arg: no_argument, flag: nil, val: OptLongCases.dryrun.rawValue),
option(name: Options.newCCharPtrFromStaticString("methtype"), has_arg: no_argument, flag: nil, val: OptLongChars.methTypeObfuscation),
option(name: Options.newCCharPtrFromStaticString("machoview-doom"), has_arg: no_argument, flag: nil, val: OptLongChars.machOViewDoom),
option(name: Options.newCCharPtrFromStaticString("swift-reflection"), has_arg: no_argument, flag: nil, val: OptLongCases.swiftReflection.rawValue),
Expand All @@ -73,6 +76,8 @@ extension Options {
debug = true
case OptLongChars.help:
help = true
case OptLongCases.dryrun.rawValue:
dryrun = true
case OptLongChars.methTypeObfuscation:
methTypeObfuscation = true
case OptLongChars.machOViewDoom:
Expand Down Expand Up @@ -116,6 +121,7 @@ extension Options {
-q, --quiet quiet mode, no output to stdout
-v, --verbose verbose mode, output verbose info to stdout
-d, --debug debug mode, output more verbose info to stdout
--dry-run analyze only, do not save obfuscated files
-t, --methtype obfuscate methType section (objc/runtime.h methods may work incorrectly)
-D, --machoview-doom MachOViewDoom, MachOView crashes after trying to open your binary (doesn't work with caesarMangler)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Options:
-q, --quiet quiet mode, no output to stdout
-v, --verbose verbose mode, output verbose info to stdout
-d, --debug debug mode, output more verbose info to stdout
--dry-run analyze only, do not save obfuscated files
-t, --methtype obfuscate methType section (objc/runtime.h methods may work incorrectly)
-D, --machoview-doom MachOViewDoom, MachOView crashes after trying to open your binary (doesn't work with caesarMangler)
Expand Down

0 comments on commit 16c47ea

Please sign in to comment.