-
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.
Merge pull request #279 from smashery/change-password
Add more password changing structures and calls
- Loading branch information
Showing
13 changed files
with
405 additions
and
1 deletion.
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
31 changes: 31 additions & 0 deletions
31
lib/ruby_smb/dcerpc/samr/samr_change_password_user_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,31 @@ | ||
module RubySMB | ||
module Dcerpc | ||
module Samr | ||
|
||
# [3.1.5.10.1 SamrChangePasswordUser (Opnum 38)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/9699d8ca-e1a4-433c-a8c3-d7bebeb01476) | ||
class SamrChangePasswordUserRequest < BinData::Record | ||
attr_reader :opnum | ||
|
||
endian :little | ||
|
||
sampr_handle :user_handle | ||
ndr_uint8 :lm_present | ||
pencrypted_nt_owf_password :old_lm_encrypted_with_new_lm | ||
pencrypted_nt_owf_password :new_lm_encrypted_with_old_lm | ||
ndr_uint8 :nt_present | ||
pencrypted_nt_owf_password :old_nt_encrypted_with_new_nt | ||
pencrypted_nt_owf_password :new_nt_encrypted_with_old_nt | ||
ndr_uint8 :nt_cross_encryption_present | ||
pencrypted_nt_owf_password :new_nt_encrypted_with_new_nt | ||
ndr_uint8 :lm_cross_encryption_present | ||
pencrypted_nt_owf_password :new_lm_encrypted_with_new_nt | ||
|
||
def initialize_instance | ||
super | ||
@opnum = SAMR_CHANGE_PASSWORD_USER | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
lib/ruby_smb/dcerpc/samr/samr_change_password_user_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,21 @@ | ||
module RubySMB | ||
module Dcerpc | ||
module Samr | ||
|
||
# [3.1.5.10.1 SamrChangePasswordUser (Opnum 38)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/9699d8ca-e1a4-433c-a8c3-d7bebeb01476) | ||
class SamrChangePasswordUserResponse < BinData::Record | ||
attr_reader :opnum | ||
|
||
endian :little | ||
|
||
ndr_uint32 :error_status | ||
|
||
def initialize_instance | ||
super | ||
@opnum = SAMR_CHANGE_PASSWORD_USER | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
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
27 changes: 27 additions & 0 deletions
27
lib/ruby_smb/dcerpc/samr/samr_unicode_change_password_user2_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,27 @@ | ||
module RubySMB | ||
module Dcerpc | ||
module Samr | ||
|
||
# [3.1.5.10.3 SamrUnicodeChangePasswordUser2 (Opnum 55)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/acb3204a-da8b-478e-9139-1ea589edb880) | ||
class SamrUnicodeChangePasswordUser2Request < BinData::Record | ||
attr_reader :opnum | ||
|
||
endian :little | ||
|
||
prpc_unicode_string :server_name | ||
rpc_unicode_string :user_name | ||
psampr_encrypted_user_password :new_password_encrypted_with_old_nt | ||
pencrypted_nt_owf_password :old_nt_owf_password_encrypted_with_new_nt | ||
ndr_uint8 :lm_present | ||
psampr_encrypted_user_password :new_password_encrypted_with_old_lm | ||
pencrypted_nt_owf_password :old_lm_owf_password_encrypted_with_new_nt | ||
|
||
def initialize_instance | ||
super | ||
@opnum = SAMR_UNICODE_CHANGE_PASSWORD_USER2 | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
lib/ruby_smb/dcerpc/samr/samr_unicode_change_password_user2_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,21 @@ | ||
module RubySMB | ||
module Dcerpc | ||
module Samr | ||
|
||
# [3.1.5.10.3 SamrUnicodeChangePasswordUser2 (Opnum 55)](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/acb3204a-da8b-478e-9139-1ea589edb880) | ||
class SamrUnicodeChangePasswordUser2Response < BinData::Record | ||
attr_reader :opnum | ||
|
||
endian :little | ||
|
||
ndr_uint32 :error_status | ||
|
||
def initialize_instance | ||
super | ||
@opnum = SAMR_UNICODE_CHANGE_PASSWORD_USER2 | ||
end | ||
end | ||
|
||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
spec/lib/ruby_smb/dcerpc/samr/encrypted_nt_owf_password_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,10 @@ | ||
RSpec.describe RubySMB::Dcerpc::Samr::EncryptedNtOwfPassword do | ||
it 'Creates output key' do | ||
expect(described_class.to_output_key('ABCDEFG')).to eq ["40a09068442A188E"].pack('H*') | ||
expect(described_class.to_output_key('AAAAAAA')).to eq ["40A05028140A0482"].pack('H*') | ||
end | ||
|
||
it 'Encrypts a hash' do | ||
expect(described_class.encrypt_hash(hash: 'AAAAAAAAAAAAAAAA', key: 'BBBBBBBBBBBBBB')).to eq ["8cd90c3de08ecda28cd90c3de08ecda2"].pack('H*') | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
spec/lib/ruby_smb/dcerpc/samr/sampr_encrypted_user_password_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,9 @@ | ||
RSpec.describe RubySMB::Dcerpc::Samr::SamprEncryptedUserPassword do | ||
|
||
it 'Encrypts correctly' do | ||
password = 'newPassword1!' | ||
old_password_nt = 'AAAAAAAAAAAAAAAA' | ||
expected = ['c2cbe63dc0a3cda1baab695ce4f0352b774592b214a905796a6ba9fd30e0ffc56d60812bfd7f45420f5332922b50cfdcde3133e3e45c5eb6c16023006cb4ff7d41f54fa009a64fa66b00fa41094d7db6c4cc9a430a7ad43122047b696d934645974fee7551dcafac28c0869106417fd3fbfc34a87a56d6141aac2b6d134723f2224791b39749bc93f4405f78ba09dcd9b4d29e72ae0c873a8d468323793fffccc2a9d8dc4d975c42064208d898df71ef0889b2e5a9cfa6c8c2758eb15b6fdd332d6d7d2829f3a3bc2a7ecd7f87d1fd4aed25d93de6a7baf8e0247e2f5b831ca7646eef7a11e2f9410574707ef85c9db8cc125fb6254fe1e111a662006343299fcb8f8fb641cb1d188ff6e5c50334ca199603a93907093e6d35d80b2dade79360bc672870d29cdf5f80120ac53e9ce3c3718d0f8097cdae2318b8e27108fc1066491e5b034f55c1e8ff00a53d2eb7b0e0ffc10236a5a530795b84f33d66eb51388d6da112886c8ea482af0ec7e9c0a549a561244ee9185b5387b05d3c5e74d88e355aef22dab1d5039d0a0caa22437f6e520121ef5d21da729bb0cdee5cbb3b450bf1d0fcafad5ac518b0535628e2a96a2d0d2f8acd3e42147e700c2889cbc92c5533f1889b49d41c0ae9a05fc0a754060c0680296de5c712a3299cdd5c646582348fc2e32a68ae4fc2a3b91fb423adc617a20b28c1d6297f14a870329e6aa802d22ba97c'].pack('H*') | ||
expect(described_class.encrypt_password(password, old_password_nt)).to eq expected | ||
end | ||
end |
Oops, something went wrong.