0 command-line shell bash shell-script
我正在尝试将 windows 命令传递到 linux netcat shell,然后读回输出。
到目前为止,我有:
cat <( printf 'ipconfig\n' )| nc -v 137.148.70.243 443
Run Code Online (Sandbox Code Playgroud)
当复制并粘贴到我漂亮的 linux 终端时,它会从连接的 Windows 机器获取 ip 信息。
但是,当我尝试通过 bash 调用相同的命令时,出现以下错误:
./DumpIP.sh: line n: syntax error near unexpected token `('
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?
编辑
所以如果我尝试:
#!/bin/sh
cat <( printf 'ipconfig\n' )| nc -l
Run Code Online (Sandbox Code Playgroud)
我得到
./DumpCreds.sh: line 2: syntax error near unexpected token `('
./DumpCreds.sh: line 2: `cat <( printf 'ipconfig\n' )| nc -l'
Run Code Online (Sandbox Code Playgroud)
您的问题是您正在调用sh
而不是bash
在 shebang 行中为您的脚本调用。的语法约定<(command)
是一种 bashism,在通过 调用时不存在sh
,它模拟 POSIX shell(如果/bin/sh
是到 的符号链接/bin/bash
)。