-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Land #270, Adding NetrWkstaUserEnum implementation
Adding NetrWkstaUserEnum implementation
- Loading branch information
Showing
11 changed files
with
372 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_request.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module RubySMB | ||
module Dcerpc | ||
module Wkssvc | ||
|
||
# [3.2.4.3 NetrWkstaUserEnum (Opnum 2)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/4af41d6f-b800-4de1-af5b-0b15a85f8e04) | ||
class NetrWkstaUserEnumRequest < BinData::Record | ||
attr_reader :opnum | ||
|
||
endian :little | ||
|
||
wkssvc_identify_handle :server_name | ||
wksta_user_enum_structure :user_info | ||
ndr_uint32 :preferred_max_length, initial_value: 0xFFFFFFFF | ||
ndr_uint32_ptr :result_handle, initial_value: 0 | ||
|
||
def initialize_instance | ||
super | ||
@opnum = NETR_WKSTA_USER_ENUM | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
25 changes: 25 additions & 0 deletions
25
lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_response.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module RubySMB | ||
module Dcerpc | ||
module Wkssvc | ||
|
||
# [3.2.4.3 NetrWkstaUserEnum (Opnum 2)](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wkst/4af41d6f-b800-4de1-af5b-0b15a85f8e04) | ||
class NetrWkstaUserEnumResponse < BinData::Record | ||
attr_reader :opnum | ||
|
||
endian :little | ||
|
||
wksta_user_enum_structure :user_info | ||
ndr_uint32_ptr :total_entries | ||
ndr_uint32_ptr :result_handle | ||
ndr_uint32 :error_status | ||
|
||
def initialize_instance | ||
super | ||
@opnum = NETR_WKSTA_USER_ENUM | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
8 changes: 0 additions & 8 deletions
8
spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_get_info_request_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_identity_handle.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
RSpec.describe RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle do | ||
subject(:packet) { described_class.new } | ||
|
||
it 'is a Ndr::NdrWideStringPtr' do | ||
expect(packet).to be_a(RubySMB::Dcerpc::Ndr::NdrWideStringPtr) | ||
end | ||
end |
71 changes: 71 additions & 0 deletions
71
spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_request_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
RSpec.describe RubySMB::Dcerpc::Wkssvc::NetrWkstaUserEnumRequest do | ||
subject(:packet) { described_class.new } | ||
|
||
def random_str(nb = 8) | ||
nb.times.map { rand('a'.ord..'z'.ord).chr }.join | ||
end | ||
|
||
it { is_expected.to respond_to :server_name } | ||
it { is_expected.to respond_to :user_info } | ||
it { is_expected.to respond_to :preferred_max_length } | ||
it { is_expected.to respond_to :result_handle } | ||
it { is_expected.to respond_to :opnum } | ||
|
||
it 'is little endian' do | ||
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little | ||
end | ||
it 'is a BinData::Record' do | ||
expect(packet).to be_a(BinData::Record) | ||
end | ||
describe '#server_name' do | ||
it 'is a WkssvcIdentifyHandle structure' do | ||
expect(packet.server_name).to be_a RubySMB::Dcerpc::Wkssvc::WkssvcIdentifyHandle | ||
end | ||
end | ||
describe '#user_info' do | ||
it 'is a WkstaUserEnumStructure structure' do | ||
expect(packet.user_info).to be_a RubySMB::Dcerpc::Wkssvc::WkstaUserEnumStructure | ||
end | ||
end | ||
describe '#preferred_max_length' do | ||
it 'is a NdrUint32 structure' do | ||
expect(packet.preferred_max_length).to be_a RubySMB::Dcerpc::Ndr::NdrUint32 | ||
end | ||
|
||
it 'has a default value of 0xFFFFFFFF' do | ||
expect(packet.preferred_max_length).to eq(0xFFFFFFFF) | ||
end | ||
end | ||
describe '#result_handle' do | ||
it 'is a NdrUint32Ptr structure' do | ||
expect(packet.result_handle).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr | ||
end | ||
|
||
it 'has a default value of 0' do | ||
expect(packet.result_handle).to eq(0) | ||
end | ||
end | ||
describe '#initialize_instance' do | ||
it 'sets #opnum to NETR_WKSTA_USER_ENUM constant' do | ||
expect(packet.opnum).to eq(RubySMB::Dcerpc::Wkssvc::NETR_WKSTA_USER_ENUM) | ||
end | ||
end | ||
it 'reads itself' do | ||
packet = described_class.new( | ||
server_name: 'TestServer', | ||
user_info: { | ||
level: RubySMB::Dcerpc::Wkssvc::WKSTA_USER_INFO_0, | ||
info: { | ||
wkui0_entries_read: 1, | ||
wkui0_buffer: [{ | ||
wkui0_username: random_str | ||
}], | ||
}, | ||
}, | ||
preferred_max_length: 0xFFFFFFFF, | ||
result_handle: 0 | ||
) | ||
binary = packet.to_binary_s | ||
expect(described_class.read(binary)).to eq(packet) | ||
end | ||
end |
65 changes: 65 additions & 0 deletions
65
spec/lib/ruby_smb/dcerpc/wkssvc/netr_wksta_user_enum_response_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
RSpec.describe RubySMB::Dcerpc::Wkssvc::NetrWkstaUserEnumResponse do | ||
subject(:packet) { described_class.new } | ||
|
||
def random_str(nb = 8) | ||
nb.times.map { rand('a'.ord..'z'.ord).chr }.join | ||
end | ||
|
||
it { is_expected.to respond_to :user_info } | ||
it { is_expected.to respond_to :total_entries } | ||
it { is_expected.to respond_to :result_handle } | ||
it { is_expected.to respond_to :error_status } | ||
|
||
it 'is little endian' do | ||
expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little | ||
end | ||
it 'is a BinData::Record' do | ||
expect(packet).to be_a(BinData::Record) | ||
end | ||
describe '#user_info' do | ||
it 'is a WkstaUserEnumStructure structure' do | ||
expect(packet.user_info).to be_a RubySMB::Dcerpc::Wkssvc::WkstaUserEnumStructure | ||
end | ||
end | ||
describe '#total_entries' do | ||
it 'is a NdrUint32Ptr structure' do | ||
expect(packet.total_entries).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr | ||
end | ||
end | ||
describe '#result_handle' do | ||
it 'is a NdrUint32Ptr structure' do | ||
expect(packet.result_handle).to be_a RubySMB::Dcerpc::Ndr::NdrUint32Ptr | ||
end | ||
end | ||
describe '#error_status' do | ||
it 'is a NdrUint32 structure' do | ||
expect(packet.error_status).to be_a RubySMB::Dcerpc::Ndr::NdrUint32 | ||
end | ||
end | ||
describe '#initialize_instance' do | ||
it 'sets #opnum to NETR_WKSTA_USER_ENUM constant' do | ||
expect(packet.opnum).to eq(RubySMB::Dcerpc::Wkssvc::NETR_WKSTA_USER_ENUM) | ||
end | ||
end | ||
it 'reads itself' do | ||
packet = described_class.new( | ||
user_info: { | ||
level: RubySMB::Dcerpc::Wkssvc::WKSTA_USER_INFO_1, | ||
info: { | ||
wkui1_entries_read: 1, | ||
wkui1_buffer: [{ | ||
wkui1_username: random_str, | ||
wkui1_logon_domain: random_str, | ||
wkui1_oth_domains: random_str, | ||
wkui1_logon_server: random_str | ||
}], | ||
}, | ||
}, | ||
total_entries: 1, | ||
result_handle: 0, | ||
error_status: 0 | ||
) | ||
binary = packet.to_binary_s | ||
expect(described_class.read(binary)).to eq(packet) | ||
end | ||
end |
Oops, something went wrong.