使用WScript.Exec将文本管道化为netcat

时间:2017-09-18 13:14:13

标签: vbscript netcat

我正在玩一个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命令,因为删除它工作正常。我做错了什么?

1 个答案:

答案 0 :(得分:0)

@ m0atz as @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