Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b756dd5
fix(snmp): validate response request ID and community
ItsWanheda Nov 6, 2026
a8efae4
fix(rdp): enforce TPKT and X.224 negotiation framing
ItsWanheda Nov 6, 2026
02381fe
fix(mongodb): require exact response correlation ID
ItsWanheda Nov 6, 2026
228f31b
fix(rtsp): validate status headers and content length
ItsWanheda Nov 6, 2026
83a8aa5
fix(smtp): reject malformed multiline SMTP responses
ItsWanheda Nov 6, 2026
cb45297
fix(rtsp): correct CRLF parsing and status validation
ItsWanheda Nov 6, 2026
1079e7b
test(protocols): cover malformed and mismatched responses
ItsWanheda Nov 6, 2026
cef1e33
test(protocols): add strict response validation regressions
ItsWanheda Nov 6, 2026
27f24aa
test(smtp): fix malformed multiline regression fixtures
ItsWanheda Nov 6, 2026
80db13f
test(smtp): assert connection close for unterminated replies
ItsWanheda Nov 6, 2026
eb221e4
docs(readme): document SpectraScan 2.2.4 stable release
ItsWanheda Nov 6, 2026
5f5e90e
docs(changelog): add 2.2.4 stable release notes
ItsWanheda Nov 6, 2026
1b4134e
docs(security): align supported versions with 2.2.4
ItsWanheda Nov 6, 2026
5ad67b7
chore(release): add canonical 2.2.4 version file
ItsWanheda Nov 6, 2026
f132fe7
fix(rdp): read complete TPKT response frames
ItsWanheda Nov 6, 2026
e6f2073
test(rdp): assert disabled NLA is not a vulnerability
ItsWanheda Nov 6, 2026
7ee89b9
docs(changelog): clarify historical beta status
ItsWanheda Nov 6, 2026
49b7f94
docs(readme): mark 2.2.4 release line as stable
ItsWanheda Nov 6, 2026
644ca1c
test(protocols): disambiguate SNMP and RTSP parser imports
ItsWanheda Nov 6, 2026
24a176c
fix(smtp): require CRLF-terminated response lines
ItsWanheda Nov 6, 2026
5a0ca5c
test(smtp): reject unterminated CRLF response lines
ItsWanheda Nov 6, 2026
1351cbf
test(snmp): use the explicitly aliased SNMP parser
ItsWanheda Nov 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

---

## [2.2.4] — Stable release preparation (2026-11-07)

> **Release status:** This branch prepares the 2.2.4 stable release. The version becomes an official published artifact when the release PR is merged and the corresponding GitHub tag/release is created.

### Security

- Validate SNMPv2c response version, request ID, community string, response PDU boundaries, and requested OID before accepting returned values.
- Require MongoDB OP_MSG `responseTo` to equal the outstanding request ID; reject zero and every other mismatched value.
- Remove the unsupported medium-severity RDP finding for disabled NLA. NLA negotiation without HYBRID/HYBRID_EX is retained as a configuration observation, not a confirmed vulnerability.
- Keep BlueKeep status explicitly unassessed unless product, OS, and patch-level evidence is available.

### Fixed

- Enforce exact TPKT length, X.224 Connection Confirm type/length, and RDP negotiation structure before reporting a server response or NLA capability.
- Validate RTSP status-line syntax and header structure; reject duplicate headers, malformed or oversized Content-Length values, and body-length mismatches.
- Enforce SMTP multiline reply grammar, consistent three-digit status codes, valid terminating lines, and explicit failure for incomplete responses.

### Tests

- Add regression coverage for SNMP request-ID/community mismatches.
- Add RDP malformed TPKT and negotiation-length cases.
- Add MongoDB response-correlation tests for matching and zero/mismatched `responseTo` values.
- Add RTSP malformed status, duplicate Content-Length, and declared-body-length tests.
- Add SMTP inconsistent-code, malformed-line, and unterminated multiline-response tests.

### Documentation

- Replace the stale 2.2.0/Beta status in the README with the 2.2.4 stable-release target and its protocol/security changes.
- Align supported-version guidance with the 2.2.4 release line.
- Add a canonical `VERSION` file containing `2.2.4`.

