codeobscure 0.1.2 → 0.1.3
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/filtsymbols.rb +19 -6
- data/lib/codeobscure/funclist.rb +0 -1
- data/lib/codeobscure/obscure.rb +4 -30
- data/lib/codeobscure/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f0fed590b8e0d0a7cc9ddd175ad10e9cd55835d
|
4
|
+
data.tar.gz: 3deda2e09f16a629884f683cf58977aba8663ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d34946f8bf2471ea101f88796b773ba4d971c3736c3a5ffa6449bbb78ed30a4088ad0e7466fe987a95bf9636f851f89b0c311231d10fd9496ef801dad47f61b8
|
7
|
+
data.tar.gz: 32582c1c8977f7c7d081421ee4157f8f505846edd1a588e3df2f6caaf703dd127788759eeaea67c4f393935d2e78ef9f52a18b37cd9a219f2b8d7791b5ee337c
|
@@ -1,26 +1,41 @@
|
|
1
1
|
require_relative "funclist.rb"
|
2
|
+
require 'sqlite3'
|
2
3
|
require "colorize"
|
3
4
|
module FiltSymbols
|
4
5
|
@@filt_db_path = "#{File.expand_path '../../..', __FILE__}/filtSymbols"
|
5
6
|
@@table_name = "symbols"
|
6
7
|
@@key_words = ["interface","NSInteger","BOOL","Class","free","M_PI_2","abort","change","top","bottom","NSUIntegerMax","intoString"]
|
7
8
|
|
9
|
+
def self.open_db
|
10
|
+
if @@db.nil? || @@db.closed?
|
11
|
+
@@db = SQLite3::Database.new(@@filt_db_path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
def self.createTable
|
9
|
-
|
10
|
-
|
16
|
+
open_db
|
17
|
+
if @@db
|
18
|
+
@@db.execute "create table if not exists #{@@table_name}(src text,PRIMARY KEY (src));"
|
11
19
|
end
|
12
20
|
end
|
13
21
|
|
14
22
|
def self.insertValue(line)
|
15
|
-
|
23
|
+
open_db
|
24
|
+
@@db.execute "insert or ignore into #{@@table_name} values('#{line}');"
|
16
25
|
end
|
17
26
|
|
18
27
|
def self.query(line)
|
19
|
-
|
28
|
+
open_db
|
29
|
+
results = []
|
30
|
+
@@db.execute "select * from #{@@table_name} where src='#{line}';" do |row|
|
31
|
+
results << row
|
32
|
+
end
|
33
|
+
results
|
20
34
|
end
|
21
35
|
|
22
36
|
def self.loadFiltSymbols(path)
|
23
37
|
|
38
|
+
@@db = SQLite3::Database.new(@@filt_db_path)
|
24
39
|
createTable
|
25
40
|
|
26
41
|
funclist_path = FuncList.genFuncList path , "h" , false
|
@@ -40,8 +55,6 @@ module FiltSymbols
|
|
40
55
|
`rm -f #{funclist_path}`
|
41
56
|
end
|
42
57
|
|
43
|
-
`sqlite3 #{@@filt_db_path} .dump`
|
44
|
-
|
45
58
|
end
|
46
59
|
|
47
60
|
end
|
data/lib/codeobscure/funclist.rb
CHANGED
data/lib/codeobscure/obscure.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'filtsymbols.rb'
|
2
|
+
require 'sqlite3'
|
2
3
|
|
3
4
|
class String
|
4
5
|
def upcase_first_letter
|
@@ -8,27 +9,9 @@ end
|
|
8
9
|
|
9
10
|
module Obscure
|
10
11
|
|
11
|
-
|
12
|
-
@@TABLENAME="symbols"
|
13
|
-
@@SYMBOL_DB_FILE="symbols"
|
14
12
|
@@STRING_SYMBOL_FILE="func.list"
|
15
13
|
@@IGNORE_NAME="ignoresymbols"
|
16
14
|
|
17
|
-
#维护数据库方便日后作排重
|
18
|
-
def self.createTable
|
19
|
-
if !File.exist? @@SYMBOL_DB_FILE
|
20
|
-
`echo "create table #{@@TABLENAME}(src text, des text,PRIMARY KEY (src));" | sqlite3 #{@@SYMBOL_DB_FILE}`
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.insertValue(line,ramdom)
|
25
|
-
`echo "insert or ignore into #{@@TABLENAME} values('#{line}' ,'#{ramdom}');" | sqlite3 #{@@SYMBOL_DB_FILE}`
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.query(line)
|
29
|
-
`echo "select * from #{@@TABLENAME} where src='#{line}';" | sqlite3 #{@@SYMBOL_DB_FILE}`
|
30
|
-
end
|
31
|
-
|
32
15
|
def self.ramdomString
|
33
16
|
`openssl rand -base64 64 | tr -cd 'a-zA-Z' |head -c 16`
|
34
17
|
end
|
@@ -37,30 +20,26 @@ module Obscure
|
|
37
20
|
def self.run(root_dir)
|
38
21
|
|
39
22
|
@@HEAD_FILE="#{root_dir}/codeObfuscation.h"
|
40
|
-
@@SYMBOL_DB_FILE = "#{root_dir}/#{@@SYMBOL_DB_FILE}"
|
41
23
|
@@STRING_SYMBOL_FILE = "#{root_dir}/#{@@STRING_SYMBOL_FILE}"
|
42
24
|
|
43
25
|
ignore_symbols = []
|
44
26
|
ignore_path = "#{root_dir}/#{@@IGNORE_NAME}"
|
45
27
|
if File.exist? ignore_path
|
46
28
|
ignore_content = File.read ignore_path
|
47
|
-
ignore_symbols = ignore_content.gsub(" " , "").split "
|
29
|
+
ignore_symbols = ignore_content.gsub(" " , "").split ","
|
48
30
|
end
|
49
31
|
|
50
|
-
if File.exist? @@SYMBOL_DB_FILE
|
51
|
-
`rm -f #{@@SYMBOL_DB_FILE}`
|
52
|
-
end
|
53
32
|
if File.exists? @@HEAD_FILE
|
54
33
|
`rm -f #{@@HEAD_FILE}`
|
55
34
|
end
|
56
|
-
|
57
|
-
|
35
|
+
|
58
36
|
date = `date`
|
59
37
|
file = File.new @@HEAD_FILE , 'w'
|
60
38
|
file.puts "#ifndef co_codeObfuscation_h"
|
61
39
|
file.puts "#define co_codeObfuscation_h"
|
62
40
|
file.puts "//confuse string at #{date.to_s}"
|
63
41
|
|
42
|
+
#beginTransition
|
64
43
|
symbol_file = File.open(@@STRING_SYMBOL_FILE).read
|
65
44
|
symbol_file.each_line do |line|
|
66
45
|
line_type = line.rstrip.split(":").first
|
@@ -68,7 +47,6 @@ module Obscure
|
|
68
47
|
result = FiltSymbols.query(line_content)
|
69
48
|
if result.nil? || result.empty?
|
70
49
|
ramdom = ramdomString
|
71
|
-
insertValue line_content , ramdom
|
72
50
|
if line_type == "p"
|
73
51
|
result = FiltSymbols.query("set#{line_content.upcase_first_letter}")
|
74
52
|
if result.nil? || result.empty?
|
@@ -89,10 +67,6 @@ module Obscure
|
|
89
67
|
file.puts "#endif"
|
90
68
|
file.close
|
91
69
|
|
92
|
-
`sqlite3 #{@@SYMBOL_DB_FILE} .dump`
|
93
|
-
if File.exist? @@SYMBOL_DB_FILE
|
94
|
-
`rm -f #{@@SYMBOL_DB_FILE}`
|
95
|
-
end
|
96
70
|
if File.exist? @@STRING_SYMBOL_FILE
|
97
71
|
`rm -f #{@@STRING_SYMBOL_FILE}`
|
98
72
|
end
|
data/lib/codeobscure/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaich
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 1.0.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: sqlite3
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
89
103
|
description: Code Obscure Tool.You can use it simplely
|
90
104
|
email:
|
91
105
|
- chengkai1853@163.com
|