Skip to content

Techdebt examples bootstrapping v2#1928

Merged
anadrianmanrique merged 11 commits into
masterfrom
techdebt_examples_bootstrapping_v2
Mar 27, 2025
Merged

Techdebt examples bootstrapping v2#1928
anadrianmanrique merged 11 commits into
masterfrom
techdebt_examples_bootstrapping_v2

Conversation

@gabrielg5

@gabrielg5 gabrielg5 commented Mar 21, 2025

Copy link
Copy Markdown
Collaborator

Created as a replacement of #1918

This PR aims to standardize some examples requirements and group them in a single utils script that could be leveraged by existing and future examples.

Shared Functionality

Logging initialization

  • Added flags -ts and -debug to every example
  • Created a single function to initialize logging and call it from all examples...
    def init(ts=False, debug=False):

LDAP Login

  • Extracted common LDAP login functions - calling them from examples that were redefining it
    def ldap3_kerberos_login(connection, target, user, password, domain='', lmhash='', nthash='', aesKey='', kdcHost=None, TGT=None, TGS=None, useCache=True):

    def init_ldap_session(domain, username, password, lmhash, nthash, k, dc_ip, aesKey, use_ldaps):

    def ldap_login(target, base_dn, kdc_ip, kdc_host, do_kerberos, username, password, domain, lmhash, nthash, aeskey, target_domain=None, fqdn=False):

Identity Parsing

  • Extracted identity parsing functionality and replaced it in examples that were needing it
    def parse_identity(credentials, hashes=None, no_pass=False, aesKey=None, k=False, getpass_msg='Password:'):

@anadrianmanrique

Copy link
Copy Markdown
Collaborator

Great PR, lots of duplicated code is now gone. Merging!

@anadrianmanrique anadrianmanrique merged commit ae0ec30 into master Mar 27, 2025
@anadrianmanrique anadrianmanrique deleted the techdebt_examples_bootstrapping_v2 branch March 27, 2025 01:58
NtAlexio2 pushed a commit to NtAlexio2/impacket that referenced this pull request Jul 13, 2025
* Standardized examples logger init method

* Fixing missing import

* Standardized examples init_ldap_session function fortra#1

* Calling new shared function _ldap3_kerberos_login from example addcomputer

* Removed considering -debug in each example. Now it's handled in utils.

* Standardized EMPTY_LM_HASH in impacket.examples.utils

* Unify parse_identity function (phase 1)

* Standardized parse_identity

* Renamed "_ldap3_kerberos_login" to "ldap3_kerberos_login" (as it is called from outside)

* Standardize "logger" init in regsecrets.py

* Standardized LDAP login into a single function in utils.py:ldap_login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Examples high High priority item Library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants