Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group Membership CSV Has Inconsistent Number of Columns #32

Open
gjhami opened this issue Jan 17, 2024 · 0 comments
Open

Group Membership CSV Has Inconsistent Number of Columns #32

gjhami opened this issue Jan 17, 2024 · 0 comments

Comments

@gjhami
Copy link

gjhami commented Jan 17, 2024

When values are not found, ad-ldap-enum sometimes outputs rows with different numbers of columns, instead of outputting a consistent number of columns with empty strings for values that aren't found. This causes problems when passing ad-ldap-enum output files to other tools.

I'm not sure if this applies to just Domain Group Membership, but many (though not all) members of the groups Domain Admins, Domain Computers, Domain Controllers, and Domain Users did not have a Distinguished Name returned. Additionally, all computer account members of Domain Users and Domain Computers were missing both Member Status and Group Distinguished name values.

The problem is not that the values were not present, but the output did not contain empty strings in their place. Instead, entries missing the Distinguished Name contained 3 columns instead of 4. I believe entries missing both Member Status and Group Distinguished Name contained only 2 columns. This problem was limited to the Domain Group Membership file in my case but may also apply to other files, apologies for the lack of detail. Further testing is required.

For the time being I am using the following function to normalize the number of columns in output files, but ideally a fix should be implemented to output empty strings in place of values (such as Group Distinguished Name) ad-ldap-enum can't retrieve.

def normalize_csv(file_path):
    """
    Normalize a CSV file by adding empty columns to each row as necessary.

    Args:
        file_path (str): The path to the CSV file.

    Returns:
        None
    """
    # Read the CSV file
    with open(file_path, 'r') as file:
        reader = csv.reader(file)
        rows = list(reader)

    # Find the maximum number of columns in the CSV
    max_columns = max(len(row) for row in rows)

    # Normalize the rows by adding empty columns
    normalized_rows = [row + [''] * (max_columns - len(row)) for row in rows]

    # Write the normalized rows back to the CSV file
    with open(file_path, 'w', newline='') as file:
        writer = csv.writer(file)
        writer.writerows(normalized_rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant