Add specs for TRANSACTION2 helper methods
parent
bece2e7088
commit
a204b550d2
|
@ -0,0 +1,68 @@
|
|||
# -*- coding:binary -*-
|
||||
require 'spec_helper'
|
||||
|
||||
require 'msf/core'
|
||||
require 'msf/core/exploit/smb/server/share'
|
||||
require 'rex/proto/smb/constants'
|
||||
|
||||
describe Msf::Exploit::Remote::SMB::Server::Share do
|
||||
|
||||
subject(:mod) do
|
||||
mod = Msf::Exploit.new
|
||||
mod.extend described_class
|
||||
mod.send(:initialize)
|
||||
|
||||
mod
|
||||
end
|
||||
|
||||
let(:unicode_path) { "\x5c\x00\x74\x00\x65\x00\x73\x00\x74\x00\x2e\x00\x65\x00\x78\x00\x65\x00\x00\x00" }
|
||||
let(:normalized_path) { '\\test.exe' }
|
||||
let(:ascii_path) { 'test.exe' }
|
||||
let(:broken_path) { 'ts.x' }
|
||||
let(:wildcard_filename) { '\\*.exe' }
|
||||
let(:wildcard_ext) { '\\test.*' }
|
||||
let(:alternate_wildcard_filename) { '\\<.exe' }
|
||||
|
||||
before(:each) do
|
||||
mod.lo = 0
|
||||
mod.hi = 0
|
||||
mod.share = 'test'
|
||||
mod.path_name = "\\"
|
||||
mod.file_name = 'test.exe'
|
||||
mod.file_contents = 'metasploit'
|
||||
end
|
||||
|
||||
describe "#normalize_path" do
|
||||
context "when unicode path" do
|
||||
it "returns the normalized path" do
|
||||
expect(mod.normalize_path(unicode_path)).to eq(normalized_path)
|
||||
end
|
||||
end
|
||||
|
||||
context "when ascii path" do
|
||||
it "returns a broken path" do
|
||||
expect(mod.normalize_path(ascii_path)).to eq(broken_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#smb_expand" do
|
||||
context "when * wildcard" do
|
||||
it "expands the filename" do
|
||||
expect(mod.smb_expand(wildcard_filename)).to eq(normalized_path)
|
||||
end
|
||||
|
||||
it "doesn't expand the extension" do
|
||||
expect(mod.smb_expand(wildcard_ext)).to eq('\\test.*')
|
||||
end
|
||||
end
|
||||
|
||||
context "when < wildcard" do
|
||||
it "expands the filename" do
|
||||
expect(mod.smb_expand(alternate_wildcard_filename)).to eq(normalized_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue