from samba import NTSTATUSError
from subprocess import call
from ldb import LdbError
+from samba.dcerpc.windows_event_ids import (
+ EVT_ID_SUCCESSFUL_LOGON,
+ EVT_ID_UNSUCCESSFUL_LOGON
+)
import re
msg = messages[0]
self.assertEquals("Authentication", msg["type"])
self.assertEquals("NT_STATUS_OK", msg["Authentication"]["status"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
self._assert_ncacn_np_serviceDescription(binding,
msg["Authentication"]["serviceDescription"])
self.assertEquals(authTypes[1],
self.assertEquals(authTypes[3],
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
def rpc_ncacn_np_krb5_check(
self,
msg["Authentication"]["serviceDescription"])
self.assertEquals(authTypes[1],
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
# Check the second message it should be an Authentication
# This this the TCP Authentication in response to the message too big
msg["Authentication"]["serviceDescription"])
self.assertEquals(authTypes[2],
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
# Check the third message it should be an Authorization
msg = messages[2]
msg["Authentication"]["serviceDescription"])
self.assertEquals(authTypes[2],
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
def rpc_ncacn_ip_tcp_krb5_check(self, messages, authTypes, service,
binding, protection):
msg["Authentication"]["serviceDescription"])
self.assertEquals(authTypes[2],
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
# Check the third message it should be an Authentication
msg = messages[2]
msg["Authentication"]["serviceDescription"])
self.assertEquals(authTypes[2],
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
def test_rpc_ncacn_ip_tcp_ntlm_dns_sign(self):
creds = self.insta_creds(template=self.get_credentials(),
self.assertEquals("ENC-TS Pre-authentication",
msg["Authentication"]["authDescription"])
self.assertTrue(msg["Authentication"]["duration"] > 0)
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
# Check the second message it should be an Authentication
msg = messages[1]
self.assertEquals("ENC-TS Pre-authentication",
msg["Authentication"]["authDescription"])
self.assertTrue(msg["Authentication"]["duration"] > 0)
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
def test_ldap_ntlm(self):
msg["Authentication"]["serviceDescription"])
self.assertEquals("NTLMSSP", msg["Authentication"]["authDescription"])
self.assertTrue(msg["Authentication"]["duration"] > 0)
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
def test_ldap_simple_bind(self):
def isLastExpectedMessage(msg):
msg["Authentication"]["serviceDescription"])
self.assertEquals("simple bind",
msg["Authentication"]["authDescription"])
+ self.assertEquals(
+ EVT_ID_SUCCESSFUL_LOGON, msg["Authentication"]["eventId"])
def test_ldap_simple_bind_bad_password(self):
def isLastExpectedMessage(msg):
msg["Authentication"]["serviceDescription"] == "LDAP" and
(msg["Authentication"]["status"] ==
"NT_STATUS_WRONG_PASSWORD") and
- msg["Authentication"]["authDescription"] == "simple bind")
+ (msg["Authentication"]["authDescription"] ==
+ "simple bind") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials())
creds.set_password("badPassword")
msg["Authentication"]["serviceDescription"] == "LDAP" and
(msg["Authentication"]["status"] ==
"NT_STATUS_NO_SUCH_USER") and
- msg["Authentication"]["authDescription"] == "simple bind")
+ (msg["Authentication"]["authDescription"] ==
+ "simple bind") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials())
creds.set_bind_dn("%s\\%s" % (creds.get_domain(), "badUser"))
msg["Authentication"]["serviceDescription"] == "LDAP" and
(msg["Authentication"]["status"] ==
"NT_STATUS_NO_SUCH_USER") and
- msg["Authentication"]["authDescription"] == "simple bind")
+ (msg["Authentication"]["authDescription"] ==
+ "simple bind") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials())
creds.set_bind_dn("%s\\%s" % (creds.get_domain(), "abdcef"))
msg["Authentication"]["serviceDescription"])
self.assertEquals("ENC-TS Pre-authentication",
msg["Authentication"]["authDescription"])
+ self.assertEquals(EVT_ID_SUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
# Check the second message it should be an Authentication
msg = messages[1]
msg["Authentication"]["serviceDescription"])
self.assertEquals("ENC-TS Pre-authentication",
msg["Authentication"]["authDescription"])
+ self.assertEquals(EVT_ID_SUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
def test_smb_bad_password(self):
def isLastExpectedMessage(msg):
(msg["Authentication"]["status"] ==
"NT_STATUS_NO_SUCH_USER") and
(msg["Authentication"]["authDescription"] ==
- "ENC-TS Pre-authentication"))
+ "ENC-TS Pre-authentication") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials())
creds.set_username("badUser")
msg["Authentication"]["authDescription"])
self.assertEquals("No-Password",
msg["Authentication"]["passwordType"])
+ self.assertEquals(EVT_ID_UNSUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
# Check the second message it should be an Authentication
msg = messages[1]
msg["Authentication"]["passwordType"])
self.assertEquals("ANONYMOUS LOGON",
msg["Authentication"]["becameAccount"])
+ self.assertEquals(EVT_ID_SUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
def test_smb2_anonymous(self):
def isLastExpectedMessage(msg):
msg["Authentication"]["authDescription"])
self.assertEquals("No-Password",
msg["Authentication"]["passwordType"])
+ self.assertEquals(EVT_ID_UNSUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
# Check the second message it should be an Authentication
msg = messages[1]
msg["Authentication"]["passwordType"])
self.assertEquals("ANONYMOUS LOGON",
msg["Authentication"]["becameAccount"])
+ self.assertEquals(EVT_ID_SUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
def test_smb_no_krb_spnego(self):
def isLastExpectedMessage(msg):
msg["Authentication"]["authDescription"])
self.assertEquals("NTLMv2",
msg["Authentication"]["passwordType"])
+ self.assertEquals(EVT_ID_SUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
def test_smb_no_krb_spnego_bad_password(self):
def isLastExpectedMessage(msg):
msg["Authentication"]["authDescription"] == "NTLMSSP" and
msg["Authentication"]["passwordType"] == "NTLMv2" and
(msg["Authentication"]["status"] ==
- "NT_STATUS_WRONG_PASSWORD"))
+ "NT_STATUS_WRONG_PASSWORD") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials(),
kerberos_state=DONT_USE_KERBEROS)
msg["Authentication"]["authDescription"] == "NTLMSSP" and
msg["Authentication"]["passwordType"] == "NTLMv2" and
(msg["Authentication"]["status"] ==
- "NT_STATUS_NO_SUCH_USER"))
+ "NT_STATUS_NO_SUCH_USER") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials(),
kerberos_state=DONT_USE_KERBEROS)
msg["Authentication"]["authDescription"])
self.assertEquals("NTLMv1",
msg["Authentication"]["passwordType"])
+ self.assertEquals(EVT_ID_SUCCESSFUL_LOGON,
+ msg["Authentication"]["eventId"])
def test_smb_no_krb_no_spnego_no_ntlmv2_bad_password(self):
def isLastExpectedMessage(msg):
msg["Authentication"]["authDescription"] == "bare-NTLM" and
msg["Authentication"]["passwordType"] == "NTLMv1" and
(msg["Authentication"]["status"] ==
- "NT_STATUS_WRONG_PASSWORD"))
+ "NT_STATUS_WRONG_PASSWORD") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials(),
kerberos_state=DONT_USE_KERBEROS)
msg["Authentication"]["authDescription"] == "bare-NTLM" and
msg["Authentication"]["passwordType"] == "NTLMv1" and
(msg["Authentication"]["status"] ==
- "NT_STATUS_NO_SUCH_USER"))
+ "NT_STATUS_NO_SUCH_USER") and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
creds = self.insta_creds(template=self.get_credentials(),
kerberos_state=DONT_USE_KERBEROS)
"interactive") and
msg["Authentication"]["status"] == "NT_STATUS_OK" and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_SUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
(msg["Authentication"]["status"] ==
"NT_STATUS_WRONG_PASSWORD") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
(msg["Authentication"]["status"] ==
"NT_STATUS_NO_SUCH_USER") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = "badUser"
msg["Authentication"]["authDescription"] == "network" and
msg["Authentication"]["status"] == "NT_STATUS_OK" and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_SUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
(msg["Authentication"]["status"] ==
"NT_STATUS_WRONG_PASSWORD") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
(msg["Authentication"]["status"] ==
"NT_STATUS_NO_SUCH_USER") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = "badUser"
(msg["Authentication"]["status"] == "NT_STATUS_OK") and
(msg["Authentication"]["passwordType"] == "MSCHAPv2") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_SUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
"NT_STATUS_WRONG_PASSWORD") and
(msg["Authentication"]["passwordType"] == "MSCHAPv2") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
"NT_STATUS_NO_SUCH_USER") and
(msg["Authentication"]["passwordType"] == "MSCHAPv2") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_UNSUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = "badUser"
(msg["Authentication"]["authDescription"] == "network") and
(msg["Authentication"]["status"] == "NT_STATUS_OK") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_SUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]
(msg["Authentication"]["authDescription"] == "network") and
(msg["Authentication"]["status"] == "NT_STATUS_OK") and
(msg["Authentication"]["workstation"] ==
- r"\\%s" % workstation))
+ r"\\%s" % workstation) and
+ (msg["Authentication"]["eventId"] ==
+ EVT_ID_SUCCESSFUL_LOGON))
server = os.environ["SERVER"]
user = os.environ["USERNAME"]