Giter Club home page Giter Club logo

siriusobfuscator's Introduction

Sirius - Swift Obfuscator

Overview

Sirius is a tool for performing source-to-source obfuscation of Swift projects.

Basically, it transforms your code from this:

class Sample: UIViewController {
  var value = 42
  
  override func viewDidLoad() {
    super.viewDidLoad()
    configure()
    foo(bar: 1)
  }
  
  func foo(bar baz: Int) {
    value += baz
  }
}

protocol Configurable {
  func configure()
}

extension Sample: Configurable {
  func configure() { }
}

to this:

class aqoxMfcPUXffEuurviH_ZPMDW2hCmXDR: UIViewController {
  var a0vLRcFFAQ1Lvw2sf4ZIigWKjXjpJpug = 42
  
  override func viewDidLoad() {
    super.viewDidLoad()
    A6PP2E5mcmjEsgOvTeXwy2G44vzYLa6H()
    xG1qrXIMEJC1Eoma2Qbp_ZWJ5y2lrGYX(KuT5vOLIISvSJyju6bYxsHO_vlWUU589: 1)
  }
  
  func xG1qrXIMEJC1Eoma2Qbp_ZWJ5y2lrGYX(KuT5vOLIISvSJyju6bYxsHO_vlWUU589 vjCKgTT7Cf0ZlEi9giLZstzgdC9XLQcd: Int) {
    a0vLRcFFAQ1Lvw2sf4ZIigWKjXjpJpug += vjCKgTT7Cf0ZlEi9giLZstzgdC9XLQcd
  }
}

protocol dVUt_HSz_a1q1JsbyTJVfk0KeXej8a4z {
  func A6PP2E5mcmjEsgOvTeXwy2G44vzYLa6H()
}

extension aqoxMfcPUXffEuurviH_ZPMDW2hCmXDR: dVUt_HSz_a1q1JsbyTJVfk0KeXej8a4z {
  func A6PP2E5mcmjEsgOvTeXwy2G44vzYLa6H() { }
}

The resulting obfuscated project is much more difficult to reverse engineer by the attacker.

Usage

  1. Get latest sirius executable from here.

  2. Run:

$ bin/sirius -projectrootpath <path-to-xcode-project> -obfuscatedproject `<path-for-obfuscated-project>` [-namemappingstrategy <name-mapping-strategy>] [-keepintermediates] [-inplace] [-verbose]

where

<path-to-xcode-project> is a path to Xcode project root folder. It's the folder that contains both the Xcode project file (.xcodeproj or .xcworkspace) and the source files. It is passed to file-extractor tool.

<path-for-obfuscated-project> is the path to the directory that the newly generated obfuscated Swift source code files will be written to, as well as the new project. Is is passed to renamer tool.

In case when project should be obfuscated in place (without making a copy), -inplace argument can be used instead of -obfuscatedproject.

<name-mapping-strategy> is the optional parameter of type enum string. Is is passed to name-mapper tool. Is determines, which of the following strategies is used when generating the obfuscated symbol names:

  • random strategy generates random alphanumeric strings of length 32, e.g. gnxWyHU0uN3bXejy8bVAoNbyfg4gRuN8.
  • deterministic strategy generates deterministic renames based on symbol's original name, e.g. T1_RootViewController.
  • minifying strategy generates strings as short as possible, e.g. a.

When the -namemappingstrategy parameter is not provided, the default random strategy is used.

-keepintermediates is the optional flag. When present, the interemediate files used to pass the necessary info between the tools invoked by ObfuscatorTool (files.json, symbols.json, renames.json) will not be removed after successful obfuscation process.

-verbose is the optional flag. When present, the flag is passed to each tool invoked by ObfuscatorTool and all debug info messages from each tool are printed to standard output.

Verification

Verify the outcome of the obfuscation by opening the obfuscated project in Xcode. Use verification-suite and Hopper to check symbol names in mach-O file built from the obfuscated project.

Motivation

This project was developed for a particular iOS app that we needed to obfuscate. It is therefore a non-generalizable tool designed to solve the problem of obfuscating the single source code.

It shows, however, how the Swift compiler might be used as a library for building the powerful and flexible developer tools.

The app that motivated the development of Sirius is using:

  • Swift 4.0 only (no Objective-C)
  • Cocoapods
  • .storyboard files
  • CoreData

If your app has the same set of characteristics, we encourage you to try to obfuscate it. It may or may not work, depending on the Swift language constructs that you used.

Limitations

Sirius is not production-ready. Some code constructs that are allowed in Swift, won't be properly renamed by Sirius. This might lead to obfuscated project that is not compiling or crashes at runtime.

Some code constructs that are not yet supported:

  • Backticks
func `backticksName`() {}
  • #if #else #endif preprocessor macros
  • Old Swift selectors
let foo = Selector(("bar:"))

Symbols that won't be renamed by Sirius even though they are visible in mach-O binary:

  • Enum associated values
enum EnumWithAssoc {
  case1(assoc: Int)
}

For more examples of unsupported constructs head here.

For constructs that are deliberately excluded from renaming head here.

Components

The Sirius - Swift Obfuscator suite consists of command line tools organized in repositories:

Repository Tool Overview
ObfuscatorTool sirius Umbrella tool that exposes the unified command line interface to perform the obfuscation of Xcode project. It executes tools: file-extractor, symbol-extractor, name-mapper, renamer and passes the intermediate files between them.
FileExtractor file-extractor Extracts the data about Xcode project based on the root project's path (e.g. the list of .swift source files, the list of frameworks required to build the project) to files.json.
SymbolExtractorAndRenamer symbol-extractor Extracts symbols from .swift source files to symbols.json.
SymbolExtractorAndRenamer name-mapper Generates the new names for the symbols provided in symbols.json.
SymbolExtractorAndRenamer renamer Performs the renaming of symbols based on renames.json.
VerificationSuite verification-suite Tool for presenting the changes made in obfuscation process.

Contributing

Contributing to main command line tool (sirius)

If you wish to contribute to sirius (umbrella command line tool), head to BuildNotes and GettingStarted.

Contributing to other tools from Sirius suite

If you wish to contribute to other tools from Sirius - Swift Obfuscator suite, head to the repositories:

Contributors to Sirius suite

In the alphabetical order:

CLA

We require contributors to have signed Contributor Licence Agreement.

Support

Polidea may provide commercial support for extending the Sirius obfuscator to work with your app.

Licence

Copyright 2018 Polidea Sp. z o.o

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

siriusobfuscator's People

Contributors

jerzykleszcz avatar siejkowski avatar zeveisenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

siriusobfuscator's Issues

[0.6] Road to "Crash de-obfuscation"

This issue presents the roadmap for the version 0.6 of Sirius obfuscator tool.

Vision

The version 0.6 adds one of the crucial features to Sirius obfuscator: ability to transform the crash log from the obfuscated app into the crash log containing the original names. It can be done either after the symbolization or by providing a transformed DSYM file.

Scope (initial, might change on further research)

  • Create script that takes the non-symbolicated crash log, the DSYM file from obfuscated app and Renames.json file and produces the deobfuscated crash log

[0.4] Road to "Multi-target projects"

This issue presents the roadmap for the version 0.4 of Sirius obfuscator tool.

Vision

The version 0.4 expands the usage of Sirius obfuscator to multi-target projects. It's especially important for:

  • ability to run tests after obfucation (to ensure that the obfuscation process have not caused any regressions)
  • apps with extensions
  • apps modularized with the use of frameworks

Scope

  • Renaming in the test targets
  • Renaming in the extensions
  • Renaming in the frameworks
  • (bugfix) Ensure that the generated obfuscated name has no name collision with any symbol that already exists in the app

[1.0] Road to "Polishing"

This issue presents the roadmap for the version 1.0 of Sirius obfuscator tool.

Vision

The version 1.0 is the first feature-complete release. All the remaining bugfixes, minor improvements, small refactors that we believe should be part of 1.0 should be addressed here.

Scope (initial)

  • SymbolExtractor and Renamer are path-case-sensitive
  • Add tests to the SymbolWithRange comparator
  • Link Clang Format to compiler fork
  • Ability to use the iOS SDK in the obfuscator tests

Error for v0.5.0: ruby/2.2.0/find.rb:42:in `block in find': No such file or directory

I am getting following error when I try to obfuscate the project

===========================

1) File Extractor:
⡀⡀⡀⠄⠂⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄Extracting⡀⡀⡀⠄⠂⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄
STDERR: /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/find.rb:42:in `block in find': No such file or directory (Errno::ENOENT)
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/find.rb:42:in `collect!'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/find.rb:42:in `find'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/carthage_determiner.rb:8:in `each'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/carthage_determiner.rb:8:in `select'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/carthage_determiner.rb:8:in `find_cartfile_directory'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/command.rb:90:in `run'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/vendor/ruby/2.2.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/command.rb:76:in `run'
	from /Users/xxxxxxxx/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/bin/file-extractor:20:in `<main>'
STDOUT: 

