Thursday, April 14, 2011

Winexe: To run code on windows machines from Linux

References:
The instructions on this post are a summary of information collected from this link. And I made some changes to it as well

These are instructions of how to get winexe working on Ubuntu 10.04.1 LTS system

To begin with make sure your system has the required libraries:
sudo apt-get install build-essential autoconf checkinstall

You will also need the python development libraries and header files:
sudo aptitude install python python-all python-dev python-all-dev python-setuptools


Now get the source code of winexe using svn. And apply the first patch:
svn co http://dev.zenoss.org/svn/trunk/wmi/Samba/source
cd source
wget https://gist.github.com/raw/843062/5bb87c4fa13688f65ca8b1e54fc42676aee42e5a/fix_winexe_service.diff
patch -p0 -i fix_winexe_service.diff


Now there is bug in the source/winexe/service.c file:
replace file
#define NT_STATUS_SERVICE_DOES_NOT_EXIST NT_STATUS(0xc0000424)

with
#define NT_STATUS_SERVICE_DOES_NOT_EXIST NT_STATUS(0x00000424)


Save,close and you are ready to compile:
cd source/
./autogen.sh
./configure
make proto bin/winexe
sudo cp bin/winexe /usr/local/bin/


and now you can test that that winexe is working correctly by doing:
winexe -W WORKGROUP -U Administrator%SecretPassword //192.168.xxx.xxx 'cmd.exe'