Why can't python.exe be served by remote.exe - windbg

I'm learning Debugging Tools for Windows, and I know there is a Remote.exe that can serve console input/output to a remote machine. I have tried this with diskpart and it works well.
Server side: remote /s diskpart mysession
Client side: remote /c 172.27.0.120 mysession
However, when I try to serve python.exe, it does not work. Whether I type command(python statement line) into server-side cmd window or client-side cmd window, no output is seen on either side.
Can someone explain why remote.exe can't work with python.exe ?
I'm using Remote.exe 6.3.9600.17029 (Win81 era) on both sides, Windows 7 .

Related

How do I run cygwin ssh properly on powershell?

My OS is Windows 10 (x64) and I installed both Powershell 7 and cygwin.
Then, I installed "sshpass" using cygwin.
And, here are the cases I am experiencing right now.
From cmd, if I enter "C:\cygwin64\bin\mintty.exe -", cygwin pops up with initial directory "~". Then, if I type "sshpass -p<password> ssh <username>#<host>", it perfectly works smoothly!
From cmd, if I enter "C:\cygwin64\bin\mintty.exe", cygwin pops up with directory "/cygdrive/c/Users/myname". Then, if I type "sshpass -p<password> ssh <username>#<host>", it asks me to type the password. This means that sshpass is not working correctly here.
From powershell, if I type "C:\cygwin64\bin\sshpass.exe -p<password> C:\cygwin64\bin\ssh <username>#<host>", nothing happens.
My questions are the following:
How do I properly run sshpass command in Powershell?
Let's say my ip address is 1.1.1.1 and I am connecting to a server whose ip is 2.2.2.2, and both computers OS systems are Windows. When I connect to the server through ssh, it shows the "cmd" terminal of the server. How can I change it to show "cygwin" terminal when I connect to the server?
I am having very hard time fixing this out.. Thank you very much in advance..
I am not sure i am getting this, anyway, if i understand correctly you have a hard time launching sshpass from powershell.
Try using Start-Process commandlet: (maybe add the full path to ssh in arguments (?))
start-process -filepath C:\cygwin64\bin\sshpass.exe -ArgumentList '-p<password> ssh <username>#<host>' -Wait -NoNewWindow
Anyway instead of reaching linux commands to windows and run it from powershell, why don't you check powershell modules?
ssh using powerShell script by passing the password along with the Commnad
Also, Powershell Remoting towards linux is a thing nowadays, and it runs over ssh (not bash afaik)

PSExec could not start Regedit.exe on remote PC

Background:
I have several registry keys that are saved and used to update/configure remote PCs in my environment. I may not have deployed the device, previously, but I use these registry keys to update the PC as I fix/repair/etc...I am part of a team of 45 managing about 25,000 workstations and peripherals in our region of the enterprise.
if I use this command from my Win 10 PC to a Win 7 PC, it executes without problems.
psexec \remotecomputer -u domain\adminaccount regedit.exe /i /s "\server\share\directory1\directory2\directory3\someregistry.reg"
psexec starts regedit, imports the above registry file and closes.
If I run that exact same command from my Win 10 PC to another Win 10 PC, I get the following error, from CMD as ADMIN,
"PsExec could not start regedit.exe on REMOTEPC_HOSTNAME:
The system cannot find the file specified."
it can't find regedit??? WTF??
I'm curious why Win 10 is blocking me, as an admin, from importing a registry key?
I've tried reg import as a solution, but I keep getting syntax errors and it can't find the file/pathway.
It's almost like the remote PC, doesn't recognize admin input due to UAC settings?
In testing, I've set the group policy editor to enable remote registry tools, no change. I've enabled remote registry services and set to start the service automatically. I can access the PC registry via remote registry...but psexec just won't work on the remote device.
I can RDP to the device and run the command line equivalent:
regedit.exe /i /s "\UNC\pathway...\etc*.*reg" it executes, without issues.
this proves that regedit is working
Can anyone provide some expertise on this?
add -s flag to psexec to run regedit
The old PsExec trick of running RegEdit doesn't always work. This is because psexec depend on a hidden SMB Administrator service. (Which in any security sense should be disabled.)
PsExec allows redirects of the input and output of a remotely started
executable through the use of SMB and the hidden $ADMIN share on the
remote system. With this share, PsExec uses the Windows Service
control Manager API to start the PsExecsvc service on the remote
system which creates a named pipe that PsExec communicates with. This
named pipe is what allows for input/output redirection back to the
system that launched PsExec.
So instead, in order to remove any TrustedInstaller owned registry Keys, you can use a different tool. This worked:
ExecTI - Run as TrustedInstaller
Run it to open the ExecTI GUI and enter: C:\Windows\regedit.exe

how do i make a service run a script outside of session 0

The UPS software I am using has functionality to run a script on the management PC (PC1) when it goes into battery mode. I have come up with a powershell script (ShutdownVM.ps1) that works fine on its own to Invoke-Commands on the VM server; shutting down VM's gracefully and turning off the host machine (SERVER). The first problem arose when the UPS software could not directly run a .ps1 file.
Simple enough, I thought I would make a simple .bat (shutdown.bat) file to run the .ps1 file on PC1 to shut everything off on SERVER. Running my .bat file from the desktop pc worked perfectly, but as the UPS software would run it as a service, my poor .bat file would run from Session 0.
Here is the code i used in Shutdown.bat:
#echo on
Powershell.exe -executionpolicy unrestricted -command C:\Windows\ShutdownVM.ps1
The interactive services manager would pop up and my computer would hang and finally the UPS software would turn it off and I'd be back to square one, with SERVER and its VM's still running. So I thought I would download and use PSExec to execute my shutdown.bat file.
I made another .bat file and called it PSExec.bat and below is the code in it:
#echo on
psexec.exe -accepteula \\PC1 -h -u user -p pass -i 2 C:\Windows\shutdown.bat
Finally! It tries to run! Upon checking the interactive services manager, it showed the PSExec was throwing the error "the system cannot find the file specified"
"The System Cannot Find The File Specified"
I have no idea what file it is even looking for, I have double, triple checked the path names in my scripts and still have no idea as to what it is doing. If anyone could shed any light (or let me know of an easier way to achieve what I am trying to do) that would be great. Thanks!
-F

Noninteractive Remote Commands with Powershell

I am developing a script which uses ssh to connect to a windows host, run a powershell command, and parse the output. While I can connect to the host and run the command, powershell will not exit and return control back to the local script until I press the enter key.
At the moment, the specific command being run is ssh HOSTNAME 'echo $(hostname)' and the ssh server is configured to pass remote execution requests to powershell -noninteractive -command CMD, where HOSTNAME is the name of the windows host and CMD is the remote command to be run (in this case echo $(hostname)).
The end goal is to have the script which is calling remote powershell commands to run completely noninteractively, but this is currently impossible as the powershell command will not run noninteractively.
How do I get powershell to run remote commands noninteractively?
I've resolved the issue. While I haven't determined what was causing the issue, I can at least overcome the issue at hand by redirecting stdin to /dev/null on the side that initiates the ssh connection.
$ ssh HOSTNAME "CMD" </dev/null
This solution doesn't involve powershell at all, but rather treats the symptoms from the other side of the connection.

FreeSSHd in jenkins and from commandline

i have installed fresshd in one of my windows server.now i am connect to the system through putty. It is working fine.
my issue us when i am running from command line
PuTTY.lnk -ssh -2 -P 22 username#XXX -pw pswd -m command.txt
commands given in the command.txt files are not executed it just open the putty console and it is closing.
when Running from Jenkins also same issue.
I am not sure if you are connecting to Windows from a Linux machine, or to Linux from a Windows machine. Or Windows to Windows?
PuTTY.lnk is not an executable. If you try to run that, it should produce an error 'PuTTY.lnk' is not recognized as an internal or external command. I am assuming you are running the command from a Windows machine, since you are referring to windows shortcut file (.lnk)
You need to use PuTTY.exe + the rest of your command line. Please note that unless it is in your $PATH settings, you would have to provide a full path to the .exe, for example C:\LocationOfPuttyInstall\putty.exe -ssh -2 -P 22 username#XXX -pw pswd -m command.txt. For the sake of preventing any other problem, you should also specify a correct full path to the command.txt file.
If you are not sure where your Putty is installed, on the Windows machine, do the following:
Right click your PuTTY shortcut (the PuTTY.lnk file)
Look under "Target"
That would list your full path to PuTTY.exe executable.
This should resolve your problem.
p.s.
Usually Putty is used to connect from a Windows machine to a Linux machine. From your question, it almost looks like you are trying to connect from a Windows machine to another Windows machine.
You should use PsExec windows tool for such purposes:
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx