Metadata-Version: 2.4
Name: oscura
Version: 0.5.0
Summary: Unified hardware reverse engineering framework. Extract all information from any system through signals and data. Unknown protocol discovery, state machine extraction, CRC recovery, security analysis. 16+ protocols, 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: 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: pandas<3.0.0,>=2.0.0
Requires-Dist: psutil<7.0.0,>=5.9.0
Requires-Dist: pyyaml<7.0.0,>=6.0
Requires-Dist: scipy<2.0.0,>=1.10.0
Requires-Dist: tm-data-types<1.0.0,>=0.3.0
Provides-Extra: all
Requires-Dist: asammdf<9.0.0,>=8.0.0; extra == 'all'
Requires-Dist: cantools<40.0.0,>=39.4.0; extra == 'all'
Requires-Dist: check-jsonschema<1.0.0,>=0.29.0; extra == 'all'
Requires-Dist: h5py<4.0.0,>=3.0.0; extra == 'all'
Requires-Dist: hypothesis<7.0.0,>=6.0.0; extra == 'all'
Requires-Dist: interrogate<2.0.0,>=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: nbconvert<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: openpyxl<4.0.0,>=3.0.0; extra == 'all'
Requires-Dist: pytest-benchmark<6.0.0,>=4.0.0; extra == 'all'
Requires-Dist: pytest-cov<8.0.0,>=6.0; extra == 'all'
Requires-Dist: pytest-timeout<3.0.0,>=2.3.0; extra == 'all'
Requires-Dist: pytest<10.0.0,>=8.0; extra == 'all'
Requires-Dist: python-can<5.0.0,>=4.4.0; extra == 'all'
Requires-Dist: python-pptx<1.0.0,>=0.6.21; 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: reportlab<6.0.0,>=4.4.7; extra == 'all'
Requires-Dist: rigolwfm<2.0.0,>=1.0.0; extra == 'all'
Requires-Dist: scapy<3.0.0,>=2.5.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: openpyxl<4.0.0,>=3.0.0; extra == 'analysis'
Requires-Dist: pywavelets<2.0.0,>=1.0.0; extra == 'analysis'
Provides-Extra: automotive
Requires-Dist: asammdf<9.0.0,>=8.0.0; extra == 'automotive'
Requires-Dist: cantools<40.0.0,>=39.4.0; extra == 'automotive'
Requires-Dist: python-can<5.0.0,>=4.4.0; extra == 'automotive'
Requires-Dist: scapy<3.0.0,>=2.5.0; extra == 'automotive'
Provides-Extra: dev
Requires-Dist: check-jsonschema<1.0.0,>=0.29.0; extra == 'dev'
Requires-Dist: hypothesis<7.0.0,>=6.0.0; extra == 'dev'
Requires-Dist: interrogate<2.0.0,>=1.7.0; extra == 'dev'
Requires-Dist: pytest-benchmark<6.0.0,>=4.0.0; extra == 'dev'
Requires-Dist: pytest-cov<8.0.0,>=6.0; extra == 'dev'
Requires-Dist: pytest-timeout<3.0.0,>=2.3.0; extra == 'dev'
Requires-Dist: pytest<10.0.0,>=8.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: 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: 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<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: reporting
Requires-Dist: python-pptx<1.0.0,>=0.6.21; extra == 'reporting'
Requires-Dist: reportlab<6.0.0,>=4.4.7; extra == 'reporting'
Description-Content-Type: text/markdown

# Oscura

**Unified hardware reverse engineering framework. Extract all information from any system through signals and data.**

**Build Status:**
[![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)
[![Documentation](https://github.com/oscura-re/oscura/actions/workflows/docs.yml/badge.svg?branch=main)](https://github.com/oscura-re/oscura/actions/workflows/docs.yml)
[![Test Quality](https://github.com/oscura-re/oscura/actions/workflows/test-quality.yml/badge.svg?branch=main)](https://github.com/oscura-re/oscura/actions/workflows/test-quality.yml)

**Package:**
[![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)
[![PyPI Downloads](https://img.shields.io/pypi/dm/oscura)](https://pypi.org/project/oscura/)

**Code Quality:**
[![codecov](https://codecov.io/gh/oscura-re/oscura/graph/badge.svg)](https://codecov.io/gh/oscura-re/oscura)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Docstring Coverage](https://raw.githubusercontent.com/oscura-re/oscura/main/docs/badges/interrogate_badge.svg)](https://github.com/oscura-re/oscura/tree/main/docs)

**Project Status:**
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/oscura-re/oscura/graphs/commit-activity)
[![Last Commit](https://img.shields.io/github/last-commit/oscura-re/oscura)](https://github.com/oscura-re/oscura/commits/main)

---

## What is Oscura?

Oscura is a hardware reverse engineering framework for security researchers, right-to-repair advocates, defense analysts, and commercial intelligence teams. From oscilloscope captures to complete system understanding.

**Reverse Engineering**: Unknown protocol discovery • State machine extraction • CRC/checksum recovery • Proprietary device replication • Security vulnerability analysis • Black-box protocol analysis

**Signal Analysis**: IEEE-compliant measurements (181/1241/1459/2414) • Comprehensive protocol decoding (16+ protocols) • Spectral analysis • Timing characterization • Side-channel analysis (DPA/CPA/timing attacks)

**Unified Acquisition**: File-based • Hardware sources (SocketCAN, Saleae, PyVISA - Phase 2) • Synthetic generation • Polymorphic Source protocol

**Interactive Sessions**: Domain-specific analysis sessions • BlackBoxSession for protocol RE • Differential analysis • Field hypothesis generation • Protocol specification export

**Built For**: Exploitation • Replication • Defense analysis • Commercial intelligence • Right-to-repair • Cryptographic research

---

## Installation

```bash
# Using uv (recommended)
uv pip install oscura

# Or with pip
pip install oscura

# Development install (RECOMMENDED)
git clone https://github.com/oscura-re/oscura.git
cd oscura
./scripts/setup.sh            # Complete setup (dependencies + hooks)
./scripts/verify-setup.sh     # Verify environment is ready
```

---

## Quick Start

### Signal Analysis

```python
import oscura as osc

# Load oscilloscope capture
trace = osc.load("capture.wfm")

# Basic measurements
print(f"Frequency: {osc.frequency(trace) / 1e6:.3f} MHz")
print(f"Rise time: {osc.rise_time(trace) * 1e9:.1f} ns")

# Decode protocol
from oscura.protocols import UARTDecoder
decoder = UARTDecoder(baud_rate=115200)
messages = decoder.decode(trace)
```

### Black-Box Protocol Reverse Engineering

```python
from oscura.sessions import BlackBoxSession
from oscura.acquisition import FileSource

# Create analysis session
session = BlackBoxSession(name="IoT Device RE")

# Add recordings from different stimuli
session.add_recording("idle", FileSource("idle.bin"))
session.add_recording("button_press", FileSource("button.bin"))

# Differential analysis
diff = session.compare("idle", "button_press")
print(f"Changed bytes: {diff.changed_bytes}")

# Generate protocol specification
spec = session.generate_protocol_spec()
print(f"Detected {len(spec['fields'])} protocol fields")

# Export Wireshark dissector
session.export_results("dissector", "protocol.lua")
```

### CAN Protocol Analysis

```python
from oscura.automotive.can import CANSession
from oscura.acquisition import FileSource

# Create session
session = CANSession(name="Vehicle Analysis")

# Add recordings from CAN bus captures
session.add_recording("idle", FileSource("idle.blf"))
session.add_recording("accelerate", FileSource("accelerate.blf"))

# Analyze traffic
analysis = session.analyze()
print(f"Messages: {analysis['inventory']['total_messages']}")
print(f"Unique IDs: {len(analysis['inventory']['message_ids'])}")

# Compare recordings
diff = session.compare("idle", "accelerate")
print(f"Changed IDs: {len(diff.details['changed_ids'])}")

# Export DBC file
session.export_dbc("vehicle.dbc")
```

---

## Learn by Example

**Demos are the documentation.** Each category includes working code with comprehensive explanations.

### Core Capabilities

| Demo | Description |
|------|-------------|
| [01_waveform_analysis](demos/01_waveform_analysis/) | Load and analyze Tektronix, Rigol, LeCroy captures |
| [02_file_format_io](demos/02_file_format_io/) | CSV, HDF5, NumPy, custom binary formats |
| [03_custom_daq](demos/03_custom_daq/) | Streaming loaders for custom DAQ systems |
| [04_serial_protocols](demos/04_serial_protocols/) | UART, SPI, I2C, 1-Wire decoding |
| [05_protocol_decoding](demos/05_protocol_decoding/) | Protocol auto-detection and decoding |
| [06_udp_packet_analysis](demos/06_udp_packet_analysis/) | Network packet capture and analysis |

### Advanced Analysis

| Demo | Description |
|------|-------------|
| [07_protocol_inference](demos/07_protocol_inference/) | State machine learning, CRC reverse engineering |
| [08_automotive_protocols](demos/08_automotive_protocols/) | CAN, CAN-FD, LIN, FlexRay analysis |
| [09_automotive](demos/09_automotive/) | OBD-II, UDS, J1939 diagnostics |
| [10_timing_measurements](demos/10_timing_measurements/) | Rise/fall time, duty cycle (IEEE 181) |
| [11_mixed_signal](demos/11_mixed_signal/) | Analog + digital combined analysis |
| [12_spectral_compliance](demos/12_spectral_compliance/) | FFT, THD, SNR, SINAD (IEEE 1241) |
| [13_jitter_analysis](demos/13_jitter_analysis/) | TIE, RJ/DJ, eye diagrams (IEEE 2414) |
| [14_power_analysis](demos/14_power_analysis/) | DC-DC, ripple, efficiency (IEEE 1459) |
| [15_signal_integrity](demos/15_signal_integrity/) | TDR, S-parameters, setup/hold timing |
| [16_emc_compliance](demos/16_emc_compliance/) | CISPR, FCC, MIL-STD testing |
| [17_signal_reverse_engineering](demos/17_signal_reverse_engineering/) | Complete unknown signal analysis |
| [18_advanced_inference](demos/18_advanced_inference/) | Bayesian inference, Protocol DSL |
| [19_complete_workflows](demos/19_complete_workflows/) | End-to-end reverse engineering |

### Run Your First Demo

```bash
# Generate demo data
python demos/generate_all_demo_data.py

# Run a demo
uv run python demos/01_waveform_analysis/comprehensive_wfm_analysis.py
```

---

## Key Features

### Protocols (16+)

UART • SPI • I2C • 1-Wire • CAN • CAN-FD • LIN • FlexRay • JTAG • SWD • Manchester • Miller • USB • HDLC • I2S • MDIO • DMX512

### File Formats (18+)

Tektronix WFM • Rigol WFM • LeCroy TRC • Sigrok • VCD • CSV • NumPy • HDF5 • MATLAB • WAV • JSON • BLF • MF4 • PCAP • PCAPNG

### Standards Compliance

**IEEE 181-2011**: Rise/fall time, pulse width, overshoot

**IEEE 1241-2010**: SNR, SINAD, THD, SFDR, ENOB

**IEEE 1459-2010**: Power factor, harmonics, efficiency

**IEEE 2414-2020**: TIE, period jitter, RJ/DJ

---

## Command Line Interface

```bash
# Characterize signal measurements
oscura characterize capture.wfm

# Decode protocol
oscura decode uart.wfm --protocol uart

# Batch process multiple files
oscura batch '*.wfm' --analysis characterize

# Compare two signals
oscura compare before.wfm after.wfm

# Interactive shell
oscura shell
```

See [CLI Reference](docs/cli.md) for complete documentation.

---

## Contributing

We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.

```bash
# Quick setup
git clone https://github.com/oscura-re/oscura.git
cd oscura
uv sync --all-extras
./scripts/setup/install-hooks.sh

# Run tests
./scripts/test.sh

# Quality checks
./scripts/check.sh
```

---

## Documentation

### Getting Started

- **[Quick Start Guide](docs/guides/quick-start.md)** - Begin here
- **[Demos](demos/)** - Working examples for every feature
- **[Migration Guide](docs/migration/v0-to-v1.md)** - Upgrade from older versions

### User Guides

- **[Black-Box Protocol Analysis](docs/guides/blackbox-analysis.md)** - Unknown protocol reverse engineering
- **[Hardware Acquisition](docs/guides/hardware-acquisition.md)** - Direct hardware integration (Phase 2)
- **[Side-Channel Analysis](docs/guides/side-channel-analysis.md)** - Power/timing/EM attacks
- **[Workflows](docs/guides/workflows.md)** - Complete analysis workflows

### API Reference

- **[API Reference](docs/api/)** - Complete API documentation
- **[Session Management](docs/api/session-management.md)** - Interactive analysis sessions
- **[CLI Reference](docs/cli.md)** - Command line usage

### Development

- **[Architecture](docs/architecture/)** - Design principles and patterns
- **[Testing Guide](docs/testing/)** - Test suite architecture
- **[CHANGELOG](CHANGELOG.md)** - Version history

---

## License

MIT License - see [LICENSE](LICENSE) for details.

---

## Citation

If you use Oscura in research:

```bibtex
@software{oscura,
  title = {Oscura: Signal Reverse Engineering Toolkit},
  author = {Oscura Contributors},
  year = {2026},
  url = {https://github.com/oscura-re/oscura}
}
```

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

---

## Support

- **[GitHub Issues](https://github.com/oscura-re/oscura/issues)** - Bug reports and feature requests
- **[Discussions](https://github.com/oscura-re/oscura/discussions)** - Questions and community

---

**Oscura** • Reverse engineer any system from captured waveforms
