forked from RUB-NDS/PRET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpret.py
executable file
·68 lines (58 loc) · 2.98 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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# python standard library
import os, sys, 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.35")
print(" |=== |----| || by Jens Mueller <[email protected]> ")
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("")