Changes from Brian Caswell
git-svn-id: file:///home/svn/incoming/trunk@3165 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
daa523ef70
commit
526b9f199d
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/ruby -I..
|
||||
|
||||
require 'test/unit'
|
||||
require 'rex'
|
||||
|
||||
require 'rex/exceptions.rb.ut'
|
||||
require 'rex/transformer.rb.ut'
|
||||
|
@ -9,8 +8,6 @@ require 'rex/text.rb.ut'
|
|||
require 'rex/evasion.rb.ut'
|
||||
require 'rex/file.rb.ut'
|
||||
|
||||
require 'rex/arch/x86'
|
||||
|
||||
require 'rex/encoding/xor/generic.rb.ut'
|
||||
require 'rex/encoding/xor/byte.rb.ut'
|
||||
require 'rex/encoding/xor/word.rb.ut'
|
||||
|
@ -27,8 +24,7 @@ require 'rex/socket/comm/local.rb.ut'
|
|||
require 'rex/socket/switch_board.rb.ut'
|
||||
require 'rex/socket/subnet_walker.rb.ut'
|
||||
|
||||
# require 'rex/proto'
|
||||
require 'rex/proto.ts'
|
||||
require 'rex/proto.rb.ts'
|
||||
|
||||
require 'rex/parser/arguments.rb.ut'
|
||||
|
||||
|
@ -37,53 +33,3 @@ require 'rex/ui/text/table.rb.ut'
|
|||
|
||||
require 'rex/exploitation/egghunter.rb.ut'
|
||||
require 'rex/exploitation/seh.rb.ut'
|
||||
|
||||
class Rex::TestSuite
|
||||
def self.suite
|
||||
suite = Test::Unit::TestSuite.new("Rex")
|
||||
|
||||
# General
|
||||
suite << Rex::Exceptions::UnitTest.suite
|
||||
suite << Rex::Transformer::UnitTest.suite
|
||||
suite << Rex::Text::UnitTest.suite
|
||||
suite << Rex::Evasion::UnitTest.suite
|
||||
suite << Rex::File::UnitTest.suite
|
||||
|
||||
# Arch
|
||||
suite << Rex::Arch::X86::UnitTest.suite
|
||||
|
||||
# Encoding
|
||||
suite << Rex::Encoding::Xor::Generic::UnitTest.suite
|
||||
suite << Rex::Encoding::Xor::Byte::UnitTest.suite
|
||||
suite << Rex::Encoding::Xor::Word::UnitTest.suite
|
||||
suite << Rex::Encoding::Xor::Dword::UnitTest.suite
|
||||
suite << Rex::Encoding::Xor::DwordAdditive::UnitTest.suite
|
||||
|
||||
# Sockets
|
||||
suite << Rex::Socket::UnitTest.suite
|
||||
suite << Rex::Socket::Parameters::UnitTest.suite
|
||||
suite << Rex::Socket::Tcp::UnitTest.suite
|
||||
suite << Rex::Socket::SslTcp::UnitTest.suite
|
||||
suite << Rex::Socket::TcpServer::UnitTest.suite
|
||||
suite << Rex::Socket::Udp::UnitTest.suite
|
||||
suite << Rex::Socket::Comm::Local::UnitTest.suite
|
||||
suite << Rex::Socket::SwitchBoard::UnitTest.suite
|
||||
suite << Rex::Socket::SubnetWalker::UnitTest.suite
|
||||
|
||||
# Protocols
|
||||
suite << Rex::Proto::TestSuite.suite
|
||||
|
||||
# Parsers
|
||||
suite << Rex::Parser::Arguments::UnitTest.suite
|
||||
|
||||
# Ui
|
||||
suite << Rex::Ui::Color::Table::UnitTest.suite
|
||||
suite << Rex::Ui::Text::Table::UnitTest.suite
|
||||
|
||||
# Exploitation
|
||||
suite << Rex::Exploitation::Egghunter::UnitTest.suite
|
||||
suite << Rex::Exploitation::Seh::UnitTest.suite
|
||||
|
||||
return suite;
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,11 +30,20 @@ class UUID
|
|||
)
|
||||
end
|
||||
|
||||
# Validate a text based UUID
|
||||
def self.is? (uuid_str)
|
||||
raise ArgumentError if !uuid_str
|
||||
if uuid_str.match(/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
# Convert a UUID in string format to the binary representation
|
||||
def self.uuid_pack (uuid_str)
|
||||
raise ArgumentError if uuid_str.length != 36
|
||||
raise ArgumentError if !self.is?(uuid_str)
|
||||
parts = uuid_str.split('-')
|
||||
raise ArgumentError if parts.length != 5
|
||||
[ parts[0].hex, parts[1].hex, parts[2].hex, parts[3].hex ].pack('Vvvn') + [ parts[4] ].pack('H*')
|
||||
end
|
||||
|
||||
|
|
|
@ -10,6 +10,15 @@ class Rex::Proto::DCERPC::UUID::UnitTest < Test::Unit::TestCase
|
|||
|
||||
Klass = Rex::Proto::DCERPC::UUID
|
||||
|
||||
def test_is_uuid
|
||||
assert(Klass.is?('afa8bd80-7d8a-11c9-bef4-08002b102989'), 'valid')
|
||||
assert(!Klass.is?('afa8bd80-7d8a-11c9-bef4-08002b10298'), 'too short')
|
||||
assert(!Klass.is?('afa8bd80-7d8a-11c9-bef4-08002b10298Z'), 'invalid character')
|
||||
assert(!Klass.is?('afa8bd80-7d8a-11c9-bef4a08002b10298a'), 'missing dash')
|
||||
assert(!Klass.is?('afa8bd80-7d8a-11c9-bef-a08002b10298a'), 'dash in wrong place')
|
||||
assert_raise(Rex::ArgumentError, 'pack - too short') { Klass.is?(nil) }
|
||||
end
|
||||
|
||||
def test_lookup
|
||||
assert_equal(Klass.uuid_by_name('MGMT'), 'afa8bd80-7d8a-11c9-bef4-08002b102989', 'uuid_by_name')
|
||||
assert_equal(Klass.vers_by_name('MGMT'), '2.0', 'vers_by_name')
|
||||
|
|
|
@ -19,12 +19,14 @@ class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
|||
"\r\n" +
|
||||
"Super body"
|
||||
|
||||
assert_equal(Klass::ParseCode::Partial, h.parse(req1))
|
||||
h.auto_cl = false
|
||||
h.parse(req1)
|
||||
assert_equal(Klass::ParseCode::Completed, h.parse(req1))
|
||||
assert_equal(true, h.completed?)
|
||||
assert_equal("Bird", h.headers['Foo'])
|
||||
assert_equal("text/html", h.headers['Accept'])
|
||||
assert_equal("Super body", h.body);
|
||||
assert_equal(req1, h.to_s)
|
||||
assert_equal(req1, h.to_s)
|
||||
end
|
||||
|
||||
def test_to_s
|
||||
|
|
|
@ -5,7 +5,7 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
|
|||
require 'test/unit'
|
||||
require 'rex/proto/http'
|
||||
|
||||
class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
||||
class Rex::Proto::Http::Request::UnitTest < Test::Unit::TestCase
|
||||
|
||||
Klass = Rex::Proto::Http::Request
|
||||
|
||||
|
@ -17,7 +17,7 @@ class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
|||
h.auto_cl = true
|
||||
|
||||
assert_equal(
|
||||
"GET / HTTP/1.0\r\n" +
|
||||
"GET / HTTP/1.1\r\n" +
|
||||
"Foo: Fishing\r\n" +
|
||||
"Content-Length: 0\r\n" +
|
||||
"Chicken: 47\r\n\r\n", h.to_s)
|
||||
|
|
|
@ -5,7 +5,7 @@ $:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..'))
|
|||
require 'test/unit'
|
||||
require 'rex/proto/http'
|
||||
|
||||
class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
||||
class Rex::Proto::Http::Response::UnitTest < Test::Unit::TestCase
|
||||
|
||||
Klass = Rex::Proto::Http::Response
|
||||
|
||||
|
@ -17,7 +17,7 @@ class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
|||
h.auto_cl = true
|
||||
|
||||
assert_equal(
|
||||
"HTTP/1.0 200 OK\r\n" +
|
||||
"HTTP/1.1 200 OK\r\n" +
|
||||
"Foo: Fishing\r\n" +
|
||||
"Content-Length: 0\r\n" +
|
||||
"Chicken: 47\r\n\r\n", h.to_s)
|
||||
|
@ -33,7 +33,7 @@ class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
|
|||
"Eat: Babies\r\n" +
|
||||
"\r\n")
|
||||
|
||||
assert_equal('404', h.code)
|
||||
assert_equal(404, h.code)
|
||||
assert_equal('File not found', h.message)
|
||||
assert_equal('1.0', h.proto)
|
||||
assert_equal("HTTP/1.0 404 File not found\r\n", h.cmd_string)
|
||||
|
|
|
@ -7,7 +7,7 @@ require 'rex/proto/smb'
|
|||
require 'rex/proto/dcerpc'
|
||||
require 'rex/socket'
|
||||
|
||||
class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
||||
class Rex::Proto::SMB::SimpleClient::UnitTest < Test::Unit::TestCase
|
||||
|
||||
Klass = Rex::Proto::SMB::SimpleClient
|
||||
|
||||
|
@ -23,11 +23,11 @@ class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
|||
FILE_OPEN = 0x01
|
||||
|
||||
|
||||
@@host = '192.168.0.219'
|
||||
@@host = '192.168.0.219'
|
||||
# @@host = '10.4.10.58'
|
||||
@@port = 445
|
||||
|
||||
def test_smb_open_share
|
||||
|
||||
user = 'SMBTest'
|
||||
pass = 'SMBTest'
|
||||
share = 'C$'
|
||||
|
@ -58,9 +58,29 @@ class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
|||
c.delete(filename)
|
||||
c.disconnect(share)
|
||||
|
||||
assert_equal(write_data, d)
|
||||
|
||||
c.connect('IPC$')
|
||||
rescue
|
||||
puts $!.to_s + $!.backtrace.join("\n")
|
||||
return
|
||||
end
|
||||
|
||||
s.close
|
||||
end
|
||||
|
||||
def test_smb_dcerpc
|
||||
s = Rex::Socket.create_tcp(
|
||||
'PeerHost' => @@host,
|
||||
'PeerPort' => @@port
|
||||
)
|
||||
|
||||
c = Klass.new(s, true)
|
||||
c.client.evasion_level = 0
|
||||
|
||||
user = ''
|
||||
pass = ''
|
||||
|
||||
begin
|
||||
c.login('*SMBSERVER', user, pass)
|
||||
c.connect('IPC$')
|
||||
f = c.create_pipe('\BROWSER')
|
||||
|
||||
bind, ctx = DCERPCPacket.make_bind_fake_multi(
|
||||
|
@ -93,16 +113,12 @@ class Rex::Proto::SMB::Client::UnitTest < Test::Unit::TestCase
|
|||
assert_equal(r.type, 12)
|
||||
assert_equal(r.ack_result[ctx-0], 0)
|
||||
assert_equal(r.ack_result[ctx-1], 2)
|
||||
|
||||
|
||||
rescue
|
||||
puts $!.to_s + $!.backtrace.join("\n")
|
||||
return
|
||||
end
|
||||
rescue
|
||||
puts $!.to_s + $!.backtrace.join("\n")
|
||||
return
|
||||
end
|
||||
|
||||
s.close
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue