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', 'crypt32',
'iphlpapi', 'netapi32', 'advapi32', 'shell32'] | 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 60
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 118
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
53
54
55
56
57
58
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 53
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 92
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")
end
end
|
#test_known_dll_names ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 26
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
82
83
84
85
86
87
88
89
90
|
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/railgun.rb.ut.rb', line 82
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
|