From 9ce60280b1de2790cffaf93a15c30187cc80e527 Mon Sep 17 00:00:00 2001 From: Noratrieb <48135649+Noratrieb@users.noreply.github.com> Date: Sat, 24 Aug 2024 00:51:47 +0200 Subject: [PATCH] the clueless rename --- Cargo.lock | 304 +++++++++--------- .../Cargo.toml | 6 +- .../src/main.rs | 6 +- bin/{sshdos => cluelessh-dos}/Cargo.toml | 6 +- bin/{sshdos => cluelessh-dos}/README.md | 0 bin/{sshdos => cluelessh-dos}/src/main.rs | 8 +- bin/{fakesshd => cluelessh-faked}/Cargo.toml | 4 +- bin/{fakesshd => cluelessh-faked}/README.md | 0 .../smoke-test.sh | 8 +- bin/{fakesshd => cluelessh-faked}/src/main.rs | 6 +- bin/{ssh-key => cluelessh-key}/Cargo.toml | 4 +- bin/{ssh-key => cluelessh-key}/src/main.rs | 12 +- bin/{ssh => cluelessh}/Cargo.toml | 10 +- bin/{ssh => cluelessh}/README.md | 0 bin/{ssh => cluelessh}/src/main.rs | 12 +- .../Cargo.toml | 4 +- .../README.md | 0 .../src/lib.rs | 2 +- .../Cargo.toml | 4 +- .../README.md | 2 +- .../src/lib.rs | 8 +- lib/{ssh-keys => cluelessh-keys}/Cargo.toml | 4 +- lib/{ssh-keys => cluelessh-keys}/README.md | 0 .../src/crypto.rs | 2 +- lib/{ssh-keys => cluelessh-keys}/src/lib.rs | 2 +- lib/cluelessh-protocol/Cargo.toml | 11 + .../README.md | 4 +- .../src/lib.rs | 38 +-- lib/cluelessh-tokio/Cargo.toml | 13 + lib/{ssh-tokio => cluelessh-tokio}/README.md | 0 .../src/client.rs | 18 +- lib/{ssh-tokio => cluelessh-tokio}/src/lib.rs | 0 .../Cargo.toml | 2 +- .../README.md | 2 +- .../src/client.rs | 0 .../src/crypto.rs | 0 .../src/crypto/encrypt.rs | 0 .../src/key.rs | 0 .../src/lib.rs | 0 .../src/numbers.rs | 0 .../src/packet.rs | 0 .../src/packet/ctors.rs | 0 .../src/parse.rs | 0 .../src/server.rs | 0 lib/ssh-protocol/Cargo.toml | 11 - lib/ssh-tokio/Cargo.toml | 13 - 46 files changed, 264 insertions(+), 262 deletions(-) rename bin/{ssh-agentctl => cluelessh-agentctl}/Cargo.toml (65%) rename bin/{ssh-agentctl => cluelessh-agentctl}/src/main.rs (96%) rename bin/{sshdos => cluelessh-dos}/Cargo.toml (69%) rename bin/{sshdos => cluelessh-dos}/README.md (100%) rename bin/{sshdos => cluelessh-dos}/src/main.rs (93%) rename bin/{fakesshd => cluelessh-faked}/Cargo.toml (75%) rename bin/{fakesshd => cluelessh-faked}/README.md (100%) rename bin/{fakesshd => cluelessh-faked}/smoke-test.sh (66%) rename bin/{fakesshd => cluelessh-faked}/src/main.rs (98%) rename bin/{ssh-key => cluelessh-key}/Cargo.toml (72%) rename bin/{ssh-key => cluelessh-key}/src/main.rs (92%) rename bin/{ssh => cluelessh}/Cargo.toml (55%) rename bin/{ssh => cluelessh}/README.md (100%) rename bin/{ssh => cluelessh}/src/main.rs (92%) rename lib/{ssh-agent-client => cluelessh-agent-client}/Cargo.toml (62%) rename lib/{ssh-agent-client => cluelessh-agent-client}/README.md (100%) rename lib/{ssh-agent-client => cluelessh-agent-client}/src/lib.rs (99%) rename lib/{ssh-connection => cluelessh-connection}/Cargo.toml (66%) rename lib/{ssh-connection => cluelessh-connection}/README.md (88%) rename lib/{ssh-connection => cluelessh-connection}/src/lib.rs (99%) rename lib/{ssh-keys => cluelessh-keys}/Cargo.toml (71%) rename lib/{ssh-keys => cluelessh-keys}/README.md (100%) rename lib/{ssh-keys => cluelessh-keys}/src/crypto.rs (98%) rename lib/{ssh-keys => cluelessh-keys}/src/lib.rs (99%) create mode 100644 lib/cluelessh-protocol/Cargo.toml rename lib/{ssh-protocol => cluelessh-protocol}/README.md (57%) rename lib/{ssh-protocol => cluelessh-protocol}/src/lib.rs (91%) create mode 100644 lib/cluelessh-tokio/Cargo.toml rename lib/{ssh-tokio => cluelessh-tokio}/README.md (100%) rename lib/{ssh-tokio => cluelessh-tokio}/src/client.rs (93%) rename lib/{ssh-tokio => cluelessh-tokio}/src/lib.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/Cargo.toml (93%) rename lib/{ssh-transport => cluelessh-transport}/README.md (98%) rename lib/{ssh-transport => cluelessh-transport}/src/client.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/crypto.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/crypto/encrypt.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/key.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/lib.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/numbers.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/packet.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/packet/ctors.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/parse.rs (100%) rename lib/{ssh-transport => cluelessh-transport}/src/server.rs (100%) delete mode 100644 lib/ssh-protocol/Cargo.toml delete mode 100644 lib/ssh-tokio/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 310ef7c..47f276e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -273,6 +273,158 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +[[package]] +name = "cluelessh" +version = "0.1.0" +dependencies = [ + "clap", + "cluelessh-agent-client", + "cluelessh-protocol", + "cluelessh-tokio", + "cluelessh-transport", + "eyre", + "rand", + "rpassword", + "tokio", + "tracing", + "tracing-subscriber", + "users", +] + +[[package]] +name = "cluelessh-agent-client" +version = "0.1.0" +dependencies = [ + "cluelessh-transport", + "eyre", + "tokio", + "tracing", +] + +[[package]] +name = "cluelessh-agentctl" +version = "0.1.0" +dependencies = [ + "clap", + "cluelessh-agent-client", + "cluelessh-transport", + "eyre", + "hex", + "pem", + "rpassword", + "sha2", + "tokio", + "tracing-subscriber", +] + +[[package]] +name = "cluelessh-connection" +version = "0.1.0" +dependencies = [ + "cluelessh-transport", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cluelessh-dos" +version = "0.1.0" +dependencies = [ + "clap", + "cluelessh-protocol", + "cluelessh-transport", + "eyre", + "futures", + "rand", + "rpassword", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cluelessh-faked" +version = "0.1.0" +dependencies = [ + "cluelessh-protocol", + "eyre", + "hex-literal", + "rand", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cluelessh-key" +version = "0.1.0" +dependencies = [ + "base64", + "clap", + "cluelessh-keys", + "eyre", + "pem", + "rpassword", + "tracing", +] + +[[package]] +name = "cluelessh-keys" +version = "0.1.0" +dependencies = [ + "aes", + "bcrypt-pbkdf", + "cluelessh-transport", + "ctr", + "ed25519-dalek", + "pem", + "rand", +] + +[[package]] +name = "cluelessh-protocol" +version = "0.1.0" +dependencies = [ + "cluelessh-connection", + "cluelessh-transport", + "rand", + "tracing", +] + +[[package]] +name = "cluelessh-tokio" +version = "0.1.0" +dependencies = [ + "cluelessh-connection", + "cluelessh-protocol", + "cluelessh-transport", + "eyre", + "futures", + "tokio", + "tracing", +] + +[[package]] +name = "cluelessh-transport" +version = "0.1.0" +dependencies = [ + "aes", + "aes-gcm", + "base64", + "chacha20", + "crypto-bigint", + "ctr", + "ed25519-dalek", + "hex-literal", + "p256", + "poly1305", + "rand_core", + "sha2", + "subtle", + "tracing", + "x25519-dalek", +] + [[package]] name = "colorchoice" version = "1.0.2" @@ -446,19 +598,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "fakesshd" -version = "0.1.0" -dependencies = [ - "eyre", - "hex-literal", - "rand", - "ssh-protocol", - "tokio", - "tracing", - "tracing-subscriber", -] - [[package]] name = "ff" version = "0.13.0" @@ -1200,145 +1339,6 @@ dependencies = [ "der", ] -[[package]] -name = "ssh" -version = "0.1.0" -dependencies = [ - "clap", - "eyre", - "rand", - "rpassword", - "ssh-agent-client", - "ssh-protocol", - "ssh-tokio", - "ssh-transport", - "tokio", - "tracing", - "tracing-subscriber", - "users", -] - -[[package]] -name = "ssh-agent-client" -version = "0.1.0" -dependencies = [ - "eyre", - "ssh-transport", - "tokio", - "tracing", -] - -[[package]] -name = "ssh-agentctl" -version = "0.1.0" -dependencies = [ - "clap", - "eyre", - "hex", - "pem", - "rpassword", - "sha2", - "ssh-agent-client", - "ssh-transport", - "tokio", - "tracing-subscriber", -] - -[[package]] -name = "ssh-connection" -version = "0.1.0" -dependencies = [ - "ssh-transport", - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "ssh-key" -version = "0.1.0" -dependencies = [ - "base64", - "clap", - "eyre", - "pem", - "rpassword", - "ssh-keys", - "tracing", -] - -[[package]] -name = "ssh-keys" -version = "0.1.0" -dependencies = [ - "aes", - "bcrypt-pbkdf", - "ctr", - "ed25519-dalek", - "pem", - "rand", - "ssh-transport", -] - -[[package]] -name = "ssh-protocol" -version = "0.1.0" -dependencies = [ - "rand", - "ssh-connection", - "ssh-transport", - "tracing", -] - -[[package]] -name = "ssh-tokio" -version = "0.1.0" -dependencies = [ - "eyre", - "futures", - "ssh-connection", - "ssh-protocol", - "ssh-transport", - "tokio", - "tracing", -] - -[[package]] -name = "ssh-transport" -version = "0.1.0" -dependencies = [ - "aes", - "aes-gcm", - "base64", - "chacha20", - "crypto-bigint", - "ctr", - "ed25519-dalek", - "hex-literal", - "p256", - "poly1305", - "rand_core", - "sha2", - "subtle", - "tracing", - "x25519-dalek", -] - -[[package]] -name = "sshdos" -version = "0.1.0" -dependencies = [ - "clap", - "eyre", - "futures", - "rand", - "rpassword", - "ssh-protocol", - "ssh-transport", - "tokio", - "tracing", - "tracing-subscriber", -] - [[package]] name = "strsim" version = "0.11.1" diff --git a/bin/ssh-agentctl/Cargo.toml b/bin/cluelessh-agentctl/Cargo.toml similarity index 65% rename from bin/ssh-agentctl/Cargo.toml rename to bin/cluelessh-agentctl/Cargo.toml index 0902a43..c165ab9 100644 --- a/bin/ssh-agentctl/Cargo.toml +++ b/bin/cluelessh-agentctl/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "ssh-agentctl" +name = "cluelessh-agentctl" version = "0.1.0" edition = "2021" [dependencies] -ssh-agent-client = { path = "../../lib/ssh-agent-client" } -ssh-transport = { path = "../../lib/ssh-transport" } +cluelessh-agent-client = { path = "../../lib/cluelessh-agent-client" } +cluelessh-transport = { path = "../../lib/cluelessh-transport" } clap = { version = "4.5.16", features = ["derive"] } eyre = "0.6.12" diff --git a/bin/ssh-agentctl/src/main.rs b/bin/cluelessh-agentctl/src/main.rs similarity index 96% rename from bin/ssh-agentctl/src/main.rs rename to bin/cluelessh-agentctl/src/main.rs index 31bce81..416e4b1 100644 --- a/bin/ssh-agentctl/src/main.rs +++ b/bin/cluelessh-agentctl/src/main.rs @@ -3,8 +3,8 @@ use std::{io::Write, path::PathBuf}; use clap::Parser; use eyre::{bail, Context}; use sha2::Digest; -use ssh_agent_client::{IdentityAnswer, SocketAgentConnection}; -use ssh_transport::{key::PublicKey, parse::Writer}; +use cluelessh_agent_client::{IdentityAnswer, SocketAgentConnection}; +use cluelessh_transport::{key::PublicKey, parse::Writer}; #[derive(clap::Parser, Debug)] struct Args { @@ -52,7 +52,7 @@ async fn main() -> eyre::Result<()> { .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")); tracing_subscriber::fmt().with_env_filter(env_filter).init(); - let mut agent = ssh_agent_client::SocketAgentConnection::from_env().await?; + let mut agent = cluelessh_agent_client::SocketAgentConnection::from_env().await?; match args.command { Subcommand::AddIdentity { identity } => { diff --git a/bin/sshdos/Cargo.toml b/bin/cluelessh-dos/Cargo.toml similarity index 69% rename from bin/sshdos/Cargo.toml rename to bin/cluelessh-dos/Cargo.toml index 3b53f19..fc69f2b 100644 --- a/bin/sshdos/Cargo.toml +++ b/bin/cluelessh-dos/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "sshdos" +name = "cluelessh-dos" version = "0.1.0" edition = "2021" [dependencies] -ssh-protocol = { path = "../../lib/ssh-protocol" } -ssh-transport = { path = "../../lib/ssh-transport" } +cluelessh-protocol = { path = "../../lib/cluelessh-protocol" } +cluelessh-transport = { path = "../../lib/cluelessh-transport" } clap = { version = "4.5.15", features = ["derive"] } eyre = "0.6.12" rand = "0.8.5" diff --git a/bin/sshdos/README.md b/bin/cluelessh-dos/README.md similarity index 100% rename from bin/sshdos/README.md rename to bin/cluelessh-dos/README.md diff --git a/bin/sshdos/src/main.rs b/bin/cluelessh-dos/src/main.rs similarity index 93% rename from bin/sshdos/src/main.rs rename to bin/cluelessh-dos/src/main.rs index d650129..c19eab3 100644 --- a/bin/sshdos/src/main.rs +++ b/bin/cluelessh-dos/src/main.rs @@ -16,14 +16,14 @@ use tokio::{ }; use tracing::{error, info}; -use ssh_protocol::{ +use cluelessh_protocol::{ transport::{self}, SshStatus, }; use tracing_subscriber::EnvFilter; struct ThreadRngRand; -impl ssh_protocol::transport::SshRng for ThreadRngRand { +impl cluelessh_protocol::transport::SshRng for ThreadRngRand { fn fill_bytes(&mut self, dest: &mut [u8]) { rand::thread_rng().fill_bytes(dest); } @@ -96,9 +96,9 @@ async fn execute_attempt_inner(mut conn: TcpStream) -> eyre::Result<()> { let mut transport = transport::client::ClientConnection::new(ThreadRngRand); transport.abort_for_dos = true; - let mut state = ssh_protocol::ClientConnection::new( + let mut state = cluelessh_protocol::ClientConnection::new( transport, - ssh_protocol::auth::ClientAuth::new(username.as_bytes().to_vec()), + cluelessh_protocol::auth::ClientAuth::new(username.as_bytes().to_vec()), ); let mut buf = [0; 1024]; diff --git a/bin/fakesshd/Cargo.toml b/bin/cluelessh-faked/Cargo.toml similarity index 75% rename from bin/fakesshd/Cargo.toml rename to bin/cluelessh-faked/Cargo.toml index d72795c..49dc8d2 100644 --- a/bin/fakesshd/Cargo.toml +++ b/bin/cluelessh-faked/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "fakesshd" +name = "cluelessh-faked" version = "0.1.0" edition = "2021" @@ -7,7 +7,7 @@ edition = "2021" eyre = "0.6.12" hex-literal = "0.4.1" rand = "0.8.5" -ssh-protocol = { path = "../../lib/ssh-protocol" } +cluelessh-protocol = { path = "../../lib/cluelessh-protocol" } tokio = { version = "1.39.2", features = ["full"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "json"] } diff --git a/bin/fakesshd/README.md b/bin/cluelessh-faked/README.md similarity index 100% rename from bin/fakesshd/README.md rename to bin/cluelessh-faked/README.md diff --git a/bin/fakesshd/smoke-test.sh b/bin/cluelessh-faked/smoke-test.sh similarity index 66% rename from bin/fakesshd/smoke-test.sh rename to bin/cluelessh-faked/smoke-test.sh index c359caf..6be64fc 100755 --- a/bin/fakesshd/smoke-test.sh +++ b/bin/cluelessh-faked/smoke-test.sh @@ -2,9 +2,11 @@ set -euxo pipefail -cargo build -p fakesshd +pkill cluelessh-faked || true -cargo run -p fakesshd & +cargo build -p cluelessh-faked + +cargo run -p cluelessh-faked & sleep 1 @@ -13,4 +15,4 @@ ssh -p 2222 -oCiphers=aes256-gcm@openssh.com \ -oHostKeyAlgorithms=ecdsa-sha2-nistp256 \ -oKexAlgorithms=ecdh-sha2-nistp256 127.0.0.1 true -pkill fakesshd +pkill cluelessh-faked diff --git a/bin/fakesshd/src/main.rs b/bin/cluelessh-faked/src/main.rs similarity index 98% rename from bin/fakesshd/src/main.rs rename to bin/cluelessh-faked/src/main.rs index 703b4d6..1e00da1 100644 --- a/bin/fakesshd/src/main.rs +++ b/bin/cluelessh-faked/src/main.rs @@ -8,7 +8,7 @@ use tokio::{ }; use tracing::{debug, error, info, info_span, Instrument}; -use ssh_protocol::{ +use cluelessh_protocol::{ connection::{ChannelOpen, ChannelOperationKind, ChannelRequest}, transport::{self}, ChannelUpdateKind, ServerConnection, SshStatus, @@ -16,7 +16,7 @@ use ssh_protocol::{ use tracing_subscriber::EnvFilter; struct ThreadRngRand; -impl ssh_protocol::transport::SshRng for ThreadRngRand { +impl cluelessh_protocol::transport::SshRng for ThreadRngRand { fn fill_bytes(&mut self, dest: &mut [u8]) { rand::thread_rng().fill_bytes(dest); } @@ -94,7 +94,7 @@ async fn handle_connection( 0x95, 0x18, 0x4b, 0xd2, 0xcb, 0xd0, 0x64, 0x06, ]; struct HardcodedRng(Vec); - impl ssh_protocol::transport::SshRng for HardcodedRng { + impl cluelessh_protocol::transport::SshRng for HardcodedRng { fn fill_bytes(&mut self, dest: &mut [u8]) { dest.copy_from_slice(&self.0[..dest.len()]); self.0.splice(0..dest.len(), []); diff --git a/bin/ssh-key/Cargo.toml b/bin/cluelessh-key/Cargo.toml similarity index 72% rename from bin/ssh-key/Cargo.toml rename to bin/cluelessh-key/Cargo.toml index 4d403bf..83c8496 100644 --- a/bin/ssh-key/Cargo.toml +++ b/bin/cluelessh-key/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ssh-key" +name = "cluelessh-key" version = "0.1.0" edition = "2021" @@ -8,7 +8,7 @@ clap = { version = "4.5.16", features = ["derive"] } eyre = "0.6.12" tracing.workspace = true -ssh-keys = { path = "../../lib/ssh-keys" } +cluelessh-keys = { path = "../../lib/cluelessh-keys" } base64 = "0.22.1" rpassword = "7.3.1" pem = "3.0.4" diff --git a/bin/ssh-key/src/main.rs b/bin/cluelessh-key/src/main.rs similarity index 92% rename from bin/ssh-key/src/main.rs rename to bin/cluelessh-key/src/main.rs index b928985..4a86265 100644 --- a/bin/ssh-key/src/main.rs +++ b/bin/cluelessh-key/src/main.rs @@ -6,8 +6,8 @@ use std::{ use base64::Engine; use clap::Parser; +use cluelessh_keys::{KeyEncryptionParams, PrivateKeyType}; use eyre::{bail, Context}; -use ssh_keys::{KeyEncryptionParams, PrivateKeyType}; #[derive(clap::Parser)] struct Args { @@ -82,7 +82,7 @@ fn main() -> eyre::Result<()> { } => { let file = std::fs::read(&id_file) .wrap_err_with(|| format!("reading file {}", id_file.display()))?; - let keys = ssh_keys::EncryptedPrivateKeys::parse(&file)?; + let keys = cluelessh_keys::EncryptedPrivateKeys::parse(&file)?; let passphrase = if keys.requires_passphrase() { let phrase = rpassword::prompt_password("passphrase: ")?; Some(phrase) @@ -115,7 +115,7 @@ fn info(id_file: &Path, decrypt: bool, show_private: bool) -> eyre::Result<()> { let file = std::fs::read(&id_file).wrap_err_with(|| format!("reading file {}", id_file.display()))?; - let keys = ssh_keys::EncryptedPrivateKeys::parse(&file)?; + let keys = cluelessh_keys::EncryptedPrivateKeys::parse(&file)?; if decrypt { let passphrase = if keys.requires_passphrase() { @@ -149,14 +149,14 @@ fn info(id_file: &Path, decrypt: bool, show_private: bool) -> eyre::Result<()> { fn generate(type_: KeyType, comment: String, path: &Path) -> eyre::Result<()> { let type_ = match type_ { - KeyType::Ed25519 => ssh_keys::KeyType::Ed25519, + KeyType::Ed25519 => cluelessh_keys::KeyType::Ed25519, }; let passphrase = rpassword::prompt_password("Enter passphrase (empty for no passphrase): ")?; - let key = ssh_keys::PlaintextPrivateKey::generate( + let key = cluelessh_keys::PlaintextPrivateKey::generate( comment, - ssh_keys::KeyGenerationParams { key_type: type_ }, + cluelessh_keys::KeyGenerationParams { key_type: type_ }, ); println!("{} {}", key.private_key.public_key(), key.comment); diff --git a/bin/ssh/Cargo.toml b/bin/cluelessh/Cargo.toml similarity index 55% rename from bin/ssh/Cargo.toml rename to bin/cluelessh/Cargo.toml index f4f193f..131ca8a 100644 --- a/bin/ssh/Cargo.toml +++ b/bin/cluelessh/Cargo.toml @@ -1,13 +1,13 @@ [package] -name = "ssh" +name = "cluelessh" version = "0.1.0" edition = "2021" [dependencies] -ssh-protocol = { path = "../../lib/ssh-protocol" } -ssh-transport = { path = "../../lib/ssh-transport" } -ssh-agent-client = { path = "../../lib/ssh-agent-client" } -ssh-tokio = { path = "../../lib/ssh-tokio" } +cluelessh-protocol = { path = "../../lib/cluelessh-protocol" } +cluelessh-transport = { path = "../../lib/cluelessh-transport" } +cluelessh-agent-client = { path = "../../lib/cluelessh-agent-client" } +cluelessh-tokio = { path = "../../lib/cluelessh-tokio" } clap = { version = "4.5.15", features = ["derive"] } eyre = "0.6.12" diff --git a/bin/ssh/README.md b/bin/cluelessh/README.md similarity index 100% rename from bin/ssh/README.md rename to bin/cluelessh/README.md diff --git a/bin/ssh/src/main.rs b/bin/cluelessh/src/main.rs similarity index 92% rename from bin/ssh/src/main.rs rename to bin/cluelessh/src/main.rs index c0d5474..4c68526 100644 --- a/bin/ssh/src/main.rs +++ b/bin/cluelessh/src/main.rs @@ -3,12 +3,12 @@ use std::{collections::HashSet, sync::Arc}; use clap::Parser; use eyre::{bail, Context, ContextCompat, OptionExt, Result}; -use ssh_tokio::client::{PendingChannel, SignatureResult}; -use ssh_transport::{key::PublicKey, numbers, parse::Writer}; +use cluelessh_tokio::client::{PendingChannel, SignatureResult}; +use cluelessh_transport::{key::PublicKey, numbers, parse::Writer}; use tokio::net::TcpStream; use tracing::{debug, error}; -use ssh_protocol::connection::{ChannelOpen, ChannelOperationKind, ChannelRequest}; +use cluelessh_protocol::connection::{ChannelOpen, ChannelOperationKind, ChannelRequest}; use tracing_subscriber::EnvFilter; #[derive(clap::Parser, Debug)] @@ -50,9 +50,9 @@ async fn main() -> eyre::Result<()> { .wrap_err("connecting")?; let username1 = username.clone(); - let mut tokio_conn = ssh_tokio::client::ClientConnection::connect( + let mut tokio_conn = cluelessh_tokio::client::ClientConnection::connect( conn, - ssh_tokio::client::ClientAuth { + cluelessh_tokio::client::ClientAuth { username: username.clone(), prompt_password: Arc::new(move || { let username = username1.clone(); @@ -76,7 +76,7 @@ async fn main() -> eyre::Result<()> { Box::pin(async move { // TODO: support agentless manual key opening // TODO: move - let mut agent = ssh_agent_client::SocketAgentConnection::from_env() + let mut agent = cluelessh_agent_client::SocketAgentConnection::from_env() .await .wrap_err("failed to connect to SSH agent")?; let identities = agent.list_identities().await?; diff --git a/lib/ssh-agent-client/Cargo.toml b/lib/cluelessh-agent-client/Cargo.toml similarity index 62% rename from lib/ssh-agent-client/Cargo.toml rename to lib/cluelessh-agent-client/Cargo.toml index f415d7f..85a0d05 100644 --- a/lib/ssh-agent-client/Cargo.toml +++ b/lib/cluelessh-agent-client/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "ssh-agent-client" +name = "cluelessh-agent-client" version = "0.1.0" edition = "2021" [dependencies] eyre = "0.6.12" -ssh-transport = { path = "../ssh-transport" } +cluelessh-transport = { path = "../cluelessh-transport" } tokio = { version = "1.39.3", features = ["net"] } tracing.workspace = true diff --git a/lib/ssh-agent-client/README.md b/lib/cluelessh-agent-client/README.md similarity index 100% rename from lib/ssh-agent-client/README.md rename to lib/cluelessh-agent-client/README.md diff --git a/lib/ssh-agent-client/src/lib.rs b/lib/cluelessh-agent-client/src/lib.rs similarity index 99% rename from lib/ssh-agent-client/src/lib.rs rename to lib/cluelessh-agent-client/src/lib.rs index 23f04b7..cb4eb30 100644 --- a/lib/ssh-agent-client/src/lib.rs +++ b/lib/cluelessh-agent-client/src/lib.rs @@ -1,5 +1,5 @@ use eyre::{bail, eyre, Context}; -use ssh_transport::{ +use cluelessh_transport::{ packet::PacketParser, parse::{Parser, Writer}, SshStatus, diff --git a/lib/ssh-connection/Cargo.toml b/lib/cluelessh-connection/Cargo.toml similarity index 66% rename from lib/ssh-connection/Cargo.toml rename to lib/cluelessh-connection/Cargo.toml index e0486c6..dd65e27 100644 --- a/lib/ssh-connection/Cargo.toml +++ b/lib/cluelessh-connection/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "ssh-connection" +name = "cluelessh-connection" version = "0.1.0" edition = "2021" [dependencies] -ssh-transport = { path = "../ssh-transport" } +cluelessh-transport = { path = "../cluelessh-transport" } tracing.workspace = true [dev-dependencies] diff --git a/lib/ssh-connection/README.md b/lib/cluelessh-connection/README.md similarity index 88% rename from lib/ssh-connection/README.md rename to lib/cluelessh-connection/README.md index cbff87c..381f8ed 100644 --- a/lib/ssh-connection/README.md +++ b/lib/cluelessh-connection/README.md @@ -1,4 +1,4 @@ -# ssh-connection +# cluelessh-connection Connection layer for SSH. This crate takes care of channel multiplexing. diff --git a/lib/ssh-connection/src/lib.rs b/lib/cluelessh-connection/src/lib.rs similarity index 99% rename from lib/ssh-connection/src/lib.rs rename to lib/cluelessh-connection/src/lib.rs index 125fcfc..a11f593 100644 --- a/lib/ssh-connection/src/lib.rs +++ b/lib/cluelessh-connection/src/lib.rs @@ -2,9 +2,9 @@ use std::cmp; use std::collections::{HashMap, VecDeque}; use tracing::{debug, info, trace, warn}; -use ssh_transport::packet::Packet; -use ssh_transport::Result; -use ssh_transport::{numbers, peer_error}; +use cluelessh_transport::packet::Packet; +use cluelessh_transport::Result; +use cluelessh_transport::{numbers, peer_error}; /// A channel number (on our side). #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] @@ -728,7 +728,7 @@ impl ChannelOperation { #[cfg(test)] mod tests { - use ssh_transport::{numbers, packet::Packet}; + use cluelessh_transport::{numbers, packet::Packet}; use crate::{ChannelNumber, ChannelOperation, ChannelOperationKind, ChannelsState}; diff --git a/lib/ssh-keys/Cargo.toml b/lib/cluelessh-keys/Cargo.toml similarity index 71% rename from lib/ssh-keys/Cargo.toml rename to lib/cluelessh-keys/Cargo.toml index 7e32308..74f51fa 100644 --- a/lib/ssh-keys/Cargo.toml +++ b/lib/cluelessh-keys/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ssh-keys" +name = "cluelessh-keys" version = "0.1.0" edition = "2021" @@ -10,4 +10,4 @@ ctr = "0.9.2" ed25519-dalek = { version = "2.1.1", features = ["rand_core"] } pem = "3.0.4" rand = "0.8.5" -ssh-transport = { path = "../ssh-transport" } +cluelessh-transport = { path = "../cluelessh-transport" } diff --git a/lib/ssh-keys/README.md b/lib/cluelessh-keys/README.md similarity index 100% rename from lib/ssh-keys/README.md rename to lib/cluelessh-keys/README.md diff --git a/lib/ssh-keys/src/crypto.rs b/lib/cluelessh-keys/src/crypto.rs similarity index 98% rename from lib/ssh-keys/src/crypto.rs rename to lib/cluelessh-keys/src/crypto.rs index 5b11ce0..a77d3ad 100644 --- a/lib/ssh-keys/src/crypto.rs +++ b/lib/cluelessh-keys/src/crypto.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use aes::cipher::{KeySizeUser, StreamCipher}; -use ssh_transport::parse::{self, Parser, Writer}; +use cluelessh_transport::parse::{self, Parser, Writer}; use crate::PrivateKeyType; diff --git a/lib/ssh-keys/src/lib.rs b/lib/cluelessh-keys/src/lib.rs similarity index 99% rename from lib/ssh-keys/src/lib.rs rename to lib/cluelessh-keys/src/lib.rs index 03dc872..b1b165a 100644 --- a/lib/ssh-keys/src/lib.rs +++ b/lib/cluelessh-keys/src/lib.rs @@ -1,7 +1,7 @@ mod crypto; use crypto::{Cipher, Kdf}; -use ssh_transport::{ +use cluelessh_transport::{ key::PublicKey, parse::{self, Parser, Writer}, }; diff --git a/lib/cluelessh-protocol/Cargo.toml b/lib/cluelessh-protocol/Cargo.toml new file mode 100644 index 0000000..4b5f34b --- /dev/null +++ b/lib/cluelessh-protocol/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "cluelessh-protocol" +version = "0.1.0" +edition = "2021" + +[dependencies] +rand = "0.8.5" +cluelessh-connection = { path = "../cluelessh-connection" } +cluelessh-transport = { path = "../cluelessh-transport" } +tracing.workspace = true + diff --git a/lib/ssh-protocol/README.md b/lib/cluelessh-protocol/README.md similarity index 57% rename from lib/ssh-protocol/README.md rename to lib/cluelessh-protocol/README.md index b1fdd39..8bca89a 100644 --- a/lib/ssh-protocol/README.md +++ b/lib/cluelessh-protocol/README.md @@ -1,5 +1,5 @@ -# ssh-protocol +# cluelessh-protocol -Combines `ssh-connection` and `ssh-transport` into a higher level interface. +Combines `cluelessh-connection` and `cluelessh-transport` into a higher level interface. Also implements authentication based on [RFC 4252 The Secure Shell (SSH) Authentication Protocol](https://datatracker.ietf.org/doc/html/rfc4252). diff --git a/lib/ssh-protocol/src/lib.rs b/lib/cluelessh-protocol/src/lib.rs similarity index 91% rename from lib/ssh-protocol/src/lib.rs rename to lib/cluelessh-protocol/src/lib.rs index dc581a9..b63c858 100644 --- a/lib/ssh-protocol/src/lib.rs +++ b/lib/cluelessh-protocol/src/lib.rs @@ -1,10 +1,10 @@ use std::mem; -pub use ssh_connection as connection; -use ssh_connection::ChannelOperation; -pub use ssh_connection::{ChannelUpdate, ChannelUpdateKind}; -pub use ssh_transport as transport; -pub use ssh_transport::{Result, SshStatus}; +pub use cluelessh_connection as connection; +use cluelessh_connection::ChannelOperation; +pub use cluelessh_connection::{ChannelUpdate, ChannelUpdateKind}; +pub use cluelessh_transport as transport; +pub use cluelessh_transport::{Result, SshStatus}; use tracing::debug; pub struct ThreadRngRand; @@ -16,17 +16,17 @@ impl transport::SshRng for ThreadRngRand { } pub struct ServerConnection { - transport: ssh_transport::server::ServerConnection, + transport: cluelessh_transport::server::ServerConnection, state: ServerConnectionState, } enum ServerConnectionState { Auth(auth::BadAuth), - Open(ssh_connection::ChannelsState), + Open(cluelessh_connection::ChannelsState), } impl ServerConnection { - pub fn new(transport: ssh_transport::server::ServerConnection) -> Self { + pub fn new(transport: cluelessh_transport::server::ServerConnection) -> Self { Self { transport, state: ServerConnectionState::Auth(auth::BadAuth::new()), @@ -45,7 +45,7 @@ impl ServerConnection { } if auth.is_authenticated() { self.state = - ServerConnectionState::Open(ssh_connection::ChannelsState::new(true)); + ServerConnectionState::Open(cluelessh_connection::ChannelsState::new(true)); } } ServerConnectionState::Open(con) => { @@ -59,11 +59,11 @@ impl ServerConnection { Ok(()) } - pub fn next_msg_to_send(&mut self) -> Option { + pub fn next_msg_to_send(&mut self) -> Option { self.transport.next_msg_to_send() } - pub fn next_channel_update(&mut self) -> Option { + pub fn next_channel_update(&mut self) -> Option { match &mut self.state { ServerConnectionState::Auth(_) => None, ServerConnectionState::Open(con) => con.next_channel_update(), @@ -97,18 +97,18 @@ impl ServerConnection { } pub struct ClientConnection { - transport: ssh_transport::client::ClientConnection, + transport: cluelessh_transport::client::ClientConnection, state: ClientConnectionState, } enum ClientConnectionState { Setup(Option), Auth(auth::ClientAuth), - Open(ssh_connection::ChannelsState), + Open(cluelessh_connection::ChannelsState), } impl ClientConnection { - pub fn new(transport: ssh_transport::client::ClientConnection, auth: auth::ClientAuth) -> Self { + pub fn new(transport: cluelessh_transport::client::ClientConnection, auth: auth::ClientAuth) -> Self { Self { transport, state: ClientConnectionState::Setup(Some(auth)), @@ -140,7 +140,7 @@ impl ClientConnection { } if auth.is_authenticated() { self.state = - ClientConnectionState::Open(ssh_connection::ChannelsState::new(false)); + ClientConnectionState::Open(cluelessh_connection::ChannelsState::new(false)); } } ClientConnectionState::Open(con) => { @@ -162,7 +162,7 @@ impl ClientConnection { } } - pub fn channels(&mut self) -> Option<&mut ssh_connection::ChannelsState> { + pub fn channels(&mut self) -> Option<&mut cluelessh_connection::ChannelsState> { match &mut self.state { ClientConnectionState::Open(channels) => Some(channels), _ => None, @@ -173,11 +173,11 @@ impl ClientConnection { matches!(self.state, ClientConnectionState::Open(_)) } - pub fn next_msg_to_send(&mut self) -> Option { + pub fn next_msg_to_send(&mut self) -> Option { self.transport.next_msg_to_send() } - pub fn next_channel_update(&mut self) -> Option { + pub fn next_channel_update(&mut self) -> Option { match &mut self.state { ClientConnectionState::Setup(_) => None, ClientConnectionState::Auth(_) => None, @@ -218,7 +218,7 @@ impl ClientConnection { pub mod auth { use std::collections::VecDeque; - use ssh_transport::{numbers, packet::Packet, parse::NameList, peer_error, Result}; + use cluelessh_transport::{numbers, packet::Packet, parse::NameList, peer_error, Result}; use tracing::{debug, info}; pub struct BadAuth { diff --git a/lib/cluelessh-tokio/Cargo.toml b/lib/cluelessh-tokio/Cargo.toml new file mode 100644 index 0000000..7483db0 --- /dev/null +++ b/lib/cluelessh-tokio/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "cluelessh-tokio" +version = "0.1.0" +edition = "2021" + +[dependencies] +eyre = "0.6.12" +cluelessh-transport = { path = "../cluelessh-transport" } +cluelessh-connection = { path = "../cluelessh-connection" } +cluelessh-protocol = { path = "../cluelessh-protocol" } +tokio = { version = "1.39.3", features = ["net"] } +tracing.workspace = true +futures = "0.3.30" diff --git a/lib/ssh-tokio/README.md b/lib/cluelessh-tokio/README.md similarity index 100% rename from lib/ssh-tokio/README.md rename to lib/cluelessh-tokio/README.md diff --git a/lib/ssh-tokio/src/client.rs b/lib/cluelessh-tokio/src/client.rs similarity index 93% rename from lib/ssh-tokio/src/client.rs rename to lib/cluelessh-tokio/src/client.rs index 8b06bbe..88484f5 100644 --- a/lib/ssh-tokio/src/client.rs +++ b/lib/cluelessh-tokio/src/client.rs @@ -1,10 +1,10 @@ -use ssh_connection::{ChannelNumber, ChannelOpen, ChannelOperation, ChannelOperationKind}; +use cluelessh_connection::{ChannelNumber, ChannelOpen, ChannelOperation, ChannelOperationKind}; use std::{collections::HashMap, pin::Pin, sync::Arc}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use eyre::{bail, ContextCompat, OptionExt, Result, WrapErr}; use futures::future::BoxFuture; -use ssh_protocol::{ChannelUpdateKind, SshStatus}; +use cluelessh_protocol::{ChannelUpdateKind, SshStatus}; use tokio::io::{AsyncRead, AsyncWrite}; use tracing::{debug, info, warn}; @@ -12,7 +12,7 @@ pub struct ClientConnection { stream: Pin>, buf: [u8; 1024], - proto: ssh_protocol::ClientConnection, + proto: cluelessh_protocol::ClientConnection, operations_send: tokio::sync::mpsc::Sender, operations_recv: tokio::sync::mpsc::Receiver, @@ -74,9 +74,9 @@ impl ClientConnection { channel_ops_send, channel_ops_recv, channels: HashMap::new(), - proto: ssh_protocol::ClientConnection::new( - ssh_transport::client::ClientConnection::new(ssh_protocol::ThreadRngRand), - ssh_protocol::auth::ClientAuth::new(auth.username.as_bytes().to_vec()), + proto: cluelessh_protocol::ClientConnection::new( + cluelessh_transport::client::ClientConnection::new(cluelessh_protocol::ThreadRngRand), + cluelessh_protocol::auth::ClientAuth::new(auth.username.as_bytes().to_vec()), ), auth, }; @@ -94,7 +94,7 @@ impl ClientConnection { if let Some(auth) = self.proto.auth() { for req in auth.user_requests() { match req { - ssh_protocol::auth::ClientUserRequest::Password => { + cluelessh_protocol::auth::ClientUserRequest::Password => { let send = self.operations_send.clone(); let prompt_password = self.auth.prompt_password.clone(); tokio::spawn(async move { @@ -102,7 +102,7 @@ impl ClientConnection { let _ = send.send(Operation::PasswordEntered(password)).await; }); } - ssh_protocol::auth::ClientUserRequest::PrivateKeySign { + cluelessh_protocol::auth::ClientUserRequest::PrivateKeySign { session_identifier, } => { let send = self.operations_send.clone(); @@ -112,7 +112,7 @@ impl ClientConnection { let _ = send.send(Operation::Signature(signature_result)).await; }); } - ssh_protocol::auth::ClientUserRequest::Banner(_) => { + cluelessh_protocol::auth::ClientUserRequest::Banner(_) => { warn!("ignoring banner as it's not implemented..."); } } diff --git a/lib/ssh-tokio/src/lib.rs b/lib/cluelessh-tokio/src/lib.rs similarity index 100% rename from lib/ssh-tokio/src/lib.rs rename to lib/cluelessh-tokio/src/lib.rs diff --git a/lib/ssh-transport/Cargo.toml b/lib/cluelessh-transport/Cargo.toml similarity index 93% rename from lib/ssh-transport/Cargo.toml rename to lib/cluelessh-transport/Cargo.toml index 5ffa24e..cbf89fa 100644 --- a/lib/ssh-transport/Cargo.toml +++ b/lib/cluelessh-transport/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ssh-transport" +name = "cluelessh-transport" version = "0.1.0" edition = "2021" diff --git a/lib/ssh-transport/README.md b/lib/cluelessh-transport/README.md similarity index 98% rename from lib/ssh-transport/README.md rename to lib/cluelessh-transport/README.md index 7bef03b..7a95226 100644 --- a/lib/ssh-transport/README.md +++ b/lib/cluelessh-transport/README.md @@ -1,4 +1,4 @@ -# ssh-transport +# cluelessh-transport Transport layer of SSH. diff --git a/lib/ssh-transport/src/client.rs b/lib/cluelessh-transport/src/client.rs similarity index 100% rename from lib/ssh-transport/src/client.rs rename to lib/cluelessh-transport/src/client.rs diff --git a/lib/ssh-transport/src/crypto.rs b/lib/cluelessh-transport/src/crypto.rs similarity index 100% rename from lib/ssh-transport/src/crypto.rs rename to lib/cluelessh-transport/src/crypto.rs diff --git a/lib/ssh-transport/src/crypto/encrypt.rs b/lib/cluelessh-transport/src/crypto/encrypt.rs similarity index 100% rename from lib/ssh-transport/src/crypto/encrypt.rs rename to lib/cluelessh-transport/src/crypto/encrypt.rs diff --git a/lib/ssh-transport/src/key.rs b/lib/cluelessh-transport/src/key.rs similarity index 100% rename from lib/ssh-transport/src/key.rs rename to lib/cluelessh-transport/src/key.rs diff --git a/lib/ssh-transport/src/lib.rs b/lib/cluelessh-transport/src/lib.rs similarity index 100% rename from lib/ssh-transport/src/lib.rs rename to lib/cluelessh-transport/src/lib.rs diff --git a/lib/ssh-transport/src/numbers.rs b/lib/cluelessh-transport/src/numbers.rs similarity index 100% rename from lib/ssh-transport/src/numbers.rs rename to lib/cluelessh-transport/src/numbers.rs diff --git a/lib/ssh-transport/src/packet.rs b/lib/cluelessh-transport/src/packet.rs similarity index 100% rename from lib/ssh-transport/src/packet.rs rename to lib/cluelessh-transport/src/packet.rs diff --git a/lib/ssh-transport/src/packet/ctors.rs b/lib/cluelessh-transport/src/packet/ctors.rs similarity index 100% rename from lib/ssh-transport/src/packet/ctors.rs rename to lib/cluelessh-transport/src/packet/ctors.rs diff --git a/lib/ssh-transport/src/parse.rs b/lib/cluelessh-transport/src/parse.rs similarity index 100% rename from lib/ssh-transport/src/parse.rs rename to lib/cluelessh-transport/src/parse.rs diff --git a/lib/ssh-transport/src/server.rs b/lib/cluelessh-transport/src/server.rs similarity index 100% rename from lib/ssh-transport/src/server.rs rename to lib/cluelessh-transport/src/server.rs diff --git a/lib/ssh-protocol/Cargo.toml b/lib/ssh-protocol/Cargo.toml deleted file mode 100644 index d3e9ea9..0000000 --- a/lib/ssh-protocol/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "ssh-protocol" -version = "0.1.0" -edition = "2021" - -[dependencies] -rand = "0.8.5" -ssh-connection = { path = "../ssh-connection" } -ssh-transport = { path = "../ssh-transport" } -tracing.workspace = true - diff --git a/lib/ssh-tokio/Cargo.toml b/lib/ssh-tokio/Cargo.toml deleted file mode 100644 index a3b7d79..0000000 --- a/lib/ssh-tokio/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "ssh-tokio" -version = "0.1.0" -edition = "2021" - -[dependencies] -eyre = "0.6.12" -ssh-transport = { path = "../ssh-transport" } -ssh-connection = { path = "../ssh-connection" } -ssh-protocol = { path = "../ssh-protocol" } -tokio = { version = "1.39.3", features = ["net"] } -tracing.workspace = true -futures = "0.3.30"