Windows – Get *hostname* of a RDP client computer

command linenetstatnetworkingremote desktopwindows

This question: Get hostname of a RDP client computer,
asked how an RDP server can identify a client
(i.e., the host that is being used to login remotely), and got this answer:

netstat -na | find "3389" | find "ESTABLISHED" >> C:\path_to_rdplog.txt
date /T >> C:\path_to_rdplog.txt
time /T >> C:\path_to_rdplog.txt
echo. >> C:\path_to_rdplog.txt
echo ----------- >> C:\path_to_rdplog.txt
echo. >> C:\path_to_rdplog.txt

The above captures and logs the IP address of the client host.
I want to capture the hostname also; how can that be done?

Best Answer

You can use nmap

nmap -A

you should get something in output like this:

Computer name:
NetBIOS computer name:
Domain name:
Forest name:

Man Page - Linux

Documentation - Windows/Linux

Here is the Download Page to get the software, but for windows it haves a GUI and it's called Zen-nmap.

WARNING: Some Firewall recognize this software like "sniffer" and because they are indeed, be sure your host haves the right rules to run it without problems or be blocked by your own firewall