Module: Codeobscure
- Defined in:
- lib/codeobscure.rb,
lib/codeobscure/version.rb
Constant Summary collapse
- VERSION =
"0.1.8.0"
- @@ignore_symbols_path =
"ignoresymbols"
Class Method Summary collapse
-
.obscure ⇒ Object
waiting for add optionparse and add class obscure.
- .root ⇒ Object
Class Method Details
.obscure ⇒ Object
waiting for add optionparse and add class obscure
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/codeobscure.rb', line 21 def self.obscure = {} #默认是随机替换的方式 [:type] = "r" OptionParser.new do |opts| opts. = "Usage: obscure code for object-c project" opts.on("-o", "--obscure XcodeprojPath", "obscure code") do |v| [:obscure] = v end opts.on("-l", "--load path1,path2,path3",Array,"load filt symbols from path") do |v| [:load] = v end opts.on("-r", "--reset", "reset loaded symbols") do |v| [:reset] = true end opts.on("-f", "--fetch type1,type2,type3", "fetch and replace type,default type is [c,p,f,i]. c for class, p for property, f for function") do |v| [:fetch] = v end opts.on("-i", "--ignore XcodeprojPath", "create a ignore file, you can write your filt symbols in it.eg:name,age ...") do |v| [:ignore] = v end opts.on("-t", "--type replaceType", "obscure type = [r,w,c] ,r: random w: random words c: custom replace rule") do |v| [:type] = v end opts.on("-s", "--strict", "strict mode. It will filter all string. If there are many kvo in code, please add -s.") do |v| [:strict] = true end end.parse! if [:reset] `rm -f '#{root}/filtSymbols'` `cp '#{root}/filtSymbols_standard' '#{root}/filtSymbols'` puts "重置完毕!".colorize(:green) end if [:ignore] xpj_path = [:ignore] if File.exist? xpj_path root_dir = xpj_path.split("/")[0...-1].join "/" ignore_path = "#{root_dir}/#{@@ignore_symbols_path}" if !File.exist? ignore_path `touch #{ignore_path}` end end end #only load, execute load only #only obscure, execute obscure only #load and obscure at same time,load firt,then obscure.That's mean you can get rid of some directoies. load_pathes = [:load] if load_pathes load_pathes.each do |load_path| if File.exist? load_path FiltSymbols.loadFiltSymbols load_path puts "加载完毕!".colorize(:green) else puts "指定的目录不存在:#{load_path}".colorize(:red) end end end fetch_types = ["p","c","f"] if ![:fetch].nil? && [:fetch].length > 0 fetch_types = [:fetch] end if [:obscure] xpj_path = [:obscure] if File.exist? xpj_path root_dir = xpj_path.split("/")[0...-1].join "/" ImageMix.mix root_dir if [:strict] FiltSymbols.loadStrictMode root_dir puts "准备严格模式完成!".colorize(:green) end FuncList.genFuncList root_dir , "h", true, fetch_types header_file = Obscure.run root_dir , [:type] project = Xcodeproj::Project.open xpj_path project_name = xpj_path.split("/").last main_group = project.main_group if !main_group.find_file_by_path("codeObfuscation.h") main_group.new_reference header_file end project.targets.each do |target| if "#{target.name}.xcodeproj" == project_name build_configs = target.build_configurations build_configs.each do |build_config| build_settings = build_config.build_settings prefix_key = "GCC_PREFIX_HEADER" prefix_header = build_settings[prefix_key] if prefix_header.nil? || prefix_header.empty? build_config.build_settings[prefix_key] = "./codeObfuscation.h" elsif prefix_header.include? "codeObfuscation.h" puts "#{target.name}:#{build_config}配置文件已配置完成".colorize(:green) else puts "请在#{prefix_header}中#import \"codeObfuscation.h\"".colorize(:green) end end end end project.save #Fix bug for SIP system "chmod 755 '#{xpj_path}/project.pbxproj'" puts "配置完成!".colorize(:green) puts "请直接运行项目,如果项目中出现类似: `+[LoremIpsum PyTJvHwWNmeaaVzp:]: unrecognized selector sent to class`。在codeObfuscation.h中查询PyTJvHwWNmeaaVzp并删除它!".colorize(:yellow) else puts "指定的目录不存在:#{path}".colorize(:red) end end end |
.root ⇒ Object
16 17 18 |
# File 'lib/codeobscure.rb', line 16 def self.root File.dirname __dir__ end |