Unmodified copy of the tsclientlib workspace crates (MIT OR Apache-2.0)
with the tsdeclarations submodule (83cb8a9) flattened into plain files.
See crates/proto/UPSTREAM.md for the path mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-25 12:46:11 +00:00
commit 1cb7b0bdf2
119 files changed
+24322

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
use std::net::SocketAddr;
use anyhow::{bail, Result};
use clap::Parser;
use tokio::time::{self, Duration};
use tracing::info;
use tsproto_packets::packets::*;
mod utils;
use crate::utils::*;
#[derive(Parser, Debug)]
#[command(author, about)]
struct Args {
/// The address of the server to connect to
#[arg(short, long, default_value = "127.0.0.1:9987")]
address: SocketAddr,
/// The listening address of the client
#[arg(long, default_value = "0.0.0.0:0")]
local_address: SocketAddr,
/// Print the content of all packets
///
/// 0. Print nothing
/// 1. Print command string
/// 2. Print packets
/// 3. Print udp packets
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
}
#[tokio::main]
async fn main() -> Result<()> { real_main().await }
async fn real_main() -> Result<()> {
// Parse command line options
let args = Args::parse();
create_logger();
let mut con = create_client(args.local_address, args.address, args.verbose).await?;
// Connect
connect(&mut con).await?;
info!("Connected");
// Wait some time
tokio::select! {
_ = time::sleep(Duration::from_secs(2)) => {}
_ = con.wait_disconnect() => {
bail!("Disconnected");
}
};
info!("Waited");
// Send packet
let mut cmd =
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "sendtextmessage");
cmd.write_arg("targetmode", &3);
cmd.write_arg("msg", &"Hello");
let id = con.send_packet(cmd.into_packet())?;
con.wait_for_ack(id).await?;
// Disconnect
disconnect(&mut con).await?;
info!("Disconnected");
Ok(())
}
@@ -0,0 +1,21 @@
use std::io::{Cursor, Write};
use clap::Parser;
use tsproto::utils;
#[derive(Parser, Debug)]
#[command(author, about)]
struct Args {
/// Data (hex)
#[arg()]
data: String,
}
fn main() {
// Parse command line options
let args = Args::parse();
let data = utils::read_hex(&args.data).unwrap();
let data = quicklz::decompress(&mut Cursor::new(data), std::u32::MAX).unwrap();
std::io::stdout().write_all(&data).unwrap();
}
@@ -0,0 +1,71 @@
use std::net::SocketAddr;
use anyhow::Result;
use clap::Parser;
use futures::prelude::*;
use tokio::time::{self, Duration};
use tracing::info;
mod utils;
use crate::utils::*;
#[derive(Parser, Clone, Debug)]
#[command(author, about)]
struct Args {
/// The address of the server to connect to
#[arg(short, long, default_value = "127.0.0.1:9987")]
address: SocketAddr,
/// The listening address of the client
#[arg(long, default_value = "0.0.0.0:0")]
local_address: SocketAddr,
/// Print the content of all packets
///
/// 0. Print nothing
/// 1. Print command string
/// 2. Print packets
/// 3. Print udp packets
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
/// How many connections
#[arg()]
count: usize,
}
#[tokio::main]
async fn main() -> Result<()> { real_main().await }
async fn real_main() -> Result<()> {
// Parse command line options
let args = Args::parse();
create_logger();
stream::iter(0..args.count)
.for_each_concurrent(None, |_| {
let args = args.clone();
tokio::spawn(async move {
let mut con =
create_client(args.local_address, args.address, args.verbose).await.unwrap();
// Connect
connect(&mut con).await.unwrap();
info!("Connected");
// Wait some time
tokio::select! {
_ = time::sleep(Duration::from_secs(2)) => {}
_ = con.wait_disconnect() => {
panic!("Disconnected");
}
};
info!("Waited");
// Disconnect
let _ = disconnect(&mut con).await;
info!("Disconnected");
})
.map(|_| ())
})
.await;
Ok(())
}
@@ -0,0 +1,19 @@
use base64::prelude::*;
use clap::Parser;
use tsproto::license::*;
#[derive(Parser, Debug)]
#[command(author, about)]
struct Args {
/// The license data (base64)
#[arg()]
license: String,
}
fn main() {
// Parse command line options
let args = Args::parse();
let l = Licenses::parse(BASE64_STANDARD.decode(&args.license).unwrap()).unwrap();
println!("{:#?}", l);
}
@@ -0,0 +1,52 @@
use std::io::Write;
use clap::Parser;
use tsproto::algorithms as algs;
use tsproto::utils;
use tsproto_packets::packets::*;
#[derive(Parser, Debug)]
#[command(author, about)]
struct Args {
/// Print backtrace
#[arg(short, long = "debug")]
debug: bool,
/// Server to client
#[arg(short, long = "client")]
c2s: bool,
/// Data (hex)
#[arg()]
data: String,
}
fn main() {
// Parse command line options
let args = Args::parse();
let dir = if args.c2s { Direction::C2S } else { Direction::S2C };
let data = utils::read_hex(&args.data).unwrap();
let packet = match InPacket::try_new(dir, &data) {
Ok(p) => p,
Err(e) => {
if args.debug {
println!("Failed to decode: {:?}", e);
} else {
println!("Failed to decode: {}", e);
}
return;
}
};
let decrypted = match algs::decrypt_fake(&packet) {
Ok(d) => d,
Err(e) => {
if args.debug {
println!("Failed to decrypt: {:?}", e);
} else {
println!("Failed to decrypt: {}", e);
}
return;
}
};
std::io::stdout().write_all(&decrypted).unwrap();
}
@@ -0,0 +1,39 @@
use base64::prelude::*;
use clap::Parser;
use curve25519_dalek_ng::edwards::CompressedEdwardsY;
use curve25519_dalek_ng::scalar::Scalar;
#[derive(Parser, Debug)]
#[command(author, about)]
struct Args {
/// Public key
#[arg(short, long = "pub")]
pub_key: String,
/// Private key
#[arg(short, long = "priv")]
priv_key: String,
}
fn main() {
// Parse command line options
let args = Args::parse();
let pub_key = BASE64_STANDARD.decode(&args.pub_key).unwrap();
let priv_key = BASE64_STANDARD.decode(&args.priv_key).unwrap();
let mut pubk = [0; 32];
pubk.copy_from_slice(&pub_key);
let mut privk = [0; 32];
privk.copy_from_slice(&priv_key);
/*privk[0] &= 248;
privk[31] &= 63;
privk[31] |= 64;*/
let priv_scal = Scalar::from_bytes_mod_order(privk);
//let priv_scal = Scalar::from_bytes_mod_order(privk);
let pub_point_compr = CompressedEdwardsY(pubk);
let pub_point = -pub_point_compr.decompress().unwrap();
//let pub_point = curve25519_dalek::constants::ED25519_BASEPOINT_POINT;
let res = (pub_point * priv_scal).compress();
println!("Result: {}", BASE64_STANDARD.encode(&res.0));
}
@@ -0,0 +1,35 @@
use base64::prelude::*;
use clap::Parser;
use tsproto_types::crypto::EccKeyPubP256;
#[derive(Parser, Debug)]
#[command(author, about)]
struct Args {
/// Public key
#[arg(short, long)]
key: String,
/// Data (base64)
#[arg(short, long)]
data: String,
/// Signature (base64)
#[arg(short, long)]
signature: String,
}
fn main() {
// Parse command line options
let args = Args::parse();
// l → proof
// ek || beta → proof
let data = BASE64_STANDARD.decode(&args.data).unwrap();
let signature = BASE64_STANDARD.decode(&args.signature).unwrap();
let key = EccKeyPubP256::from_ts(&args.key).unwrap();
/*let keyts = tomcrypt::P256EccKey::import(&BASE64_STANDARD.decode(&args.key).unwrap())
.unwrap();
let res = keyts.verify_hash(&data, &signature).unwrap();
println!("Res: {:?}", res);*/
key.verify(&data, &signature).unwrap();
}
+101
View File
@@ -0,0 +1,101 @@
use std::net::SocketAddr;
use anyhow::Result;
use tokio::net::UdpSocket;
use tracing::{info, info_span};
use tsproto::algorithms as algs;
use tsproto::client::Client;
use tsproto_packets::packets::*;
use tsproto_types::crypto::EccKeyPrivP256;
pub fn create_logger() { tracing_subscriber::fmt::init(); }
pub async fn create_client(
local_address: SocketAddr, remote_address: SocketAddr, verbose: u8,
) -> Result<Client> {
// Get P-256 ECDH key
let private_key = EccKeyPrivP256::import_str(
"MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\
k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nm\
DBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap();
let udp_socket = UdpSocket::bind(local_address).await?;
let mut con = Client::new(remote_address, Box::new(udp_socket), private_key);
if verbose >= 1 {
tsproto::log::add_logger_with_verbosity(verbose, &mut con)
}
Ok(con)
}
/// Returns the `initserver` command.
pub async fn connect(con: &mut Client) -> Result<InCommandBuf> {
con.connect().await?;
// Send clientinit
let private_key = EccKeyPrivP256::import_str(
"MG0DAgeAAgEgAiAIXJBlj1hQbaH0Eq0DuLlCmH8bl+veTAO2+\
k9EQjEYSgIgNnImcmKo7ls5mExb6skfK2Tw+u54aeDr0OP1ITsC/50CIA8M5nm\
DBnmDM/gZ//4AAAAAAAAAAAAAAAAAAAAZRzOI").unwrap();
// Compute hash cash
let offset;
{
let _span = info_span!("Compute public key hash cash level").entered();
let private_key_as_pub = private_key.to_pub();
offset = algs::hash_cash(&private_key_as_pub, 8);
let omega = private_key_as_pub.to_ts();
info!(
level = algs::get_hash_cash_level(&omega, offset),
offset, "Computed hash cash level"
);
}
// Create clientinit packet
let offset = offset.to_string();
let mut cmd =
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientinit");
cmd.write_arg("client_nickname", &"Bot");
cmd.write_arg("client_version", &"3.?.? [Build: 5680278000]");
cmd.write_arg("client_platform", &"Linux");
cmd.write_arg("client_input_hardware", &"1");
cmd.write_arg("client_output_hardware", &"1");
cmd.write_arg("client_default_channel", &"");
cmd.write_arg("client_default_channel_password", &"");
cmd.write_arg("client_server_password", &"");
cmd.write_arg("client_meta_data", &"");
cmd.write_arg(
"client_version_sign",
&"Hjd+N58Gv3ENhoKmGYy2bNRBsNNgm5kpiaQWxOj5HN2DXttG6REjymSwJtpJ8muC2gSwRuZi0R+8Laan5ts5CQ==",
);
cmd.write_arg("client_nickname_phonetic", &"");
cmd.write_arg("client_key_offset", &offset);
cmd.write_arg("client_default_token", &"");
cmd.write_arg("client_badges", &"Overwolf=0");
cmd.write_arg("hwid", &"923f136fb1e22ae6ce95e60255529c00,d13231b1bc33edfecfb9169cc7a63bcc");
con.send_packet(cmd.into_packet())?;
Ok(con
.filter_commands(|con, cmd| {
Ok(if cmd.data().packet().content().starts_with(b"initserver ") {
Some(cmd)
} else {
con.hand_back_buffer(cmd.into_buffer());
None
})
})
.await?)
}
pub async fn disconnect(con: &mut Client) -> Result<()> {
let mut cmd =
OutCommand::new(Direction::C2S, Flags::empty(), PacketType::Command, "clientdisconnect");
cmd.write_arg("reasonid", &8);
cmd.write_arg("reasonmsg", &"Bye");
con.send_packet(cmd.into_packet())?;
con.wait_disconnect().await?;
Ok(())
}