autoit-obfuscator 1.5.0
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 +7 -0
- data/LICENSE +203 -0
- data/README.md +1151 -0
- data/lib/autoit-obfuscator/client.rb +104 -0
- data/lib/autoit-obfuscator/http.rb +85 -0
- data/lib/autoit-obfuscator/version.rb +5 -0
- data/lib/autoit-obfuscator.rb +5 -0
- metadata +48 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "base64"
|
|
4
|
+
require "json"
|
|
5
|
+
require "zlib"
|
|
6
|
+
|
|
7
|
+
class AutoItObfuscator
|
|
8
|
+
API_URL = "https://www.pelock.com/api/autoit-obfuscator/v1"
|
|
9
|
+
ERROR_SUCCESS = 0
|
|
10
|
+
ERROR_INPUT_SIZE = 1
|
|
11
|
+
ERROR_INPUT = 2
|
|
12
|
+
ERROR_PARSING = 3
|
|
13
|
+
ERROR_OBFUSCATION = 4
|
|
14
|
+
ERROR_OUTPUT = 5
|
|
15
|
+
USER_AGENT = "PELock AutoIt Obfuscator"
|
|
16
|
+
|
|
17
|
+
# All strategy flags default to false (same as the JavaScript / PHP SDKs).
|
|
18
|
+
FLAG_PARAMS = {
|
|
19
|
+
anti_debug: "anti_debug",
|
|
20
|
+
anti_vm: "anti_vm",
|
|
21
|
+
anti_sandbox: "anti_sandbox",
|
|
22
|
+
anti_emulator: "anti_emulator",
|
|
23
|
+
random_integers: "random_bucket_integers",
|
|
24
|
+
random_characters: "random_bucket_characters",
|
|
25
|
+
random_anti_regex: "random_bucket_anti_regex",
|
|
26
|
+
random_arrays: "random_bucket_arrays",
|
|
27
|
+
random_arrays_multidimensional: "random_bucket_arrays_multidimensional",
|
|
28
|
+
random_functions: "random_bucket_functions",
|
|
29
|
+
random_autostarted: "random_bucket_autostart",
|
|
30
|
+
mix_code_flow: "mix_code_flow",
|
|
31
|
+
rename_variables: "rename_variables",
|
|
32
|
+
rename_functions: "rename_functions",
|
|
33
|
+
rename_function_calls: "rename_function_calls",
|
|
34
|
+
shuffle_functions: "shuffle_functions",
|
|
35
|
+
resolve_constants: "resolve_const",
|
|
36
|
+
crypt_numbers: "crypt_numbers",
|
|
37
|
+
split_strings: "split_strings",
|
|
38
|
+
modify_strings: "modify_strings",
|
|
39
|
+
crypt_strings: "crypt_strings",
|
|
40
|
+
insert_ternary_operators: "insert_ternary_operators"
|
|
41
|
+
}.freeze
|
|
42
|
+
|
|
43
|
+
attr_accessor :enable_compression, *FLAG_PARAMS.keys
|
|
44
|
+
|
|
45
|
+
def initialize(api_key = nil)
|
|
46
|
+
@api_key = api_key
|
|
47
|
+
@enable_compression = false
|
|
48
|
+
FLAG_PARAMS.each_key { |name| instance_variable_set("@#{name}", false) }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def login(return_as_object = true)
|
|
52
|
+
post_request({ "command" => "login" }, return_as_object)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def obfuscate_script_file(script_file_path, return_as_object = true)
|
|
56
|
+
source = File.read(script_file_path, encoding: "UTF-8")
|
|
57
|
+
return nil if source.nil? || source.empty?
|
|
58
|
+
|
|
59
|
+
obfuscate_script_source(source, return_as_object)
|
|
60
|
+
rescue StandardError
|
|
61
|
+
nil
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def obfuscate_script_source(script_source, return_as_object = true)
|
|
65
|
+
post_request({ "command" => "obfuscate", "source" => script_source }, return_as_object)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def post_request(params_array, return_as_object)
|
|
71
|
+
params = params_array.dup
|
|
72
|
+
params["key"] = @api_key unless @api_key.nil? || @api_key.to_s.empty?
|
|
73
|
+
|
|
74
|
+
FLAG_PARAMS.each do |name, key|
|
|
75
|
+
params[key] = "1" if instance_variable_get("@#{name}")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if @enable_compression && params["source"]
|
|
79
|
+
params["source"] = Base64.strict_encode64(Zlib::Deflate.deflate(params["source"], 9))
|
|
80
|
+
params["compression"] = "1"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
body = Http.post_multipart(API_URL, params, user_agent: USER_AGENT)
|
|
84
|
+
return nil if body.nil? || body.empty?
|
|
85
|
+
|
|
86
|
+
result = Http.parse_json(body)
|
|
87
|
+
return nil if result.nil?
|
|
88
|
+
|
|
89
|
+
depacked = false
|
|
90
|
+
if @enable_compression && result["error"] == ERROR_SUCCESS && result["output"]
|
|
91
|
+
begin
|
|
92
|
+
result["output"] = Zlib::Inflate.inflate(Base64.decode64(result["output"]))
|
|
93
|
+
depacked = true
|
|
94
|
+
rescue StandardError
|
|
95
|
+
return nil
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
return result if return_as_object
|
|
100
|
+
return JSON.generate(result) if depacked
|
|
101
|
+
|
|
102
|
+
body
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "net/http"
|
|
5
|
+
require "openssl"
|
|
6
|
+
require "securerandom"
|
|
7
|
+
require "uri"
|
|
8
|
+
|
|
9
|
+
class AutoItObfuscator
|
|
10
|
+
# Stdlib HTTP helper. Multipart for API form posts / file uploads; urlencoded when needed.
|
|
11
|
+
module Http
|
|
12
|
+
class << self
|
|
13
|
+
def post_multipart(url, fields, user_agent:, files: {})
|
|
14
|
+
boundary = "----PELock#{SecureRandom.hex(16)}"
|
|
15
|
+
body = build_multipart(fields, files, boundary)
|
|
16
|
+
request(url, body, user_agent, "multipart/form-data; boundary=#{boundary}")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def post_urlencoded(url, fields, user_agent:)
|
|
20
|
+
pairs = []
|
|
21
|
+
fields.each do |key, value|
|
|
22
|
+
next if value.nil?
|
|
23
|
+
|
|
24
|
+
pairs << [key.to_s, normalize_form_value(value)]
|
|
25
|
+
end
|
|
26
|
+
request(url, URI.encode_www_form(pairs), user_agent, "application/x-www-form-urlencoded")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def parse_json(body)
|
|
30
|
+
return nil if body.nil? || body.to_s.empty?
|
|
31
|
+
|
|
32
|
+
JSON.parse(body)
|
|
33
|
+
rescue JSON::ParserError
|
|
34
|
+
nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def request(url, body, user_agent, content_type)
|
|
38
|
+
uri = URI.parse(url)
|
|
39
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
40
|
+
http.use_ssl = uri.scheme == "https"
|
|
41
|
+
http.open_timeout = 30
|
|
42
|
+
http.read_timeout = 180
|
|
43
|
+
req = Net::HTTP::Post.new(uri.request_uri)
|
|
44
|
+
req["User-Agent"] = user_agent
|
|
45
|
+
req["Content-Type"] = content_type
|
|
46
|
+
req.body = body
|
|
47
|
+
http.request(req).body
|
|
48
|
+
rescue StandardError
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def build_multipart(fields, files, boundary)
|
|
53
|
+
body = String.new(encoding: Encoding::ASCII_8BIT)
|
|
54
|
+
fields.each do |name, value|
|
|
55
|
+
next if value.nil?
|
|
56
|
+
|
|
57
|
+
body << "--#{boundary}\r\n"
|
|
58
|
+
body << "Content-Disposition: form-data; name=\"#{name}\"\r\n\r\n"
|
|
59
|
+
body << value.to_s.dup.force_encoding(Encoding::UTF_8).b
|
|
60
|
+
body << "\r\n"
|
|
61
|
+
end
|
|
62
|
+
files.each do |name, file|
|
|
63
|
+
filename = file[:filename] || File.basename(file[:path].to_s)
|
|
64
|
+
content = file[:content] || File.binread(file[:path])
|
|
65
|
+
content_type = file[:content_type] || "application/octet-stream"
|
|
66
|
+
body << "--#{boundary}\r\n"
|
|
67
|
+
body << "Content-Disposition: form-data; name=\"#{name}\"; filename=\"#{filename}\"\r\n"
|
|
68
|
+
body << "Content-Type: #{content_type}\r\n\r\n"
|
|
69
|
+
body << content.b
|
|
70
|
+
body << "\r\n"
|
|
71
|
+
end
|
|
72
|
+
body << "--#{boundary}--\r\n"
|
|
73
|
+
body
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def normalize_form_value(value)
|
|
77
|
+
case value
|
|
78
|
+
when true then "1"
|
|
79
|
+
when false then "0"
|
|
80
|
+
else value.to_s
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: autoit-obfuscator
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.5.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bartosz Wójcik
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
email:
|
|
13
|
+
- support@pelock.com
|
|
14
|
+
executables: []
|
|
15
|
+
extensions: []
|
|
16
|
+
extra_rdoc_files: []
|
|
17
|
+
files:
|
|
18
|
+
- LICENSE
|
|
19
|
+
- README.md
|
|
20
|
+
- lib/autoit-obfuscator.rb
|
|
21
|
+
- lib/autoit-obfuscator/client.rb
|
|
22
|
+
- lib/autoit-obfuscator/http.rb
|
|
23
|
+
- lib/autoit-obfuscator/version.rb
|
|
24
|
+
homepage: https://www.pelock.com/products/autoit-obfuscator
|
|
25
|
+
licenses:
|
|
26
|
+
- Apache-2.0
|
|
27
|
+
metadata:
|
|
28
|
+
homepage_uri: https://www.pelock.com/products/autoit-obfuscator
|
|
29
|
+
source_code_uri: https://github.com/PELock/AutoIt-Obfuscator-Ruby
|
|
30
|
+
bug_tracker_uri: https://www.pelock.com
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: 2.7.0
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 4.0.20
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: AutoIt Obfuscator Web API Ruby SDK
|
|
48
|
+
test_files: []
|