Tag Archives: remote execution

Using winexe on CentOS 7 to execute commands on remote Windows 7 machines

winexe is an application for Linux that you can use to execute remote commands on Windows machines. Similar to how a meterpreter would work or how you use psexec on Windows.
The reason for using it could be that you want to script certain actions on remote machines, such as executing powershell scripts and gather information for forensic purposes etc. I was interested in it because of the last example.

In this guide I will show you how to do that and build a scenario for you and show you how one could use it to collect remote information on your endpoints. As usual I use CentOS 7 with the latest updates as per the date of this post.

Download winexe from here. If you download the current source (as per this date) it is called “winexe-winexe-waf-b787d2a2c4b1abc3653bad10aec943b8efcd7aab.zip” with sha1sum cbbebd80c935a8408448f3a92c04b85ea19a8b64

Or, clone it using git:

Make sure you have all the packages installed. You will need the epel repo for some packages as well.

3. Unzip the package downloaded in step 1 (I downloaded it to /root/) and navigate into the source folder. Or if you used git simple go into the folder and then in the source folder.

4. Build it

5. If everything works good you will get the output

Time for the fun stuff. Now you will have your winexe binary in the build directory. Navigate into the folder build

Now. Before we continue you need to set up the Windows machine. There are some issues with Windows 7 and later as described here. I had to add this key to my machine to make it work:

Start cmd as administrator and paste it in. That should be everything.

I have already uploaded a powershell script to my machine. It will run some commands and output this to a text file locally on the system. The local user I have created is called “bob” with the password of “secretpassword”. The system I am targeting is a system called windows.domain.local. Note that it is not joined to a active directory domain, it is just a domain I use for testing. You could do it with kerberos and an active directory account as well. The command line for executing the powershell script is:

The –uninstall parameter removes the service that winexe installs after it is done.
The other parameters you can read about here

To just run a simple ipconfig you can do like this

Or maybe drop yourself into a shell: