Printer 0-Day Exploit

Sleep
1 min readJan 31, 2023

--

Written by ClumsyLulz

#!/usr/bin/python
import os
import sys

# Check for valid input
if len(sys.argv) < 2:
print("Error: missing argument")
sys.exit(1)

# Set command and parameters
cmd = sys.argv[1]
params = sys.argv[2:]

# Execute the command
if cmd == 'print':
# Execute print command
os.system('lp -d printer_name ' + ' '.join(params))
elif cmd == 'config':
# Execute config command
os.system('lpadmin -p printer_name ' + ' '.join(params))
elif cmd == 'status':
# Execute status command
os.system('lpstat -p printer_name')
elif cmd == 'restart':
# Execute restart command
os.system('sudo /etc/init.d/cups restart')
else:
# Unknown command
print("Error: invalid command")
sys.exit(1)

This code is a Python script for managing a printer through the command line. It accepts a command line argument as input, which specifies the operation to be performed on the printer. The commands include “print”, “config”, “status”, and “restart”. If an insufficient number of arguments are provided, the script displays an error message and terminates. If an invalid command is provided, the script displays an error message and terminates. The script executes the appropriate shell command to perform the operation requested by the input argument, such as printing a file, configuring the printer, checking the status of the printer, or restarting the printing system. The printer being managed is identified as “printer_name”.

We can also refer to the tool know as PRETPrinter Remote Exploitation Tool Kit

--

--

No responses yet