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
|
# File 'lib/codeobscure/obscure.rb', line 36
def self.run(root_dir)
@@HEAD_FILE="#{root_dir}/codeObfuscation.h"
@@SYMBOL_DB_FILE = "#{root_dir}/#{@@SYMBOL_DB_FILE}"
@@STRING_SYMBOL_FILE = "#{root_dir}/#{@@STRING_SYMBOL_FILE}"
if File.exist? @@SYMBOL_DB_FILE
`rm -f #{@@SYMBOL_DB_FILE}`
end
if File.exists? @@HEAD_FILE
`rm -f #{@@HEAD_FILE}`
end
createTable
date = `date`
file = File.new @@HEAD_FILE , 'w'
file.puts "#ifndef co_codeObfuscation_h"
file.puts "#define co_codeObfuscation_h"
file.puts "//confuse string at #{date.to_s}"
symbol_file = File.open(@@STRING_SYMBOL_FILE).read
symbol_file.each_line do |line|
line_type = line.rstrip.split(":").first
line_content = line.rstrip.split(":").last
result = FiltSymbols.query(line_content)
if result.nil? || result.empty?
ramdom = ramdomString
insertValue line_content , ramdom
if line_type == "p"
result = FiltSymbols.query("set#{line_content.upcase_first_letter}")
if result.nil? || result.empty?
file.puts "#define #{line_content} #{ramdom}"
file.puts "#define _#{line_content} _#{ramdom}"
file.puts "#define set#{line_content.upcase_first_letter} set#{ramdom.upcase_first_letter}"
end
else
file.puts "#define #{line_content} #{ramdom}"
end
end
end
file.puts "#endif"
file.close
`sqlite3 #{@@SYMBOL_DB_FILE} .dump`
if File.exist? @@SYMBOL_DB_FILE
`rm -f #{@@SYMBOL_DB_FILE}`
end
if File.exist? @@STRING_SYMBOL_FILE
`rm -f #{@@STRING_SYMBOL_FILE}`
end
@@HEAD_FILE
end
|