codeobscure 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/codeobscure.rb +5 -1
- data/lib/codeobscure/filtsymbols.rb +1 -0
- data/lib/codeobscure/funclist.rb +28 -0
- data/lib/codeobscure/obscure.rb +48 -5
- data/lib/codeobscure/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34b0c0a649a9f5f5e7d0fa859ce85847806365f1
|
4
|
+
data.tar.gz: b864a37fff7c401365b62bd2e7dca0fa9024a552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb470a8c3c72af243c2b34d68466b9f7d42ff83b904d8a17a186f11b166638204fd94ca825eae87bba223e048f1c203b479bb8c55466cdae511d225ac08d870
|
7
|
+
data.tar.gz: 2d9aa9786f3a42c90d89c482ba4e2c00ec26d3ce2731ae921f857eea76a744951eae09c65201ff886a573d2c095d5bae3a9482a85b3d91f2388c7e715e794628
|
data/lib/codeobscure.rb
CHANGED
@@ -42,6 +42,10 @@ module Codeobscure
|
|
42
42
|
options[:ignore] = v
|
43
43
|
end
|
44
44
|
|
45
|
+
opts.on("-t", "--type replaceType", "obscure type = [r,w,c] ,r: random w: random words c: custom replace rule") do |v|
|
46
|
+
options[:type] = v
|
47
|
+
end
|
48
|
+
|
45
49
|
end.parse!
|
46
50
|
|
47
51
|
if options[:reset]
|
@@ -86,7 +90,7 @@ module Codeobscure
|
|
86
90
|
if File.exist? xpj_path
|
87
91
|
root_dir = xpj_path.split("/")[0...-1].join "/"
|
88
92
|
FuncList.genFuncList root_dir , "all", true, fetch_types
|
89
|
-
header_file = Obscure.run root_dir
|
93
|
+
header_file = Obscure.run root_dir , options[:type]
|
90
94
|
project = Xcodeproj::Project.open xpj_path
|
91
95
|
project_name = xpj_path.split("/").last
|
92
96
|
main_group = project.main_group
|
@@ -2,6 +2,7 @@ require_relative "funclist.rb"
|
|
2
2
|
require 'sqlite3'
|
3
3
|
require "colorize"
|
4
4
|
module FiltSymbols
|
5
|
+
@@db = nil
|
5
6
|
@@filt_db_path = "#{File.expand_path '../../..', __FILE__}/filtSymbols"
|
6
7
|
@@table_name = "symbols"
|
7
8
|
@@key_words = ["interface","NSInteger","BOOL","Class","free","M_PI_2","abort","change","top","bottom","NSUIntegerMax","intoString"]
|
data/lib/codeobscure/funclist.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module FuncList
|
2
2
|
|
3
|
+
require_relative "filtSymbols.rb"
|
4
|
+
|
3
5
|
@@func_regex = /\s*(\w+)\s*:\s*\(\s*\w*\s*\s*\w+\s*\*?\s*\)\s*\w+\s*/
|
4
6
|
@@func_simple_regex = /\s*[-\+]\s*\(\s*\w+\s*\*?\)\s*(\w+)\s*;*/
|
5
7
|
@@hcls_regex = /@interface\s+(\w+)\s*/
|
@@ -7,6 +9,8 @@ module FuncList
|
|
7
9
|
@@property_regex = /\s*@property\s*\(.*?getter=(\w+).*?\)\s*\w+\s*\*?\s*\w+\s*.*;/
|
8
10
|
@@property_regex2 = /\s*@property\s*\(.*?\)\s*\w+\s*\*?\s*(\w+)\s*.*;/
|
9
11
|
@@property_regex3 = /\s*@property\s*\(.*?\)\s*\w+\s*<.*>\s*\*?\s*(\w+)\s*.*;/
|
12
|
+
@@value_for_key_filte_regex = /\[\w*\s+setValue\s*:\s*.*\s* forKey\s*:\s*@\"(.*)\"\]/
|
13
|
+
@@class_from_str_regex = /NSClassFromString\(\s*@"(\w+)"\s*\)/
|
10
14
|
|
11
15
|
def self.to_utf8(str)
|
12
16
|
str = str.force_encoding('UTF-8')
|
@@ -96,6 +100,30 @@ module FuncList
|
|
96
100
|
end
|
97
101
|
end
|
98
102
|
end
|
103
|
+
|
104
|
+
#---------------记录可能引起崩溃的字段----------------
|
105
|
+
str.scan @@value_for_key_filte_regex do |curr_match|
|
106
|
+
md = Regexp.last_match
|
107
|
+
whole_match = md[0]
|
108
|
+
captures = md.captures
|
109
|
+
|
110
|
+
captures.each do |capture|
|
111
|
+
FiltSymbols.insertValue capture
|
112
|
+
p "过滤的[setValue forkey]数据:#{capture}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
str.scan @@class_from_str_regex do |curr_match|
|
118
|
+
md = Regexp.last_match
|
119
|
+
whole_match = md[0]
|
120
|
+
captures = md.captures
|
121
|
+
|
122
|
+
captures.each do |capture|
|
123
|
+
FiltSymbols.insertValue capture
|
124
|
+
p "过滤的[NSClassFromString]数据:#{capture}"
|
125
|
+
end
|
126
|
+
end
|
99
127
|
|
100
128
|
results
|
101
129
|
end
|
data/lib/codeobscure/obscure.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require_relative 'filtsymbols.rb'
|
2
2
|
require 'sqlite3'
|
3
|
+
require 'random_word'
|
3
4
|
|
4
5
|
class String
|
5
6
|
def upcase_first_letter
|
@@ -11,13 +12,56 @@ module Obscure
|
|
11
12
|
|
12
13
|
@@STRING_SYMBOL_FILE="func.list"
|
13
14
|
@@IGNORE_NAME="ignoresymbols"
|
15
|
+
|
16
|
+
#type 1 :随机字符, 2 : 随机单词, 3 : 自定义单词替换
|
17
|
+
def self.ramdomString(var_type , replace_type = 1)
|
18
|
+
result = ""
|
19
|
+
case replace_type
|
20
|
+
when 1
|
21
|
+
result = `openssl rand -base64 64 | tr -cd 'a-zA-Z' |head -c 16`
|
22
|
+
when 2
|
23
|
+
words = RandomWord.phrases.next.split /[ _]/
|
24
|
+
join_words = ""
|
25
|
+
words.each_with_index do |word,index|
|
26
|
+
if index == 0
|
27
|
+
|
28
|
+
join_words += word
|
29
|
+
if var_type == "c"
|
30
|
+
join_words.capitalize!
|
31
|
+
end
|
32
|
+
else
|
33
|
+
join_words += word.capitalize
|
34
|
+
end
|
35
|
+
end
|
36
|
+
result = join_words
|
37
|
+
when 3
|
38
|
+
raise "c选项功能暂未实现,下一版本中加入!"
|
39
|
+
end
|
14
40
|
|
15
|
-
|
16
|
-
|
41
|
+
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.toTypeNumber(type)
|
46
|
+
result = 1
|
47
|
+
case type
|
48
|
+
when "r"
|
49
|
+
result = 1
|
50
|
+
when "w"
|
51
|
+
result = 2
|
52
|
+
when "c"
|
53
|
+
result = 3
|
54
|
+
else
|
55
|
+
raise "该参数不符合!"
|
56
|
+
end
|
57
|
+
|
58
|
+
result
|
17
59
|
end
|
18
60
|
|
19
61
|
#有define重复的问题等待解决
|
20
|
-
def self.run(root_dir)
|
62
|
+
def self.run(root_dir,type = 'r')
|
63
|
+
|
64
|
+
replace_type = toTypeNumber type
|
21
65
|
|
22
66
|
@@HEAD_FILE="#{root_dir}/codeObfuscation.h"
|
23
67
|
@@STRING_SYMBOL_FILE = "#{root_dir}/#{@@STRING_SYMBOL_FILE}"
|
@@ -39,14 +83,13 @@ module Obscure
|
|
39
83
|
file.puts "#define co_codeObfuscation_h"
|
40
84
|
file.puts "//confuse string at #{date.to_s}"
|
41
85
|
|
42
|
-
#beginTransition
|
43
86
|
symbol_file = File.open(@@STRING_SYMBOL_FILE).read
|
44
87
|
symbol_file.each_line do |line|
|
45
88
|
line_type = line.rstrip.split(":").first
|
46
89
|
line_content = line.rstrip.split(":").last
|
47
90
|
result = FiltSymbols.query(line_content)
|
48
91
|
if result.nil? || result.empty?
|
49
|
-
ramdom = ramdomString
|
92
|
+
ramdom = ramdomString line_type , replace_type
|
50
93
|
if line_type == "p"
|
51
94
|
result = FiltSymbols.query("set#{line_content.upcase_first_letter}")
|
52
95
|
if result.nil? || result.empty?
|
data/lib/codeobscure/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeobscure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: random-word
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
103
117
|
description: Code Obscure Tool.You can use it simplely
|
104
118
|
email:
|
105
119
|
- chengkai1853@163.com
|