C++ DHCP Host Name Used As Unique Identifier? - c++

I'm currently looking into some ways to identify different machines using my software, I am working with a old gaming console in which I cannot access the typical unique identifiers most people would use (HWID, etc...).
After looking through the SDK required to compile software on this old gaming console I noticed I can get a users DHCP Host Name, (You can view your DHCP Host Name on a windows machine by entering "hostname.exe" within command prompt)
So my question is, would using the DHCP Host Name as a way to uniquely identify different machines accessing my software be effective in differentiating different users?

Related

C++ application: discover other IPs on LAN

I want to create a C++ application that can be used (in part) to communicate between users on a local area network using UDP. Each instance of the application will have a thread dedicated to listening for other instances of the application and broadcasting its presence to other instances.
Is there a reliable way to perform this type of broadcast/listening on the LAN using pure C++ and POSIX system calls? I know there's no generally reliable way to find all IPs on a LAN, but I assume this is only because other devices are not willing to respond to pings.
Don't re-invent the wheel. There are two existing technologies, that, when combined, solve your problem in a standardized, well-designed, proven manner:
RFC6762 mDNS (Multicast DNS) is a protocol that works almost exactly like DNS, except it works using IP multicast. Instead of sending your DNS request to a unicast address, you send your DNS request to a multicast group, and any member of that group can answer your request (so you may get multiple answers).
RFC6763 DNS-SD (DNS-based Service Discovery) is a way to encode Services as DNS entries, which allows you then to retrieve Services from DNS using specially encoded hostnames. (For example, looking up the hostname _ipp._tcp.example.com would return a list of all printers that support the Internet Printing Protocol over TCP within the domain example.com)
So, we have one protocol that allows us to ask DNS about Services, and we have one protocol that allows us to ask a group of hosts to answer DNS queries … when we put the two together, we get a way of asking hosts for services! The combination of those two protocols is sometimes called Zeroconf networking, and is already implemented in macOS, iOS, tvOS, and watchOS (where it is called Bonjour), Android, most Unices (via Avahi, a portable implementation of those two protocols), and many home devices such as TVs. E.g. Spotify Connect, ChromeCast, Philips Hue and many others are also based on it. It's how iTunes devices find each other on the local network, for example.
Unfortunately, support in Windows is still limited, at the moment it seems to only exist for Windows 10 apps implemented in ECMAScript. (However, nothing stops you from shipping your own implementation with your app, and AFAIK, both Avahi and Apple's mDNSResponder work on Windows.)
So, what you would basically do is to send an mDNS query to the mDNS multicast group and ask for _myprotocol._udp.local. Then, assuming that your application registers itself with the OS's mDNS service (i.e. Bonjour on macOS, Avahi on Unices, …), you would get back a list of all hosts on the local network that support your protocol.

Finding VMWare ESX host name from within a guest

this question has been asked before several times, but never anyone brought up any reasonable solution.
? Is there any way, from within a Windows guest, to find the hostname or IP address of the ESX host ?
The scenario is as follows:
I am working on a virtual host (Windows 7 guest, I have Admin privileges on the guest, VMWare Tools are installed, I can install PowerCLI or any other tool if I want to [though I assume it wouldn't help]).
Now I need to contact the administrator of the underlying ESX server. If I can find out either the ESX server name, or the IP address, I can find out whom I must contact.
Is there any way from within the client to find either the ESX host name or its IP address?
Thx, Armin.
P.S. please don't - like many other postings do - suggest workarounds requiring that I do
a) set any info on the host side which I can later query from the client - cannot do this in my scenario, and to have anyone else do this I need to find the responsible person first.
b) say it cannot be technically done for some reason (including "sandbox" and "security") - I have VMware Tools installed, look at the "VMWareToolboxCmd.exe stat" command - it can retrieve various infos from the underlying host, like the clock time or the speed of the CPU, so there are ways to communicate with the host, but I failed to find any command to retrieve the host name or IP address.
c) use PowerCLI, VSphere client, etc. As far as I know all those approaches require that one knows the ESX hostname and has login credentials for the host, not the guest. I don't have login credentials for any ESX machine in the company.

gethostname on a machine with multiple network interfaces

