使用 WScript.Exec 将文本通过管道传输到 netcat
Piping text into netcat using WScript.Exec
我正在玩 CTF 并希望将一些内容通过管道传输到 netcat 中,以便从监听端口的应用程序中获取非法响应。
这是我正在尝试做的事情:
Dim oShell : Set oShell = CreateObject("WScript.Shell")
oShell.Run "C:\users\me\Desktop\my_app.exe"
WScript.Sleep 1000
oShell.Exec "echo hello > C:\users\me\Desktop\netcat\nc.exe 127.0.0.1 4444"
我得到的是一个错误
WshShell.Exec: The system cannot find the file specified.
我认为这与 echo 命令有关,因为删除它效果很好。我做错了什么?
@m0atz 如@omegastripes 所述,您需要使用 StdIn。下面演示如何:
Dim wshShell, oExec, buffer
Set wshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\users\me\Desktop\netcat\nc.exe 127.0.0.1 4444")
oExec.StdIn.Write "hello" & vbCrLf
buffer = ""
While Not oExec.StdOut.AtEndOfStream
buffer = buffer & oExec.StdOut.Read(1)
Wend
WScript.Echo buffer
我正在玩 CTF 并希望将一些内容通过管道传输到 netcat 中,以便从监听端口的应用程序中获取非法响应。
这是我正在尝试做的事情:
Dim oShell : Set oShell = CreateObject("WScript.Shell")
oShell.Run "C:\users\me\Desktop\my_app.exe"
WScript.Sleep 1000
oShell.Exec "echo hello > C:\users\me\Desktop\netcat\nc.exe 127.0.0.1 4444"
我得到的是一个错误
WshShell.Exec: The system cannot find the file specified.
我认为这与 echo 命令有关,因为删除它效果很好。我做错了什么?
@m0atz 如@omegastripes 所述,您需要使用 StdIn。下面演示如何:
Dim wshShell, oExec, buffer
Set wshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("C:\users\me\Desktop\netcat\nc.exe 127.0.0.1 4444")
oExec.StdIn.Write "hello" & vbCrLf
buffer = ""
While Not oExec.StdOut.AtEndOfStream
buffer = buffer & oExec.StdOut.Read(1)
Wend
WScript.Echo buffer