cleaned up prints
This commit is contained in:
parent
499bff76d4
commit
d33fc8d300
|
@ -24,3 +24,6 @@ md-5 = "0.10.5"
|
|||
hex-literal = "0.4.1"
|
||||
actix-web = "4.4.0"
|
||||
actix-files = "0.6.2"
|
||||
colored = "2.0.4"
|
||||
actix-service = "2.0.2"
|
||||
futures-util = "0.3.28"
|
||||
|
|
87
src/main.rs
87
src/main.rs
|
@ -2,7 +2,8 @@
|
|||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
use actix_web::{Result, get, http::header::ContentType, post, web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, Error, Result, get, http::header::ContentType, post, web, App, HttpRequest, HttpResponse, HttpServer};
|
||||
use actix_service::Service;
|
||||
use aes::cipher::{AsyncStreamCipher, KeyIvInit};
|
||||
use log::{debug, error, info, log_enabled, Level};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -14,6 +15,7 @@ use rsa::RsaPublicKey;
|
|||
use rsa::pkcs8::DecodePublicKey;
|
||||
use actix_files::NamedFile;
|
||||
use std::path::PathBuf;
|
||||
use colored::Colorize;
|
||||
|
||||
// Reading the cert
|
||||
//use rustls_pemfile::{certs, pkcs8_private_keys};
|
||||
|
@ -22,17 +24,20 @@ use std::path::PathBuf;
|
|||
// AES encryption
|
||||
use openssl::rsa::{Padding, Rsa};
|
||||
type Aes128CfbEnc = cfb_mode::Encryptor<aes::Aes128>;
|
||||
type Aes128CfbDec = cfb_mode::Decryptor<aes::Aes128>;
|
||||
|
||||
// Certify
|
||||
use hex_literal::hex;
|
||||
use md5::{Digest, Md5};
|
||||
|
||||
// Printing requests
|
||||
use actix_web::{dev::Service as _};
|
||||
use futures_util::future::FutureExt;
|
||||
|
||||
#[post("/basicinfo/")]
|
||||
async fn basicinfo() -> HttpResponse {
|
||||
// This function is technically decrypting the plaintext into cipher text for the client to
|
||||
// encrypt to read it. It's very backwards, but this is how the game works. I hate it.
|
||||
println!("____________________________");
|
||||
println!("/basicinfo");
|
||||
let mut key_file = File::open("priv.pem").unwrap();
|
||||
let mut key_buffer = Vec::new();
|
||||
key_file.read_to_end(&mut key_buffer).unwrap();
|
||||
|
@ -41,7 +46,7 @@ async fn basicinfo() -> HttpResponse {
|
|||
let plaintext = r#"{"result":200,"response":{"base_url":"http://data.nesys.jp/game","download_url":"http://data.nesys.jp/download","key":"01234567890123456789012345678901","iv":"0123456789012345","tenpo_index":1337}}"#;
|
||||
let mut ciphertext = vec![0; rsa.size() as usize];
|
||||
rsa.private_encrypt(plaintext.as_bytes(), &mut ciphertext, Padding::PKCS1).unwrap();
|
||||
println!("\t{:?}", &plaintext);
|
||||
println!("{}",format!("RSA Public Encrypt").bold().red());
|
||||
// println!("{:?}", String::from_utf8_lossy(&ciphertext));
|
||||
HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext)
|
||||
}
|
||||
|
@ -72,69 +77,44 @@ macro_rules! resp {
|
|||
|
||||
#[get("/alive/{id}/Alive.txt")]
|
||||
async fn alive(id: web::Path<String>, req: actix_web::HttpRequest) -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("get -> /alive/{}/Alive.txt", id);
|
||||
resp!("")
|
||||
}
|
||||
|
||||
#[get("/alive/i.php")]
|
||||
async fn alive_i() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("get -> /alive/i.php");
|
||||
resp!("REMOTE ADDRESS:10.3.0.53\nSERVER NAME:harasho\nSERVER ADDR:10.3.0.53")
|
||||
}
|
||||
|
||||
#[post("/service/incom/incomALL.php")]
|
||||
async fn incomALL() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("post -> /service/card/incomALL.php");
|
||||
resp!("1+1")
|
||||
}
|
||||
|
||||
#[post("/service/respone/respone.php")]
|
||||
async fn respone() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("post -> /service/respone/respone.php");
|
||||
resp!("1")
|
||||
}
|
||||
|
||||
#[get("/server/FireAlert.php")]
|
||||
async fn fire_alert() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("get -> /server/FireAlert.php");
|
||||
resp!("Success")
|
||||
}
|
||||
|
||||
#[get("/server/cursel.php")]
|
||||
async fn cursel() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("get -> /server/cursel.php");
|
||||
resp!("1\n")
|
||||
}
|
||||
|
||||
#[get("/server/gameinfo.php")]
|
||||
async fn gameinfo() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("get -> /server/gameinfo.php");
|
||||
resp!("0\n3\n301000,test1\n302000,test2\n303000,test3\n")
|
||||
}
|
||||
/*
|
||||
#[post("/game")]
|
||||
async fn game_stuff(body: web::Bytes, req: actix_web::HttpRequest) -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("post -> /game");
|
||||
println!("{:?}",String::from_utf8_lossy(&body));
|
||||
resp!("")
|
||||
}
|
||||
*/
|
||||
|
||||
#[post("/game/info")]
|
||||
async fn game_info() -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("post -> /game/info");
|
||||
// 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"}}"#;
|
||||
let ciphertext = aes_en(&plaintext);
|
||||
|
||||
println!("{:?}", String::from_utf8_lossy(&ciphertext));
|
||||
HttpResponse::Ok().append_header(ContentType::octet_stream()).body(ciphertext)
|
||||
}
|
||||
|
@ -151,8 +131,6 @@ pub struct Certify {
|
|||
#[get("/server/certify.php")]
|
||||
async fn certify() -> HttpResponse {
|
||||
//async fn certify(data: web::Query<Certify>, req: HttpRequest) -> HttpResponse {
|
||||
println!("____________________________");
|
||||
println!("get -> /server/certify.php");
|
||||
/*
|
||||
dbg!(&data);
|
||||
let mut hasher = Md5::new();
|
||||
|
@ -163,17 +141,7 @@ async fn certify() -> HttpResponse {
|
|||
for byte in hash_result {
|
||||
ticket.push_str(&format!("{:x?}", &byte));
|
||||
}*/
|
||||
let res = format!(
|
||||
"host=http://ll.aoeu.top
|
||||
no=1337
|
||||
name=LLServer
|
||||
pref=nesys
|
||||
addr=Local
|
||||
x-next-time=15
|
||||
x-img=http://ll.aoeu.top/news.png
|
||||
x-ranking=http://ll.aoeu.top/ranking/ranking.php
|
||||
ticket=63c6598e9ddd2961e7dfa4d4eb8144a1");
|
||||
println!("Response:\n{}", &res);
|
||||
let res = format!("host=https://ll.aoeu.top\nno=1337\nname=harasho\npref=静岡県\naddr=沼津市\nx-next-time=999\nx-img=https://ll.aoeu.top/news.png\nx-ranking=https://ll.aoeu.top/ranking/ranking.php\nticket=63c6598e9ddd2961e7dfa4d4eb8144a1");
|
||||
resp!(res)
|
||||
}
|
||||
|
||||
|
@ -183,29 +151,28 @@ async fn server_data() -> HttpResponse {
|
|||
}
|
||||
|
||||
async fn index(req: actix_web::HttpRequest) -> HttpResponse {
|
||||
println!("----------------------------");
|
||||
println!("Method: {:?}", req.method());
|
||||
println!("Host: {:?}", req.head().uri.host());
|
||||
println!("Path: {:?}", req.path());
|
||||
println!("{}",format!("----------------------------").black().on_yellow());
|
||||
println!("{}",format!("Method: {:?}", req.method()).yellow());
|
||||
println!("{}",format!("Host: {:?}", req.head().uri.host()).yellow());
|
||||
println!("{}",format!("Path: {:?}", req.path()).yellow());
|
||||
//dbg!(&req);
|
||||
HttpResponse::Ok().append_header(ContentType(mime::TEXT_PLAIN)).body("shit")
|
||||
}
|
||||
|
||||
async fn test(req: HttpRequest) -> Result<NamedFile> {
|
||||
println!("---");
|
||||
println!("Method: {:?}", req.method());
|
||||
println!("Host: {:?}", req.head().uri.host());
|
||||
println!("Path: {:?}", req.path());
|
||||
|
||||
println!("{}",format!("----------------------------").black().on_yellow());
|
||||
println!("{}",format!("Method: {:?}", req.method()).yellow());
|
||||
println!("{}",format!("Host: {:?}", req.head().uri.host()).yellow());
|
||||
println!("{}",format!("Path: {:?}", req.path()).yellow());
|
||||
let path: PathBuf = req.match_info().query("test.png").parse().unwrap();
|
||||
Ok(NamedFile::open(path)?)
|
||||
}
|
||||
|
||||
async fn handle_post_request(body: web::Bytes,req: HttpRequest) -> HttpResponse {
|
||||
println!("----------------------------");
|
||||
println!("Method: {:?}", req.method());
|
||||
println!("Host: {:?}", req.head().uri.host());
|
||||
println!("Path: {:?}", req.path());
|
||||
println!("{}",format!("----------------------------").black().on_yellow());
|
||||
println!("{}",format!("Method: {:?}", req.method()).yellow());
|
||||
println!("{}",format!("Host: {:?}", req.head().uri.host()).yellow());
|
||||
println!("{}",format!("Path: {:?}", req.path()).yellow());
|
||||
println!("{:?}", String::from_utf8_lossy(&body));
|
||||
HttpResponse::Ok().append_header(ContentType(mime::TEXT_PLAIN)).body("shit")
|
||||
}
|
||||
|
@ -248,7 +215,6 @@ async fn main() -> std::io::Result<()> {
|
|||
.service(cursel)
|
||||
.service(gameinfo)
|
||||
.service(game_info)
|
||||
//.service(game_stuff)
|
||||
.service(certify)
|
||||
.service(server_data)
|
||||
.service(basicinfo)
|
||||
|
@ -256,6 +222,13 @@ async fn main() -> std::io::Result<()> {
|
|||
.route("{path:.*}",web::post().to(handle_post_request))
|
||||
.route("/{test.png}",web::get().to(test))
|
||||
.route("{path:.*}", web::get().to(index))
|
||||
.wrap_fn(|req, srv| {
|
||||
println!("{}",format!("____________________________").black().on_white());
|
||||
println!("{}",format!("{} -> {}", req.method(), req.path()).magenta());
|
||||
srv.call(req).map(|res| {
|
||||
res
|
||||
})
|
||||
})
|
||||
})
|
||||
.bind("0.0.0.0:80")?
|
||||
.bind("0.0.0.0:5107")?
|
||||
|
|
Loading…
Reference in New Issue