from samba.dcerpc.misc import SEC_CHAN_BDC
from samba import gensec
from samba import sd_utils
+from samba.compat import get_string
SLEEP_OVERHEAD = 3e-4
than that requested, but not significantly.
"""
if not failed_last_time:
- if (self.badpassword_frequency > 0 and
- random.random() < self.badpassword_frequency):
+ if (self.badpassword_frequency and self.badpassword_frequency > 0
+ and random.random() < self.badpassword_frequency):
try:
f(bad)
except:
def get_authenticator(self):
auth = self.machine_creds.new_client_authenticator()
current = netr_Authenticator()
- current.cred.data = [ord(x) for x in auth["credential"]]
+ current.cred.data = [x if isinstance(x, int) else ord(x) for x in auth["credential"]]
current.timestamp = auth["timestamp"]
subsequent = netr_Authenticator()
ou = ou_name(ldb, instance_id)
dn = "cn=%s,%s" % (netbios_name, ou)
- utf16pw = unicode(
- '"' + machinepass.encode('utf-8') + '"', 'utf-8'
- ).encode('utf-16-le')
+ utf16pw = ('"%s"' % get_string(machinepass)).encode('utf-16-le')
+
start = time.time()
ldb.add({
"dn": dn,
"""Create a user account via ldap."""
ou = ou_name(ldb, instance_id)
user_dn = "cn=%s,%s" % (username, ou)
- utf16pw = unicode(
- '"' + userpass.encode('utf-8') + '"', 'utf-8'
- ).encode('utf-16-le')
+ utf16pw = ('"%s"' % get_string(userpass)).encode('utf-16-le')
start = time.time()
ldb.add({
"dn": user_dn,
# subsequent runs
newpass = context.machine_creds.get_password().encode('utf-16-le')
pwd_len = len(newpass)
- filler = [ord(x) for x in os.urandom(DATA_LEN - pwd_len)]
+ filler = [x if isinstance(x, int) else ord(x) for x in os.urandom(DATA_LEN - pwd_len)]
pwd = netlogon.netr_CryptPassword()
pwd.length = pwd_len
- pwd.data = filler + [ord(x) for x in newpass]
+ pwd.data = filler + [x if isinstance(x, int) else ord(x) for x in newpass]
context.machine_creds.encrypt_netr_crypt_password(pwd)
c.netr_ServerPasswordSet2(context.server,
# must ends with $, so use get_username instead
logon = netlogon.netr_NetworkInfo()
- logon.challenge = [ord(x) for x in challenge]
+ logon.challenge = [x if isinstance(x, int) else ord(x) for x in challenge]
logon.nt = netlogon.netr_ChallengeResponse()
logon.nt.length = len(response["nt_response"])
- logon.nt.data = [ord(x) for x in response["nt_response"]]
+ logon.nt.data = [x if isinstance(x, int) else ord(x) for x in response["nt_response"]]
+
logon.identity_info = netlogon.netr_IdentityInfo()
(username, domain) = creds.get_ntlm_username_domain()