### macOS Quick Install Script Source: https://github.com/hikariobfuscator/hikari/wiki/Compile-&-Install One-line shell script to clone, build, and install Hikari as an Xcode toolchain on macOS. Assumes the current directory is not the home directory and that cmake and ninja are installed. Installs to ~/Library/Developer/Toolchains/. ```bash git clone --recursive -b release_80 https://github.com/HikariObfuscator/Hikari.git Hikari && cd Hikari && git submodule update --remote --recursive && cd ../ && mkdir Build && cd Build && cmake -G "Ninja" -DLLDB_CODESIGN_IDENTITY='' -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on -DLLDB_USE_SYSTEM_DEBUGSERVER=YES -DLLVM_CREATE_XCODE_TOOLCHAIN=on -DCMAKE_INSTALL_PREFIX=~/Library/Developer/ ../Hikari && ninja &&ninja install-xcode-toolchain && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari && rsync -a --ignore-existing /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ ~/Library/Developer/Toolchains/Hikari.xctoolchain/ && rm ~/Library/Developer/Toolchains/Hikari.xctoolchain/ToolchainInfo.plist ``` -------------------------------- ### Unix Build Commands Source: https://github.com/hikariobfuscator/hikari/wiki/Compile-&-Install Build and install Hikari on Unix-like systems. Similar to the macOS script but without Xcode-specific commands. Installs to the default prefix. ```bash git clone --recursive -b release_80 https://github.com/HikariObfuscator/Hikari.git Hikari && cd Hikari && git submodule update --remote --recursive && cd ../ && mkdir Build && cd Build && cmake -G "Ninja" -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_APPEND_VC_REV=on ../Hikari && ninja && ninja install && git clone https://github.com/HikariObfuscator/Resources.git ~/Hikari ``` -------------------------------- ### String copy per-function example Source: https://github.com/hikariobfuscator/hikari/wiki/Known-"Bugs" Shows that modifying a global string in main() does not affect the copy used in repeat() because strings are copied per-function. This is documented behavior. ```c #include char hello[] = "HelloWorld!\n"; void repeat(){ printf(hello); } int main(){ hello[0] = 'A'; printf(hello); repeat(); return 0; } ``` -------------------------------- ### Cross-TU string reference example (main.c) Source: https://github.com/hikariobfuscator/hikari/wiki/Known-"Bugs" This code snippet, along with the next one, demonstrates that cross-translation-unit string references won't compile because the original string is wiped. This is documented behavior. ```c #include extern char c[10]; int main() { printf("c=%s\n", c); } ``` ```c #include char c[10] = {'1', '2', '3', '4', '5'}; ``` -------------------------------- ### Prerequisites: Required Unix Utilities Source: https://github.com/hikariobfuscator/hikari/wiki/Compile-&-Install Lists the standard Unix utilities expected on the compilation host, such as ar, bzip2, cat, and grep. These are required for building LLVM and Hikari. ```text ar — archive library builder bzip2 — bzip2 command for distribution generation bunzip2 — bunzip2 command for distribution checking chmod — change permissions on a file cat — output concatenation utility cp — copy files date — print the current date/time echo — print to standard output egrep — extended regular expression search utility find — find files/dirs in a file system grep — regular expression search utility gzip — gzip command for distribution generation gunzip — gunzip command for distribution checking install — install directories/files mkdir — create a directory mv — move (rename) files ranlib — symbol table builder for archive libraries rm — remove (delete) files and directories sed — stream editor for transforming output sh — Bourne shell for make build scripts tar — tape archive for distribution generation test — test things in file system unzip — unzip command for distribution checking zip — zip command for distribution generation ``` -------------------------------- ### CocoaPods post_install script for Hikari integration Source: https://github.com/hikariobfuscator/hikari/wiki/CocoaPods-Integration Add this script to your Podfile's post_install hook. It sets the clang runtime search path (adjust the path if building from source), adds the appropriate libclang_rt library for each target, and configures build settings to disable bitcode symbol hiding and index store to prevent build errors. ```ruby clang_rt_search_path = '/Library/Developer/Toolchains/Hikari.xctoolchain/usr/lib/clang/10.0.0/lib/darwin/' # This path is different depending on how you are installing Hikari # The 10.0.0 part depends on Xcode version and will change to 11.0.0 when Xcode enters 11.0.0 era # Below is the alternative path if you are not using the pkg installer and are building and installing from source # clang_rt_search_path = '~/Library/Developer/Toolchains/Hikari.xctoolchain/usr/lib/clang/10.0.0/lib/darwin/' post_install do |installer| generator_group = installer.pods_project.main_group.find_subpath("Frameworks", true) files_references_hash = Hash.new clang_rt_reference = files_references_hash[target.platform_name.to_s] if clang_rt_reference == nil clang_rt_path = clang_rt_search_path + 'libclang_rt.'+target.platform_name.to_s+'.a' clang_rt_reference = generator_group.new_reference(clang_rt_path) files_references_hash[target.platform_name.to_s] = clang_rt_reference end target.add_file_references([clang_rt_reference]) target.frameworks_build_phase.add_file_reference(clang_rt_reference, true) target.build_configurations.each do |config| origin_build_config = config.base_configuration_reference origin_build_config_parser = Xcodeproj::Config.new(origin_build_config.real_path) lib_search_path = origin_build_config_parser.attributes()['LIBRARY_SEARCH_PATHS'] if lib_search_path != nil config.build_settings['LIBRARY_SEARCH_PATHS'] = lib_search_path + ' ' + clang_rt_search_path else config.build_settings['LIBRARY_SEARCH_PATHS'] = clang_rt_search_path end #ld: loaded libLTO doesn't support -bitcode_hide_symbols: LLVM version 7.0.0 for architecture armv7 config.build_settings['HIDE_BITCODE_SYMBOLS'] = 'NO' #Issues:-index-store-path cannot specify -o when generating multiple output files config.build_settings['COMPILER_INDEX_STORE_ENABLE'] = 'NO' end end end ``` -------------------------------- ### Compile LLVM IR with Apple Clang Source: https://github.com/hikariobfuscator/hikari/wiki/Troubleshooting Command to compile the .ll file produced by Noctilucence using Apple Clang. You may need to manually set target triple and SDKRoot. ```bash clang FLAGS_SETTING_TRIPLES_AND_STUFF -c -o /PATH/TO/COMPILED_OBJECT ``` -------------------------------- ### Link with extracted linker flags Source: https://github.com/hikariobfuscator/hikari/wiki/Troubleshooting Command to link the compiled object file using the linker flags extracted from Noctilucence output. Add the object file and output path, and set syslibroot to the SDK. ```bash /PATH/TO/COMPILED_OBJECT -o /PATH/TO/LINKED/PRODUCT -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk (or whatever SDKROOT you prefer) ``` -------------------------------- ### Copy Xcode Default Toolchain to Hikari Toolchain Source: https://github.com/hikariobfuscator/hikari/wiki/Troubleshooting Use this rsync command to copy the missing directories from Xcode's default toolchain to Hikari's toolchain. This resolves 'ld: file not found' errors caused by missing files in Hikari's toolchain. ```bash rsync -ua /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ ~/Library/Developer/Toolchains/Hikari.xctoolchain/ ``` -------------------------------- ### Invoke Noctilucence to dump LLVM IR Source: https://github.com/hikariobfuscator/hikari/wiki/Troubleshooting Command to run Noctilucence on a binary to emit obfuscated LLVM assembly. The program may abort due to missing AArch64e backend; ignore the crash and find the output .ll file. ```bash Noctilucence -i /PATH/TO/BINARY -o OUTPUT/PATH -dump-ir OTHER_OBFUSCATION_FLAGS ``` -------------------------------- ### Add Linker Flags to Suppress Android/ELF Warnings Source: https://github.com/hikariobfuscator/hikari/wiki/Troubleshooting Add these linker flags to your project's linker settings to suppress the 'Warning: relocation refers to discarded section' error, which may occur due to Android toolchain LTO issues. ```text -Wno-error=all -Wl,--no-fatal-warnings ``` -------------------------------- ### C/C++ function annotation with fla Source: https://github.com/hikariobfuscator/hikari/wiki/Functions-Annotations Use __attribute__((annotate("fla"))) to apply Control Flow Flattening to a specific function. The annotation is added to the function declaration, and the definition follows. Multiple annotations can be used per function, and the 'reverse flag' (e.g., 'nobcf') disables an obfuscation. ```cpp int foo() __attribute((__annotate__(("fla")))); int foo() { return 2; } ``` -------------------------------- ### ObjC method annotation with hikari_fla pseudo call Source: https://github.com/hikariobfuscator/hikari/wiki/Functions-Annotations For ObjC methods, attributes are ignored, so Hikari uses a pseudo call to hikari_fla() to apply the 'fla' annotation. The pseudo call is placed inside the method body. ```objectivec extern void hikari_fla(void); @implementation foo2:NSObject +(void)foo{ hikari_fla(); NSLog(@"FOOOO2"); } @end ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.