SPNEGO: add new from_cli_arguments function, improvements#4805
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4805 +/- ##
==========================================
+ Coverage 80.73% 80.98% +0.25%
==========================================
Files 365 365
Lines 89075 89112 +37
==========================================
+ Hits 71913 72168 +255
+ Misses 17162 16944 -218
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances SPNEGO functionality by adding a new from_cli_arguments factory method to simplify authentication setup, improving code reusability across different clients. It also adds support for target_name parameter in GSS authentication flows and includes various improvements to AutoArgparse for better CLI experience.
- Added
SPNEGOSSP.from_cli_arguments()utility method for simplified authentication setup - Added
target_nameparameter to GSS_Init_sec_context across multiple layers - Enhanced AutoArgparse to support bytes parameters with hex input validation
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scapy/utils.py | Enhanced AutoArgparse with bytes parameter support and improved error handling |
| scapy/libs/rfc3961.py | Reorganized exports to include KRB_FX_CF2 and SP800108_KDFCTR by default |
| scapy/layers/spnego.py | Added from_cli_arguments factory method and target_name parameter support |
| scapy/layers/smbclient.py | Refactored to use new SPNEGOSSP.from_cli_arguments method |
| scapy/layers/smb2.py | Fixed trailing comma syntax |
| scapy/layers/ntlm.py | Added target_name parameter to GSS_Init_sec_context |
| scapy/layers/msrpce/rpcclient.py | Added target_name parameter and hostname tracking |
| scapy/layers/msrpce/msnrpc.py | Added target_name and chan_bindings parameters |
| scapy/layers/ldap.py | Added target_name parameter and hostname tracking |
| scapy/layers/kerberos.py | Enhanced to use target_name when SPN not provided |
| scapy/layers/http.py | Added target_name parameter for HTTP authentication |
| scapy/layers/gssapi.py | Added target_name parameter to base GSS interface |
| scapy/config.py | Added duplicate extension loading prevention |
| doc/scapy/layers/smb.rst | Updated documentation to reflect SPN parameter changes |
Comments suppressed due to low confidence (16)
scapy/utils.py:3943
- [nitpick] The variable name 'hexarguments' should follow Python naming conventions and be 'hex_arguments' for better readability.
hexarguments = []
scapy/utils.py:3960
- [nitpick] Consistent with the previous comment, this should be 'hex_arguments.append(parname)' to maintain naming consistency.
hexarguments.append(parname)
scapy/utils.py:4013
- [nitpick] This should be 'for p in hex_arguments:' to maintain naming consistency throughout the function.
for p in hexarguments:
scapy/layers/spnego.py:635
- Parameter names should follow Python naming conventions. 'UPN' should be 'upn' to be consistent with snake_case naming.
UPN: str,
scapy/layers/spnego.py:638
- Parameter names should follow Python naming conventions. 'HashNt' should be 'hash_nt' to be consistent with snake_case naming.
HashNt: bytes = None,
scapy/layers/spnego.py:639
- Parameter names should follow Python naming conventions. 'HashAes256Sha96' should be 'hash_aes256_sha96' to be consistent with snake_case naming.
HashAes256Sha96: bytes = None,
scapy/layers/spnego.py:640
- Parameter names should follow Python naming conventions. 'HashAes128Sha96' should be 'hash_aes128_sha96' to be consistent with snake_case naming.
HashAes128Sha96: bytes = None,
scapy/layers/spnego.py:642
- Parameter names should follow Python naming conventions. 'ST' should be 'st' to be consistent with snake_case naming.
ST=None,
scapy/layers/spnego.py:643
- Parameter names should follow Python naming conventions. 'KEY' should be 'key' to be consistent with snake_case naming.
KEY=None,
scapy/layers/spnego.py:674
- The variable should use snake_case naming. This should be '_parse_upn(upn)' if the parameter name is changed as suggested.
_, realm = _parse_upn(UPN)
scapy/layers/spnego.py:682
- These variable references should use snake_case naming to match the corrected parameter names: 'hash_nt', 'st'.
if HashNt is None and password is None and ST is None:
scapy/layers/smbclient.py:1122
- Parameter names should follow Python naming conventions. 'HashNt' should be 'hash_nt' to be consistent with snake_case naming.
HashNt: bytes = None,
scapy/layers/smbclient.py:1123
- Parameter names should follow Python naming conventions. 'HashAes256Sha96' should be 'hash_aes256_sha96' to be consistent with snake_case naming.
HashAes256Sha96: bytes = None,
scapy/layers/smbclient.py:1124
- Parameter names should follow Python naming conventions. 'HashAes128Sha96' should be 'hash_aes128_sha96' to be consistent with snake_case naming.
HashAes128Sha96: bytes = None,
scapy/layers/smbclient.py:1129
- Parameter names should follow Python naming conventions. 'ST' should be 'st' to be consistent with snake_case naming.
ST=None,
scapy/layers/smbclient.py:1130
- Parameter names should follow Python naming conventions. 'KEY' should be 'key' to be consistent with snake_case naming.
KEY=None,
smbclientuse ittarget_nameparameter in Gss_Init_sec_Context, that is populated by the various clients. SPN still overwrites it.