What will the gethostname system call return on a machine with multiple network interfaces? Is it possible to configure this at the OS level?
The number of network interfaces used to connect the machine to the world is more or less independent of the number of host names. You can have multiple interfaces with a single name (even though it's somewhat unusual) or multiple names with a single interface (considerably more common).
As to what value it does return, MSDN says:
f the gethostname function is used on a cluster resource on Windows Server 2008, Windows Server 2003, or Windows 2000 Server and the _CLUSTER_NETWORK_NAME_ environment variable is defined, then the value in this environment variable overrides the actual hostname and is returned. On a cluster resource, the _CLUSTER_NETWORK_NAME_ environment variable contains the name of the cluster.
The gethostname function queries namespace providers to determine the local host name using the SVCID_HOSTNAME GUID defined in the Svgguid.h header file. If no namespace provider responds, then the gethostname function returns the NetBIOS name of the local computer.
As such, it's normally a question of DNS configuration, but for a member of a cluster you can set an environment variable.
http://beej.us/guide/bgnet/output/html/multipage/gethostnameman.html
there will be one hostname -> root name
The Hostname is stored at the OS Level .It doesn't matter how many NIC's your PC has, it will be the same for all of them.

Portable C++ approach to listing all adapter IPv4 addresses?

I want to generate the list of IP addresses on the local machine using C++. I looked at boost and it doesn't seem to have any function to do so.
I need this because I want to see if the host name/IP address entered by the user is for the local machine.
I want to see if the host name/IP address entered by the user is for the local machine.
In general, you cannot do that. There could be any number of host names registered for the local machine. You could try to open a socket and see if ends up at yourself though.
If you are looking for portable solution, try ACE library. This library provide cross-platform functionality for network applications development.

Is there any possibility to get VMWARE HOST computer name from GUEST workstation without changing things on HOST? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Let's suppose I have VMWARE workstation (guesting Windows and hosted by Windows).
Is there any possible way to receive host name of hosting machine?
And without changing things on host machine like in this link.
I do this by passing a string from host to guest via machine.id. It does require making a change on the host (in every VM's .vmx file, too), and it doesn't automatically discover the host's hostname, but it works. On the host, with the VM in question powered down, edit the .vmx file for the VM. Find or add a line that looks like:
machine.id = "<string>"
Set <string> equal to some identifying string that will tell you the name of the server. This could be the hostname, or it could be a shortened version of it, or even some unintelligible code if you prefer, as long as you know what it means. If, however, the .vmx file has a line that sets
isolation.tools.machine.id.get.disable = TRUE
passing a string won't work, so if this line is present you might want to either remove/comment it or set the value to FALSE.
On the guest OS, if you have VMware Tools installed, you can then do this (for Linux guests):
vmware-guestd --cmd 'machine.id.get'
or (for Windows guests, which I haven't tried):
VMwareService --cmd machine.id.get
I know this is an old thread, however if anyone is still interested "thomas lee"'s answer above works on recent version of VMWare workstation and VMWare fusion. The new command to retrieve the value is
rpctool machine.id.get
Using this in deploying managed VMs for Fusion so that the machine name is auto set at first boot. Thanks Thomas.....
If you are able to install PowerCLI on your guest operating system, you can access some ESX host information by looking up the VM that your script is running on:
Connect-VIServer -Server <myvcenterserver>
$myVM = Get-VM -Name $(dir env:COMPUTERNAME).Value
$myVM.Host.Name
Note: This assumes your guest has the same hostname as the VM name in vCenter.
For Linux guests (the OP stated Windows) I use the pyVmomi Python module to perform a similar lookup.
In principle - no.
However, it is possible that there may exist (or will exist) certain vulnerabilities that allow a malicious guest OS to bypass the VM sandbox. For instance, read up on the Blue Pill. You can also read more details on the researcher's own blog, Invisible Things by Joanna Rutkowska.
Of course, these are just proof of concept, but any security implemented in software is subject to software bugs...
I think there are probably a number of ways to do this, and can think of two off the bat:
One would be to install ViX in the guest, connect to the host without specifying the hostname, (Google "ViX reference" then see "common tasks") then use Vix_CopyFileFromHostToGuest() to copy the file /etc/vmware/esx.conf.
Another would be to create some sort of network connection from the guest to the host (I used ssh but if you don't know the hostname or IP you could still do the ViX connection thing as above and dispatch a job that takes a while) and then say netstat -a in the guest. The netstat output will contain the hostname, if it is resolvable.
You have effectively two computers on a network. If you use one of the private network/NAT style set-ups for the virtual NICs, then the host has a fairly predictable IP address, so you could then use any of the many remote admin approaches to ask it just like you would any other.
If there is only the one guest OS, then just trying every IP address with the same leading 24 bits as the guest's IP address would save baking in a guess at an address.
In vSphere
Click your host
Click Configuration Tab
In Software Section Click DNS and Routing