| Crates.io | stalkermap |
| lib.rs | stalkermap |
| version | 0.1.51 |
| created_at | 2025-09-26 02:08:11.725757+00 |
| updated_at | 2025-11-26 14:08:18.510784+00 |
| description | A comprehensive Rust library for building CLI network scanner applications with robust input validation, terminal interaction, and URL parsing capabilities. |
| homepage | |
| repository | https://github.com/seakerOner/stalkermap-rs |
| max_upload_size | |
| id | 1855311 |
| size | 249,630 |
A comprehensive Rust library for building CLI network scanner applications with robust input validation, terminal interaction, and URL parsing capabilities.
(All feature versions)
("std" feature)
("tokio-dep" feature)
("Agnostic" feature)
Agnostic version
Default (std) version
Blocking TCP/UDP transport using std::net.
Fully functional DNS resolver for blocking queries.
Tokio (async) version
Replaces blocking transport with tokio::net for async TCP/UDP.
Supports non-blocking behaviors inspired by RFCs (TCP fallback, EDNS, retries, etc.). (Planned)
Add this to your Cargo.toml:
[dependencies]
stalkermap = { version = "0.1.50", features = ["std"]}
stalkermap = { version = "0.1.50", features = ["tokio-dep"]}
stalkermap = { version = "0.1.50", default-features = false, features = ["agnostic"]}
use stalkermap::scanner::*;
use stalkermap::actions;
use stalkermap::utils::UrlParser;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() {
// Create the scanner (requires feature = "tokio-dep")
let scanner = Scanner::<StructuredFormatter>::new().build();
// Subscribe to log events
let mut logs = scanner.get_logs_stream().await.unwrap();
// Add a simple task using the built-in ActionIsPortOpen
scanner.add_task(
actions!(ActionIsPortOpen {}),
UrlParser::from_str("https://127.0.0.1:80").unwrap()
);
// Start executing tasks
scanner.execute_tasks();
// Consume logs in real-time
tokio::spawn(async move {
while let Some(event) = logs.next().await {
println!("{event:?}");
// Pause until new tasks arrive when scanner goes idle
if StructuredFormatter::is_idle_signal(&event) {
logs.notify_when_new_tasks().await;
}
}
});
// Wait until scanner finishes all tasks
scanner.await_idle().await;
// Graceful shutdown
scanner.shutdown_graceful().await;
}
use stalkermap::dns::resolver::{resolve_ipv4, resolve_mx};
let a_records = resolve_ipv4("example.com").unwrap();
let mx_records = resolve_mx("example.com").unwrap();
println!("A records: {:#?}", a_records);
println!("MX records: {:#?}", mx_records);
use stalkermap::utils::{Terminal, Sanitize, DesiredType};
// Get validated user input with range checking
let threads = Terminal::ask(
"Enter scan threads (1-16):",
&[Sanitize::IsBetween(1, 16)],
);
println!("Threads: {}", threads.answer);
use stalkermap::utils::UrlParser;
// Parse and validate URLs
match UrlParser::new("https://example.com:8080/api") {
Ok(url) => {
println!("Scheme: {}", url.scheme);
println!("Target: {}", url.target);
println!("Port: {}", url.port);
println!("Path: {}", url.subdirectory);
}
Err(e) => eprintln!("Invalid URL: {}", e),
}
use stalkermap::utils::{Terminal, Sanitize, DesiredType};
// Multiple validation rules
let choice = Terminal::ask(
"Choose scan type (quick/deep/custom):",
&[
Sanitize::IsType(DesiredType::String),
Sanitize::MatchStrings(vec![
"quick".to_string(),
"deep".to_string(),
"custom".to_string(),
]),
],
);
This example demonstrates the complete workflow of getting user input, validating it, and parsing URLs - perfect for network scanner applications:
use stalkermap::utils::{Terminal, Sanitize, DesiredType, UrlParser};
fn main() {
// Get URL from user with validation
let url: UrlParser = loop {
let input = Terminal::ask(
"Enter a URL (http:// or https://):",
&[Sanitize::IsType(DesiredType::String)],
);
// Parse and validate the URL
match UrlParser::new(&input.answer) {
Ok(url) => break url,
Err(e) => println!("{}", e)
}
};
println!("{}", url);
}
Users can either build a DNS message manually using their own structures
or use the DnsMessage struct provided by this library. Example with a raw buffer:
use std::collections::HashMap;
use stalkermap::dns::compressor::MessageCompressor;
let mut message = Vec::new();
let mut pointer_map = HashMap::new();
// Compress a domain name
MessageCompressor::compress("www.example.com", &mut message, &mut pointer_map).unwrap();
// Reusing the same domain (or suffix) inserts a pointer instead of repeating bytes
MessageCompressor::compress("mail.example.com", &mut message, &mut pointer_map).unwrap();
use stalkermap::dns::resolver::agnostic::{DnsMessage, RecordType, OpCodeOptions};
// Build a query for example.com A record
let msg = DnsMessage::new_query("example.com", RecordType::A, OpCodeOptions::StandardQuery);
// Encode into raw bytes, ready to send via UDP/TCP
let bytes = msg.encode_query();
assert!(!bytes[12..].is_empty()); // includes header + question
The library is designed with modularity and composability in mind:
utils - Core utilities for input handling and URL parsingdns - DNS resolution and query utilitiesscanner - Port scanning and network discoveryreporter - Report generation and export (planned)All operations return Result<T, E> types for safe error handling:
use stalkermap::utils::{UrlParser, UrlParserErrors};
match UrlParser::new("invalid-url") {
Ok(url) => println!("Valid URL: {}", url),
Err(UrlParserErrors::InvalidScheme) => eprintln!("Only HTTP/HTTPS supported"),
Err(UrlParserErrors::InvalidTargetType) => eprintln!("Invalid hostname or IP"),
Err(e) => eprintln!("Other error: {}", e),
}
This repository also includes a CLI application demonstrating the library usage:
# Clone and run
git clone https://github.com/seakerOner/stalkermap-rs
cd stalkermap-rs
cargo run --bin stalkermap-cli
This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes and version history.