Skip to content

Commit ffa47d0

Browse files
committed
A bunch of cleanups and moves
1 parent f9feafa commit ffa47d0

11 files changed

Lines changed: 401 additions & 521 deletions

File tree

scapy/layers/kerberos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
)
147147
from scapy.layers.inet import TCP, UDP
148148
from scapy.layers.smb import _NV_VERSION
149-
from scapy.layers.smb2 import STATUS_ERREF
150149
from scapy.layers.tls.cert import (
151150
Cert,
152151
CertList,
@@ -161,6 +160,7 @@
161160
Hash_SHA512,
162161
)
163162
from scapy.layers.tls.crypto.groups import _ffdh_groups
163+
from scapy.layers.windows.erref import STATUS_ERREF
164164
from scapy.layers.x509 import (
165165
_CMS_ENCAPSULATED,
166166
CMS_ContentInfo,

scapy/layers/ldap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
NETLOGON,
100100
NETLOGON_SAM_LOGON_RESPONSE_EX,
101101
)
102-
from scapy.layers.smb2 import STATUS_ERREF
102+
from scapy.layers.windows.erref import STATUS_ERREF
103103

104104
# Typing imports
105105
from typing import (

scapy/layers/msrpce/msnrpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
from scapy.layers.msrpce.rpcclient import (
3838
DCERPC_Client,
3939
DCERPC_Transport,
40-
STATUS_ERREF,
4140
)
41+
from scapy.layers.windows.erref import STATUS_ERREF
4242
from scapy.layers.msrpce.raw.ms_nrpc import (
4343
NetrServerAuthenticate3_Request,
4444
NetrServerAuthenticate3_Response,
@@ -610,7 +610,7 @@ def __init__(
610610

611611
def connect(self, host, **kwargs):
612612
"""
613-
This calls DCERPC_Client's connect_and_bind to bind the 'logon' interface.
613+
This calls DCERPC_Client's connect to bind the 'logon' interface.
614614
"""
615615
super(NetlogonClient, self).connect(
616616
host=host,

scapy/layers/msrpce/rpcclient.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
GSS_S_CONTINUE_NEEDED,
5151
GSS_C_FLAGS,
5252
)
53-
from scapy.layers.smb2 import STATUS_ERREF
5453
from scapy.layers.smbclient import (
5554
SMB_RPC_SOCKET,
5655
)
56+
from scapy.layers.windows.erref import STATUS_ERREF
5757

5858
# RPC
5959
from scapy.layers.msrpce.ept import (
@@ -331,6 +331,7 @@ def sr1_req(self, pkt, **kwargs):
331331
print(
332332
conf.color_theme.opening(">> REQUEST: %s" % pkt.__class__.__name__)
333333
)
334+
334335
# Add sectrailer if first time talking on this interface
335336
vt_trailer = b""
336337
if (
@@ -400,6 +401,7 @@ def sr1_req(self, pkt, **kwargs):
400401
):
401402
resp[DceRpc5Fault].payload.show()
402403
result = resp
404+
403405
if self.verb and getattr(resp, "status", 0) != 0:
404406
if resp.status in _DCE_RPC_ERROR_CODES:
405407
print(conf.color_theme.fail(f"! {_DCE_RPC_ERROR_CODES[resp.status]}"))

scapy/layers/smb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
GSSAPI_BLOB,
6767
)
6868
from scapy.layers.smb2 import (
69-
STATUS_ERREF,
7069
SMB2_Compression_Transform_Header,
7170
SMB2_Header,
7271
SMB2_Transform_Header,
7372
)
73+
from scapy.layers.windows.erref import STATUS_ERREF
7474

7575

7676
SMB_COM = {

scapy/layers/smb2.py

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
_NTLM_ENUM,
7676
_NTLM_post_build,
7777
)
78+
from scapy.layers.windows.erref import STATUS_ERREF
7879

7980

8081
# EnumField
@@ -87,62 +88,6 @@
8788
0x0311: "SMB 3.1.1",
8889
}
8990

90-
# SMB2 sect 3.3.5.15 + [MS-ERREF]
91-
STATUS_ERREF = {
92-
0x00000000: "STATUS_SUCCESS",
93-
0x00000002: "ERROR_FILE_NOT_FOUND",
94-
0x00000005: "ERROR_ACCESS_DENIED",
95-
0x00000103: "STATUS_PENDING",
96-
0x0000010B: "STATUS_NOTIFY_CLEANUP",
97-
0x0000010C: "STATUS_NOTIFY_ENUM_DIR",
98-
0x00000532: "ERROR_PASSWORD_EXPIRED",
99-
0x00000533: "ERROR_ACCOUNT_DISABLED",
100-
0x000006FE: "ERROR_TRUST_FAILURE",
101-
0x80000005: "STATUS_BUFFER_OVERFLOW",
102-
0x80000006: "STATUS_NO_MORE_FILES",
103-
0x8000002D: "STATUS_STOPPED_ON_SYMLINK",
104-
0x80070005: "E_ACCESSDENIED",
105-
0x8007000E: "E_OUTOFMEMORY",
106-
0x80090308: "SEC_E_INVALID_TOKEN",
107-
0x8009030C: "SEC_E_LOGON_DENIED",
108-
0x8009030F: "SEC_E_MESSAGE_ALTERED",
109-
0x80090310: "SEC_E_OUT_OF_SEQUENCE",
110-
0x80090346: "SEC_E_BAD_BINDINGS",
111-
0x80090351: "SEC_E_SMARTCARD_CERT_REVOKED",
112-
0xC0000003: "STATUS_INVALID_INFO_CLASS",
113-
0xC0000004: "STATUS_INFO_LENGTH_MISMATCH",
114-
0xC000000D: "STATUS_INVALID_PARAMETER",
115-
0xC000000F: "STATUS_NO_SUCH_FILE",
116-
0xC0000016: "STATUS_MORE_PROCESSING_REQUIRED",
117-
0xC0000022: "STATUS_ACCESS_DENIED",
118-
0xC0000033: "STATUS_OBJECT_NAME_INVALID",
119-
0xC0000034: "STATUS_OBJECT_NAME_NOT_FOUND",
120-
0xC0000043: "STATUS_SHARING_VIOLATION",
121-
0xC0000061: "STATUS_PRIVILEGE_NOT_HELD",
122-
0xC0000064: "STATUS_NO_SUCH_USER",
123-
0xC000006D: "STATUS_LOGON_FAILURE",
124-
0xC000006E: "STATUS_ACCOUNT_RESTRICTION",
125-
0xC0000070: "STATUS_INVALID_WORKSTATION",
126-
0xC0000071: "STATUS_PASSWORD_EXPIRED",
127-
0xC0000072: "STATUS_ACCOUNT_DISABLED",
128-
0xC000009A: "STATUS_INSUFFICIENT_RESOURCES",
129-
0xC00000BA: "STATUS_FILE_IS_A_DIRECTORY",
130-
0xC00000BB: "STATUS_NOT_SUPPORTED",
131-
0xC00000C9: "STATUS_NETWORK_NAME_DELETED",
132-
0xC00000CC: "STATUS_BAD_NETWORK_NAME",
133-
0xC0000120: "STATUS_CANCELLED",
134-
0xC0000122: "STATUS_INVALID_COMPUTER_NAME",
135-
0xC0000128: "STATUS_FILE_CLOSED", # backup error for older Win versions
136-
0xC000015B: "STATUS_LOGON_TYPE_NOT_GRANTED",
137-
0xC000018B: "STATUS_NO_TRUST_SAM_ACCOUNT",
138-
0xC000019C: "STATUS_FS_DRIVER_REQUIRED",
139-
0xC0000203: "STATUS_USER_SESSION_DELETED",
140-
0xC000020C: "STATUS_CONNECTION_DISCONNECTED",
141-
0xC0000225: "STATUS_NOT_FOUND",
142-
0xC0000257: "STATUS_PATH_NOT_COVERED",
143-
0xC000035C: "STATUS_NETWORK_SESSION_EXPIRED",
144-
}
145-
14691
# SMB2 sect 2.1.2.1
14792
REPARSE_TAGS = {
14893
0x00000000: "IO_REPARSE_TAG_RESERVED_ZERO",

scapy/layers/smbclient.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,16 +1876,7 @@ def getsd_output(self, results):
18761876
Print the output of 'getsd'
18771877
"""
18781878
sd = SECURITY_DESCRIPTOR(results)
1879-
print("Owner:", sd.OwnerSid.summary())
1880-
print("Group:", sd.GroupSid.summary())
1881-
if getattr(sd, "DACL", None):
1882-
print("DACL:")
1883-
for ace in sd.DACL.Aces:
1884-
print(" - ", ace.toSDDL())
1885-
if getattr(sd, "SACL", None):
1886-
print("SACL:")
1887-
for ace in sd.SACL.Aces:
1888-
print(" - ", ace.toSDDL())
1879+
sd.show_print()
18891880

18901881

18911882
if __name__ == "__main__":

scapy/layers/spnego.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ def from_cli_arguments(
851851
)
852852
else:
853853
# We have a ST, use it with the key.
854+
print(repr(ST), repr(KEY))
854855
ssps.append(
855856
KerberosSSP(
856857
UPN=UPN,

scapy/layers/windows/erref.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
# This file is part of Scapy
3+
# See https://scapy.net/ for more information
4+
# Copyright (C) Gabriel Potter
5+
6+
"""
7+
[MS-ERREF] error codes
8+
"""
9+
10+
# SMB2 sect 3.3.5.15 + [MS-ERREF]
11+
STATUS_ERREF = {
12+
0x00000000: "STATUS_SUCCESS",
13+
0x00000002: "ERROR_FILE_NOT_FOUND",
14+
0x00000003: "ERROR_PATH_NOT_FOUND",
15+
0x00000005: "ERROR_ACCESS_DENIED",
16+
0x00000006: "ERROR_INVALID_HANDLE",
17+
0x00000011: "ERROR_NOT_SAME_DEVICE",
18+
0x00000013: "ERROR_WRITE_PROTECT",
19+
0x00000057: "ERROR_INVALID_PARAMETER",
20+
0x0000007A: "ERROR_INSUFFICIENT_BUFFER",
21+
0x0000007B: "ERROR_INVALID_NAME",
22+
0x000000A1: "ERROR_BAD_PATHNAME",
23+
0x000000B7: "ERROR_ALREADY_EXISTS",
24+
0x000000EA: "ERROR_MORE_DATA",
25+
0x00000103: "STATUS_PENDING",
26+
0x0000010B: "STATUS_NOTIFY_CLEANUP",
27+
0x0000010C: "STATUS_NOTIFY_ENUM_DIR",
28+
0x000003E6: "ERROR_NOACCESS",
29+
0x00000532: "ERROR_PASSWORD_EXPIRED",
30+
0x00000533: "ERROR_ACCOUNT_DISABLED",
31+
0x000006F7: "ERROR_SUBKEY_NOT_FOUND",
32+
0x000006FE: "ERROR_TRUST_FAILURE",
33+
0x80000005: "STATUS_BUFFER_OVERFLOW",
34+
0x80000006: "STATUS_NO_MORE_FILES",
35+
0x8000002D: "STATUS_STOPPED_ON_SYMLINK",
36+
0x80070005: "E_ACCESSDENIED",
37+
0x8007000E: "E_OUTOFMEMORY",
38+
0x80090308: "SEC_E_INVALID_TOKEN",
39+
0x8009030C: "SEC_E_LOGON_DENIED",
40+
0x8009030F: "SEC_E_MESSAGE_ALTERED",
41+
0x80090310: "SEC_E_OUT_OF_SEQUENCE",
42+
0x80090346: "SEC_E_BAD_BINDINGS",
43+
0x80090351: "SEC_E_SMARTCARD_CERT_REVOKED",
44+
0xC0000003: "STATUS_INVALID_INFO_CLASS",
45+
0xC0000004: "STATUS_INFO_LENGTH_MISMATCH",
46+
0xC000000D: "STATUS_INVALID_PARAMETER",
47+
0xC000000F: "STATUS_NO_SUCH_FILE",
48+
0xC0000016: "STATUS_MORE_PROCESSING_REQUIRED",
49+
0xC0000022: "STATUS_ACCESS_DENIED",
50+
0xC0000033: "STATUS_OBJECT_NAME_INVALID",
51+
0xC0000034: "STATUS_OBJECT_NAME_NOT_FOUND",
52+
0xC0000043: "STATUS_SHARING_VIOLATION",
53+
0xC0000061: "STATUS_PRIVILEGE_NOT_HELD",
54+
0xC0000064: "STATUS_NO_SUCH_USER",
55+
0xC000006D: "STATUS_LOGON_FAILURE",
56+
0xC000006E: "STATUS_ACCOUNT_RESTRICTION",
57+
0xC0000070: "STATUS_INVALID_WORKSTATION",
58+
0xC0000071: "STATUS_PASSWORD_EXPIRED",
59+
0xC0000072: "STATUS_ACCOUNT_DISABLED",
60+
0xC000009A: "STATUS_INSUFFICIENT_RESOURCES",
61+
0xC00000BA: "STATUS_FILE_IS_A_DIRECTORY",
62+
0xC00000BB: "STATUS_NOT_SUPPORTED",
63+
0xC00000C9: "STATUS_NETWORK_NAME_DELETED",
64+
0xC00000CC: "STATUS_BAD_NETWORK_NAME",
65+
0xC0000120: "STATUS_CANCELLED",
66+
0xC0000122: "STATUS_INVALID_COMPUTER_NAME",
67+
0xC0000128: "STATUS_FILE_CLOSED", # backup error for older Win versions
68+
0xC000015B: "STATUS_LOGON_TYPE_NOT_GRANTED",
69+
0xC000018B: "STATUS_NO_TRUST_SAM_ACCOUNT",
70+
0xC000019C: "STATUS_FS_DRIVER_REQUIRED",
71+
0xC0000203: "STATUS_USER_SESSION_DELETED",
72+
0xC000020C: "STATUS_CONNECTION_DISCONNECTED",
73+
0xC0000225: "STATUS_NOT_FOUND",
74+
0xC0000257: "STATUS_PATH_NOT_COVERED",
75+
0xC000035C: "STATUS_NETWORK_SESSION_EXPIRED",
76+
}

0 commit comments

Comments
 (0)