forked from JakeVincet/nvt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasip-status.nasl
240 lines (192 loc) · 5.6 KB
/
asip-status.nasl
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# OpenVAS Vulnerability Test
# $Id: asip-status.nasl 11885 2018-10-12 13:47:20Z cfischer $
# Description: AppleShare IP Server status query
#
# Authors:
# James W. Abendschan <[email protected]>
#
# Copyright:
# Copyright (C) 2004 James W. Abendschan <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2,
# as published by the Free Software Foundation
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# NASL script to send a DSIGetStatus / FPGetSrvrInfo to an AppleShare IP
# server & parse the reply
# based off of http://www.jammed.com/~jwa/hacks/security/asip/asip-status
if (description)
{
script_oid("1.3.6.1.4.1.25623.1.0.10666");
script_tag(name:"cvss_base_vector", value:"AV:N/AC:L/Au:N/C:N/I:N/A:N");
script_version("$Revision: 11885 $");
script_tag(name:"last_modification", value:"$Date: 2018-10-12 15:47:20 +0200 (Fri, 12 Oct 2018) $");
script_tag(name:"creation_date", value:"2005-11-03 14:08:04 +0100 (Thu, 03 Nov 2005)");
script_tag(name:"cvss_base", value:"0.0");
script_name("AppleShare IP Server status query");
script_category(ACT_GATHER_INFO);
script_tag(name:"qod_type", value:"remote_banner");
script_family("Service detection");
script_copyright("Copyright (C) 2004 James W. Abendschan <[email protected]>");
script_dependencies("find_service.nasl");
script_require_ports(548);
script_tag(name:"summary", value:"File sharing service is available.
Description :
The remote host is running an AppleShare IP file service.
By sending DSIGetStatus request on tcp port 548, it was
possible to disclose information about the remote host.");
exit(0);
}
include("misc_func.inc");
function b2dw(a, b, c, d)
{
local_var a1, b2, c1, dword;
a1 = a * 256 * 256 * 256;
b1 = b * 256 * 256;
c1 = c * 256;
dword = a1 + b1 + c1 + d;
return(dword);
}
function b2w(low, high)
{
local_var word;
word = high * 256;
word = word + low;
return(word);
}
# return a pascal string
function pstring(offset, packet)
{
local_var plen, i, pstr;
plen = ord(packet[offset]);
#display("offset: ", offset, " length: ", plen, "\n");
pstr = ""; # avoid interpreter warning
for (i=1;i<plen+1;i=i+1)
{
pstr = pstr + packet[offset+i];
}
return (pstr);
}
# pull out counted pstrings in packet starting at offset
function pluck_counted(offset, packet)
{
local_var count, str, plucked, count_offset, j;
count = ord(packet[offset]);
#display("plucking ", count, " items\n");
str = "";
plucked = "";
count_offset = offset + 1;
for (j=0;j<count;j=j+1)
{
str = pstring(offset:count_offset, packet:packet);
# offset + length of data + length byte
count_offset = count_offset + strlen(str) + 1;
plucked = plucked + str;
# lame coz there's no != ?
if (j < count-1)
plucked = plucked + "/";
}
return(plucked);
}
#
# parse FPGetSrvrInfo reply (starting at DSIGetRequest reply packet + 16)
#
function parse_FPGetSrvrInfo(packet)
{
machinetype_offset = b2w(low:ord(packet[17]), high:ord(packet[16])) + 16;
machinetype = pstring(offset:machinetype_offset, packet:packet);
afpversioncount_offset = b2w(low:ord(packet[19]), high:ord(packet[18])) + 16;
versions = pluck_counted(offset:afpversioncount_offset, packet:packet);
uamcount_offset = b2w(low:ord(packet[21]), high:ord(packet[20])) + 16;
uams = pluck_counted(offset:uamcount_offset, packet:packet);
servername = pstring(offset:26, packet:packet);
report = string(
"This host is running an AppleShare File Services over IP.\n",
" Machine type: ", machinetype, "\n",
" Server name: ", servername, "\n",
" UAMs: ", uams, "\n",
" AFP Versions: ", versions, "\n");
if ("No User Authen" >< uams) {
report += '\nThis AppleShare File Server allows the "guest" user to connection';
}
log_message(port:548, data:report);
register_service(port:548, proto:"appleshare");
}
#
# parse ASIP reply packet
#
function parse_DSIGetStatus(packet)
{
flags = ord(packet[0]);
cmd = ord(packet[1]);
reqidL = ord(packet[2]);
reqidH = ord(packet[3]);
reqid = b2w(low:reqidL, high:reqidH);
if (!(reqid == 57005))
{
exit(1);
}
# ignore error / data offset DO for now
edo = b2dw(a:ord(packet[4]), b:ord(packet[5]), c:ord(packet[6]), d:ord(packet[7]));
datalen = b2dw(a:ord(packet[8]), b:ord(packet[9]), c:ord(packet[10]), d:ord(packet[11]));
reserved = b2dw(a:ord(packet[12]), b:ord(packet[13]), c:ord(packet[14]), d:ord(packet[15]));
if (!(cmd == 3))
{
exit(1);
}
return (parse_FPGetSrvrInfo(packet:packet));
}
#
# send the DSIGetStatus packet
#
function send_DSIGetStatus(sock)
{
packet = raw_string
(
0x00, # 0- request, 1-reply
0x03, # 3- DSIGetStatus
0xad, 0xde, 0x00, # request ID
0x00, 0x00, 0x00, 0x00, # data field
0x00, 0x00, 0x00, 0x00, # length of data stream header
0x00, 0x00, 0x00, 0x00 # reserved
);
send (socket:sock, data:packet);
buf = recv(socket:sock, length:8192, timeout:30);
if (strlen(buf) == 0)
{
exit(1);
}
return(buf);
}
#
# do it
#
function asip_status(port)
{
s = open_sock_tcp(port);
if (s)
{
packet = send_DSIGetStatus(sock:s);
if(strlen(packet) > 17)
{
parse_DSIGetStatus(packet:packet);
}
close(s);
}
}
#
# main
#
if (get_port_state(548))
{
asip_status(port:548);
}