randomize UNAME_RESPONSES
parent
6280fec83f
commit
b6dfad22fb
|
@ -1058,6 +1058,7 @@ dependencies = [
|
|||
"env_logger",
|
||||
"futures",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
"russh",
|
||||
"russh-keys",
|
||||
"tokio",
|
||||
|
|
|
@ -14,3 +14,4 @@ log = "*"
|
|||
env_logger = "*"
|
||||
anyhow = "*"
|
||||
chrono = "0.4"
|
||||
rand = "0.8"
|
||||
|
|
|
@ -5,6 +5,7 @@ use std::pin::Pin;
|
|||
|
||||
use futures::FutureExt;
|
||||
use log::info;
|
||||
use rand::{Rng, thread_rng};
|
||||
use russh::server::{Auth, Session};
|
||||
use russh::*;
|
||||
|
||||
|
@ -23,6 +24,12 @@ enum CommandStatus {
|
|||
Scp,
|
||||
}
|
||||
|
||||
const UNAME_RESPONSES: &[&str] = &[
|
||||
"Linux fnordister 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64 GNU/Linux",
|
||||
"Linux raspberrypi 5.19.9 #1-NixOS SMP Thu Sep 15 08:47:20 UTC 2022 aarch64 GNU/Linux",
|
||||
"Linux OpenWrt 5.10.138 #0 Sat Sep 3 02:55:34 2022 mips GNU/Linux",
|
||||
];
|
||||
|
||||
pub struct Handler {
|
||||
filename: String,
|
||||
lazy_file: Option<File>,
|
||||
|
@ -66,7 +73,11 @@ impl Handler {
|
|||
match program {
|
||||
"whoami" => respond(&self.user),
|
||||
"id" => respond(&format!("uid=0({}) gid=0(root)", self.user)),
|
||||
"uname" => respond("Linux fnordister 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64 GNU/Linux"),
|
||||
"uname" => {
|
||||
let mut rnd = thread_rng();
|
||||
let i = rnd.gen_range(0..UNAME_RESPONSES.len());
|
||||
respond(&UNAME_RESPONSES[i]);
|
||||
}
|
||||
"pwd" => respond("/"),
|
||||
"ls" => {
|
||||
respond("drwxr-xr-x 18 root root 18 Jan 4 1969 .");
|
||||
|
|
Loading…
Reference in New Issue