Skip to content

Commit 7328c08

Browse files
authored
Merge pull request Pennyw0rth#805 from termanix/patch-2
Update LDAP find-computer Module
2 parents 776b84a + 36573e3 commit 7328c08

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

nxc/modules/find-computer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import socket
21
from nxc.logger import nxc_logger
32
from impacket.ldap.ldap import LDAPSearchError
43
from impacket.ldap.ldapasn1 import SearchResultEntry
@@ -19,10 +18,11 @@ class NXCModule:
1918

2019
def options(self, context, module_options):
2120
"""
22-
find-computer: Specify find-computer to call the module
23-
TEXT: Specify the TEXT option to enter your text to search for
24-
Usage: nxc ldap $DC-IP -u Username -p Password -M find-computer -o TEXT="server"
25-
nxc ldap $DC-IP -u Username -p Password -M find-computer -o TEXT="SQL"
21+
TEXT Search TEXT in the operating system or name of the computer.
22+
23+
Examples:
24+
nxc ldap $DC-IP -u Username -p Password -M find-computer -o TEXT="server"
25+
nxc ldap $DC-IP -u Username -p Password -M find-computer -o TEXT="SQL"
2626
"""
2727
self.TEXT = ""
2828

@@ -67,12 +67,12 @@ def on_login(self, context, connection):
6767
if len(answers) > 0:
6868
context.log.success("Found the following computers: ")
6969
for answer in answers:
70-
try:
71-
ip = socket.gethostbyname(answer[0])
72-
context.log.highlight(f"{answer[0]} ({answer[1]}) ({ip})")
73-
context.log.debug("IP found")
74-
except socket.gaierror:
75-
context.log.debug("Missing IP")
70+
resolv = connection.resolver(answer[0])
71+
if resolv:
72+
context.log.highlight(f"{answer[0]} ({answer[1]}) ({resolv['host']})")
73+
context.log.debug("IP found via DNS query")
74+
else:
75+
context.log.debug(f"No DNS response for {answer[0]}")
7676
context.log.highlight(f"{answer[0]} ({answer[1]}) (No IP Found)")
7777
else:
7878
context.log.success(f"Unable to find any computers with the text {self.TEXT}")

0 commit comments

Comments
 (0)