
#!/usr/bin/env python3
# printer_firmware_server.py - Simulated printer that fetches updates over HTTP
import requests, hashlib, os
FIRMWARE_URL = "http://updates.printer.local/firmware.bin"
CURRENT_VERSION = 1.0
def check_update():
try:
r = requests.get(FIRMWARE_URL, timeout=5)
if r.status_code == 200:
firmware = r.content
# No signature verification! Just check hash?
# Insecure: any file can be flashed.
with open("/tmp/firmware.bin", "wb") as f:
f.write(firmware)
print("Firmware downloaded and saved. (In real printer, it would be flashed.)")
except Exception as e:
print("Update check failed:", e)
if __name__ == '__main__':
check_update()
网络打印机通过明文 HTTP 从可配置的 URL 获取固件更新,且不验证数字签名。中间人攻击者或 DNS 欺骗攻击者可以提供恶意固件,从而完全控制设备。
python malicious_update_server.py
python printer_firmware_server.py