One of the software applications that I use at work relies on a linux uility called “winexe”. It turns out that this particular tool is incompatible with Windows 8.1, 10 and Server 2012R2. This incompability is due to the fact that SMB 1.0 support was removed from these versions of Windows(1), and the tool uses it, so now it doesn’t work.
The major symptom is running the tool and getting the error “NT_STATUS_INVALID_PARAMETER”, but seeing that the authentication is working successfully (I confirmed this by putting in the right + wrong password and noticing the behavior change).
The fine folks over at winexe did release a version 1.1 that fixes this issue. Unfortunately, it has to be statically compiled against Samba, and a specific version at that. This took me several hours to solve, and I drew from several resources to accomplish it. Here is the process I used.
# make sure EPEL is enabled in /etc/yum.repos.d/epel.repo # fixup a bunch of samba dependencies yum install gcc perl mingw-binutils-generic mingw-filesystem-base mingw32-binutils mingw32-cpp mingw32-crt mingw32-filesystem mingw32-gcc mingw32-headers mingw64-binutils mingw64-cpp mingw64-crt mingw64-filesystem mingw64-gcc mingw64-headers libcom_err-devel popt-devel zlib-devel zlib-static glibc-devel glibc-static python-devel yum install git gnutls-devel libacl1-dev libacl-devel libldap2-dev openldap-devel #per the docs, remove libbsd-devel if installed yum remove libbsd-devel #clone the git repos. samba is huge, like 280MB cd /usr/src git clone git://git.code.sf.net/p/winexe/winexe-waf winexe-winexe-waf git clone git://git.samba.org/samba.git samba #per winexe bug 64, samba needs to be reverted to a6bda1f2bc85779feb9680bc74821da5ccd401c5 # cd /usr/src/samba git reset --hard a6bda1f2bc85779feb9680bc74821da5ccd401c5 #fixup the build deps. I chose to build it as big and static as I could, so the only linked dependency is gnutls # cd /usr/src/winexe-winexe-waf/source # modify 'wscript_build', and at the very end ... stlib='smb_static bsd z resolv rt' lib='dl gnutls' #build it! this does a huge configure, then also compiles samba, which takes a while. ./waf --samba-dir=../../samba configure build #executable should be /usr/src/winexe-winexe-waf/source/build/winexe-static
Plenty of help from the following URLs:
(1) http://sourceforge.net/p/winexe/bugs/30/#a8c8
http://sourceforge.net/p/winexe/bugs/64/
http://sourceforge.net/p/winexe/winexe-waf/ci/master/tree/README
https://www.reddit.com/r/linuxadmin/comments/2xsmge/winexe_1001_for_centos_6_x86_64/cp3a4e8
Hi, can you confirm that winexe can successfully connect to windows 10 box ?
Thanks
Thank you so much for this. Helped a ton!
There is a very minor typo in your code.
stlib=’stlib=’smb_static bsd z resolv rt’,
lib=’dl gnutls’
Should instead be,
stlib=’smb_static bsd z resolv rt’,
lib=’dl gnutls’
Yes, this works on Windows 10 without a problem (that was my easy testbed). And thanks for the typo notice, I just cleaned that up.
Just wanted to say THANK YOU.
I am hitting following error
Could not find the program i386-mingw32-gcc,i386-mingw32msvc-gcc,i386-w64-mingw32-gcc,i586-mingw32-gcc,i586-mingw32msvc-gcc,i586-w64-mingw32-gcc,i686-mingw32-gcc,i686-mingw32msvc-gcc,i686-w64-mingw32-gcc
(complete log in /scratch/cjoshi/winexe-waf/source/build/config.log)
where as these packages are shown as existing..
not sure whats issue here
It appears that you may not have the ming source code in your compile path?
This has fixed it. Like you I’d spent hours trying to dig to the bottom of why salt isn’t talking to my Windows 8.1 box. I found most of the bits to the puzzle but without your explanation I wouldn’t’ve succeeded.
Great work and thanks.
ps: I did it on Centos 7.2 and all the steps worked perfectly.
Worked perfectly on Centos 7.2 !
Thank you so much
Thank you. Worked on Centos 6.x
FWIW kudos. Scary thing is winexe (as best I can tell) hasn’t been updated in about 2.5 years.
Worked fine on Ubuntu 16.04.1 x86_64 with Windows 10 x86_64 after:
– the following packages were installed:
libacl1-dev libldap2-dev libgnutls-dev comerr-dev libbsd-dev mingw-w64-i686-dev
mingw-w64-x86-64-dev
– some minor changes in the code were made: the lines containing calls to
gnutls_certificate_type_set_priority() had to be commented-out in the following
files:
source4/lib/tls/tls.c (line #601)
source4/lib/tls/tls_tstream.c (line #1017)
This call is obsolete in latest versions of gnutls it seems:
https://www.redhat.com/archives/libvir-list/2011-July/msg01555.html
– modified LocalAccountTokenFilterPolicy in the registry according to:
https://sourceforge.net/p/winexe/winexe-waf/ci/master/tree
https://support.microsoft.com/en-gb/kb/942817
Thank you very much for the great quality of your original post, it was very, very helpful.
Hello,
When I build I’ve got a bunch of ‘undefined reference to ….’ and it leads to an error:
Build failed
-> task in ‘winexe-static’ failed (exit status 1):
{task 39427536: cprogram winexe.c.6.o,svcinstall.c.6.o,async.c.6.o,winexesvc32_exe.c.6.o,winexesvc64_exe.c.6.o -> winexe-static}
[‘/usr/bin/gcc’, ‘-pthread’, ‘winexe.c.6.o’, ‘svcinstall.c.6.o’, ‘async.c.6.o’, ‘winexesvc32_exe.c.6.o’, ‘winexesvc64_exe.c.6.o’, ‘-o’, ‘/usr/src/winexe-winexe-waf/source/build/winexe-static’, ‘-Wl,-Bstatic’, ‘-L/usr/src/winexe-winexe-waf/source/smb_static/build’, ‘-lsmb_static’, ‘-lbsd’, ‘-lz’, ‘-lresolv’, ‘-lrt’, ‘-Wl,-Bdynamic’, ‘-ldl’]
Have you got any tips for this issue please ?
does not work for me – did build a static version of winexe as described above – but I only get NT_STATUS_ACCESS_DENIED.
the supplied credentials are definitely correct. 🙁
now it is working – on the destination windows machine (version > windows 7) you need to change a registry key, do that in an administrative console:
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
Hi,
thanks full for this post, help me very much.
Thanks.
Note: in Centos 7 is not required install libacl1-dev and libldap2-dev.
Regards.
I got this at the end of the build, anyone know why?
Waf: Leaving directory `/usr/src/samba/bin’
‘build’ finished successfully (4m58.451s)
Checking for library smb_static : yes
Checking for library popt : yes
Checking for library com_err : yes
Checking for library bsd : yes
Checking for library z : yes
Checking for library resolv : yes
Checking for library rt : yes
Checking for library dl : yes
Checking for program i386-mingw32-gcc,i386-mingw32msvc-gcc,i386-w64-mingw32-gcc,i586-mingw32-gcc,i586-mingw32msvc-gcc,i586-w64-mingw32-gcc,i686-mingw32-gcc,i686-mingw32msvc-gcc,i686-w64-mingw32-gcc : /usr/bin/i686-w64-mingw32-gcc
Checking for program x86_64-mingw32-gcc,x86_64-mingw32msvc-gcc,x86_64-w64-mingw32-gcc,amd64-mingw32-gcc,amd64-mingw32msvc-gcc,amd64-w64-mingw32-gcc : /usr/bin/x86_64-w64-mingw32-gcc
‘configure’ finished successfully (5m56.952s)
Waf: Entering directory `/usr/src/winexe/source/build’
[ 1/16] c: winexesvc_launch.c -> build/winexesvc_launch.c.1.o
[ 2/16] c: winexesvc_loop.c -> build/winexesvc_loop.c.1.o
[ 3/16] c: winexesvc_launch.c -> build/winexesvc_launch.c.2.o
[ 4/16] c: winexesvc_loop.c -> build/winexesvc_loop.c.2.o
[ 5/16] c: bin2c.c -> build/bin2c.c.3.o
[ 6/16] c: winexe.c -> build/winexe.c.6.o
[ 7/16] c: svcinstall.c -> build/svcinstall.c.6.o
[ 8/16] c: async.c -> build/async.c.6.o
[ 9/16] cprogram: build/winexesvc_launch.c.1.o build/winexesvc_loop.c.1.o -> build/winexesvc32.exe
[10/16] cprogram: build/winexesvc_launch.c.2.o build/winexesvc_loop.c.2.o -> build/winexesvc64.exe
[11/16] cprogram: build/bin2c.c.3.o -> build/bin2c
[12/16] winexesvc32_exe.c: build/bin2c build/winexesvc32.exe -> build/winexesvc32_exe.c
[13/16] c: build/winexesvc32_exe.c -> build/winexesvc32_exe.c.6.o
[14/16] winexesvc64_exe.c: build/bin2c build/winexesvc64.exe -> build/winexesvc64_exe.c
[15/16] c: build/winexesvc64_exe.c -> build/winexesvc64_exe.c.6.o
[16/16] cprogram: build/winexe.c.6.o build/svcinstall.c.6.o build/async.c.6.o build/winexesvc32_exe.c.6.o build/winexesvc64_exe.c.6.o -> build/winexe-static
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
Waf: Leaving directory `/usr/src/winexe/source/build’
Build failed
-> task in ‘winexe-static’ failed (exit status 1):
{task 15314000: cprogram winexe.c.6.o,svcinstall.c.6.o,async.c.6.o,winexesvc32_exe.c.6.o,winexesvc64_exe.c.6.o -> winexe-static}
[‘/usr/bin/gcc’, ‘-pthread’, ‘winexe.c.6.o’, ‘svcinstall.c.6.o’, ‘async.c.6.o’, ‘winexesvc32_exe.c.6.o’, ‘winexesvc64_exe.c.6.o’, ‘-o’, ‘/usr/src/winexe/source/build/winexe-static’, ‘-Wl,-Bstatic’, ‘-L/usr/src/winexe/source/smb_static/build’, ‘-lsmb_static’, ‘-lbsd’, ‘-lz’, ‘-lresolv’, ‘-lrt’, ‘-Wl,-Bdynamic’, ‘-ldl’, ‘-lgnutls’]
nevermind, missing the package “zlib-static”, installed it and re configure, works.
Doesn’t work on Win 10 Pro Edu (1709). Still, while trying with psexec (from sysinternals), client responds. But with winexec-static it doesn’t. With Win7 it’sOK.