Native-first asynchronous network discovery CLI
moon run --target native cmd/mscan -- --help
moon run --target native cmd/mscan -- 127.0.0.1 -p 1-1024 --all --format jsonl
moon run --target native cmd/mscan -- -f targets.txt --scope authorized-scope.txt --rate 100
moon build --target native --releasemoon check --target native --deny-warn
moon test --target native
moon info --target native
moon fmt
moon build --target native --release
moon run --target native tests/cli_smoke.mbtx
moon run --target native tests/tls_smoke.mbtxmoon run --target native cmd/mscan -- 127.0.0.1 -p 8080 --probe http --checks --rules fingerprints/example.json --format jsonl{"version":1,"rules":[{"id":"nginx","name":"nginx server","field":"server","contains":"nginx"}]}///|
test {
assert_eq(@mscan.parse_ports("443,80-81,80"), [80, 81, 443])
let plan = @mscan.TargetPlan::parse(["192.0.2.0/30"], exclude=["192.0.2.1"])
assert_eq(plan.hosts().collect(), ["192.0.2.0", "192.0.2.2", "192.0.2.3"])
}pub(open) trait Detector {
fn id(Self) -> String
async fn inspect(Self, ScanResult) -> Array[Finding]
}pub struct CertificateInfo {
subject : String
issuer : String
not_before : String
not_after : String
sha256_fingerprint : String
dns_names : Array[String]
ip_addresses : Array[String]
verification : CertificateVerification
} derive(Debug, ToJson)pub struct InventoryDetector {
// private fields
}impl Detector for InventoryDetectorpub struct RuleSet {
// private fields
}test {
let rules = @mscan.RuleSet::parse("{\"version\":1,\"rules\":[]}")
assert_eq(@mscan.Detector::id(rules), "fingerprints.v1")
}pub struct ScanResult {
target : String
address : String
port : Int
state : PortState
elapsed_ms : Int64
error : String?
service : ServiceInfo?
probe_error : String?
attempts : Int
detection : DetectionReport?
} derive(Debug)pub struct ScanSummary {
completed : Int64
open : Int64
closed : Int64
timed_out : Int64
failed : Int64
} derive(Debug)pub struct Scope {
// private fields
}test {
let scope = @mscan.Scope::parse(["192.0.2.0/24", "::1"])
assert_true(scope.contains("192.0.2.10"))
assert_false(scope.contains("198.51.100.1"))
}pub struct ServiceInfo {
protocol : String
banner : String?
http_status : Int?
title : String?
server : String?
location : String?
certificate_der_base64 : String?
certificate : CertificateInfo?
certificate_error : String?
truncated : Bool
} derive(Debug)pub struct TargetPlan {
// private fields
}fn TargetPlan::parse(targets : ArrayView[String], exclude? : ArrayView[String]) -> TargetPlan raise InputErrorfn TargetPlan::preview(self : TargetPlan, ports : ArrayView[Int], scope? : Scope, retries? : Int, max_hosts? : Int, max_attempts? : Int) -> ScanPreview raise InputErrortest {
let plan = @mscan.TargetPlan::parse(["127.0.0.0/30"])
assert_eq(plan.preview([80, 443]).worst_case_attempts, 8)
}async fn detect(result : ScanResult, detectors : ArrayView[&Detector], timeout_ms? : Int, max_findings? : Int) -> DetectionReportasync fn inspect_certificate(der : Bytes, target : String, verify? : Bool, ca_file? : String, openssl? : String) -> CertificateInfotest {
assert_eq(@mscan.parse_ports("443,80,80-81"), [80, 81, 443])
}async fn scan(targets : TargetPlan, ports : ArrayView[Int], concurrency? : Int, timeout_ms? : Int, rate? : Int, probe? : ProbeMode, probe_timeout_ms? : Int, max_probe_bytes? : Int, retries? : Int, retry_delay_ms? : Int, scope? : Scope, max_hosts? : Int, max_attempts? : Int, deadline_ms? : Int, cert_verify? : Bool, cert_ca_file? : String, openssl? : String, on_result~ : async (ScanResult) -> Unit) -> ScanSummary