Added build script
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
cd src-tauri && cargo clean
|
||||
cargo clippy --fix --all-targets --allow-dirty
|
||||
cargo fmt
|
||||
cargo tauri build
|
||||
cargo tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc
|
||||
@@ -1,12 +1,11 @@
|
||||
use pulldown_cmark::{Options, Parser, html};
|
||||
use pulldown_cmark::{html, Options, Parser};
|
||||
|
||||
const CHANGELOG_MD: &str = include_str!("../../../CHANGELOG.md");
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_changelog() -> Result<String, String> {
|
||||
let options = Options::ENABLE_HEADING_ATTRIBUTES
|
||||
| Options::ENABLE_STRIKETHROUGH
|
||||
| Options::ENABLE_TABLES;
|
||||
let options =
|
||||
Options::ENABLE_HEADING_ATTRIBUTES | Options::ENABLE_STRIKETHROUGH | Options::ENABLE_TABLES;
|
||||
|
||||
let parser = Parser::new_ext(CHANGELOG_MD, options);
|
||||
let mut html_output = String::new();
|
||||
|
||||
@@ -11,8 +11,7 @@ pub struct ExportRequest {
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn export_csv(request: ExportRequest) -> Result<(), String> {
|
||||
let file = File::create(&request.path)
|
||||
.map_err(|e| format!("Failed to create file: {}", e))?;
|
||||
let file = File::create(&request.path).map_err(|e| format!("Failed to create file: {}", e))?;
|
||||
|
||||
let mut writer = csv::Writer::from_writer(file);
|
||||
|
||||
|
||||
@@ -40,7 +40,16 @@ pub async fn start_scan(app: AppHandle, config: ScanConfig) -> Result<(), String
|
||||
let port_timeout_ms = config.port_timeout_ms.unwrap_or(1000);
|
||||
|
||||
tokio::spawn(async move {
|
||||
ping_sweep(&app, &ips, timeout_ms, cancel, port_scan, ports, port_timeout_ms).await;
|
||||
ping_sweep(
|
||||
&app,
|
||||
&ips,
|
||||
timeout_ms,
|
||||
cancel,
|
||||
port_scan,
|
||||
ports,
|
||||
port_timeout_ms,
|
||||
)
|
||||
.await;
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ pub enum HostStatus {
|
||||
Up,
|
||||
Down,
|
||||
Filtered,
|
||||
Unknown
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -42,7 +42,7 @@ pub struct PortResult {
|
||||
pub struct NetbiosInfo {
|
||||
pub computer_name: Option<String>,
|
||||
pub workgroup: Option<String>,
|
||||
pub mac_from_netbios: Option<String>
|
||||
pub mac_from_netbios: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
@@ -3,9 +3,7 @@ use std::net::IpAddr;
|
||||
/// Perform reverse DNS lookup on a single IP.
|
||||
/// Returns the hostname if found, None otherwise.
|
||||
pub async fn reverse_lookup(ip: IpAddr) -> Option<String> {
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
dns_lookup::lookup_addr(&ip)
|
||||
}).await;
|
||||
let result = tokio::task::spawn_blocking(move || dns_lookup::lookup_addr(&ip)).await;
|
||||
|
||||
match result {
|
||||
Ok(Ok(hostname)) => {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
pub mod range;
|
||||
pub mod dns;
|
||||
pub mod range;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub mod netbios;
|
||||
pub mod ping;
|
||||
pub mod ports;
|
||||
pub mod netbios;
|
||||
@@ -91,8 +91,7 @@ pub async fn ping_sweep(
|
||||
let nb_fut = query_netbios(enriched.ip, 500);
|
||||
|
||||
if port_scan {
|
||||
let scan_ports = ports2
|
||||
.unwrap_or_else(|| DEFAULT_PORTS.to_vec());
|
||||
let scan_ports = ports2.unwrap_or_else(|| DEFAULT_PORTS.to_vec());
|
||||
let (nb_result, port_results) = tokio::join!(
|
||||
nb_fut,
|
||||
scan_host_ports(enriched.ip, &scan_ports, port_timeout_ms)
|
||||
|
||||
@@ -42,8 +42,7 @@ fn service_name(port: u16) -> Option<String> {
|
||||
}
|
||||
|
||||
pub const DEFAULT_PORTS: &[u16] = &[
|
||||
21, 22, 23, 25, 53, 80, 110, 111, 135, 139, 143,
|
||||
443, 445, 993, 995, 1433, 1521, 3306, 3389,
|
||||
21, 22, 23, 25, 53, 80, 110, 111, 135, 139, 143, 443, 445, 993, 995, 1433, 1521, 3306, 3389,
|
||||
5432, 5900, 5985, 5986, 8080, 8088, 8443,
|
||||
];
|
||||
|
||||
@@ -96,7 +95,10 @@ async fn grab_banner(mut stream: TcpStream, port: u16) -> Option<String> {
|
||||
};
|
||||
|
||||
if let Some(data) = probe {
|
||||
if timeout(banner_timeout, stream.write_all(data)).await.is_err() {
|
||||
if timeout(banner_timeout, stream.write_all(data))
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
@@ -107,8 +109,15 @@ async fn grab_banner(mut stream: TcpStream, port: u16) -> Option<String> {
|
||||
Ok(Ok(n)) if n > 0 => {
|
||||
buf.truncate(n);
|
||||
// Strip to printable ASCII, replace control chars
|
||||
let banner: String = buf.iter()
|
||||
.map(|&b| if b >= 0x20 && b < 0x7f { b as char } else { ' ' })
|
||||
let banner: String = buf
|
||||
.iter()
|
||||
.map(|&b| {
|
||||
if (0x20..0x7f).contains(&b) {
|
||||
b as char
|
||||
} else {
|
||||
' '
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let banner = banner.trim().to_string();
|
||||
if banner.is_empty() {
|
||||
@@ -124,11 +133,7 @@ async fn grab_banner(mut stream: TcpStream, port: u16) -> Option<String> {
|
||||
|
||||
const MAX_PORT_CONCURRENT: usize = 64;
|
||||
|
||||
pub async fn scan_host_ports(
|
||||
ip: IpAddr,
|
||||
ports: &[u16],
|
||||
timeout_ms: u64,
|
||||
) -> Vec<PortResult> {
|
||||
pub async fn scan_host_ports(ip: IpAddr, ports: &[u16], timeout_ms: u64) -> Vec<PortResult> {
|
||||
let mut results = Vec::with_capacity(ports.len());
|
||||
|
||||
for chunk in ports.chunks(MAX_PORT_CONCURRENT) {
|
||||
|
||||
Reference in New Issue
Block a user