cea-sec / sanzu

Graphical remote desktop solution
GNU General Public License v3.0
175 stars 27 forks source link

proxycommand support for Windows clients #117

Closed Ch1nkara closed 1 year ago

Ch1nkara commented 1 year ago

Hello,

To my understanding, it is not yet possible to do the equivalent to

sanzu_client 127.0.0.1 1337 --proxycommand "ssh rochefort DISPLAY=:1234 sanzu_server --stdio"

on a windows client, due to the client.rs proxycommand handling (via SHELL_PATH: &str = "/bin/sh";, among other things). Is it correct or did I miss something ? So far, I've used the proxycommand on Linux clients, but I had to manually build a ssh tunnel on windows clients to do the equivalent.

Thanks for your amazing work !

serpilliere commented 1 year ago

Hi @Ch1nkara

Oh! Correct: I didn't tested it on windows, and as you noticed, the code needs to be fixed.

Ch1nkara commented 1 year ago

I rebuilt with this code instead, and it worked fine (if it can helps)

            let mut child;
            if cfg!(target_os = "windows") {
              child = Command::new("cmd")
                .args(["/C", &commandline])
                .stdout(Stdio::piped())
                .stdin(Stdio::piped())
                .spawn()
                .context("Error in launch proxycommand")?; 
            } else {
              child = Command::new("/bin/sh")
                .arg("-c")
                .arg(&commandline)
                .stdout(Stdio::piped())
                .stdin(Stdio::piped())
                .spawn()
                .context("Error in launch proxycommand")?;
            }
            info!("Proxycommand {:?}", child);
serpilliere commented 1 year ago

Nice! Tell me if you are ok with the pr #118 to fix this: The only difference is that the distinction between os is done in a structure creation.

Ch1nkara commented 1 year ago

Your solution is cleaner !