How do I determine the identity of a Windows machine? - windows

I have a program consisting of a server and a client processes. Both run on Windows systems - Windows 2000 or later versions. The two processes can run on the same machine or on two different machines.
How can the client determine if it is run on the same machine as the server? If the server is not running the client can't work anyway and doesn't care where the server possibly is - so this case is out of the question. I've heard that each Windows machine has an UUID - can I obtain it and use for that purpose?

Windows networking requires computer names to be unique, so calling the GetComputerName api and having the client and server swap names (and compare the received name to the name they see) should suffice. If the client and server can start up independently of one another then you'll need some sort of protocol for this process. It seems logical for the client to initiate the exchange, and the server to only send its name when it has received a name from a client. The client can then abort the connection if it sees the same name.
I believe most virtual machine systems will allow the virtual machine to have its own name, so it should still be possible for you to test on virtual machines. However I don't have extensive experience of all the virtualisation technologies out there, so can't say for sure.

Previous question about generating a unique machine id that might help.
Link to previous answer which mentions MachineGUID
It is straightforward to add an API to the server that reports its machine name. The environment variable is COMPUTERNAME. The client could check that, right?
Do you need to deal with any of these cases?
The client is running, but the server is not responding, and you want to know whether the unresponsive server is on a remote machine.
The client and the server are running in two distinct virtual machines on the same host machine, and you want to report that as "running on the same machine."
The client is running in a virtual machine hosted by the same machine as the server is running on, and you want to report that as "running on the same machine."
The client and the server are running on uncoordinated networks and both might have been assigned the same name.
The server is possibly hostile, and will attempt to deceive the client.
The network card will have a unique MAC. If both server and client report the same MAC then they are using the same network card. If both client and server are running in different virtual machines but using the same network card, do you consider them running on the same machine or different machines?

how about trying to establish a loopback tcp connection? or maybe checking for some lock file created by the server in a predefined folder...
I don't know exactly how, but there's for sure something equivalent in Win32 to the /proc filesystem in Unix (I think there are free replacements for the windows taskmanager, maybe you could look at their sources) where you could search for your server process.

Related

Microservice HTTP port problem on Windows Server

We have written (in Go and Delphi) several Windows microservices, which respond to HTTP requests on specific ports in the 11000-12000 range. These are designed to run internally within the Domain or Private network of the client (i.e. not on the internet).
They run perfectly on all but one of our 50+ client systems, on OS's ranging from Windows 7/10/11 to Windows Server 2008R2/2012/2016/2019. The installation process for each of these services sets up rules in the Windows firewall to accept the requests to each service exe.
The one client system that they dont work on is running Windows Server 2016 Essentials. This is the only client system running that specific OS, so that may be a factor in the problem.
Even locally using a web browser on that system to query the services they dont work. The requests just wait for a while and then timeout: ERR_CONNECTION_TIMED_OUT.
However the same requests to the same ports at address 127.0.0.1 (localhost) work instantly - proving the services are actually running.
The mode of failure when the targeted service is not running, or if we address the wrong port, is different. In that case we get a quick "refused to connect" failure: ERR_CONNECTION_REFUSED
There are no third party antivirus or firewall products installed on the system, which is only using Windows Defender with the normal Windows firewall. We've tried everything we can think of with the Windows firewall, including turning it off completely. Nothing we've tried made any difference.
We've tried using many alternative port numbers, but we dont get any success until we get up to the 49000 range and above, but we'd really rather not have to change from our normal port number range unless its completely unavoidable.
We've spent many hours trying to find any solution without any luck. We are really hoping that some bright person out there has some idea that will lead to finding the cause of the problem.

Can you have a single domain across 2 servers within Hyper-V Manager?

I am running a Hyper-V lab for a client to test the functionality of a Powershell script and due to memory constraints, I would like to move my file and database VM servers off of my main desktop PC to my laptop. I set up Hyper-V on the laptop, and successfully exported/imported the VM's into the other Hyper-V server. I can boot them, all the configuration and files are intact however, I am predictably having trouble reconnecting to the domain they were a part of prior to the move. I understand I need an External virtual switch to handle that communication, as internal and private will not reach outside of the Hyper-V server they reside in. Obviously I would prefer to not use an external, but this is strictly to continue testing. I've trouble-shooted entering different DNS server values from the client machine's IPv4 properties and changing the virtual switch to External for the existing Hyper-V server, and re-register the DNS records on the DC. All result in the same error when I try to connect to the domain: "(error code 0x0000232B RCODE_NAME_ERROR) The query was for the SRV record for _ldap._tcp.dc."... "The DNS SRV records required to locate a AD DC for the domain are not registered in DNS".
In summary, I want to move a VM from the first server listed to the second, and then re-connect to the domain they were part of previously. Both machines are just running Windows 10, not Windows Servers, if that matters. Another note, I can do remote sessions from the desktop to the laptop just fine which would lead to believe this is not related to a firewall. Thanks!
The best it to set up a VLAN. If you can't do that, change the network class of your AD lab machine (192.168.55.x ?) to another in order to avoid conflicts.
Your DNS server has to be AD to make your machines connecting to it.
And last but not least, if you're on 2 different hyperV servers, you have to use external switch in hyperV:
https://redmondmag.com/articles/2018/05/04/hyper-v-private-networks.aspx

Detect RDP Session on Remote WinXP machine (not on local network or domain)

I have set up a Win XP machine at work that we use as our server, to allow RDP connections. This allows all our staff to access the server from home when needed. As it is not a server OS, we are missing many of the terminal services features a regular server would have. The machine only allows one RDP session at a time (which is a minor inconvenience, but not a big deal).
What is bothersome, is that no one can tell if the server is currently being used in an RDP session, and we all keep booting each other off. Every solution I have found online assumes the remote computer is a Server OS or on a local network/domain. Our staff's home computers are not connected to the office network and we have no domain set up at the office.
Is there any way to tell if the server is in an RDP session before remoting onto the server from home? Ideally we would be able to detect which home computer is accessing the server. But if that is not possible, it would be extremely helpful to at least know that an RDP session is running.
We were previously using logmein, which could tell us if the remote computer keyboard and mouse were active and allow a chat with the user currently remoted on/physically on the machine. This was extremely convenient, but involves logging onto the logmein website and going through a semi-lengthy process of connecting. It is also much slower and resolution is much worse than RDP. Not super convenient for regular daily use.
This post deals with the same issue
https://superuser.com/questions/313390/ways-to-check-if-user-is-active-on-remote-machine-before-rdping
but the accepted response is to use qwinsta on cmd, which I believe is only available on server OS's. Other responses include using psexec (I've tried using psloggedon.exe, but this appears to only work for users on the same domain). Another suggests using the wmic.exe command, but when I try that I get the error: The RPC Server is unavailable (I think this also needs to be run on the same domain).
So basically - is there any way to check for active rdp sessions on a Win XP machine from a remote computer not on the local network/domain?
I'm open to outside-the-box solutions like writing a simple app to run on the xp server and tell remote machines what IP is connected in an RDP session.
Going on Harry Johnston's suggestion, I wrote an app which finds who is connected to the xp machine on port 3389, and relays that information by udp to receiving apps. Now we can check if someone is connected and who it is before unwittingly booting them off. Thanks Harry!

How can I indirectly access a server that only allows connections from certain IP addresses?

I need to connect to a Windows Server 2003 machine at work from a Windows 7 machine at home via remote deskop. The problem is, the server is set up so that only a very restricted range of IP addresses is allowed to connect to the server. For a few weeks I will be unable to physically access the machine to change these settings, so I'm screwed unless I can somehow spoof my own IP address into one that the server allows.
I know this sounds shady and variations on this question have probably been asked a million times, but it's not like I need to break into this server. I have full administrator rights to the machine, I just can't connect to the machine from outside the work network.
Is there any way to do this? Thanks for any help.

Need to Automate PPTP connectivity from Linux to Windows

I'm in need of setting up cron-based VPN connectivity from Ubuntu "Jaunty" to a Windows-based VPN over PPTP for incremental DB synchronization. Using the default Network Manager and PPTP module everything seems to work fine. However, I have 2 issues:
1) Despite checking "Use this only for resources", I still lose my local internet connection and am routed through their servers.
2) As a result of 1 I have need to automate connecting to and disconnecting from the VPN in order to perform various tasks as the machine is at the office and I am not.
Much of the information I'm finding on PPTPing from Linux to Windows involves the use of GUI Network Manager, etc. However, I need to perform these steps from the command line for the sake of automation. Can anyone point me to a quality bit of documentation for this specific case?
Best.
http://pptpclient.sourceforge.net/
I think this site has everything that you need :)

Resources