CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex.rb
Views: 1903
1
# -*- coding: binary -*-
2
=begin
3
4
The Metasploit Rex library is provided under the 3-clause BSD license.
5
6
Copyright (c) 2005-2014, Rapid7, Inc.
7
All rights reserved.
8
9
Redistribution and use in source and binary forms, with or without modification,
10
are permitted provided that the following conditions are met:
11
12
* Redistributions of source code must retain the above copyright notice, this
13
list of conditions and the following disclaimer.
14
15
* Redistributions in binary form must reproduce the above copyright notice,
16
this list of conditions and the following disclaimer in the documentation
17
and/or other materials provided with the distribution.
18
19
* Neither the name of Rapid7, Inc. nor the names of its contributors may be
20
used to endorse or promote products derived from this software without
21
specific prior written permission.
22
23
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
27
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34
=end
35
36
module Rex
37
Root = File.join(File.expand_path(File.dirname(__FILE__)), 'rex')
38
LogSource = "rex"
39
end
40
41
#
42
# REX Gems
43
#
44
45
# Text manipulation library for things like generating random string
46
require 'rex/text'
47
# Library for Generating Randomized strings valid as Identifiers such as variable names
48
require 'rex/random_identifier'
49
# library for creating Powershell scripts for exploitation purposes
50
require 'rex/powershell'
51
# Library for processing and creating Zip compatible archives
52
require 'rex/zip'
53
# Library for parsing offline Windows Registry files
54
require 'rex/registry'
55
# Library for parsing Java serialized streams
56
require 'rex/java'
57
# Library for creating C-style Structs
58
require 'rex/struct2'
59
# Library for working with OLE
60
require 'rex/ole'
61
# Library for creating and/or parsing MIME messages
62
require 'rex/mime'
63
# Library for polymorphic encoders
64
require 'rex/encoder'
65
# Architecture subsystem
66
require 'rex/arch'
67
# Exploit Helper Library
68
require 'rex/exploitation'
69
70
# Generic classes
71
require 'rex/file'
72
73
# Thread safety and synchronization
74
require 'rex/sync'
75
76
# Assembly
77
require 'rex/assembly/nasm'
78
79
# Logging
80
require 'rex/logging/log_dispatcher'
81
82
# IO
83
require 'rex/io/stream'
84
require 'rex/io/stream_abstraction'
85
require 'rex/io/stream_server'
86
87
# Sockets
88
require 'rex/socket'
89
90
# Compatibility
91
require 'rex/compat'
92
93
# SSLScan
94
require 'rex/sslscan/scanner'
95
require 'rex/sslscan/result'
96
97
# Versions
98
require 'rex/version'
99
100
# Overload the Kernel.sleep() function to be thread-safe
101
Kernel.class_eval(<<-EOF, __FILE__, __LINE__ + 1)
102
def sleep(seconds=nil)
103
Rex::ThreadSafe.sleep(seconds)
104
end
105
EOF
106
107
# Overload the Kernel.select function to be thread-safe
108
Kernel.class_eval(<<-EOF, __FILE__, __LINE__ + 1)
109
def select(rfd = nil, wfd = nil, efd = nil, to = nil)
110
Rex::ThreadSafe.select(rfd, wfd, efd, to)
111
end
112
EOF
113
114
# Add the deprecated File.exists? method to call non-deprecated File.exist?
115
File.class_eval(<<-EOF, __FILE__, __LINE__ + 1)
116
def File.exists?(fname)
117
File.exist?(fname)
118
end
119
EOF
120
121