From 6d7640b08544ba34f2e4f92a9d82246e90e90b44 Mon Sep 17 00:00:00 2001 From: caret Date: Sun, 4 Jun 2023 22:48:35 -0500 Subject: [PATCH] Certify --- Cargo.toml | 2 ++ src/main.rs | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 865f3a2..87e4645 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,3 +20,5 @@ serde = {version="1.0.163",features = ['derive']} serde_json = {version = "1.0.96", features = ['std']} #rsa = "0.9.2" rand = "0.8.5" +md-5 = "0.10.5" +hex-literal = "0.4.1" diff --git a/src/main.rs b/src/main.rs index daac760..743a080 100755 --- a/src/main.rs +++ b/src/main.rs @@ -8,18 +8,21 @@ use actix_web::{get, http::header::ContentType, post, web, App, HttpRequest, Htt use aes::cipher::{AsyncStreamCipher, KeyIvInit}; use log::{debug, error, info, log_enabled, Level}; use rustls::{Certificate, PrivateKey, ServerConfig}; -use rustls_pemfile::{certs, pkcs8_private_keys}; - use serde::{Deserialize, Serialize}; + +// Reading the cert +use rustls_pemfile::{certs, pkcs8_private_keys}; use std::fs::File; use std::io::BufReader; use std::io::Read; +// AES encryption use openssl::rsa::{Padding, Rsa}; type Aes128CfbEnc = cfb_mode::Encryptor; -//use rsa::pkcs8::DecodePublicKey; -//use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey}; +// Certify +use hex_literal::hex; +use md5::{Digest, Md5}; #[post("/basicinfo")] async fn basicinfo() -> HttpResponse { @@ -120,9 +123,29 @@ async fn game_info() -> HttpResponse { //println!("{:?}", String::from_utf8_lossy(&ciphertext)); HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext) } + +#[derive(Serialize, Deserialize, Debug)] +pub struct Certify { + pub gid: u32, + pub mac: String, + pub r: u32, + pub md: String, + pub cn: String, +} + #[get("/server/certify.php")] -async fn certify() -> HttpResponse { +async fn certify(data: web::Query, req: HttpRequest) -> HttpResponse { + println!("Certify!"); + dbg!(&data); // Need to + let mut hasher = Md5::new(); + let gid_bytes = "303807".as_bytes(); // LL game nesys id + hasher.update(gid_bytes); + let hash_result = hasher.finalize(); + for byte in hash_result { + print!("{:x?}", &byte); + } + println!(""); let res = format!( "host=http://10.3.0.53 no=1337