Skip to content

Instantly share code, notes, and snippets.

@tearfulDalvik
Created July 17, 2020 15:35
Show Gist options
  • Save tearfulDalvik/43cd42f106419ae20e23d8d6f9285d6e to your computer and use it in GitHub Desktop.
Save tearfulDalvik/43cd42f106419ae20e23d8d6f9285d6e to your computer and use it in GitHub Desktop.
signCqupt
[package]
name = "sign_cqupt"
version = "0.1.0"
authors = ["Gufeng <meizaizheli@ifengge.cn>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde_json = "1.0"
base64 = "0.12.3"
chrono = "0.4"
reqwest = { version = "0.10", features = ["json"] }
tokio = { version = "0.2", features = ["full"] }
use std::time::{SystemTime, UNIX_EPOCH};
use base64;
use chrono::{Local};
use reqwest::header::{CONTENT_TYPE, USER_AGENT};
use serde_json::json;
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("© Gufeng Shen 2020. All rights reserved.");
println!("{}", Local::now().to_rfc2822());
println!("SignCqupt is merely a project for fun. Any information uploaded by this tool should subject to the school regulations.\n");
let args: Vec<_> = env::args().collect();
if args.len() != 5 {
println!("Usage: sign_cqupt [studentNumber] [studentName] [phoneNumber] [location]");
return Ok(());
}
let template = r#"{"lxdh":"${dh}","xxdz":"${dz}","szdq":"四川省,成都市,武侯区","jbsks":"否","jbsfl":"否","jbsbs":"否","jbslt":"否","jbsyt":"否","jbsfx":"否","name":"${name}","xh":"${xh}","xb":"男","latitude":30.626590320581055,"longitude":104.02320455214844,"locationBig":"中国,四川省,成都市,武侯区","locationSmall":"成都市武侯区聚龙路988号","hjsfly":"否","ywjchblj":"无","ywjcqzbl":"无","xjzdywqzbl":"无","twsfzc":"是","ywytdzz":"无","brsfqz":"无","brsfys":"无","jbs":"无","sfyfy":"无","fyjtgj":"无","fyddsj":"无","sfbgsq":"无","sfjjgl":"无","jjglqssj":"无","wjjglmqqx":"无","beizhu":"无","qtycqk":"无","mrdkkey":"6_Kf_Kk4","timestamp":${timestamp}}"#;
let data = String::from(template)
.replace("${dh}", &args[3])
.replace("${name}", &args[2])
.replace("${dz}", &args[4])
.replace("${xh}", &args[1])
.replace("${timestamp}", &SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs().to_string());
let json = json!({
"key": base64::encode(&data)
}).to_string();
println!("Information will be uploaded: {}", data);
println!("Checking out...");
let client = reqwest::Client::new();
let res = client.post("https://we.cqu.pt/api/mrdk/post_mrdk_info.php")
.body(json)
.header(USER_AGENT, "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.13(0x17000d29) NetType/WIFI Language/zh_CN")
.header(CONTENT_TYPE, "application/json")
.send()
.await;
match res {
Ok(res) => println!("Done: {}", res.status()),
Err(err) => println!("Error: {}", err),
}
Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment