mirror of
https://github.com/samba-team/samba.git
synced 2025-02-25 17:57:42 +03:00
python:samba/netcmd/domain: make use of the generic arcfour_encrypt() and string_to_byte_array() functions
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11699 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
This commit is contained in:
parent
d5423feb4b
commit
452234b7bc
@ -60,7 +60,7 @@ from samba.upgrade import upgrade_from_samba3
|
||||
from samba.drs_utils import (
|
||||
sendDsReplicaSync, drsuapi_connect, drsException,
|
||||
sendRemoveDsServer)
|
||||
from samba import remove_dc
|
||||
from samba import remove_dc, arcfour_encrypt, string_to_byte_array
|
||||
|
||||
from samba.dsdb import (
|
||||
DS_DOMAIN_FUNCTION_2000,
|
||||
@ -2230,24 +2230,16 @@ class cmd_domain_trust_create(DomainTrustCommand):
|
||||
password = None
|
||||
self.outf.write("Sorry, passwords do not match.\n")
|
||||
|
||||
def string_to_array(string):
|
||||
blob = [0] * len(string)
|
||||
|
||||
for i in range(len(string)):
|
||||
blob[i] = ord(string[i])
|
||||
|
||||
return blob
|
||||
|
||||
incoming_secret = None
|
||||
outgoing_secret = None
|
||||
remote_policy_access = lsa.LSA_POLICY_VIEW_LOCAL_INFORMATION
|
||||
if create_location == "local":
|
||||
if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_INBOUND:
|
||||
incoming_password = get_password("Incoming Trust")
|
||||
incoming_secret = string_to_array(incoming_password.encode('utf-16-le'))
|
||||
incoming_secret = string_to_byte_array(incoming_password.encode('utf-16-le'))
|
||||
if local_trust_info.trust_direction & lsa.LSA_TRUST_DIRECTION_OUTBOUND:
|
||||
outgoing_password = get_password("Outgoing Trust")
|
||||
outgoing_secret = string_to_array(outgoing_password.encode('utf-16-le'))
|
||||
outgoing_secret = string_to_byte_array(outgoing_password.encode('utf-16-le'))
|
||||
|
||||
remote_trust_info = None
|
||||
else:
|
||||
@ -2272,7 +2264,7 @@ class cmd_domain_trust_create(DomainTrustCommand):
|
||||
#
|
||||
# We can remove this once our client libraries
|
||||
# support using the correct NTHASH.
|
||||
return string_to_array(pw1.encode('utf-16-le'))
|
||||
return string_to_byte_array(pw1.encode('utf-16-le'))
|
||||
|
||||
# We mix characters from generate_random_password
|
||||
# with random numbers from random.randint()
|
||||
@ -2425,11 +2417,6 @@ class cmd_domain_trust_create(DomainTrustCommand):
|
||||
except RuntimeError as error:
|
||||
raise self.RemoteRuntimeError(self, error, "failed to get netlogon dc info")
|
||||
|
||||
def arcfour_encrypt(key, data):
|
||||
from Crypto.Cipher import ARC4
|
||||
c = ARC4.new(key)
|
||||
return c.encrypt(data)
|
||||
|
||||
def generate_AuthInOutBlob(secret, update_time):
|
||||
if secret is None:
|
||||
blob = drsblobs.trustAuthInOutBlob()
|
||||
@ -2473,7 +2460,7 @@ class cmd_domain_trust_create(DomainTrustCommand):
|
||||
|
||||
auth_blob = lsa.DATA_BUF2()
|
||||
auth_blob.size = len(encrypted_trustpass)
|
||||
auth_blob.data = string_to_array(encrypted_trustpass)
|
||||
auth_blob.data = string_to_byte_array(encrypted_trustpass)
|
||||
|
||||
auth_info = lsa.TrustDomainInfoAuthInfoInternal()
|
||||
auth_info.auth_blob = auth_blob
|
||||
|
Loading…
x
Reference in New Issue
Block a user