Class: Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::UnitTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::Railgun::UnitTest
show all
- Includes:
- MockMagic
- Defined in:
- lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb
Constant Summary
collapse
- STOCK_DLLS =
DLLs we know should be available at the time of this writing, and DLLs that because of changes since then should be available
[
'kernel32',
'ntdll',
'user32',
'ws2_32',
'iphlpapi',
'advapi32',
'shell32',
'netapi32',
'crypt32',
] | Railgun::BUILTIN_DLLS
Constants included
from MockMagic
MockMagic::TLV_TYPE_NAMES
Instance Method Summary
collapse
Methods included from MockMagic
#make_mock_client, #mock_function_descriptions
Instance Method Details
#test_add_dll ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 69
def test_add_dll
railgun = Railgun.new(make_mock_client())
target_dll_name = 'discordia'
target_windows_name = 'C:\look\behind\you'
railgun.add_dll(target_dll_name, target_windows_name)
actual_dll = railgun.get_dll(target_dll_name);
assert_not_nil(actual_dll,
"add_dll should make a DLL accessible via get_dll")
assert_equal(actual_dll.dll_path, target_windows_name,
"add_dll should set a dll path when specified")
wrapper = railgun.send(target_dll_name.to_sym)
assert_same(wrapper._dll, actual_dll,
"railgun instance responds with dll wrapper of requested dll")
end
|
#test_add_function ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 135
def test_add_function
mock_function_descriptions.each do |func|
railgun = Railgun.new(make_mock_client(func[:platform]))
dll_name = func[:dll_name]
function_name = func[:name]
railgun.add_dll(dll_name)
railgun.add_function(dll_name, function_name, func[:return_type], func[:params])
assert(railgun.get_dll(dll_name).functions.has_key?(function_name),
"add_function should add a function to the DLL specified")
end
end
|
#test_const ⇒ Object
62
63
64
65
66
67
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 62
def test_const
railgun = Railgun.new(make_mock_client())
assert_equal(0, railgun.const('SUCCESS'),
"const should look up constants like SUCCESS")
end
|
#test_get_dll ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 101
def test_get_dll
railgun = Railgun.new(make_mock_client())
STOCK_DLLS.each do |dll_name|
dll = railgun.get_dll(dll_name)
assert(dll.instance_of?(DLL),
"get_dll should be able to return a value for dll #{dll_name}")
assert(dll.frozen?,
"Stock DLLs loaded lazily in get_dll should be frozen")
railgun.add_function(dll_name, '__lolz', 'VOID', [])
unfrozen_dll = railgun.get_dll(dll_name)
assert_not_same(dll, unfrozen_dll,
"add_function should create a local unfrozen instance that get_dll can then access")
assert(!unfrozen_dll.frozen?,
"add_function should create a local unfrozen instance that get_dll can then access")
railgun2 = Railgun.new(make_mock_client())
assert(!railgun2.get_dll(dll_name).functions.has_key?('__lolz'),
"functions added to one instance of railgun should not be accessible to others")
assert_not_same(!railgun2.get_dll(dll_name).functions, unfrozen_dll.functions,
"function hash should have been duplicated during unfreeze")
end
end
|
#test_known_dll_names ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 35
def test_known_dll_names
railgun = Railgun.new(make_mock_client())
dll_names = railgun.known_dll_names
assert_equal(dll_names.length, dll_names.uniq.length,
"known_dll_names should not have duplicates")
STOCK_DLLS.each do |name|
assert(dll_names.include?(name),
"known_dll_names should include #{name}")
end
end
|
#test_method_missing ⇒ Object
91
92
93
94
95
96
97
98
99
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 91
def test_method_missing
railgun = Railgun.new(make_mock_client())
STOCK_DLLS.each do |dll_name|
assert_nothing_raised do
railgun.send(dll_name.to_sym)
end
end
end
|