Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/extensions/evasion/obfuscation/minify.rb
1154 views
1
#
2
# Copyright (c) 2006-2025 Wade Alcorn - [email protected]
3
# Browser Exploitation Framework (BeEF) - https://beefproject.com
4
# See the file 'doc/COPYING' for copying permission
5
#
6
module BeEF
7
module Extension
8
module Evasion
9
require 'uglifier'
10
class Minify
11
include Singleton
12
13
def need_bootstrap?
14
false
15
end
16
17
def execute(input, config)
18
opts = {
19
output: {
20
comments: :none
21
},
22
compress: {
23
# show warnings in debug mode
24
warnings: (config.get('beef.debug') ? true : false),
25
# remove dead code
26
dead_code: true,
27
# remove all beef.debug calls (console.log wrapper) unless client debugging is enabled
28
pure_funcs: (config.get('beef.client_debug') ? [] : ['beef.debug']),
29
# remove all console.log calls unless client debugging is enabled
30
drop_console: (config.get('beef.client_debug') ? false : true)
31
}
32
}
33
output = Uglifier.compile(input, opts)
34
print_debug '[OBFUSCATION - Minifier] JavaScript has been minified'
35
output
36
rescue StandardError => e
37
print_error "[OBFUSCATION - Minifier] JavaScript couldn't be minified: #{e.messsage}"
38
input
39
end
40
end
41
end
42
end
43
end
44
45