#!/usr/bin/env python3 """ Ethernet Printer Test Program v2.0 Supports: RAW TCP on port 9100, LPD on port 515, optional SNMP. """ import socket import time import json import sys import threading from concurrent.futures import ThreadPoolExecutor from datetime import datetime try: from pysnmp.hlapi import * SNMP_AVAILABLE = True except ImportError: SNMP_AVAILABLE = False ========== CONFIGURATION ========== TEST_PAGE = b"\x1b%-12345X@PJL JOB\r\n@PJL ENTER LANGUAGE=PCL\r\n\x1bEPrinter Test Page v2.0 - Ethernet Test\x1b&l0o0\x1bE\x1b%-12345X@PJL EOJ\r\n" RAW_PORT = 9100 LPD_PORT = 515 TIMEOUT = 5 THREADS = 5 ========== CORE FUNCTIONS ========== def test_port(ip, port): """Test if a TCP port is open.""" try: with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.settimeout(TIMEOUT) s.connect((ip, port)) return True except: return False
return result def discover_printers(ip_range_start, ip_range_end): """Discover printers by scanning IP range for open port 9100.""" base = '.'.join(ip_range_start.split('.')[:3]) start_octet = int(ip_range_start.split('.')[-1]) end_octet = int(ip_range_end.split('.')[-1]) printers = [] ethernet printer test program v2.0 download
if '-' in ip: start_ip, end_ip = ip.split('-') printers = discover_printers(start_ip, end_ip) else: printers = [ip] LPD on port 515
# SNMP toner toner = get_snmp_toner(ip) if toner is not None: result["toner_level"] = toner end_ip = ip.split('-') printers = discover_printers(start_ip
print(f"\n[*] Testing len(printers) printer(s) with THREADS threads...\n") results = []
Save the following code and run it.
# Option 1: Single IP ip = input("Enter printer IP (or range e.g., 192.168.1.10-20): ").strip()