===========================

[1.0] Road to "1.0"

This issue describes the roadmap to the first version that we believe is feature-complete enough to be called "1.0".

Vision

The version 1.0 of Sirius obfuscator is the version that contains at least initial implementation of all the features that we believe that are crucial for using the tool in the majority of real-world apps.

Scope

The roadmap is split into 9 steps, each one of them referenced by the increment on the minor version indicator:

The high-level vision and the actual scope of each one of these versions is described in the linked issues.

Casting issue in "'Utility.ArgumentParserError' (0x1032616f0) to 'ShellOut.ShellOutError'"

Hello,
When i set up this system, I have completed all process but when i run my final command on terminal, i got below issue.

COMMAND WHICH I HAVE RUN -
bin/sirius -projectrootpath /Users/admin/Desktop/YatinTest -obfuscatedproject /Users/admin/Desktop/TEST [-namemappingstrategy] [-keepintermediates] [-inplace] [-verbose]

====================================

ISSUNE FACING - -
Could not cast value of type 'Utility.ArgumentParserError' (0x1032616f0) to 'ShellOut.ShellOutError' (0x103219780).
Abort trap: 6

====================================

Here is details -

YatinTest - is my test project which i want to convert.
TEST - is a folder where i want to store encrypted code.

Also From where i can get list.

Please help me out to resolve this issue.

[0.5] Road to "Objective-C & Swift"

This issue presents the roadmap for the version 0.5 of Sirius obfuscator tool.

Vision

The version 0.5 provides the initial support for the mixed Objective-C / Swift codebases.

The symbols should be renamed using a shared pool, so that there's no exception neither when using Swift symbol in Objective-C, nor when using Objective-C symbol in Swift.

Scope

  • Identifying the Objective-C files from the Xcode project
  • Ability to rename the Objective-C type names in the Objective-C files
  • Renaming of the symbols from Objective-C in the Swift source code
  • Renaming of the symbols from Swift in the Objective-C files

[0.2] Road to "Open source"

This issue presents the roadmap for the version 0.2 of Sirius obfuscator tool.

Vision

Version 0.2 is the first version that is completely open sourced. By the "completeness" of open sourcing I mean that not only the source code is open, but also:

  • the development process is public,
  • the issue tracker is public,
  • the plans for future work are public,
  • the CI is integrated with the public repository and the results of build and test are public.

Scope

Could not run in xcode 10.2.1

Run below script:
bash Scripts/build.sh

Error:

` _$s5Basic15LocalFileSystem33_6FEC4E2BAB746063854EC7E201C2329FLLCAA0cD0A2aEP06removeC4TreeyyAA12AbsolutePathVKFTW in FileSystem.swift.o
...
ld: symbol(s) not found for architecture x86_64

cp: /Users/apple/Documents/Github/SiriusObfuscator/.build/x86_64-apple-macosx/release/Sirius: No such file or directory`

TDERR: Error during JSON file read STDOUT: Swift obfuscator symbol extractor tool

Hi ,

While I was running below script /Users/ME/Documents/Workspace/bin/sirius -projectrootpath /UsersME/Documents/Practices/Samples/ObfusTest -obfuscatedproject /Users/ME/Documents/Practices/1.Samples/outsampleObfuscator.
I am getting following error.

  1. Symbol Extractor:
    ⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄⡀⢀⠠⠐⠈Extracting⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄⡀⢀⠠⠐⠈
    STDERR: Error during JSON file read
    STDOUT: Swift obfuscator symbol extractor tool
    XXXComputerName:~ ME$

Xcode Version:10
Swift :4.2 (Pure Swift project).
Kindly help me regarding this .

[0.3] Road to "Multiple Swift versions"

This issue presents the roadmap for the version 0.3 of Sirius obfuscator tool.

Vision

Version 0.3 allows for obfuscating projects written in various Swift language version.

The initial release should support:

  • Swift 4.0.3 (Xcode 9.2)
  • Swift 4.1 (Xcode 9.3)
  • Swift 4.1.2 (Xcode 9.4)
  • Swift 4.2 (Xcode 10)

Scope

[0.7] Road to "Missing Swift constructs"

This issue presents the roadmap for the version 0.7 of Sirius obfuscator tool.

Vision

The version 0.7 expands the space of Swift constructs that are properly identified and supported by the Sirius obfuscator.

Scope (initial)

  • Solving the #if / #else / #endif problem by taking the bodies of the if-branches and resolving them independently
  • Ensure on renaming of functions and computed properties which satisfy the requirements from multiple protocols that all these protocols are from our module. If not, no rename
  • Support renaming of the names in backticks
  • Renaming of the local variables
  • Renaming enum case associated values

[0.9] Road to "User interface"

This issue presents the roadmap for the version 0.9 of Sirius obfuscator tool.

Vision

The version 0.9 focuses on user experience of Sirius obfuscator. It cleans up the interface, allows for deeper customization and helps with the seamless usage of the tool

Scope (initial)

  • Ability to pass additional compiler flags through the main obfuscator CLI
  • Integration of Verification suite with ObfuscatorTool by additional flag that performs verification after obfuscation
  • Tab-completion for the obfuscator CLI tools for the most popular shells (bash, fish, zsh)
  • Provide the brew cask for installing the Sirius obfuscator

`configure_with_plist': [!] Xcodeproj doesn't know about the following attributes {"inputFileListPaths"=>[], "outputFileListPaths"=>[]} for the 'PBXShellScriptBuildPhase' isa. (RuntimeError)

Hi,i have a error, can you help me ?
➜ Obfuscator_2018-04-24_115109 ./bin/sirius -projectrootpath /Users/linyunyue/Workspace/久沐/KongkongiOS/KongkongVoice -obfuscatedproject /Users/linyunyue/Workspace/久沐/KongkongiOS/confuse -namemappingstrategy random -keepintermediates -inplace -verbose

Welcome to Sirius - Swift Obfuscator

===========================

  1. File Extractor:
    ⡀⡀⠄⠂⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄⡀Extracting⡀⡀⠄⠂⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄⡀
    STDERR: /Users/linyunyue/Downloads/Obfuscator_2018-04-24_115109/bin/lib/vendor/ruby/2.2.0/gems/xcodeproj-1.5.3/lib/xcodeproj/project/object.rb:321:in `configure_with_plist': [!] Xcodeproj doesn't know about the following attributes {"inputFileListPaths"=>[], "outputFileListPaths"=>[]} for the 'PBXShellScriptBuildPhase' isa. (RuntimeError)
    If this attribute was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new

cannot able to get obfuscated code

Getting below error:

  1. File Extractor:
    ⡀⡀⡀⠄⠂⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄Extracting⡀⡀⡀⠄⠂⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄
    STDERR: /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/source.rb:17:in require': cannot load such file -- stringio (LoadError) from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/source.rb:17:in create_from'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/parsers/baseparser.rb:128:in stream=' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/parsers/baseparser.rb:117:in initialize'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/parsers/treeparser.rb:9:in new' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/parsers/treeparser.rb:9:in initialize'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/document.rb:287:in new' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/document.rb:287:in build'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/ruby/lib/ruby/2.2.0/rexml/document.rb:44:in initialize' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/vendor/ruby/2.2.0/gems/xcodeproj-1.5.3/lib/xcodeproj/workspace.rb:83:in new'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/vendor/ruby/2.2.0/gems/xcodeproj-1.5.3/lib/xcodeproj/workspace.rb:83:in from_s' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/vendor/ruby/2.2.0/gems/xcodeproj-1.5.3/lib/xcodeproj/workspace.rb:66:in new_from_xcworkspace'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/xcworkspace_extractor.rb:19:in extract_projects_and_dependency_schemes' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/command.rb:96:in run'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/vendor/ruby/2.2.0/gems/claide-1.0.2/lib/claide/command.rb:334:in run' from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/lib/file-extractor/command.rb:76:in run'
    from /Users/poojab/Downloads/Obfuscator_2018-04-24_115109/bin/lib/file-extractor/bin/file-extractor:20:in `'
    STDOUT:

===========================

  1. Symbol Extractor:
    ⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄⡀⢀⠠⠐⠈Extracting⠁⠂⠄⡀⢀⠠⠐⠈⠁⠂⠄⡀⢀⠠⠐⠈
    STDERR: Error during JSON file read
    STDOUT: Swift obfuscator symbol extractor tool

[0.8] Road to "Optimization"

This issue presents the roadmap for the version 0.8 of Sirius obfuscator tool.

Vision

The version 0.8 addresses the various performance issues that arose from choosing to implement obfuscation features in a most straightforward and naive way.

Scope (initial)

  • Use the move semantics in the compiler’s data structures (these are big structures!)
  • Change the structure of Symbols.json and Renames.json so that the symbol lookup would be easier
  • When beneficial, change the standard types and containers that we use from the std implementation to the LLVM implementation
  • Use custom structure(s) for symbols that allow for viewing them based on the desired uniqueness and iteration requirements. Right now we copy sets multiple times to get this behavior

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.