-
Notifications
You must be signed in to change notification settings - Fork 617
/
Copy pathpret.py
88 lines (73 loc) · 3.27 KB
/
pret.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
# python standard library
import os
import sys
import argparse
# local pret classes
from discovery import discovery
from capabilities import capabilities
from postscript import postscript
from pjl import pjl
from pcl import pcl
# ----------------------------------------------------------------------
def usage():
parser = argparse.ArgumentParser(
description="Printer Exploitation Toolkit.")
parser.add_argument("target", help="printer device or hostname")
parser.add_argument(
"mode", choices=['ps', 'pjl', 'pcl'], help="printing language to abuse")
parser.add_argument(
"-s", "--safe", help="verify if language is supported", action="store_true")
parser.add_argument(
"-q", "--quiet", help="suppress warnings and chit-chat", action="store_true")
parser.add_argument(
"-d", "--debug", help="enter debug mode (show traffic)", action="store_true")
parser.add_argument("-i", "--load", metavar="file",
help="load and run commands from file")
parser.add_argument("-o", "--log", metavar="file",
help="log raw data sent to the target")
if len(sys.argv) < 2:
discovery(True) # list local printers if no arguments given at all
if len(sys.argv) == 2:
print("No printer language given, please select one" + os.linesep)
return parser.parse_args()
# ----------------------------------------------------------------------
def intro(quiet):
if not quiet:
print(" ________________ ")
print(" _/_______________/| ")
print(" /___________/___//|| PRET | Printer Exploitation Toolkit v0.40")
print(" |=== |----| || by Jens Mueller <jens.a.mueller@rub.de> ")
print(" | | ô| || ")
print(" |___________| ô| || ")
print(" | ||/.´---.|| | || 「 pentesting tool that made ")
print(" |-||/_____\||-. | |´ dumpster diving obsolete‥ 」 ")
print(" |_||=L==H==||_|__|/ ")
print(" ")
print(" (ASCII art by ")
print(" Jan Foerster) ")
print(" ")
# ----------------------------------------------------------------------
def main():
args = usage() # parse args/options #
intro(args.quiet) # show asciitainment #
capabilities(args) # check capabilities #
# connect to printer, use this language #
if args.mode == 'ps':
postscript(args)
if args.mode == 'pjl':
pjl(args)
if args.mode == 'pcl':
pcl(args)
# ----------------------------------------------------------------------
# clean exit
if __name__ == '__main__':
try:
main()
# catch CTRL-C
except (KeyboardInterrupt):
pass
finally:
print("")