Skip to content

feat: major service detection upgrade - #8

Open
Bulletdev wants to merge 2 commits into
mainfrom
feat/service-detection-upgrade
Open

Bulletdev wants to merge 2 commits into
mainfrom
feat/service-detection-upgrade

Conversation

@Bulletdev

Copy link
Copy Markdown
Member

Summary

  • 7 new protocol probes in banner.zig: DNS (version.bind TXT query), Kerberos (AS-REQ with realm extraction), MSRPC (DCE/RPC Bind to EPM), NetBIOS (session request), LDAP (rootDSE search with domain extraction), XMPP (stream initiation), SOCKS5 (auth negotiation)
  • 6 new scripts in scripts.zig: rdp-ntlm-info (NLA negotiation), ssl-cert (TLS cert details via tls.zig), smb2-security-mode (signing/dialect), ldap-rootdse (domain/host attributes), xmpp-info (STARTTLS/auth/server identity), socks-auth-info (method detection)
  • Multi-probe OS detection in os.zig: 3 TCP SYN probes with different options (SEQ/OPS, WIN, ECN) + ICMP Echo probe, combined fingerprinting up to 95% confidence
  • 45 new service signatures in service-probes: 4 null-probe (CouchDB, RethinkDB, Asterisk, TeamSpeak) + 41 HTTP (Tomcat, Docker Registry, Spring Boot, Kubernetes, Metabase, Airflow, n8n, Uptime Kuma, and more)
  • TLS service labeling: probeTls now identifies underlying protocol (https, ldaps, imaps, pop3s, etc.) via ALPN and port mapping
  • Expanded port classification: 53, 88, 135, 139, 389, 464, 593, 1080, 3268, 5222, 5269, 7070, 7443, 7777, 9091 now route to proper protocol probes
  • Generic probe cascade expanded with SOCKS5, DNS, LDAP fallback probes
  • 33 new unit tests across all modules

+1601 lines across 7 files. Build and all tests pass.

Test plan

  • Scan a Windows AD/Domain Controller (ports 53, 88, 135, 139, 389, 445, 636, 3268, 3269, 3389) - verify DNS, Kerberos, MSRPC, NetBIOS, LDAP, SMB, RDP detection
  • Scan a machine with XMPP/Openfire (ports 5222, 5269, 7070, 7443, 9090, 9091)
  • Scan HTTPS targets (443, 8443) - verify ssl-cert script and TLS labeling
  • Scan with -A flag against a rich target and compare output with nmap -A
  • Run zig build test on clean checkout

Add 7 new protocol probes (DNS, Kerberos, MSRPC, NetBIOS, LDAP, XMPP,
SOCKS5), 6 new scripts (rdp-ntlm, ssl-cert, smb2-info, ldap-rootdse,
xmpp-info, socks-auth), multi-probe OS detection with ICMP/ECN, 45 new
service signatures, and TLS underlying service labeling.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@github-actions

Copy link
Copy Markdown

Semgrep Static Analysis

Severity Count
Errors 0
Critical (HIGH confidence) 0
Warnings 0

No issues found.

@github-actions

Copy link
Copy Markdown

Security Scan Summary

Check Status
Semgrep success
Secret Detection success

All security checks passed!

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

⚠️ Resolve issues before merging

The DNS probe uses an incorrect TCP payload length, which can cause valid DNS servers to wait for additional data or reject the request. The OS fingerprinting path also accepts responses without validating the source address, allowing unrelated packets to affect results.

The SMB2 script constructs the NetBIOS session header unreliably and should encode the three-byte length explicitly. Automated coverage is also missing for the new probes, active scripts, and multi-probe OS detection, so those acceptance areas remain insufficiently demonstrated.

About this PR

  • Add fixture- or integration-based automated tests for the new probes, script parsers, and OS fingerprinting paths; current tests primarily cover helpers and signatures rather than the new network behavior.

Test suggestions

  • Unit-test protocol port classification and non-HTTP port recognition for all newly added ports.
  • Unit-test TLS underlying-service labeling using ALPN and port mappings.
  • Unit-test realm validation and extraction behavior.
  • Unit-test new null-probe and HTTP service signatures.
  • Exercise DNS, Kerberos, MSRPC, NetBIOS, LDAP, XMPP, and SOCKS probes against representative responses.
  • Exercise all six active scripts and validate their parsed output.
  • Test multi-probe OS fingerprinting with representative Windows, Linux, BSD, macOS, and network-device responses.
  • Run integration scans for the stated AD, XMPP, HTTPS, and rich-target scenarios.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Exercise DNS, Kerberos, MSRPC, NetBIOS, LDAP, XMPP, and SOCKS probes against representative responses.
2. Exercise all six active scripts and validate their parsed output.
3. Test multi-probe OS fingerprinting with representative Windows, Linux, BSD, macOS, and network-device responses.
4. Run integration scans for the stated AD, XMPP, HTTPS, and rich-target scenarios.

Make this review better

TIP Add a ticket key to the branch or title so the reviewer can check the PR against it. Or tell us which ticket tracker you use here.
TIP Add Codacy review.md instructions or an AGENTS.md so the reviewer knows your conventions.

TIP How was this review? Give us feedback

Comment thread src/os.zig
if (packet.fromNet(u16, tcp_hdr.src_port) != open_port) continue;
if (packet.fromNet(u16, tcp_hdr.dst_port) != src_port) continue;

const dst_port = packet.fromNet(u16, tcp_hdr.dst_port);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Validate the response source IP against the target before associating it with a probe, and also validate the expected ACK/sequence relationship where applicable.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Comment thread src/banner.zig Outdated

// DNS version.bind TXT CH query over TCP (2-byte length prefix + DNS packet)
const dns_query = [_]u8{
// TCP length prefix

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

Change the TCP length prefix from 0x00, 0x1E to 0x00, 0x1D, or compute it from the payload length.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

@Bulletdev Bulletdev self-assigned this Nov 11, 2026
- Run zig fmt on banner.zig and scripts.zig
- Compute DNS TCP length prefix from payload size instead of hardcoding
- Validate TCP ACK number in OS multi-probe response matching
@github-actions

Copy link
Copy Markdown

Semgrep Static Analysis

Severity Count
Errors 0
Critical (HIGH confidence) 0
Warnings 0

No issues found.

@github-actions

Copy link
Copy Markdown

Security Scan Summary

Check Status
Semgrep success
Secret Detection success

All security checks passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant