-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlist_files.ps
122 lines (99 loc) · 2.8 KB
/
list_files.ps
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
%!PS-Adobe-3.0 EPSF-3.0
%%Pages: 1
%%BoundingBox: 0 0 1000 1000
%%LanguageLevel: 1
%%EndComments
%%BeginProlog
%%EndProlog
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% RedTeam Pentesting GmbH %
% kontakt@redteam-pentesting.de %
% https://www.redteam-pentesting.de/ %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%% Configurable Variables
% how many chars per line
/charactercount 100 def
% Which directory should be listed
/target_directory (/tmp/*) def
%%%%%%%%%%%%%%%%%%% Page Setup
/xposinit 0 def
% white page
1 1 1 setrgbcolor clippath fill
% black text
0 0 0 setrgbcolor
/pagewidth currentpagedevice /PageSize get 0 get def
/pageheight currentpagedevice /PageSize get 1 get def
% calculate the character width
/characterWidth pagewidth xposinit sub charactercount 2 add div def
/Courier findfont setfont
/curWidth (-) stringwidth pop def
/Courier findfont characterWidth curWidth div scalefont setfont
/lineheight characterWidth curWidth div def
% initial x and y positions
/yposinit pageheight lineheight sub def
/xpos xposinit def
/ypos yposinit def
xpos ypos moveto
%%%%%%%%%%%%%%%%%%% Printing Code
% Move to new line and go to next page if current page is full
% lineheight newline -
/newline {
/lineheight exch def
% new page if we are at the bottom of the page
ypos lineheight lt {
showpage
/xpos xposinit def
/ypos yposinit def
xpos ypos moveto
} if
% decrease y position
ypos lineheight sub
/ypos exch def
% move cursor
xpos ypos moveto
} def
% Draws a triangle at the current position
% Used for indicating a forced linebreak if the current line is too long
% - drawtri -
/drawtri {
/width 5 def
currentpoint
/curY exch def
/curX exch def
newpath
curX curY lineheight 2 div add moveto
curX width add curY lineheight 4 div add lineto
curX curY lineto
curX curY lineheight 2 div add lineto
closepath
fill
stroke
curX width add curY moveto
} def
%%%%%%%%%%%%%%%%%%% Actual Code
{
target_directory { %filenameforall
/curFileName exch def
% print filename and create new lines if needed
0 charactercount curFileName length {
/i exch def
i 0 gt {
drawtri
} if
/remaining curFileName length i sub def
curFileName i charactercount remaining min getinterval show
lineheight newline
} for
} 4096 string filenameforall
} stopped {
% if an error occurs, the cause is printed
/errormessage {
$error /errorname get 50 string cvs
} def
(listing files failed : ) show
lineheight newline
errormessage show
} { } ifelse % error catching frame
showpage