我们使用winexe在Linux的Windows机器上执行命令。例如:
winexe -A authfile //syspc4.domain.com "ipconfig /all"预期上面的输出结果与您在Windows计算机上运行cmd.exe并输入"ipconfig /all“相同。
我的最终目标是远程(从Linux)获取窗口的机器序列号和型号名称。在Windows (Windows )机器上本地使用cmd.exe中的以下两个命令很容易实现这一点:
wmic bios get serialnumber
wmic computersystem get model然而,任何通过winexe执行此操作的尝试都不起作用--在按回车之后,什么也不会发生。没有错误,什么都没有。它只会被冻结,直到我ctrl+c离开它。
下面是我尝试过的命令:
winexe -A authfile //syspc4.domain.com "wmic bios get serialnumber"
winexe -A authfile //syspc4.domain.com "cmd wmic bios get serialnumber"
winexe -A authfile //syspc4.domain.com "cmd /c wmic bios get serialnumber"
winexe -A authfile //syspc4.domain.com "cmd"
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\WINDOWS\system32>wmic bios get serialnumber在所有情况下,都没有回应。快速查看winexe -help会发现一个日志选项,但是即使设置了这个选项,也没有任何类型的输出日志。
我在另一个论坛上找到了下面的帖子,在这个论坛上,这个人问的问题和我差不多,当然他从来没有得到过答案:http://www.linuxquestions.org/questions/linux-software-2/winexe-780343/
编辑:打开调试后,它就挂在这里:
winexe -d 6 -A authfile //syspc4.domain.com "wmic bios get serialnumber"
...
IN: async_open(\pipe\ahexec, 2)
IN: async_open_recv
CTRL: Sending command: get version
CTRL: Sending command: run wmic bios get serialnumber
CTRL: Recieved command: std_io_err 15C40030
IN: async_open(\pipe\ahexec_stdin15C40030, 2)
IN: async_open(\pipe\ahexec_stdout15C40030, 2)
IN: async_open(\pipe\ahexec_stderr15C40030, 2)
IN: async_open_recv
IN: async_open_recv
IN: async_open_recv
**hangs forever here**
Then ctrl+c:
^CAborting...
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: on_ctrl_pipe_error - NT_STATUS_PIPE_DISCONNECTED然而,奇怪的是,即使使用一个不会失败的命令(如ipconfig /all),它也提供了完全相同的内容:
...
IN: async_open(\pipe\ahexec, 2)
IN: async_open_recv
CTRL: Sending command: get version
CTRL: Sending command: run ipconfig /all
CTRL: Recieved command: std_io_err 15C40031
IN: async_open(\pipe\ahexec_stdin15C40031, 2)
IN: async_open(\pipe\ahexec_stdout15C40031, 2)
IN: async_open(\pipe\ahexec_stderr15C40031, 2)
IN: async_open_recv
IN: async_open_recv
IN: async_open_recv
Windows IP Configuration
...
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: smb_raw_read_recv - NT_STATUS_PIPE_DISCONNECTED
ERROR: on_ctrl_pipe_error - NT_STATUS_PIPE_DISCONNECTED发布于 2013-09-19 20:32:47
在这里使用WMI-Client:http://www.orvant.com/packages/并直接从Linux运行WMIC命令,尽管您必须使用命令的WQL等价物,因为这个版本不支持非WQL查询。
https://unix.stackexchange.com/questions/82825
复制相似问题