Repository contains the Swift compiler fork with three additional tools and one additional library added.
The tools are:
-
SymbolExtractor with sources in
swift/tools/obfuscator-symbol-extractor/
directory and the build file inswift/tools/obfuscator-symbol-extractor/CMakeLists.txt
-
NameMapper with sources in
swift/tools/obfuscator-name-mapper/
directory and the build file inswift/tools/obfuscator-name-mapper/CMakeLists.txt
-
Renamer with sources in
swift/tools/obfuscator-renamer/
directory and the build file inswift/tools/obfuscator-renamer/CMakeLists.txt
All these tools use a shared library called swiftObfuscation
. Its headers are in swift/include/swift/Obfuscation/
directory and its implementations are in swift/lib/Obfuscation/
directory. The build file is in swift/lib/Obfuscation/CMakeLists.txt
.
The descriptions of the tools are presented below.
This tool is part of Swift Obfuscator project.
It performs the analysis of Swift source code files and identifies the symbols that should be obfuscated. Once identified, the symbol is written down so that it could be recognized later.
$ obfuscator-symbol-extractor -filesjson <path-to-input-files-json> -symbolsjson <path-to-output-symbols-json>
where
<path-to-input-files-json>
is a path to Files.json
that contains the data required for performing the analysis of Swift source code. This parameter is required.
<path-to-output-symbols-json>
is a path to Symbols.json
file that the extracted symbols data will be written to. If it's an optional parameter. If ommited, tool will print out to the standard output.
The input data format is called Files.json
. It's defined and explained in the FilesExtractor project documentation.
The output data format is called Symbols.json
and presented below:
{
"symbols": [
{
"identifier": <string>,
"name": <string>,
"module": <string>,
"type": <enum string>("type", "namedFunction", "operator")
}
]
}
symbols
is a list of objects that contains symbol identifier and name.
name
is directly corresponding to the actual string defined in the Swift source code. This string will be replaced by the Renamer
.
identifier
contains all the information required to uniquely identify the given symbol in the source code. It will be used by Renamer
to decide whether the symbol it comes across should be renamed or not.
module
contains the name of the module that allows us to identify whether the symbol should be included in renaming or not.
type
contains the type of the symbol. It's a string of value from a strictly limited enumeration. type
means that the symbol represents type (like class or struct name), namedFunction
means that the symbol represents function or method with name, and operator
means that the symbol represents the operator.
- [] TBA
This tool is part of Swift Obfuscator project.
It proposes the new names for the symbols provided in the Symbols.json
file. It does not perform the actual renaming, but it generates the symbols after obfuscation.
$ obfuscator-name-mapper -symbolsjson <path-to-input-symbols-file> -renamesjson <path-to-output-renames-file>
where
<path-to-input-symbols-file>
is a path to Symbols.json
file that contains the information about the extracted symbols. It's a required parameter.
<path-to-output-renames-file>
is a path to the file that the symbols with proposed obfuscated names will be written to. It's an optional parameter. If ommited, tool will print out to the standard output.
The input format is called Symbols.json
and is described and explained in the SymbolExtractor data formats section.
The output format is called Renames.json
and presented below:
{
"symbols": [
{
"identifier": <string>,
"originalName": <string>,
"obfuscatedName": <string>,
"module": <string>,
"type": <enum string>("type", "namedFunction", "operator")
}
]
}
symbols
is an array of objects containing the original name of symbol, its identifier and the proposes obfuscated name.
originalName
and identifier
and module
and type
are the same as name
and identifier
and module
and type
fields in the Symbols.json
format, respectively.
obfuscatedName
is the proposed name that the original name of symbol should be changed to.
- [] TBA
This tool is part of Swift Obfuscator project.
It performs the actual renaming. It parses the Swift source code to identify the symbols, checks whether these symbols should be renamed and what to rename them to, and then does the actual job of changing the symbol name. It generates the new Swift source code in the process.
$ obfuscator-renamer -filesjson <path-to-input-files-json-file> -renamesjson <path-to-input-renames-json-file> -obfuscatedproject <path-to-directory-for-obfuscated-project>
where
<path-to-input-files-json-file>
is the path to the Files.json
file. It's a required parameter.
<path-to-input-renames-json-file>
is the path to the Renames.json
file. It's a required parameter.
<path-to-directory-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.
The input data formats are Files.json
and Renames.json
and are described in the SymbolExtractor data formats section and NameMapper data formats section.
- [] TBA
-
Clone the source code
git clone ssh://[email protected]:23/SwiftObfuscator/SymbolExtractorAndRenamer.git
-
Install build tools
brew install cmake ninja
-
(optional, only if there is a need for change in the dependencies) Update dependencies
/bin/bash Scripts/git_remotes.sh
Script takes the parameter defining which version of Swift will be used as the basis of the changes to the compiler. -
Build the Swift compiler in the Xcode-friendly way.
swift/utils/build-script --clean --xcode --release-debuginfo --debug-swift
-
Build the Swift compiler using ninja with support for iOS, tvOS and watchOS
swift/utils/build-script --ios --tvos --watchos --release-debuginfo --debug-swift
-
Copy the generated libraries from ninja build to Xcode build
rm -r -f build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/lib/swift
cp -r build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/lib/swift build/Xcode-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-x86_64/Debug/lib/swift
-
Install doxygen
brew install doxygen
-
Install graphviz
brew install graphviz
-
Build documentation
doxygen Doxyfile
-
Open documentation
open Documentation/doxygen/index.html
Please consult the Documentation folder for the further explanations.
TBA
In the alphabetical order: