Remote execute Windows process in the context of another machine - windows

Is it possible to execute a non interactive Windows process on remote machine B, but in the context of a different machine A (in my case the one giving the execute order).
What I try to achieve, is to use the CPU/power of a remote machine to run an executable, but it needs to use automatically the resources of my machine. That is, if the executable references a file (e.g. c:\dir\myfile.txt) or registry, it will automatically use "my" "c:\dir\myfile.txt" disk and registry and not the machine on which is actually executed.
Thanks

I think you ca achieve that with some type of Client /Server protocol. Host B listens to requests and saves the requests host Information. After that Host A gets a server state and listens to file/directory requests from host B. While the first connection is still alive it can be finished with the application result and a finished Handshake or something similar.

Related

Make Jenkins invisible to remote users

I have a Jenkins server on my local Windows device, but I want to make it invisible to the outside world (office rules regarding servers). The obvious and unsubtle way, which works satisfactorily, is to set up a firewall rule to block incoming access to its port, but I feel there must be a Jenkins setting to stop it advertising its services to anyone but localhost. Can anyone tell me if there is?
Note that setting up user credentials is not a valid solution, as the server being visible but inaccessible without login still violates office rules.
From Starting and Accessing Jenkins you need --httpListenAddress=127.0.0.1 command line parameter:
--httpListenAddress=$HTTP_HOST - Binds Jenkins to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — i.e. listening on all available interfaces.
For example, to only listen for requests from localhost, you could use: --httpListenAddress=127.0.0.1
If you run your Jenkins as Windows service, you can extend command line arguments in jenkins.xml file in Jenkins home directory.
Similar answer (for Linux-oriented platforms) on ServerFault.

How i can check which services use rsh in unix-aix?

I want to disable rsh in my unix box for security issues , but after do that i have to check if any service use it to handle it , so that anyone know how i can list all services or application use rsh ?
When you rsh from host A to host B, you should see such a login on host B's access log (wtmp / btmp).
If you want to discover this only on host A, it seems that you need to scan through all your services / cron job / etc and inspect one by one.
If you're sure the rsh fires frequently enough (e.g. not only once per year), mirror the network port on the switch (which connects to host A), capture the packets and see where it goes.
Almost nothing uses rsh. Some systems will do remote backups by using rsh to dump to a remote tape drive by running rmt(8). But if your system was being used by remote clients to do tape backups, you would already know. Aside from that there will be nothing.
In your position I would simply disable the service. No Unix systems designed for production work should ship with rsh enabled these days anyway.
If you are very cautious you can modify your inetd.conf entry for rsh by using something like tcpwappers so that attempts to use rsh produce a log message to the system log. You can also use tcpwrappers to either allow the request after issuing the log message, or drop the connection.

How to check programmatically the OS of remote host?

I need to check if remote host is Windows or Unix/Linux.
I can't assume that it has web server configured.
All I can do is to try to connect to several TCP or UDP services.
Which TCP services (TCP port numbers) usually will be opened on Windows and not on Unix/Linux and vise versa?
The other way is to try to ssh to it, and if it fails assume that it Windows host. The problem is, that I need this in order to choose the remote access method ssh or something Windows friendly like psexec.
You can read the output of nmap to detect which OS a remote host is running. It has a whole module dedicated to this. Here is a guide to using it.
Why not just try to connect one way, and if that fails, connect the other way, and if neither work, tell the user?
If that's all you're trying to do, there's no need to actually check the OS.
This is not an easy thing to answer with any degree of certainty as there are very few ports that will always be open on one OS but not on another.
You could try some/all of the following
80 http obviously
22,23 Telnet and SSH (Not usually open on windows, one at least usually open on *nix)
135 Used by WMI so often open on windows
1443 (Possibly SQL Server)
691 Used by MS Exchange routing
3389 MS Remote Desktop
I would suggest that scanning ranges of ports may lead you into trouble particularly if these are not your machines. You may find your IP address logged as a possible source of "Port Scanners"
There are some fairly extensive lists of ports available on the web. e.g. http://keir.net/portlist.html

Tunnel outbound HTTP over inbound socket connection

** This question might belong on SF except for one of the constraints below (not having admin rights on one machine) **
At my work I have two machines, A and B. Machine A is my primary development machine. It is completely disconnected from the corporate network. Machine B is connected and is used primarily for email and web access. It is rather locked down - I don't have admin rights and it does not accept inbound connections. I cannot run programs I download, however I have Visual Studio 2005 and can create and run executables which works great (notwithstanding lack of admin rights).
I have an ad-hoc wireless network between the two and I'm able to transfer files via standard Windows shares so long as I browse from Machine B to a share on Machine A. I am also able to browse to websites hosted on Machine A, including non-standard port numbers (ie, http://machineb:12121/).
My goal is to create some sort of connection initiated by Machine B to Machine A which then grants me internet access on Machine A, presumably by setting up a proxy server on Machine B. However, I would need source code to the proxy server so I could build & run it locally.
My initial thought is to create two apps, one to run on Machine B and pings the app on A (which listens for local requests on port 80), and when it receives a response (containing a URL I guess) to use a HttpWebRequest object to hit that URL and then pass that data back... but I can see this getting complicated real quick.
Any suggestions to get me started?
Any number of open source web proxies will do what you're asking. You can do it with apache, and mod_proxy, even.
However, were I your admin, and I caught you tunnelling access out of a machine I'd specifically prohibited access from/to, I would do such things to you that other programmers would weep at the very mention of your name. Tread lightly.

How do I determine the identity of a Windows machine?

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.

Resources