Immutable Threat Intelligence Ledger
A custom blockchain for logging cybersecurity threats - tamper-proof, verifiable, permanent.
NullBlock is a custom blockchain implementation built for cybersecurity use cases. Every threat record - whether a malicious IP address, an attack event, or a malware signature - is stored as an immutable block on a chain. Once written, it cannot be altered without breaking the entire chain, which is immediately detected by the validator.
This is the exact principle behind why blockchain is powerful for security: tamper-evidence. If anyone modifies a historical record, the SHA-256 hash chain breaks and the corruption is provable.
- Network Threats - Source IPs, attack types (SQL Injection, DDoS, XSS...), severity levels, ports, protocols
- Malware Signatures - File hashes, malware names, families (Ransomware, Trojan, Botnet...), hash types
- Python CLI - Terminal-based, stores chain as
nullblock_chain.json - Web UI - Browser-based explorer, stores chain in
localStorage, fully offline
NullBlock/
βββ nullblock.html # Web UI (open in any browser)
βββ nullblock_cli.py # Python CLI tool
βββ nullblock_chain.json # Chain data file (auto-created by CLI)
βββ README.md
- Python 3.8+
- pip
pip install colorama
coloramais only for colored terminal output on Windows. The tool works without it.
Before logging threats, you must register an analyst. This creates a secure 2048-bit RSA keypair under analysts/<name>/ used to sign blocks.
python nullblock_cli.py register-analyst --name "Alice"Every block must be signed by a registered analyst. Use the analyst's registered name in --reporter.
python nullblock_cli.py add-threat \
--ip 192.168.1.105 \
--type "SQL Injection" \
--severity HIGH \
--port 3306 \
--protocol TCP \
--reporter "Alice" \
--notes "Repeated attempts on MySQL port"Severity levels: LOW | MEDIUM | HIGH | CRITICAL
python nullblock_cli.py add-malware \
--hash "5f4dcc3b5aa765d61d8327deb882cf99abc12345" \
--name "WannaCry" \
--family "Ransomware" \
--severity CRITICAL \
--reporter "Alice" \
--notes "Exploits EternalBlue (MS17-010)"python nullblock_cli.py chainpython nullblock_cli.py validate[+] Returns
Chain integrity verifiedif all hashes, links, and digital signatures are valid
[-] ReturnsCHAIN COMPROMISEDif any block is tampered with, signature is forged, or public key is missing
# Search by IP
python nullblock_cli.py search --ip 192.168.1.105
# Search by malware name
python nullblock_cli.py search --name WannaCry
# Search by hash prefix
python nullblock_cli.py search --hash 5f4dccpython nullblock_cli.py stats- Open
nullblock.htmlin any browser - no internet required - ANALYSTS - register new threat analysts, generating native RSA-PSS keypairs using Web Crypto API (stored in browser
localStorage) - LOG THREAT - select an analyst, fill in IP, attack type, severity -> Commit & Sign to Chain
- LOG MALWARE - select an analyst, fill in hash, name, family -> Commit & Sign to Chain
- CHAIN - full blockchain explorer, showing the index, type, timestamps, SHA-256 SPKI public key fingerprints, and base64 signatures
- VALIDATE - verify hashes, block links, and RSA signatures of all blocks in-browser
- STATS - visual breakdown of threat data
- SEARCH - search by IP, malware name, or hash prefix
- EXPORT JSON - download the entire chain as a JSON file
{
"index": 3,
"timestamp": "2025-01-15T10:23:45.123456",
"type": "THREAT",
"data": {
"ip_address": "192.168.1.105",
"attack_type": "SQL Injection",
"severity": "HIGH",
"port": "3306",
"protocol": "TCP",
"reporter": "SOC-Team",
"notes": "Repeated attempts on MySQL port"
},
"previous_hash": "a3f2c1d9e8b7...",
"nonce": 0,
"hash": "7b9e2f1a4c8d..."
}| Field | Purpose |
|---|---|
index |
Block position in the chain |
timestamp |
UTC time of logging |
type |
GENESIS, THREAT, or MALWARE |
data |
The actual threat intelligence payload |
previous_hash |
SHA-256 hash of the block before this one |
nonce |
Reserved for future proof-of-work |
hash |
SHA-256 hash of this entire block |
GENESIS BLOCK BLOCK #1 BLOCK #2
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β index: 0 β β index: 1 β β index: 2 β
β type: GENESIS β β type: THREAT β β type: MALWARE β
β prev: 000...000 β β prev: βββββββββββͺββββββͺβΊ a3f2c1... β
β hash: a3f2c1... βββββββΊ previous_hash β β prev: 7b9e2f... β
βββββββββββββββββββ β hash: 7b9e2f...βββββββΊ hash: 9c1a4e...β
βββββββββββββββββββ βββββββββββββββββββ
Each block's hash is computed from ALL its contents including the previous_hash. This means:
- Change Block #1's data -> its hash changes
- Block #2's
previous_hashno longer matches -> invalid - Every block after is also invalid
- Validator catches this instantly
You cannot silently edit history.
def compute_hash(block):
block_copy = {k: v for k, v in block.items() if k != "hash"}
block_string = json.dumps(block_copy, sort_keys=True)
return hashlib.sha256(block_string.encode()).hexdigest()Block serialized to JSON with sorted keys (determinism) -> SHA-256 hashed. The hash field is excluded to avoid circular dependency.
for i in range(1, len(chain)):
current = chain[i]
previous = chain[i - 1]
# Check 1: Does this block's hash match its contents?
if current["hash"] != compute_hash(current):
return False, f"Block #{i} hash is CORRUPTED"
# Check 2: Does it correctly link to the previous block?
if current["previous_hash"] != previous["hash"]:
return False, f"Block #{i} is DETACHED from chain"Two checks per block. O(n) time. Catches both content tampering and chain relinking attacks.
| Concept | How NullBlock Uses It |
|---|---|
| Immutability | SHA-256 hash chain - any edit breaks all subsequent blocks |
| Tamper Evidence | Validator detects and pinpoints exact corrupted block |
| Cryptographic Hashing | SHA-256 produces a fixed 256-bit fingerprint of each block |
| Chain of Custody | Every record has timestamp, reporter, and cryptographic proof |
| Threat Intelligence | Structured logging of IPs, attack types, malware hashes |
| IOC (Indicators of Compromise) | Malware hashes and malicious IPs are classic IOC formats |
| Audit Trail | Genesis block anchors a complete, verifiable history |
| Data Integrity | Sorting keys before hashing ensures deterministic hashes |
- MITRE ATT&CK - globally shared threat intelligence framework
- VirusTotal - crowdsourced malware hash database
- Blockchain-based PKI - immutability preventing certificate fraud
- SIEM audit logs - tamper-evident security event logs in enterprise SOCs
- Ethereum event logs - smart contract events stored immutably on-chain
NullBlock demonstrates the core principle behind all of these: once written to the chain, data cannot be quietly changed.
- Web UI stores data in
localStorage- use Export JSON to back up before clearing browser data - CLI stores chain in
nullblock_chain.json- back this file up - This is a simplified blockchain - no P2P network, no consensus, no proof-of-work mining
- For production threat intel, look into STIX/TAXII format and platforms like OpenCTI or MISP
Built by H8RSH100 - CS/IT Engineering Student
Part of a cybersecurity portfolio series alongside VaultCipher.
MIT - see LICENSE.