Metadata-Version: 2.4
Name: oscura
Version: 0.14.0
Summary: Python framework for hardware reverse engineering: signal analysis, protocol decoding, and automated dissector generation. Unified workflows from oscilloscope captures to Wireshark dissectors with IEEE-compliant measurements.
Project-URL: Homepage, https://github.com/oscura-re/oscura
Project-URL: Documentation, https://github.com/oscura-re/oscura/tree/main/docs
Project-URL: Repository, https://github.com/oscura-re/oscura
Project-URL: Changelog, https://github.com/oscura-re/oscura/blob/main/CHANGELOG.md
Project-URL: Issue Tracker, https://github.com/oscura-re/oscura/issues
Project-URL: Discussions, https://github.com/oscura-re/oscura/discussions
License-Expression: MIT
License-File: LICENSE
Keywords: automotive-protocols,can-bus,crc-recovery,device-replication,embedded-systems,exploitation,hardware-reverse-engineering,hardware-security,i2c,ieee-compliance,logic-analyzer,obd-ii,oscilloscope,protocol-analysis,protocol-decoder,protocol-inference,reverse-engineering,right-to-repair,security-research,signal-analysis,spectral-analysis,spi,state-machine-learning,uart,unknown-protocol,vulnerability-analysis,waveform-analysis
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Telecommunications Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Security
Classifier: Topic :: System :: Hardware
Classifier: Topic :: System :: Hardware :: Hardware Drivers
Classifier: Typing :: Typed
Requires-Python: >=3.12
Requires-Dist: cantools<40.0.0,>=39.4.0
Requires-Dist: click<9.0.0,>=8.1.0
Requires-Dist: dpkt<2.0.0,>=1.9.0
Requires-Dist: jinja2<4.0.0,>=3.1
Requires-Dist: matplotlib<4.0.0,>=3.7.0
Requires-Dist: numpy<3.0.0,>=1.24.0
Requires-Dist: openpyxl<4.0.0,>=3.0.0
Requires-Dist: pandas<3.0.0,>=2.0.0
Requires-Dist: psutil<7.0.0,>=5.9.0
Requires-Dist: python-can<5.0.0,>=4.4.0
Requires-Dist: python-pptx<1.0.0,>=0.6.21
Requires-Dist: pyyaml<7.0.0,>=6.0
Requires-Dist: reportlab<6.0.0,>=4.4.7
Requires-Dist: scapy<3.0.0,>=2.5.0
Requires-Dist: scipy<2.0.0,>=1.10.0
Requires-Dist: tm-data-types<1.0.0,>=0.3.0
Requires-Dist: tqdm<5.0.0,>=4.65.0
Requires-Dist: weasyprint<64.0.0,>=63.0
Provides-Extra: all
Requires-Dist: asammdf<9.0.0,>=8.0.0; extra == 'all'
Requires-Dist: check-jsonschema<1.0.0,>=0.29.0; extra == 'all'
Requires-Dist: coverage[toml]<8.0.0,>=7.0; extra == 'all'
Requires-Dist: cryptography<47.0.0,>=44.0.1; extra == 'all'
Requires-Dist: h5py<4.0.0,>=3.0.0; extra == 'all'
Requires-Dist: hypothesis>=6.148.8; extra == 'all'
Requires-Dist: interrogate>=1.7.0; extra == 'all'
Requires-Dist: ipython<9.0.0,>=8.0.0; extra == 'all'
Requires-Dist: jupyter<2.0.0,>=1.0.0; extra == 'all'
Requires-Dist: mypy>=1.13.0; extra == 'all'
Requires-Dist: nbconvert!=7.16.6,<8.0.0,>=7.0.0; extra == 'all'
Requires-Dist: networkx<4.0.0,>=3.0; extra == 'all'
Requires-Dist: nptdms<2.0.0,>=1.7.0; extra == 'all'
Requires-Dist: pre-commit>=4.5.1; extra == 'all'
Requires-Dist: pyserial<4.0.0,>=3.5; extra == 'all'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'all'
Requires-Dist: pytest-benchmark>=5.2.3; extra == 'all'
Requires-Dist: pytest-cov>=7.0.0; extra == 'all'
Requires-Dist: pytest-flakefinder>=1.0.0; extra == 'all'
Requires-Dist: pytest-randomly<4.0.0,>=3.0; extra == 'all'
Requires-Dist: pytest-rerunfailures>=16.1; extra == 'all'
Requires-Dist: pytest-split>=0.2.0; extra == 'all'
Requires-Dist: pytest-timeout>=2.4.0; extra == 'all'
Requires-Dist: pytest-xdist>=3.8.0; extra == 'all'
Requires-Dist: pytest<10.0.0,>=8.0; extra == 'all'
Requires-Dist: pyvisa-py<1.0.0,>=0.7.0; extra == 'all'
Requires-Dist: pyvisa<2.0.0,>=1.13.0; extra == 'all'
Requires-Dist: pywavelets<2.0.0,>=1.0.0; extra == 'all'
Requires-Dist: rapidfuzz<4.0.0,>=3.0.0; extra == 'all'
Requires-Dist: rigolwfm<2.0.0,>=1.0.0; extra == 'all'
Requires-Dist: ruff>=0.14.0; extra == 'all'
Requires-Dist: scikit-learn<2.0.0,>=1.3.0; extra == 'all'
Requires-Dist: types-pyyaml<7.0.0,>=6.0; extra == 'all'
Requires-Dist: yamllint<2.0.0,>=1.35; extra == 'all'
Provides-Extra: analysis
Requires-Dist: networkx<4.0.0,>=3.0; extra == 'analysis'
Requires-Dist: pywavelets<2.0.0,>=1.0.0; extra == 'analysis'
Requires-Dist: scikit-learn<2.0.0,>=1.3.0; extra == 'analysis'
Provides-Extra: automotive
Requires-Dist: asammdf<9.0.0,>=8.0.0; extra == 'automotive'
Provides-Extra: dev
Requires-Dist: check-jsonschema<1.0.0,>=0.29.0; extra == 'dev'
Requires-Dist: coverage[toml]<8.0.0,>=7.0; extra == 'dev'
Requires-Dist: hypothesis>=6.148.8; extra == 'dev'
Requires-Dist: interrogate>=1.7.0; extra == 'dev'
Requires-Dist: mypy>=1.13.0; extra == 'dev'
Requires-Dist: pre-commit>=4.5.1; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest-benchmark>=5.2.3; extra == 'dev'
Requires-Dist: pytest-cov>=7.0.0; extra == 'dev'
Requires-Dist: pytest-flakefinder>=1.0.0; extra == 'dev'
Requires-Dist: pytest-randomly<4.0.0,>=3.0; extra == 'dev'
Requires-Dist: pytest-rerunfailures>=16.1; extra == 'dev'
Requires-Dist: pytest-split>=0.2.0; extra == 'dev'
Requires-Dist: pytest-timeout>=2.4.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.8.0; extra == 'dev'
Requires-Dist: pytest<10.0.0,>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.14.0; extra == 'dev'
Requires-Dist: types-pyyaml<7.0.0,>=6.0; extra == 'dev'
Requires-Dist: yamllint<2.0.0,>=1.35; extra == 'dev'
Provides-Extra: fuzzy
Requires-Dist: rapidfuzz<4.0.0,>=3.0.0; extra == 'fuzzy'
Provides-Extra: hardware
Requires-Dist: pyserial<4.0.0,>=3.5; extra == 'hardware'
Requires-Dist: pyvisa-py<1.0.0,>=0.7.0; extra == 'hardware'
Requires-Dist: pyvisa<2.0.0,>=1.13.0; extra == 'hardware'
Provides-Extra: hdf5
Requires-Dist: h5py<4.0.0,>=3.0.0; extra == 'hdf5'
Provides-Extra: iot
Requires-Dist: cryptography<47.0.0,>=44.0.1; extra == 'iot'
Provides-Extra: jupyter
Requires-Dist: ipython<9.0.0,>=8.0.0; extra == 'jupyter'
Requires-Dist: jupyter<2.0.0,>=1.0.0; extra == 'jupyter'
Requires-Dist: nbconvert!=7.16.6,<8.0.0,>=7.0.0; extra == 'jupyter'
Provides-Extra: oscilloscopes
Requires-Dist: nptdms<2.0.0,>=1.7.0; extra == 'oscilloscopes'
Requires-Dist: rigolwfm<2.0.0,>=1.0.0; extra == 'oscilloscopes'
Provides-Extra: standard
Description-Content-Type: text/markdown

# Oscura

**Python framework for hardware reverse engineering: signal analysis, protocol decoding, and automated dissector generation.**

Unified workflows from oscilloscope captures to Wireshark dissectors. IEEE-compliant measurements, native protocol decoders, differential analysis, and CRC recovery—all in Python without tool juggling.

[![CI](https://github.com/oscura-re/oscura/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/oscura-re/oscura/actions/workflows/ci.yml)
[![Code Quality](https://github.com/oscura-re/oscura/actions/workflows/code-quality.yml/badge.svg?branch=main)](https://github.com/oscura-re/oscura/actions/workflows/code-quality.yml)
[![codecov](https://codecov.io/gh/oscura-re/oscura/graph/badge.svg)](https://codecov.io/gh/oscura-re/oscura)
[![PyPI version](https://img.shields.io/pypi/v/oscura)](https://pypi.org/project/oscura/)
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

---

## What Oscura Provides

Unified Python framework for hardware reverse engineering workflows:

- **File Format Loading** - Oscilloscopes (Tektronix, Rigol), logic analyzers (Sigrok, VCD), network captures (PCAP), automotive (BLF), scientific instruments (HDF5, TDMS, Touchstone)
- **Protocol Decoding** - Serial (UART, SPI, I2C), automotive (CAN, LIN, FlexRay), debug (JTAG, SWD), industrial (Modbus, BACnet, EtherCAT, OPC UA, PROFINET), audio (I2S), wireless (BLE)
- **Signal Analysis** - Waveform measurements (IEEE 181), spectral analysis (IEEE 1241), jitter analysis (IEEE 2414), power analysis (IEEE 1459), eye diagrams, signal integrity
- **Protocol Inference** - CRC recovery, state machine extraction, field detection, format identification, magic byte discovery
- **Export Automation** - Wireshark dissectors, Scapy layers, DBC files, Kaitai Struct, 010 Editor templates, HTML/JSON reports

---

## Installation

```bash
pip install oscura
```

For development setup or detailed installation options, see [Installation Guide](docs/getting-started/installation.md).

**Requirements**: Python 3.12+ | Dependencies: numpy, scipy, matplotlib, scikit-learn, cantools (all peer-reviewed, industry-standard libraries)

---

## Usage Approaches

Oscura provides 5 usage patterns. **[→ Choose your approach](docs/getting-started/quick-start.md)**

Quick summary:

- **Comprehensive Script** - Immediate analysis ([showcase](demos/showcase/analyze_data_capture.py))
- **Convenience API** - Python applications ([examples](examples/))
- **Expert API** - Full control ([API docs](docs/api/))
- **YAML Pipeline** - Config-driven ([guide](docs/user-guide/integrations/yaml-pipelines.md))
- **CLI** - Command-line ([reference](docs/reference/cli.md))

---

## Example: Unknown Protocol Reverse Engineering

```python
from oscura.sessions import BlackBoxSession

# Differential analysis to identify protocol structure
session = BlackBoxSession(name="Unknown Device")
session.add_recording("idle", "idle.bin")
session.add_recording("active", "active.bin")
diff = session.compare("idle", "active")

# Generate Wireshark dissector from inferred structure
session.export_results("dissector", "protocol.lua")
```

---

## Capabilities Reference

### File Format Support

Unified loader with automatic format detection via `oscura.load(path)`:

- **Oscilloscopes**: Tektronix WFM/TSS, Rigol WFM
- **Logic Analyzers**: VCD, Sigrok .sr
- **Network**: PCAP/PCAPNG
- **Scientific**: HDF5, TDMS, Touchstone S-parameters
- **Generic**: WAV, CSV, NumPy, binary dumps
- **Side-Channel**: ChipWhisperer traces

### Waveform Measurements (IEEE 181-2011)

Timing, amplitude, and quality measurements with sub-sample interpolation:

- **Timing**: rise/fall time, period, frequency, pulse width, duty cycle, phase, delay, slew rate
- **Amplitude**: peak-to-peak, RMS, mean, overshoot, undershoot, top, base
- **Advanced**: area, burst width, extinction ratio, quality factor

### Spectral Analysis (IEEE 1241-2010)

FFT, PSD, quality metrics:

- **Frequency Domain**: FFT, PSD (Welch method), spectrogram, coherence
- **Quality Metrics**: THD, SNR, SINAD, SFDR, ENOB
- **Advanced**: Cepstrum, bispectrum, cross-spectrum, transfer function

### Digital Signal Analysis

- **Conversion**: Threshold detection with hysteresis, edge detection, clock extraction
- **Timing**: Clock/baud rate detection, pulse width measurement, frame sync
- **Logic Levels**: TTL, CMOS, LVCMOS, LVDS, ECL detection
- **Quality**: Glitch detection, timing violations, signal quality metrics

### Eye Diagram Analysis

Eye diagram generation and measurements: height, width, area, crossing percentage, Q-factor, BER estimation, mask testing.

### Jitter Analysis (IEEE 2414-2020)

RJ/DJ decomposition using dual-Dirac model:

- **Components**: Random jitter (RJ), deterministic jitter (DJ), periodic jitter (PJ), data-dependent jitter (DDJ)
- **Measurements**: TIE, period jitter, cycle-to-cycle jitter
- **Visualization**: Bathtub curves for BER extrapolation

### Power Analysis (IEEE 1459-2010)

- **Basic**: Instantaneous, average, peak, RMS power, energy
- **AC Power**: Active, reactive, apparent power, power factor
- **Harmonics**: THD, harmonic content, crest factor
- **Quality**: Ripple, sag/swell detection, flicker, unbalance

### Statistical Analysis

- **Descriptive**: Mean, median, std dev, quartiles, percentiles
- **Distribution**: Histograms, skewness, kurtosis, normality tests
- **Outliers**: Z-score, IQR, MAD, isolation forest, DBSCAN
- **Correlation**: Auto/cross-correlation, Pearson, Spearman
- **Time Series**: Periodicity detection, trend analysis, change points

### Pattern Recognition

- **Period Detection**: FFT-based, autocorrelation, multi-method
- **Sequences**: Repeating patterns, n-grams, Lempel-Ziv complexity
- **Entropy**: Shannon entropy, byte frequency, encrypted/compressed region detection
- **Structure**: Magic bytes, headers, delimiters, sync patterns, alignment

### Protocol Decoders

Native state machine implementations:

- **Serial**: UART, SPI, I2C, 1-Wire
- **Automotive**: CAN, CAN-FD, LIN, FlexRay
- **Debug**: JTAG (IEEE 1149.1), SWD (ARM CoreSight)
- **Industrial**: Modbus, BACnet, EtherCAT, OPC UA, PROFINET, HDLC
- **Audio**: I2S
- **Wireless**: BLE advertising packets
- **Parallel**: Centronics, GPIB (IEEE 488.2)

### Protocol Inference

- **CRC Recovery**: Brute-force parameter search, algorithm detection
- **Field Detection**: Statistical boundary inference, type classification
- **Format Analysis**: Magic bytes, framing, escaping detection
- **Protocol Detection**: Multi-heuristic with confidence scoring
- **State Machines**: RPNI algorithm for state extraction
- **Dissector Generation**: Wireshark (Lua), Scapy (Python), Kaitai Struct, 010 Editor

### Automotive Analysis

- **CAN**: Frame decoding, ID identification, statistical analysis, differential analysis
- **DBC Generation**: Signal inference, automatic naming, scaling detection
- **Diagnostics**: OBD-II, UDS, J1939, DTC lookup
- **Security**: Replay detection, fuzzing, anomaly detection

### Signal Integrity

TDR analysis, S-parameters (Touchstone), insertion/return loss, VSWR, impedance calculation, crosstalk detection.

### Machine Learning

- **Classification**: Signal type, protocol identification, modulation detection (Random Forest/SVM)
- **Feature Extraction**: Timing, spectral, statistical features
- **Clustering**: K-means, DBSCAN, hierarchical
- **Anomaly Detection**: Isolation Forest, One-Class SVM

### Visualization

Waveforms, FFT/PSD spectra, spectrograms, histograms, logic analyzer views, eye diagrams, bathtub curves, constellation diagrams, Smith charts, Bode/Nyquist plots, protocol timelines.

### Export Formats

JSON, CSV, HTML reports, Wireshark dissectors (Lua), Scapy dissectors (Python), Kaitai Struct (YAML), DBC (CAN database), 010 Editor templates, WAV, VCD, NumPy, HDF5, MATLAB.

---

## When to Use Oscura

**Best suited for:**

- End-to-end Python workflows (capture → analysis → documentation)
- Unknown protocol reverse engineering with differential analysis
- DBC generation from CAN captures (open-source CANalyzer alternative)
- Automatic Wireshark dissector generation from inferred protocols
- Unified API across 14 oscilloscope/logic analyzer formats
- Reproducible research with hypothesis tracking
- Scripted multi-tool RE pipelines

**Oscura's strength:** Workflow automation combining multiple RE steps with hypothesis-driven analysis.

---

## Standards Compliance

Oscura implements measurements per IEEE specifications.

| Standard | Coverage | Implementation |
|----------|----------|----------------|
| IEEE 181-2011 | Pulse timing, rise/fall, overshoot, duty cycle | Native algorithms |
| IEEE 1241-2010 | SNR, SINAD, THD, SFDR, ENOB | Native + scipy.signal |
| IEEE 1459-2010 | Active/reactive power, harmonics, power factor | Native + scipy.signal |
| IEEE 2414-2020 | TIE, RJ/DJ decomposition, bathtub curves | Native + scipy.stats |

**Validation**: 475 test files with 80%+ code coverage, property-based testing via Hypothesis.

---

## Quality Metrics

**Testing**: 475 test files, 80%+ coverage with branch coverage, property-based testing (Hypothesis), nightly stress tests

**CI/CD**: Pre-commit hooks (format, lint, type check), merge queue validation, security scanning (Bandit, Safety)

**Type Safety**: MyPy strict mode, comprehensive type hints

**Documentation**: Google-style docstrings, 95% documentation coverage

View metrics: [CI Dashboard](https://github.com/oscura-re/oscura/actions) | [Coverage](https://codecov.io/gh/oscura-re/oscura)

---

## Demonstrations

**Comprehensive working demonstrations** covering all framework capabilities. See [demos/README.md](demos/README.md) for complete catalog.

**Categories**: Waveform Analysis, File I/O, Custom DAQ, Serial Protocols, Protocol Decoding, UDP Analysis, Protocol Inference, Automotive, Timing, Mixed Signal, Spectral, Jitter, Power, Signal Integrity, EMC, Signal RE, Advanced Inference, Complete Workflows

**Learning Paths**:

- Beginner (2-4 hours): File loading, basic measurements, export
- Intermediate (6-10 hours): Protocol decoding (UART, SPI, I2C, PCAP)
- Advanced (12-20 hours): CRC recovery, state machines, Wireshark dissectors
- Expert (20-40 hours): Complete RE workflows with ML inference

```bash
./scripts/setup.sh
python demos/00_getting_started/00_hello_world.py
```

---

## Documentation

**User Guides**:

- [Quick Start](docs/getting-started/quick-start.md) - Installation and first steps
- [Black-Box Analysis](docs/user-guide/workflows/blackbox-analysis.md) - Unknown protocol RE
- [Side-Channel Analysis](docs/user-guide/workflows/side-channel-analysis.md) - ChipWhisperer integration
- [Hardware Acquisition](docs/user-guide/workflows/hardware-acquisition.md) - Instrument control
- [Complete Workflows](docs/user-guide/workflows.md) - End-to-end pipelines

**API Reference**: [docs/api/](docs/api/) - Complete function reference

**Development**: [Architecture](docs/developer-guide/architecture.md) | [Testing](docs/testing/) | [CHANGELOG](CHANGELOG.md)

---

## Contributing

```bash
git clone https://github.com/oscura-re/oscura.git
cd oscura
./scripts/setup.sh                    # Setup with hooks
./scripts/check.sh                    # Quality checks
./scripts/test.sh                     # Test suite
python3 .claude/hooks/validate_all.py # Must pass 5/5
```

**Needed Contributions**:

- Workflow automation (new pipelines, export formats, integrations)
- File format loaders (oscilloscope/LA formats not yet supported)
- Inference algorithms (better state machine learning, field detection)
- Protocol decoders (proprietary protocols you've reversed)
- Hardware integration (DAQ systems, instrument drivers)
- Real-world validation (test on your captures, report issues)

[Contributing Guide](CONTRIBUTING.md) | [Architecture](docs/developer-guide/architecture.md)

---

## Project Status

**Version**: [0.13.0](https://github.com/oscura-re/oscura/releases/latest) (2026-02-03)

**Active Development**: Hypothesis-driven RE workflows, automotive protocol analysis (CAN-FD, J1939, OBD-II, UDS), unknown protocol inference (state machines, field detection, CRC recovery), multi-format loading, export automation

**Stability**: Production-ready for security research, right-to-repair, academic use. API evolution documented in [CHANGELOG](CHANGELOG.md).

[Release History](https://github.com/oscura-re/oscura/releases) | [Roadmap](https://github.com/oscura-re/oscura/discussions)

---

## Legal

**License**: [MIT License](LICENSE) - Permissive use, modification, distribution

**Disclaimer**: Intended for legitimate security research, right-to-repair, academic study, and authorized testing. Users responsible for compliance with applicable laws. Unauthorized access is illegal and unethical.

**Dependencies**: Python, NumPy, SciPy, Matplotlib, scikit-learn, cantools, Hypothesis. See [pyproject.toml](pyproject.toml).

---

## Citation

```bibtex
@software{oscura2026,
  title = {Oscura: Hardware Reverse Engineering Framework},
  author = {Oscura Contributors},
  year = {2026},
  url = {https://github.com/oscura-re/oscura},
  version = {0.13.0}
}
```

Machine-readable: [CITATION.cff](CITATION.cff)

---

**Oscura** - Hardware reverse engineering framework providing unified workflows from signal capture to protocol specification. Built for security research, right-to-repair, academic study, and defense applications.
