Skip to content

GetADComputers.py and readLAPS.py#1673

Merged
anadrianmanrique merged 8 commits into
fortra:masterfrom
F-Masood:master
Mar 4, 2024
Merged

GetADComputers.py and readLAPS.py#1673
anadrianmanrique merged 8 commits into
fortra:masterfrom
F-Masood:master

Conversation

@F-Masood

@F-Masood F-Masood commented Jan 1, 2024

Copy link
Copy Markdown
Contributor

I am a big fan of impacket and when ever I start my enumeration phase, impacket is the first tool I use.
I heavily rely on impacket's GetADUsers code but I felt that we should have a similar code that basically fetches the information about computers ....
As a result, I have created a similar code (GetADComputers.py) that basically query's DC via LDAP and returns the COMPUTER objects and the useful attributes such as full dns name, operating system name and version.

Why the need of this ?
Often during pentest we land into a network/subnet where we can't see all the hosts/computers part of DC because we are in a different network / VLAN.
However, this code will request DC and as a result the hosts which are not visible in NMAP / ping /ARP scan, this code will list all those hosts in a nice format.

This code is inspired from impacket's original GetADUsers.py. 
Similar to ADUsers, this will query the DC (via ldap) and retrive the list of all the computer objects and their operating system details.
@F-Masood

F-Masood commented Jan 1, 2024

Copy link
Copy Markdown
Contributor Author

Adding a couple of examples.
GetAdComputers_4
GetAdComputers_3

year changed from 2023 to 2024
and updated/removed some comments
Added new flag -dns2IP, if this flag is specified, it will resolve all the IP address by making a query to the specified DC via tcp port53... it will not use the nameservers in /etc/resolv.conf
Updated description
@F-Masood

Copy link
Copy Markdown
Contributor Author

updated the code, now the code can resolve the IP address.
it makes query to DC on port 53 (TCP), doesn't rely on the nameserver present in /etc/resolv.conf

image

This script will try to read the LAPS password in the current domain of specified user.

Attributes searched in DC are: ms-Mcs-AdmPwd (password value) and ms-Mcs-AdmPwdExpirationTime (password expiry time).
@F-Masood F-Masood changed the title GetADComputers GetADComputers.py and readLAPS.py Jan 15, 2024
@F-Masood

Copy link
Copy Markdown
Contributor Author

after creating GetADComputers.py, i have created another code called readLAPS.py, this tries to read all the LAPS password from the current domain computers.
readLAPS

@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Feb 6, 2024
@anadrianmanrique anadrianmanrique self-assigned this Feb 22, 2024
@anadrianmanrique anadrianmanrique added medium Medium priority item and removed in review This issue or pull request is being analyzed labels Feb 29, 2024
@anadrianmanrique

Copy link
Copy Markdown
Collaborator

I've been reviewing and testing this PR. I think it's pretty much ready to be merged. Thanks for submitting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

medium Medium priority item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants