cert issues still
This commit is contained in:
parent
bc3f6f47bf
commit
8ff3d9dac2
@ -18,3 +18,5 @@ aes = "0.8.2"
|
|||||||
cfb-mode = "0.8.2"
|
cfb-mode = "0.8.2"
|
||||||
serde = {version="1.0.163",features = ['derive']}
|
serde = {version="1.0.163",features = ['derive']}
|
||||||
serde_json = {version = "1.0.96", features = ['std']}
|
serde_json = {version = "1.0.96", features = ['std']}
|
||||||
|
#rsa = "0.9.2"
|
||||||
|
rand = "0.8.5"
|
||||||
|
18
certs/install.ps1
Normal file
18
certs/install.ps1
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
$certPath = "C:\Path\to\Certificates" # Specify the path where your .crt certificates are located
|
||||||
|
|
||||||
|
$certFiles = Get-ChildItem -Path $certPath -Filter *.crt
|
||||||
|
|
||||||
|
$certStore = Get-Item -Path "Cert:\LocalMachine\Root"
|
||||||
|
|
||||||
|
foreach ($certFile in $certFiles) {
|
||||||
|
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
|
||||||
|
$cert.Import($certFile.FullName)
|
||||||
|
|
||||||
|
if (!$certStore.Contains($cert)) {
|
||||||
|
$certStore.Add($cert)
|
||||||
|
Write-Host "Certificate $($cert.Subject) imported successfully."
|
||||||
|
} else {
|
||||||
|
Write-Host "Certificate $($cert.Subject) already exists in the store."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
28
priv.pem
Normal file
28
priv.pem
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDLrefJsODZ3SXk
|
||||||
|
SblFOzHRAnhaG5PgPCvMkP9J08Ns6i1cTkGJXJx83Fx9dVJrvhK+pOHJCzgpqxnI
|
||||||
|
r81Yk3pfKLs1CCHbEphzd5WPxvwxKSHPljvrfV2xwtBFH2wOJN/b6NHy6Z3pT2in
|
||||||
|
9m5xo5TNoRzIdqWvJ55HAPyrua2UFxw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/P5f86Hl51kCVF14w06SwTgzcDqw0ZKJj5B5Qiy/GqqY0C5KgK9
|
||||||
|
cHFdV1qM3wvUtS0v2gp+Hc9Ncsw4si56IH5cWHCvh4LTXrXhbsDsdZqpAoGBAJtX
|
||||||
|
/EU/UYeHY7MTceLesV0Dg5Hj2HQyLZMDGsFQeZBYpYPmuo9NdiR/LGSwRj6GsFdc
|
||||||
|
lXv1yxgqkIuD1/+mV78JWn259xavliXQsrSpIV74YEpuGoF8b1WbzRCcUU/6zo+l
|
||||||
|
PRiRMAl4gWCpQwSzmVGSnj1RJ3rmFZWfh2e/CB41AoGBAMKnczJq3cqd2Rzm6N+Q
|
||||||
|
0uZgVjN+GKEZX+KGZd535tPnZ9NqHxbYXcpu/XzbykRHwqmH9CbW0C/+JnOHqGT9
|
||||||
|
+qbmf/FcIAHHSA3HDXOyGM1lHUXUcPfGhPJ1GD3IBqNeNWjY0aSAYxR2pRX3Bb+4
|
||||||
|
AIlPFSOu7jYSw5+prAXZxmm7
|
||||||
|
-----END PRIVATE KEY-----
|
106
src/main.rs
106
src/main.rs
@ -13,40 +13,46 @@ use rustls_pemfile::{certs, pkcs8_private_keys};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
|
use openssl::rsa::{Padding, Rsa};
|
||||||
type Aes128CfbEnc = cfb_mode::Encryptor<aes::Aes128>;
|
type Aes128CfbEnc = cfb_mode::Encryptor<aes::Aes128>;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
//use rsa::pkcs8::DecodePublicKey;
|
||||||
struct BasicInfo {
|
//use rsa::{Pkcs1v15Encrypt, RsaPrivateKey, RsaPublicKey};
|
||||||
BaseUrl: String,
|
|
||||||
DownloadUrl: String,
|
|
||||||
Key: String,
|
|
||||||
Iv: String,
|
|
||||||
TenpoIndex: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[post("/basicinfo")]
|
#[post("/basicinfo")]
|
||||||
async fn basicinfo() -> HttpResponse {
|
async fn basicinfo() -> HttpResponse {
|
||||||
// Encrypt or something first...
|
/*
|
||||||
// Very possible PGP is needed I think/? or aes portion ... idk
|
let pem = "-----BEGIN PUBLIC KEY-----
|
||||||
let data: BasicInfo = BasicInfo {
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy63nybDg2d0l5Em5RTsx
|
||||||
BaseUrl: "http://10.3.0.53/game/info".to_string(),
|
0QJ4WhuT4DwrzJD/SdPDbOotXE5BiVycfNxcfXVSa74SvqThyQs4KasZyK/NWJN6
|
||||||
DownloadUrl: "http://10.3.0.53/download".to_string(),
|
Xyi7NQgh2xKYc3eVj8b8MSkhz5Y7631dscLQRR9sDiTf2+jR8umd6U9op/ZucaOU
|
||||||
Key: "0123456789012345".to_string(),
|
zaEcyHalryeeRwD8q7mtlBccL+5dSVVWuPaJ/Oh4Oivk4qNunYHygQ/iw2vBgN3f
|
||||||
Iv: "0123456789012345".to_string(),
|
6tB1yiKlUe0T51FS1yJcavWilp2JA6XGEhh0OmFJX6wf5vPu9heTXGqnriClinXn
|
||||||
TenpoIndex: 1337u16,
|
XV1zUPDaa0udD8n2OV9NphozqD7TT4pE68G65Xz/iLAaEudSg7f1Shu+VFtt/cF4
|
||||||
};
|
NwIDAQAB
|
||||||
let plaintext: String = serde_json::to_string(&data).unwrap();
|
-----END PUBLIC KEY-----";
|
||||||
|
*/
|
||||||
|
let mut key_file = File::open("priv.pem").unwrap();
|
||||||
|
|
||||||
// Crypto constants
|
let mut key_buffer = Vec::new();
|
||||||
let key: &[u8] = "0123456789012345".as_bytes();
|
key_file.read_to_end(&mut key_buffer).unwrap();
|
||||||
let iv: &[u8] = "0123456789012345".as_bytes();
|
|
||||||
|
|
||||||
// Encrypt
|
// Load the private key from the PEM data
|
||||||
let mut ciphertext = plaintext.as_bytes().to_vec();
|
let rsa = Rsa::private_key_from_pem(&key_buffer).unwrap();
|
||||||
Aes128CfbEnc::new(key.into(), iv.into()).encrypt(&mut ciphertext);
|
|
||||||
|
|
||||||
print_valid_chars!(ciphertext.iter());
|
let plaintext = r#"
|
||||||
|
{'result':200,'response':{'base_url':'http://10.3.0.53/game/info','download_url':'http://10.3.0.53/download','key':'01234567890123456789012345678901','iv':'0123456789012345','tenpo_index':1337}}
|
||||||
|
"#;
|
||||||
|
let mut ciphertext = vec![0; rsa.size() as usize];
|
||||||
|
rsa.public_encrypt(plaintext.as_bytes(), &mut ciphertext, Padding::PKCS1).unwrap();
|
||||||
|
|
||||||
|
println!("{:?}", String::from_utf8_lossy(&ciphertext));
|
||||||
|
|
||||||
|
//let mut rng = rand::thread_rng();
|
||||||
|
//let pub_key = RsaPublicKey::from_public_key_pem(pem).unwrap();
|
||||||
|
//let ciphertext = pub_key.encrypt(&mut rng, Pkcs1v15Encrypt, &plaintext.as_bytes()).expect("failed to encrypt");
|
||||||
HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext)
|
HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,26 +63,9 @@ macro_rules! resp {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[get("/alive/{id}/Alive.txt")]
|
||||||
macro_rules! print_valid_chars {
|
async fn alive(id: web::Path<String>) -> HttpResponse {
|
||||||
($slice:expr) => {{
|
println!("/alive/{}/Alive.txt", id);
|
||||||
print!("{{{{");
|
|
||||||
let mut valid_chars = String::new();
|
|
||||||
for &byte in $slice {
|
|
||||||
if let Ok(chr) = std::str::from_utf8(&[byte]) {
|
|
||||||
if chr.is_ascii() && &byte >= &32 {
|
|
||||||
valid_chars.push_str(chr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
valid_chars.push_str(".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println!("{}}}}}", valid_chars);
|
|
||||||
}};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/alive/303807/Alive.txt")]
|
|
||||||
async fn alive() -> HttpResponse {
|
|
||||||
resp!("")
|
resp!("")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +98,22 @@ async fn cursel() -> HttpResponse {
|
|||||||
async fn gameinfo() -> HttpResponse {
|
async fn gameinfo() -> HttpResponse {
|
||||||
resp!("0\n3\n301000,test1\n302000,test2\n303000,test3\n")
|
resp!("0\n3\n301000,test1\n302000,test2\n303000,test3\n")
|
||||||
}
|
}
|
||||||
|
#[post("/game/info")]
|
||||||
|
async fn game_info() -> HttpResponse {
|
||||||
|
// JSON type that is AES encrypted
|
||||||
|
let plaintext = r#"{"result":200,"response":{"base_url":"http://10.3.0.53/game/next","information":[],"event_information":[],"encore_expiration_date":"2033-05-27"}}"#;
|
||||||
|
|
||||||
|
// Crypto constants
|
||||||
|
let key: &[u8] = "0123456789012345".as_bytes();
|
||||||
|
let iv: &[u8] = "0123456789012345".as_bytes();
|
||||||
|
|
||||||
|
// Encrypt
|
||||||
|
let mut ciphertext = plaintext.as_bytes().to_vec();
|
||||||
|
Aes128CfbEnc::new(key.into(), iv.into()).encrypt(&mut ciphertext);
|
||||||
|
|
||||||
|
//println!("{:?}", String::from_utf8_lossy(&ciphertext));
|
||||||
|
HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext)
|
||||||
|
}
|
||||||
#[get("/server/certify.php")]
|
#[get("/server/certify.php")]
|
||||||
async fn certify() -> HttpResponse {
|
async fn certify() -> HttpResponse {
|
||||||
let res = format!(
|
let res = format!(
|
||||||
@ -119,7 +123,7 @@ name=LLServer
|
|||||||
pref=nesys
|
pref=nesys
|
||||||
addr=Local
|
addr=Local
|
||||||
x-next-time=15
|
x-next-time=15
|
||||||
x-img=https://static.wikia.nocookie.net/houkai-star-rail/images/1/18/Character_March_7th_Splash_Art.png
|
x-img=http://10.3.0.53/test.png
|
||||||
x-ranking=http://10.3.0.53/ranking/ranking.php
|
x-ranking=http://10.3.0.53/ranking/ranking.php
|
||||||
ticket=9251859b560b33b031516d05c2ef3c28"
|
ticket=9251859b560b33b031516d05c2ef3c28"
|
||||||
);
|
);
|
||||||
@ -136,7 +140,7 @@ async fn index(req: actix_web::HttpRequest) -> HttpResponse {
|
|||||||
println!("Method: {:?}", req.method());
|
println!("Method: {:?}", req.method());
|
||||||
println!("Host: {:?}", req.head().uri.host());
|
println!("Host: {:?}", req.head().uri.host());
|
||||||
println!("Path: {:?}", req.path());
|
println!("Path: {:?}", req.path());
|
||||||
dbg!(&req);
|
//dbg!(&req);
|
||||||
HttpResponse::Ok().append_header(ContentType(mime::TEXT_PLAIN)).body("shit")
|
HttpResponse::Ok().append_header(ContentType(mime::TEXT_PLAIN)).body("shit")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,9 +167,10 @@ fn load_rustls_config() -> rustls::ServerConfig {
|
|||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
//env_logger::init_from_env(env_logger::Env::new().default_filter_or("debug"));
|
||||||
let config = load_rustls_config();
|
let config = load_rustls_config();
|
||||||
info!("Certificates loaded.");
|
info!("Certificates loaded.");
|
||||||
|
println!("Started!");
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.service(alive)
|
.service(alive)
|
||||||
@ -175,13 +180,14 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.service(fire_alert)
|
.service(fire_alert)
|
||||||
.service(cursel)
|
.service(cursel)
|
||||||
.service(gameinfo)
|
.service(gameinfo)
|
||||||
|
.service(game_info)
|
||||||
.service(certify)
|
.service(certify)
|
||||||
.service(server_data)
|
.service(server_data)
|
||||||
.service(basicinfo)
|
.service(basicinfo)
|
||||||
.route("{path:.*}", web::get().to(index))
|
.route("{path:.*}", web::get().to(index))
|
||||||
})
|
})
|
||||||
.bind("127.0.0.1:80")?
|
.bind("0.0.0.0:80")?
|
||||||
.bind("127.0.0.1:5107")?
|
.bind("0.0.0.0:5107")?
|
||||||
.bind_rustls("0.0.0.0:443", config)?
|
.bind_rustls("0.0.0.0:443", config)?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
|
Loading…
Reference in New Issue
Block a user