summaryrefslogtreecommitdiff
path: root/examples/winexe
AgeCommit message (Collapse)AuthorFilesLines
2025-04-18s3:libsmb: introduce smbsock_connect.hStefan Metzmacher1-0/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-18example/winexe: pass struct smb_transports through some more layersStefan Metzmacher1-6/+5
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2025-04-18s3:libsmb: pass struct smb_transports to cli_full_connection_creds()Stefan Metzmacher1-2/+5
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2024-11-13examples:winexe: Initialize Trustee.ptstrName at the right timePavel Filipenský1-1/+2
This is a regression of a39cb60 examples:winexe: Fully initialize EXPLICIT_ACCESS BUG: https://bugzilla.samba.org/show_bug.cgi?id=15752 Signed-off-by: Pavel Filipenský <pfilipensky@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org> Autobuild-Date(master): Wed Nov 13 15:47:40 UTC 2024 on atb-devel-224
2024-07-18examples:winexe: Initialize integerAndreas Schneider1-1/+1
"Error: UNINIT (CWE-457): samba-4.20.0rc2/examples/winexe/winexesvc.c:147: var_decl: Declaring variable ""res"" without initializer. samba-4.20.0rc2/examples/winexe/winexesvc.c:156: uninit_use: Using uninitialized value ""res"". 154| GetOverlappedResult(pipe->h, &pipe->o, (LPDWORD)&res, TRUE); 155| FlushFileBuffers(pipe->h); 156|-> return res; 157| } 158|" Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2024-07-18examples:winexe: Fully initialize EXPLICIT_ACCESSAndreas Schneider1-10/+14
"Error: UNINIT (CWE-457): samba-4.20.0rc2/examples/winexe/winexesvc.c:60: var_decl: Declaring variable ""ea"" without initializer. samba-4.20.0rc2/examples/winexe/winexesvc.c:86: uninit_use_in_call: Using uninitialized value ""ea"". Field ""ea.Trustee.pMultipleTrustee"" is uninitialized when calling ""SetEntriesInAclA"". 84| 85| /* Create a new ACL that contains the new ACEs */ 86|-> dwRes = SetEntriesInAcl(1, &ea, NULL, &pACL); 87| if (ERROR_SUCCESS != dwRes) { 88| dbg(""SetEntriesInAcl Error %lu\n"", GetLastError());" Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2024-06-30winexe: Make sure specificError is initializedAndreas Schneider1-1/+1
"Error: UNINIT (CWE-457): samba-4.20.0rc2/examples/winexe/winexesvc.c:684: var_decl: Declaring variable ""specificError"" without initializer. samba-4.20.0rc2/examples/winexe/winexesvc.c:711: uninit_use: Using uninitialized value ""specificError"". 709| winexesvcStatus.dwWaitHint = 0; 710| winexesvcStatus.dwWin32ExitCode = status; 711|-> winexesvcStatus.dwServiceSpecificExitCode = specificError; 712| 713| SetServiceStatus(winexesvcStatusHandle, &winexesvcStatus);" Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2024-05-31examples:winexe: embed Samba version as exe timestampDouglas Bagnall1-7/+14
It turns out the timestamp doesn't need to be real, and it isn't used, but it might as well tell you something. So let's make it tell you what version of Samba it came from, which could be useful for people who have lots of old winexes lying around, the poor souls. 00000040 0e 1f ba 0e 00 b4 09 cd 21 b8 01 4c cd 21 54 68 |........!..L.!Th| 00000050 69 73 20 70 72 6f 67 72 61 6d 20 63 61 6e 6e 6f |is program canno| 00000060 74 20 62 65 20 72 75 6e 20 69 6e 20 44 4f 53 20 |t be run in DOS | 00000070 6d 6f 64 65 2e 0d 0d 0a 24 00 00 00 00 00 00 00 |mode....$.......| 00000080 50 45 00 00 64 86 0a 00 00 15 04 00 00 00 00 00 |PE..d...........| | | | | | major 4. | minor 21. release 0 BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Fri May 31 01:28:06 UTC 2024 on atb-devel-224
2024-05-31examples:winexe: reproducible builds with zero timestampDouglas Bagnall2-2/+16
Windows Portable Executable files have a timestamp field and a checksum field. By default the timestamp field is updated to the current time, which consequently changes the checksum. This makes the build nondeterministic. It looks like this: --- a/tmp/winexe-1/winexesvc64_exe_binary.c +++ b/tmp/winexe-2/winexesvc64_exe_binary.c @@ -23,7 +23,7 @@ const DATA_BLOB *winexesvc64_exe_binary(void) 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0x0D, 0x0D, 0x0A, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x45, 0x00, 0x00, 0x64, 0x86, 0x0A, 0x00, - 0xB2, 0x16, 0x55, 0x66, 0x00, 0x00, 0x00, 0x00, + 0xD3, 0x3B, 0x55, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x2E, 0x02, 0x0B, 0x02, 0x02, 0x26, 0x00, 0x86, 0x00, 0x00, 0x00, 0xBA, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, @@ -33,7 +33,7 @@ const DATA_BLOB *winexesvc64_exe_binary(void) 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, - 0x73, 0xD7, 0x00, 0x00, 0x03, 0x00, 0x60, 0x01, + 0x94, 0xFC, 0x00, 0x00, 0x03, 0x00, 0x60, 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, https://learn.microsoft.com/en-us/windows/win32/debug/pe-format says that a timestamp of zero can be used to represent a time that is not "real or meaningful", so we do that. As far as I can tell, the timestamp and checksum are only used in DLLs, not directly executed .exe files. Thanks to Freexian and the Debian LTS project for sponsoring this work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13213 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-05-31examples:winexe: more efficient C array generation, no py2Douglas Bagnall1-18/+7
We don't need to recreate the src array every time, and we don't need to worry about Python 2 strings. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-04-29s3:libsmb: Pass memory context to cli_full_connection_creds()Andreas Schneider1-0/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2023-10-10libsmb: Pass "flags" through cli_close_send() and pylibsmbVolker Lendecke1-20/+17
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15487 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-03-28examples: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Rowland Penny <rpenny@samba.org>
2022-12-16build: Convert winexe to use enabled= in wscriptAndrew Bartlett1-26/+34
This also allows --without-winexe to stop building the .exe files even if the compilers are present on the system. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15264 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Dec 16 07:41:38 UTC 2022 on sn-devel-184
2022-07-28examples/winexe: fix fetching return code of the remote commandYury Lunev1-1/+1
ctrl_inbuf field is used to parse remote-side information. A typo was there that tried to parse return code as "version 0x%x" whereas the correct way to do it (tested on Windows 10) is to scan for "return_code %x". Signed-off-by: Yury Lunev <yury.lunev@gmail.com> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Jul 28 18:01:16 UTC 2022 on sn-devel-184
2021-12-02s3:rpc_client: Pass remote name and socket to ↵Günther Deschner1-2/+12
cli_rpc_pipe_open_noauth_transport() BUG: https://bugzilla.samba.org/show_bug.cgi?id=14767 Pair-Programmed-With: Andreas Schneider <asn@samba.org> Signed-off-by: Guenther Deschner <gd@samba.org> Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2021-11-05s3-winexe: Fix winexe core dump (use-after-free)Günther Deschner1-4/+12
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14893 Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Günther Deschner <gd@samba.org> Autobuild-Date(master): Fri Nov 5 11:43:57 UTC 2021 on sn-devel-184
2021-06-20winexe: Some code cleanup and fixesAndreas Schneider1-3/+3
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-20winexe: Use the new cmdline option parserAndreas Schneider2-109/+36
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14616 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28auth:creds: Add obtained arg to cli_credentials_set_kerberos_state()Andreas Schneider1-1/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-26winexe: Fix a possible null pointer derferenceAndreas Schneider1-9/+13
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-11-03auth:creds: Rename CRED_USE_KERBEROS valuesAndreas Schneider1-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2020-08-19s3:libsmb: Remove signing_state from cli_full_connection_creds()Andreas Schneider1-3/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-08-19s3:libsmb: Introduce CLI_FULL_CONNECTION_IPCAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2020-03-09winexe: add configure option to control whether to build it (default: auto)Günther Deschner1-1/+2
Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Mon Mar 9 16:27:21 UTC 2020 on sn-devel-184
2020-03-09librpc: fix IDL for svcctl_ChangeServiceConfigWGünther Deschner1-0/+2
Found while trying to run winexe against Windows Server 2019. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14313 Guenther Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-07-05winexe: Add support for connecting to a host on an alternate portKarl Lenz1-3/+23
This commit allows an optional port number to be specified after the hostname on the winexe command line. If no port is given, it defaults to port 445, just like it used before. Although this is probably a pretty uncommon use-case, it allows port-forwarding the service through a firewall to an alternate port, which can occassionally be helpful. $ ./bin/winexe -U karl%password1 //127.0.0.1:5445 cmd.exe Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Windows\system32> Signed-off-by: Karl Lenz <xorangekiller@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-07-05winexe: Fix translation of the winexesvc binaries to CKarl Lenz1-4/+26
Two small Windows binaries that winexe uses to execute commands on a remote system, winexesvc32.exe and winexesvc64.exe, are compiled then translated into a C byte array as hex so that they can be embedded into the winexe binary. Although the winexesvc binaries were built properly, the Python method that does the translation to C tried to open them in text mode, which would have worked in Python 2 before the concept of bytearrays was introduced, but instead raises an exception in Python 3. The exception was unfortunately suppressed, so the build didn't stop, and the winexe binary that was produced was effectively useless because it didn't contain either winexesvc binary as expected. After winexe successfully authenticated with a Windows host, it showed the error message below rather than executing the given command on the remote system. $ ./bin/winexe -U karl%password1 -d 2 //192.168.56.3 cmd winexe_svc_install: dcerpc_svcctl_StartServiceW failed: WERR_BAD_EXE_FORMAT main: winexe_svc_install failed: NT_STATUS_BAD_INITIAL_PC This commit fixes that problem by opening the winexesvc binaries in binary mode rather than text mode when the winexe build script reads them to translate them to C. Furthermore it adds an additional sanity check that will cause the winexesvc binary generator commands to fail if the winexesvc binaries cannot be opened or read correctly to guarantee that the build does not silently "succeed" if something like this ever happens again. Signed-off-by: Karl Lenz <xorangekiller@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2019-05-28winexe: Use C99 initializer for poptOption in winexe.cStefan Metzmacher1-34/+115
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-12-13s3:libsmb: pass impersonation_level to cli_ntcreate_send()Stefan Metzmacher1-0/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Tim Beale <timbeale@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-27PY3: fix "TabError: inconsistent use of tabs and spaces"Noel Power1-10/+10
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-05examples: Fix mingw64 detectionVolker Lendecke1-0/+2
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-28examples: Add winexe re-implemented on current Samba libsVolker Lendecke6-0/+2788
winexe from https://sourceforge.net/projects/winexe/ is a project based on Samba libraries from 2012. According to the winexe git repository the last Samba commit winexe was updated to is 47bbf9886f0c from November 6, 2012. As winexe uses unpublished Samba internal libraries, it broke over time. This is a port of the winexe functionality to more modern Samba versions. It still uses internal APIs, but it being part of the tree means that it is much easier to keep up to date. The Windows service files were taken literally from the original winexe from the sourceforge git. Andrzej Hajda chose GPLv3 only and not GPLv3+. As GPL evolves very slowly, this should not be a practical problem for quite some time. To build it under Linux, you need mingw binaries on your build system. Under Debian stretch, the package names are gcc-mingw-w64 and friends. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Aug 28 02:03:07 CEST 2018 on sn-devel-144