---

## [2.2.0] — 2026-10-22

This release records the feature and hardening work present on \`main\`. The release number follows Semantic Versioning: 2.2.0 is a backward-compatible minor release after 2.1.0.
Expand Down Expand Up @@ -57,7 +90,7 @@ This release records the feature and hardening work present on \`main\`. The rel

## [2.2.4b] — Beta prerelease (unreleased)

> **Beta status:** 2.2.4b is an unreleased testing candidate on `fix/2.2.4b-stabilization`. It is not an official release artifact and is not recommended for production use. The stable `main` line remains 2.2.0.
> **Historical beta note:** At the time this prerelease was prepared, 2.2.4b was an unreleased testing candidate on `fix/2.2.4b-stabilization`; it was superseded by the 2.2.4 stable-release work documented above.

This beta concentrates on protocol wire-format correctness, evidence-based detection, CLI dispatch, and cross-platform regression coverage. No GitHub Release, tag, or PyPI distribution has been published for this candidate.

Expand Down
56 changes: 18 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</a>
<img src="https://img.shields.io/badge/Python-3.10%2B-blue.svg" alt="Python">
<img src="https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey.svg" alt="Platform">
<img src="https://img.shields.io/badge/Status-Beta-orange.svg" alt="Status">
<img src="https://img.shields.io/badge/Status-Stable-brightgreen.svg" alt="Status">
<img src="https://img.shields.io/badge/Code%20Style-Black-000000.svg" alt="Black">
<img src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg" alt="PRs Welcome">
</p>
Expand All @@ -33,56 +33,36 @@

---

## 📦 Current stable release: 2.2.0
## 📦 Current stable release: 2.2.4

The current `main` branch contains the 2.2.0 feature set. This release builds on 2.1.0 with an additive async TCP scanner, bounded optional NVD CVE correlation, stricter CLI validation, bounded CIDR scans, safer credential-checking defaults, and more reliable report exports. See [CHANGELOG.md](CHANGELOG.md) for detailed release notes and [SECURITY.md](SECURITY.md) for supported versions and vulnerability reporting.
**Version:** `2.2.4` · **Release line:** Stable · **Python:** 3.10–3.12 CI target

> **Release integrity:** this documents the `main` code state; it does not claim a GitHub Release or PyPI package has been published.
SpectraScan 2.2.4 consolidates the 2.2.4b protocol-stabilization work and adds strict response validation for SNMP, RDP, MongoDB, RTSP, and SMTP. This release hardens packet correlation and framing, rejects malformed protocol responses, and keeps configuration observations separate from confirmed vulnerabilities.

### 🧪 Beta channel: 2.2.4b Beta
> **Release publication:** This branch prepares the 2.2.4 stable release. The official release artifact and version tag should be considered published only after the release PR is merged and the GitHub Release is created.

> ⚠️ **Pre-release software — testing only.** The `fix/2.2.4b-stabilization` branch is a beta candidate, not a stable release. It may still contain defects or incomplete protocol coverage. Do not use it as your only security control or as the basis for production decisions.
### 🔒 2.2.4 security and protocol hardening

The current `main` branch remains the stable 2.2.0 line. The **2.2.4b Beta** is a separate pre-release track focused on protocol correctness, more conservative service detection, CLI routing, and cross-platform reliability.
- **SNMP:** validate SNMPv2c version, response request ID, community string, PDU framing, and the requested OID before accepting a response.
- **RDP:** validate TPKT declared length, X.224 Connection Confirm framing, and the exact negotiation structure before deriving NLA status.
- **MongoDB:** require the server's `responseTo` field to match the outstanding request ID; zero is no longer accepted as a wildcard.
- **RDP findings:** report disabled NLA as a configuration observation, not as a medium-severity vulnerability by itself. BlueKeep remains unassessed without OS and patch-level evidence.
- **RTSP:** reject malformed status/header framing, duplicate headers, invalid or oversized Content-Length values, and bodies whose received length does not match the declaration.
- **SMTP:** reject malformed multiline replies, inconsistent status codes, and replies that end before a valid terminating line.

**Beta scope**
- Corrected SNMP BER, MongoDB OP_MSG/BSON, Redis RESP, MySQL/PostgreSQL framing, and NFS RPC/XDR handling.
- More evidence-based RDP, RTSP, and SMTP results, including removal of unsupported vulnerability conclusions.
- Fixed URL target handling, protocol-menu dispatch, async error handling, and per-port aggregation.
- Added protocol regression coverage and a Linux/Windows CI matrix.
### 🧪 Validation and regression coverage

**Validation recorded for this beta branch**
- ✅ Six CI jobs passed: Linux and Windows with Python 3.10, 3.11, and 3.12.
- ✅ The automated test suite passed (48 tests).
- ✅ Bandit at the configured `-ll` threshold reported no medium- or high-severity findings; seven low-severity findings remain.
- ✅ The dependency audit passed on the Linux Python 3.12 job.
The release adds regression cases for mismatched SNMP request IDs and communities, malformed RDP TPKT/X.224 lengths, MongoDB response correlation, RTSP Content-Length and status handling, and malformed or unterminated SMTP multiline replies.

These checks validate the automated test and static-analysis scope; they do **not** replace live interoperability testing against every supported service or guarantee that every target will be detected correctly. Validate results in an authorized lab and review findings before acting on them.

**Try the beta from source**

```bash
git clone https://github.com/ItsWanheda/SpectraScan.git
cd SpectraScan
git fetch origin
git switch --track origin/fix/2.2.4b-stabilization
python -m venv .venv
```

Activate the virtual environment, install dependencies, and run the regression suite:
Run the complete local suite with:

```bash
# Linux / macOS
source .venv/bin/activate

