Headless GUI Automation on Windows From Linux using Winexe

This is a demonstration of Winexe, which is an open-source remote command execution utility for Windows. It is similar to PSExec from SysInternals. They both work pretty much the same way - they install and start a Windows service. You don't need to install anything on the target machine as the installation is handled remotely by the command line utility.

Prerequisites
Windows
  • Administrative access. This would make it difficult to test on the machine using a non-admin account. This is required primarily to install and start the service. The administrative account must have a password. There maybe a couple of ways around this though - we could try and keep the service running and then remove admin access from the user account or we could use an admin account to connect but then use 'RunAs' to impersonate a non-admin user on the target machine. I haven't tested either possibility yet
  • Local Security policy - I wasn't able to get it to work even with admin access because it didn't appear to have the privileges to add a Windows service so I had to add the 'Administrators' group to to the Local Security Policy for 'Local Policies\User Rights Assignment\Act as part of the operating system'. This was a lazy thing to do but I was rushed for time and couldn't figure out which key controls the ability to add a service to the machine
  • Remote sharing and remote administration need to be enabled on the target machine
  • The 'Workstation' and 'Server' service should be enabled and and running
  • The 'Windows Network' and 'Printer and File Sharing' should be activated
  • The remote IPC and remote admin shares should be available. To check if this is available, run 'net share' at the command prompt and you should see the 'IPC$', 'C$' and 'ADMIN$' shares listed. On Windows XP you need to disable 'Simple Sharing' under 'Control Panel\Folder Options\View\Use simple file sharing'
  • Disable the firewall - again a lazy approach to prove that this works. We will need to figure out the exact ports to allow

Linux
  • I used Oracle Linux so depending on your architecture and distro, you may need to find the appropriate installers. I couldn't find python-dev so I did a 'yum search python | grep -i devel' to find python-devel.x86_64
  • At the Linux console type -
  • You might see a bunch of errors and warnings - you can ignore most of them but pay attention to the end of the list for each of the commands above - fatal problems are always listed in the end and you may be missing a library or two for ./configure to complete successfully
  • You can now run './bin/winexe -U [domain]/[user]%[password] //host-ip cmd.exe' to get access to the remote command prompt
  • I ran this on the private cloud and SMB/CIFS is blocked so I could only get this to work between two private cloud machines - a Linux host and a Windows host

Comments

Popular posts from this blog

The Forecaster Brown Fan Club

How to Create a Pentaho Report Using the REST Client

Automated Testing with vncdotool (Not Headless, but Hairless)