Skip to content

Commit e33d237

Browse files
committed
V0.2.0
0 parents  commit e33d237

File tree

6 files changed

+501
-0
lines changed

6 files changed

+501
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target
2+
*.json
3+
*.xml
4+
*.txt

Cargo.lock

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "verydisco"
3+
version = "0.2.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
serde = "1.0.210"
8+
serde-xml-rs = "0.6.0"
9+
serde_json = "1.0.128"

src/main.rs

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
use std::env;
2+
3+
mod scanner;
4+
use scanner::{Color, scan_ip, colorize, is_ip_v4, write_output_to_file};
5+
6+
7+
fn print_usage(program_name: &str, options: Vec<VDOption>) {
8+
9+
let mut usage = format!(
10+
"Usage: \n{} [options] target_ip\n\nOptions:\n",
11+
program_name
12+
);
13+
for option in options {
14+
if !option.hide {
15+
usage.push_str(&format!(
16+
" {:<20} {} - {}\n",
17+
option.aliases.join(", "),
18+
option.name,
19+
option.help
20+
));
21+
}
22+
}
23+
println!("{}", usage);
24+
}
25+
26+
fn motd() {
27+
print!("\x1B[2J\x1B[1;1H");
28+
println!(
29+
"
30+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
31+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
32+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
33+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
34+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
35+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
36+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
37+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
38+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
39+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
40+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
41+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
42+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m \x1b[48;2;240;208;67m \x1b[0m
43+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m\x1b[48;2;240;208;67m \x1b[0m
44+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m\x1b[48;2;240;208;67m \x1b[0m
45+
\x1b[38;2;146;140;150m \x1b[48;2;100;106;115m \x1b[48;2;0;0;0m\x1b[48;2;240;208;67m \x1b[0m
46+
47+
48+
- Welcome to VeriDisco v{} -
49+
50+
",
51+
env!("CARGO_PKG_VERSION")
52+
);
53+
}
54+
55+
56+
struct VDOption {
57+
name: String,
58+
enabled: bool,
59+
value: String,
60+
aliases: Vec<String>,
61+
has_arg: bool,
62+
hide: bool,
63+
help: String,
64+
}
65+
66+
67+
fn main() {
68+
let mut options: Vec<VDOption> = Vec::new();
69+
options.push(VDOption {
70+
name: "output".to_string(),
71+
enabled: false,
72+
value: "".to_string(),
73+
has_arg: true,
74+
aliases: vec!["-o".to_string(), "--output".to_string()],
75+
hide: false,
76+
help: "Output file path".to_string(),
77+
});
78+
options.push(VDOption {
79+
name: "output-type".to_string(),
80+
enabled: false,
81+
value: "".to_string(),
82+
has_arg: true,
83+
aliases: vec!["-ot".to_string(), "--output-type".to_string()],
84+
hide: false,
85+
help: "Output type (json, xml, txt)".to_string(),
86+
});
87+
options.push(VDOption {
88+
name: "target_ip".to_string(),
89+
enabled: false,
90+
value: "".to_string(),
91+
has_arg: false,
92+
aliases: vec![],
93+
hide: true,
94+
help: "".to_string(),
95+
});
96+
options.push(VDOption {
97+
name: "verbose".to_string(),
98+
enabled: false,
99+
value: "".to_string(),
100+
has_arg: false,
101+
aliases: vec!["-V".to_string(), "--verbose".to_string()],
102+
hide: false,
103+
help: "Enable verbose for more details".to_string(),
104+
});
105+
options.push(VDOption {
106+
name: "threads".to_string(),
107+
enabled: false,
108+
value: "8".to_string(),
109+
has_arg: true,
110+
aliases: vec!["-t".to_string(), "--threads".to_string()],
111+
hide: false,
112+
help: "Number of threads for the scan".to_string(),
113+
});
114+
115+
let args = env::args().collect::<Vec<String>>();
116+
117+
let program_name = args[0].clone();
118+
119+
if args.len() < 2 || args[1] == "-h" || args[1] == "--help" {
120+
print_usage(&program_name, options);
121+
return;
122+
}
123+
124+
if args[1] == "-v" || args[1] == "--version" {
125+
println!("VeriDisco v{}", env!("CARGO_PKG_VERSION"));
126+
return;
127+
}
128+
129+
motd();
130+
let mut skip = false;
131+
for i in 1..args.len() {
132+
if skip {
133+
skip = false;
134+
continue;
135+
}
136+
let arg = &args[i];
137+
let mut found = false;
138+
for option in &mut options {
139+
if option.aliases.contains(arg) {
140+
option.enabled = true;
141+
if i + 1 < args.len() && !args[i + 1].starts_with("-") && option.has_arg {
142+
option.value = args[i + 1].clone();
143+
skip = true;
144+
}
145+
found = true;
146+
break;
147+
} else if !arg.starts_with("-") && option.name == "target_ip" && is_ip_v4(arg) {
148+
option.value = arg.clone();
149+
option.enabled = true;
150+
found = true;
151+
break;
152+
}
153+
}
154+
if !found {
155+
println!("{}: {}", colorize("[X] Invalid option", Color::Red), arg);
156+
for option in &mut options {
157+
if option.enabled {
158+
option.value = arg.clone();
159+
option.enabled = false;
160+
break;
161+
}
162+
}
163+
}
164+
}
165+
166+
// get option by name
167+
let get_option = |name: &str| -> &VDOption {
168+
for option in &options {
169+
if option.name == name {
170+
return option;
171+
}
172+
}
173+
panic!("Option not found");
174+
};
175+
176+
if !get_option("target_ip").enabled {
177+
println!("{}", colorize("[X] Target IP is required\n", Color::Red));
178+
print_usage(program_name.as_str(), options);
179+
return;
180+
}
181+
182+
if get_option("verbose").enabled {
183+
for option in &options {
184+
if option.hide {
185+
continue;
186+
}
187+
println!(
188+
"{} {}: {}",
189+
if option.enabled {
190+
colorize("[V]", Color::Green)
191+
} else {
192+
colorize("[X]", Color::Red)
193+
},
194+
option.name,
195+
colorize(&option.value, Color::Cyan)
196+
);
197+
}
198+
}
199+
200+
println!(
201+
"{}: {}\n",
202+
"Target IP",
203+
colorize(&get_option("target_ip").value, Color::Cyan)
204+
);
205+
206+
let thread_count = get_option("threads").value.parse::<usize>().unwrap();
207+
208+
let open_ports = scan_ip(&get_option("target_ip").value, thread_count);
209+
210+
if get_option("output").enabled {
211+
write_output_to_file(
212+
&get_option("output").value,
213+
&get_option("output-type").value,
214+
open_ports,
215+
);
216+
println!(
217+
"{}: {}\n",
218+
"Output file",
219+
colorize(&get_option("output").value, Color::Cyan)
220+
);
221+
}
222+
223+
}

src/scanner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod scanner;
2+
pub use scanner::{Color, scan_ip, test_port, colorize, is_ip_v4, write_output_to_file};

0 commit comments

Comments
 (0)