# Windows PowerShell
.\.venv\Scripts\Activate.ps1

python -m pip install -r requirements.txt
python -m unittest discover -s tests -p "test_*.py"
```

**Distribution status:** this beta exists on the feature branch only. No official GitHub Release, version tag, or PyPI package has been published for 2.2.4b. The stable release remains 2.2.0 until a final release is explicitly published.
CI results and any remaining limitations are recorded in the pull request. Automated tests do not replace live interoperability checks against every implementation of these protocols.

See [CHANGELOG.md](CHANGELOG.md) for the complete 2.2.4 notes and [SECURITY.md](SECURITY.md) for supported-version and reporting guidance.

## 📑 Table of Contents

Expand Down
14 changes: 5 additions & 9 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ SpectraScan is a network reconnaissance and security-assessment toolkit. Its act

## Supported versions

This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The current \`main\` branch documents version 2.2.0. A supported version does not mean every optional module is free of defects; apply updates and validate findings before acting on them.
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The current release line is **2.2.4 (stable)**. A supported version does not mean every optional module is free of defects; apply updates and validate findings before acting on them.

| Version line | Security support | Notes |
|---|---|---|
| **2.2.x (stable)** | ✅ Current | Stable line; the current `main` branch documents 2.2.0 |
| **2.2.4b Beta** | 🧪 Preview only | Unreleased branch candidate; testing only, not a supported production release |
| **2.1.x** | ⚠️ Best effort | Upgrade to 2.2.x where possible |
| **2.2.4 (stable)** | ✅ Current | Current stable release line |
| **2.2.x** | ⚠️ Best effort | Upgrade to the latest 2.2.x release for current fixes |
| **2.1.x** | ⚠️ Best effort | Upgrade to 2.2.4 where possible |
| **2.0.x and earlier** | ❌ Unsupported | Upgrade before relying on security fixes |

Only versions explicitly published as releases should be treated as official release artifacts. The version documented on `main` may be ahead of a tagged release.

### Beta and other pre-release builds

The **2.2.4b Beta** is available only from the `fix/2.2.4b-stabilization` development branch. It has passed the documented automated Linux/Windows Python 3.10–3.12 CI matrix, but that does not establish complete protocol interoperability or production readiness. Treat it as preview software: test only in authorized, controlled environments, expect defects, and do not rely on it as the sole protection for production assets. Beta builds do not receive the same support commitment as published stable releases.
Only versions explicitly published as GitHub Releases should be treated as official release artifacts. This branch prepares version 2.2.4; the release becomes published when the release PR is merged and its GitHub tag/release is created.

## Reporting a vulnerability

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.2.4
2 changes: 1 addition & 1 deletion modules/mongodb_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _send_op_msg(sock: socket.socket,doc: bytes,request_id: int=1)->bytes:
response_length,_,response_to,opcode=struct.unpack("<iiii",header)
if response_length<21 or response_length>MAX_MESSAGE_SIZE or opcode!=2013:
raise ValueError("Invalid MongoDB response header")
if response_to not in (0,request_id): raise ValueError("MongoDB response id mismatch")
if response_to != request_id: raise ValueError("MongoDB response id mismatch")
payload=_recv_exact(sock,response_length-16)
if payload[4]!=0: raise ValueError("Unsupported OP_MSG section")
document=payload[5:]
Expand Down
65 changes: 51 additions & 14 deletions modules/rdp_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,57 @@ def _connection_request(protocols: int)->bytes:
tpdu=bytes([len(body)])+body
return struct.pack(">BBH",3,0,len(tpdu)+4)+tpdu

def _recv_tpkt(sock: socket.socket, max_size: int=4096)->bytes:
header=bytearray()
while len(header)<4:
chunk=sock.recv(4-len(header))
if not chunk:
return b""
header.extend(chunk)
if header[0]!=3 or header[1]!=0:
return bytes(header)
declared=struct.unpack_from(">H",header,2)[0]
if declared<4 or declared>max_size:
return bytes(header)
packet=header
while len(packet)<declared:
chunk=sock.recv(declared-len(packet))
if not chunk:
return bytes(packet)
packet.extend(chunk)
return bytes(packet)


def _parse_negotiation(data: bytes)->Dict[str,Any]:
result={"responds":False,"nla":None,"selected_protocol":None}
if len(data)<11 or data[0]!=3: return result
# TPKT: version 3, reserved 0, and an exact 16-bit packet length.
if len(data)<4 or data[0]!=3 or data[1]!=0:
return result
declared=struct.unpack_from(">H",data,2)[0]
if declared!=len(data) or declared<12:
return result
# X.224 Connection Confirm (LI=6, code=0xD0, refs, class).
li=data[4]
if li!=6 or li!=len(data[5:]) - 8 or data[5]!=0xD0:
return result
negotiation_offset=5+li
if len(data)!=negotiation_offset+8:
return result
packet_type,flags,packet_length=struct.unpack_from("<BBH",data,negotiation_offset)
if packet_length!=8:
return result
result["responds"]=True
for pos in range(4,len(data)-7):
if data[pos]==2 and data[pos+2:pos+4]==b"\x08\x00":
selected=struct.unpack_from("<I",data,pos+4)[0]
result["selected_protocol"]=selected
result["nla"]=selected in (PROTOCOL_HYBRID,PROTOCOL_HYBRID_EX)
return result
if data[pos]==3 and data[pos+2:pos+4]==b"\x08\x00":
result["negotiation_failure"]=struct.unpack_from("<I",data,pos+4)[0]
if packet_type==2:
selected=struct.unpack_from("<I",data,negotiation_offset+4)[0]
if selected not in (PROTOCOL_RDP,PROTOCOL_SSL,PROTOCOL_HYBRID,PROTOCOL_HYBRID_EX):
result["responds"]=False
return result
result["selected_protocol"]=selected
result["nla"]=selected in (PROTOCOL_HYBRID,PROTOCOL_HYBRID_EX)
elif packet_type==3:
result["negotiation_failure"]=struct.unpack_from("<I",data,negotiation_offset+4)[0]
else:
result["responds"]=False
return result

class RDPEnumerator:
Expand All @@ -54,7 +92,7 @@ def check_nla(ip: str,port: int=3389,timeout: float=5.0)->Dict[str,Any]:
with socket.create_connection((ip,port),timeout=timeout) as sock:
sock.settimeout(timeout)
sock.sendall(_connection_request(PROTOCOL_RDP|PROTOCOL_SSL|PROTOCOL_HYBRID|PROTOCOL_HYBRID_EX))
data=sock.recv(4096)
data=_recv_tpkt(sock)
parsed=_parse_negotiation(data); result.update(parsed)
result["nla_likely"]=parsed.get("nla"); result["raw"]=data.hex()[:256]
except (OSError,ConnectionError) as exc: result["error"]=type(exc).__name__
Expand All @@ -68,10 +106,9 @@ def scan(ip: str,port: int=3389)->Dict[str,Any]:
negotiation=RDPEnumerator.check_nla(ip,port)
result["nla"]=negotiation.get("nla_likely")
if result["nla"] is False:
result["vulnerabilities"].append({
"name":"RDP negotiated without Network Level Authentication","severity":"MEDIUM","cve":"N/A",
"evidence":f"Server selected protocol {negotiation.get('selected_protocol')}.",
})
result["observations"].append(
"The server did not negotiate NLA for this connection request. This is a configuration observation, not a confirmed vulnerability."
)
elif result["nla"] is True:
result["observations"].append("RDP negotiation selected an NLA-capable protocol.")
else:
Expand Down
55 changes: 41 additions & 14 deletions modules/rtsp_enum.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
"""RTSP DESCRIBE with correct response header and SDP extraction."""
from __future__ import annotations
import socket
import re, socket
from typing import Any, Dict, List

def _parse_response(raw: bytes)->Dict[str,Any]:
text=raw.decode("latin-1",errors="replace")
header,sep,body=text.partition("\r\n\r\n")
lines=header.split("\r\n")
status=lines[0].split(" ",2) if lines else []
code=int(status[1]) if len(status)>1 and status[1].isdigit() else None
if b"\r\n\r\n" not in raw:
raise ValueError("RTSP response is missing the header terminator")
header,_,body=raw.partition(b"\r\n\r\n")
try:
lines=header.decode("latin-1").split("\r\n")
except UnicodeDecodeError as exc:
raise ValueError("Invalid RTSP headers") from exc
if not lines or not re.fullmatch(r"RTSP/1\.[0-9] [1-5][0-9]{2}(?: .*)?",lines[0]):
raise ValueError("Malformed RTSP status line")
code=int(lines[0].split(" ",2)[1])
headers={}
content_length=None
for line in lines[1:]:
if not line or line[0] in " \t":
raise ValueError("Malformed RTSP header line")
name,colon,value=line.partition(":")
if colon: headers[name.strip().lower()]=value.strip()
if not colon or not name.strip():
raise ValueError("Malformed RTSP header")
key=name.strip().lower()
if key in headers:
raise ValueError("Duplicate RTSP header")
value=value.strip()
headers[key]=value
if key=="content-length":
if not value.isdigit():
raise ValueError("Invalid RTSP Content-Length")
content_length=int(value)
if content_length>65536:
raise ValueError("RTSP body exceeds parser limit")
if content_length is not None and len(body)!=content_length:
raise ValueError("RTSP Content-Length does not match received body")
body_text=body.decode("latin-1")
streams=[]
for line in body.splitlines() if sep else []:
for line in body_text.splitlines():
if line.startswith("m="):
parts=line[2:].split()
if len(parts)>=3:
streams.append({"type":parts[0],"port":int(parts[1]) if parts[1].isdigit() else None,
"protocol":parts[2],"formats":parts[3:]})
return {"status_code":code,"status_line":lines[0] if lines else "",
"headers":headers,"body":body,"streams":streams,"server":headers.get("server"),
"auth_required":code==401 or "www-authenticate" in headers,"open":code is not None}
if len(parts)<3:
raise ValueError("Malformed SDP media line")
port_text=parts[1].split("/",1)[0]
if not port_text.isdigit():
raise ValueError("Invalid SDP media port")
streams.append({"type":parts[0],"port":int(port_text),
"protocol":parts[2],"formats":parts[3:]})
return {"status_code":code,"status_line":lines[0],
"headers":headers,"body":body_text,"streams":streams,"server":headers.get("server"),
"auth_required":code==401 or "www-authenticate" in headers,"open":True}

class RTSPEnumerator:
DEFAULT_PORT=554
Expand Down
Loading
Loading