Skip to content

Commit e3f55db

Browse files
committed
Update 0.0.2
1 parent 480ef9a commit e3f55db

File tree

4 files changed

+91
-111
lines changed

4 files changed

+91
-111
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ reqwest = { version = "0.11.22", features = ["json"] }
88
tokio = { version = "1.34.0", features = ["full"] }
99
serde = { version = "1.0.192", features = ["derive"] }
1010
serde_json = "1.0.108"
11+
#fake_user_agent = "0.1.4"
1112
chrono = "0.4.31"
1213
ansi_term = "0.12.1"

src/main.rs

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
/*
2-
▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄ ▄▄ ▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄
3-
▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░▌ ▐░░▌▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
4-
▐░█▀▀▀▀▀▀▀█░▌ ▀▀▀▀█░█▀▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌░▌ ▐░▐░▌▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀▀▀▀█░▌
5-
▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌▐░▌ ▐░▌▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌
6-
▐░█▄▄▄▄▄▄▄█░▌ ▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌▐░▌ ▐░▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░█▄▄▄▄▄▄▄█░▌
7-
▐░░░░░░░░░░░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌
8-
▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▀▀▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀█░▌▐░▌ ▐░▌▐░▌ ▀ ▐░▌▐░█▀▀▀▀▀▀▀█░▌▐░█▀▀▀▀▀▀▀▀▀ ▐░█▀▀▀▀█░█▀▀
9-
▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌ ▐░▌
10-
▐░▌ ▐░▌ ▄▄▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄█░▌▐░▌ ▐░▌▐░█▄▄▄▄▄▄▄█░▌▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▐░▌
11-
▐░▌ ▐░▌ ▐░░░░░░░░░░░▌▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌
12-
▀ ▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀ ▀▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀ ▀
13-
14-
*/
15-
161
mod utils;
172
mod services;
183

@@ -36,14 +21,14 @@ fn main() {
3621

3722
println!("Enter phone number:");
3823

39-
utils::send(loop {
24+
utils::start(loop {
4025
let mut phone_number = String::new();
4126
io::stdin()
4227
.read_line(&mut phone_number)
4328
.expect("Error reading input");
4429
let phone_number = phone_number.trim().to_owned();
4530

46-
if phone_number.len() != 11 { //7 977 975 0115
31+
if phone_number.len() != 11 {
4732
println!("{}",
4833
Red.bold().paint(format!("Size {}, instead 11", phone_number.len())));
4934
} else { break phone_number; }

src/services.rs

+27-46
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,47 @@
11
use crate::utils::{PhoneNumberTypes, format_number};
22
use std::collections::HashMap;
3+
use reqwest::header::HeaderMap;
34

45
#[derive(Clone)]
56
pub struct Service {
67
pub name: String,
78
pub url: String,
9+
pub headers: HeaderMap,
810
pub post: HashMap<String, String>
911
}
1012

11-
pub fn get_services_list(phone_number: String) -> Vec<Service> {
12-
let mut services_list = Vec::new();
13+
/*
14+
Образец
1315
14-
/*{
15-
"last_name": "Kuchiki",
16-
"first_name": "Byakuya",
17-
"email": "marchenkoserofim@gmail.com",
18-
"phone": "+7(***)*******"
19-
}*/
20-
/*{ // Gosuslugi
21-
let mut service = Service {
22-
name: "Gosuslugi".to_string(),
23-
url: "https://www.gosuslugi.ru/auth-provider/mobile/register".to_string(),
24-
post: HashMap::new(),
25-
};
16+
{
17+
let mut service = Service {
18+
name: todo!(),
19+
url: todo!(),
20+
headers: HeaderMap::new(),
21+
post: HashMap::new()
22+
};
2623
27-
service.post.insert(
28-
"last_name".to_string(),
29-
"Kuchiki".to_string()
30-
);
31-
service.post.insert(
32-
"first_name".to_string(),
33-
"Byakuya".to_string()
34-
);
35-
service.post.insert(
36-
"email".to_string(),
37-
"marchenkoserofim@gmail.com".to_string()
38-
);
39-
service.post.insert(
40-
"phone".to_string(),
41-
format_number(&PhoneNumberTypes::WithPlusBrackets(phone_number.to_string())));
24+
service.headers.insert(
25+
"",
26+
r#""#.parse().unwrap());
4227
43-
services_list.push(service);
44-
}*/
28+
service.post.insert(
29+
"".to_string(),
30+
phone_number.clone());
4531
46-
{ // Telegram
47-
let mut service = Service {
48-
name: "Telegram".to_string(),
49-
url: "https://my.telegram.org/auth/send_password".to_string(),
50-
post: HashMap::new(),
51-
};
32+
services_list.push(service);
33+
}
34+
*/
5235

53-
service.post.insert(
54-
"phone".to_string(),
55-
format_number(&PhoneNumberTypes::WithPlus(phone_number.to_string())));
56-
57-
services_list.push(service);
58-
}
36+
pub fn get_services_list(phone_number: String) -> Vec<Service> {
37+
let mut services_list = Vec::new();
5938

60-
{ // MyGames
39+
// MyGames
40+
{
6141
let mut service = Service {
6242
name: "MyGames".to_string(),
6343
url: "https://account.my.games/signup_phone_init/".to_string(),
44+
headers: HeaderMap::new(),
6445
post: HashMap::new()
6546
};
6647

@@ -78,7 +59,7 @@ pub fn get_services_list(phone_number: String) -> Vec<Service> {
7859
"0".to_string());
7960
service.post.insert(
8061
"phone".to_string(),
81-
phone_number.to_string());
62+
phone_number.clone());
8263
service.post.insert(
8364
"password".to_string(),
8465
"marchenkoserofim@gmail.com".to_string());
@@ -88,6 +69,6 @@ pub fn get_services_list(phone_number: String) -> Vec<Service> {
8869

8970
services_list.push(service);
9071
}
91-
72+
9273
services_list
9374
}

src/utils.rs

+61-48
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
use crate::services::get_services_list;
1+
use crate::services::{Service, get_services_list};
2+
//use fake_user_agent::get_rua;
23
use chrono::Utc;
34

45
pub enum PhoneNumberTypes {
56
WithPlus(String), //+7**********
67
WithPlusBrackets(String) //+7(***)*******
78
}
89

9-
pub fn format_number(phone_number: &PhoneNumberTypes) -> String {
10+
pub fn format_number(phone_number: PhoneNumberTypes) -> String {
1011
match phone_number {
1112
PhoneNumberTypes::WithPlus(number) => {
1213
let mut formatted_phone = "+".to_string();
13-
formatted_phone.push_str(number);
14+
formatted_phone.push_str(number.as_str());
1415

1516
formatted_phone
1617
},
1718
PhoneNumberTypes::WithPlusBrackets(number) => {
1819
let slice = &number[0..=10];
1920
let mut formatted_phone = "+".to_string();
20-
formatted_phone.push(slice.chars().nth(0).unwrap());
21+
formatted_phone.push(slice.chars().next().unwrap());
2122
formatted_phone.push('(');
2223
formatted_phone.push_str(&slice[1..4]);
2324
formatted_phone.push(')');
@@ -29,66 +30,78 @@ pub fn format_number(phone_number: &PhoneNumberTypes) -> String {
2930
}
3031
}
3132

33+
async fn send(service: Service) {
34+
//let rua = get_rua();
35+
36+
let client = reqwest::Client::builder()
37+
//.user_agent(rua)
38+
.build()
39+
.expect("Error while client creating");
40+
41+
if !service.headers.is_empty() {
42+
let res = client
43+
.post(service.url)
44+
.headers(service.headers)
45+
.json(&service.post)
46+
.send()
47+
.await
48+
.unwrap();
49+
50+
println!("\nService with HEADERs - {}",
51+
service.name);
52+
println!("Status - {}\n{:#?}\n",
53+
res.status(),
54+
res.text()
55+
.await
56+
.unwrap());
57+
} else {
58+
let res = client
59+
.post(service.url)
60+
.json(&service.post)
61+
.send()
62+
.await
63+
.unwrap();
64+
65+
println!("\nService without HEADERs - {}",
66+
service.name);
67+
println!("Status - {}\n{:#?}\n",
68+
res.status(),
69+
res.text()
70+
.await
71+
.unwrap());
72+
}
73+
}
74+
3275
#[tokio::main]
33-
pub async fn send(phone_number: String) { //-> Result<(), Box<dyn std::error::Error>>
76+
pub async fn start(phone_number: String) {
3477
let services_list = get_services_list(phone_number);
35-
36-
let services_list_clone1 = services_list.clone();
37-
let thread1 = tokio::spawn(async move {
38-
for i in 0..services_list_clone1.len() {
39-
if (i+1) % 2 != 0 {
40-
let client = reqwest::Client::new();
41-
let res = client
42-
.post(&services_list_clone1[i].url)
43-
.json(&services_list_clone1[i].post)
44-
.send()
45-
.await
46-
.unwrap();
4778

48-
println!("\nService №{} - {}",
49-
i,
50-
&services_list_clone1[i].name);
51-
println!("Status - {}\n{:#?}\n",
52-
res.status(),
53-
res.text()
54-
.await
55-
.unwrap());
79+
let services_list_0 = services_list.clone();
80+
let thread0 = tokio::spawn(async move {
81+
for i in 0..services_list_0.len() {
82+
if (i+1) % 2 != 0 {
83+
send(services_list_0[i].clone()).await;
5684
}
5785
}
5886
});
5987

60-
let services_list_clone2 = services_list.clone();
61-
let thread2 = tokio::spawn(async move {
62-
for i in 0..services_list_clone2.len() {
88+
let services_list_1 = services_list.clone();
89+
let thread1 = tokio::spawn(async move {
90+
for i in 0..services_list_1.len() {
6391
if (i+1) % 2 == 0 {
64-
let client = reqwest::Client::new();
65-
let res = client
66-
.post(&services_list_clone2[i].url)
67-
.json(&services_list_clone2[i].post)
68-
.send()
69-
.await
70-
.unwrap();
71-
72-
println!("\nService №{} - {}",
73-
i,
74-
&services_list_clone2[i].name);
75-
println!("Status - {}\n{:#?}\n",
76-
res.status(),
77-
res.text()
78-
.await
79-
.unwrap());
92+
send(services_list_1[i].clone()).await;
8093
}
8194
}
8295
});
8396

8497
let start_time = Utc::now();
98+
thread0.await.unwrap();
8599
thread1.await.unwrap();
86-
thread2.await.unwrap();
87100

88101
let finish_time = Utc::now();
89102
let duration = finish_time - start_time;
90103
println!("Finished\nStarted at: {}\nFinished at: {}\nWorked: {}",
91-
start_time.format("%Y-%m-%d %H:%M:%S").to_string(),
92-
finish_time.format("%Y-%m-%d %H:%M:%S").to_string(),
93-
duration.num_seconds().to_string());
104+
start_time.format("%Y-%m-%d %H:%M:%S"),
105+
finish_time.format("%Y-%m-%d %H:%M:%S"),
106+
duration.num_seconds());
94107
}

0 commit comments

Comments
 (0)