-
Notifications
You must be signed in to change notification settings - Fork 42
/
vsascript.pl
executable file
·200 lines (171 loc) · 4.29 KB
/
vsascript.pl
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
#!/usr/bin/perl -w
use strict;
# Attribute Code
#-------------------------------------------
# username 101
# commonname 102
# framedip 103
# callingstationid 104
# untrustedport 105
# framedroutes 106
# vsabuf 107
my $action='';
my $reykeying='';
my $buflen='';
my $attribnumber='';
my $len='';
my $callingstationid='';
my $untrustedport='';
my $username='';
my $commonname='';
my $framedip='';
my @framedroutes='';
my $pipe='';
my @attributes;
my $i=0;
my $j=0;
$pipe = $ARGV[0];
open(FIFO, "< $pipe") || print "fifo: $!\n";
my $l;
read (FIFO,$l,4);
$action=unpack('N1',$l);
#print "VSAScript: Action: $action\n";
read (FIFO,$l,4);
$reykeying=unpack('N1',$l);
#print "VSAScript: Rekeying: $action\n";
read (FIFO,$l,4);
$buflen=unpack('N1',$l);
#print "VSAScript: buflen: $buflen\n";
$buflen=$buflen-12;
while($buflen > 0)
{
read (FIFO,$l,4);
$attribnumber=unpack('N1',$l);
#print "VSAScript: Attribute Number : $attribnumber\n";
read (FIFO,$l,4);
$len=unpack('N1',$l);
#print "VSAScript: Attribute Length : $len\n";
$buflen=$buflen-8;
if($attribnumber eq 101)
{
read (FIFO,$l,$len);
#print "VSAScript: Attribute Value : $l\n";
$buflen=$buflen-$len;
$username = $l;
}
elsif($attribnumber eq 102)
{
read (FIFO,$l,$len);
#print "VSAScript: Attribute Value : $l\n";
$buflen=$buflen-$len;
$commonname = $l;
}
elsif($attribnumber eq 103)
{
read (FIFO,$l,$len);
#print "VSAScript: Attribute Value : $l\n";
$buflen=$buflen-$len;
$framedip = $l;
}
elsif($attribnumber eq 104)
{
read (FIFO,$l,$len);
#print "VSAScript: Attribute Value : $l\n";
$buflen=$buflen-$len;
$callingstationid = $l;
}
elsif($attribnumber eq 105)
{
read (FIFO,$l,$len);
#print "VSAScript: Attribute Value : $l\n";
$buflen=$buflen-$len;
$untrustedport = $l;
}
elsif($attribnumber eq 106)
{
read (FIFO,$l,$len);
#print "VSAScript: Attribute Value : $l\n";
$buflen=$buflen-$len;
$framedroutes[$i] = $l;
$i++;
}
elsif($attribnumber eq 107)
{
while($len>0)
{
print "VSAScript: Vendor specific attribute\n";
my $vendor_id;
my $vendor_number;
my $vendor_len;
read (FIFO,$l,4);
$vendor_id=unpack('N1',$l);
#print "VSAScript: Vendor ID : $vendor_id\n";
read (FIFO,$l,1);
$vendor_number=unpack('C',$l);
#print "VSAScript: Vendor Number : $vendor_number\n";
read (FIFO,$l,1);
$vendor_len=unpack('C1',$l)-2;
#print "VSAScript: Vendor Value length : $vendor_len\n";
read (FIFO,$l,$vendor_len);
#decoding for integer values
if(
($vendor_id eq 529 && $vendor_number eq 197) #vendor specific attribute : Ascend-Data-Rate
or ($vendor_id eq 529 && $vendor_number eq 255) #vendor specific attribute : Ascend-Xmit-Rate
)
{
$l=unpack('N1',$l);
$attributes[$j]{'id'}=$vendor_id;
$attributes[$j]{'number'}=$vendor_number;
$attributes[$j]{'value'}=$l;
#print "VSAScript: Vendor Value: $l\n";
}
else # decoding for sting values
{
$attributes[$j]{'id'}=$vendor_id;
$attributes[$j]{'number'}=$vendor_number;
$attributes[$j]{'value'}=$l;
#print "VSAScript: Vendor Value: $l\n";
}
$buflen=$buflen-6-$vendor_len;
$len=$len-6-$vendor_len;
$len=$len-1;
$buflen=$buflen-1;
$j++;
}
}
else
{
read (FIFO,$l,$len);
#print "VSAScript: Undefined Attribute Value : $l\n";
$buflen=$buflen-$len;
}
}
close(FIFO);
print "\n---------------VSAScript----------------------\n";
if ($action eq 0) { print "\nAction: Authentication";}
elsif ($action eq 1) { print "\nAction: Client connect";}
elsif ($action eq 2) { print "\nAction: Client disconnect";}
else { print "\nAction: undefined!";}
if ($reykeying eq 0) { print "\nReykeying: No";}
elsif ($reykeying eq 1) { print "\nReykeying: Yes";}
else { print "\nReykeying: undefined!";}
print "\nUsername: $username";
print "\nCommonname: $commonname";
print "\nCallingstationid: $callingstationid";
print "\nUntrustedport: $untrustedport";
print "\nFramedIP: $framedip";
while($i>0)
{
$i--;
print "\nFramedRoute: $framedroutes[$i]";
}
while($j>0)
{
$j--;
print "\nVSA attribute: ";
print "\nId ($j): ".$attributes[$j]{'id'};
print "\nNumber ($j): ".$attributes[$j]{'number'};
print "\nValue ($j): ".$attributes[$j]{'value'};
}
print "\n---------------VSAScript----------------------\n";
exit(0);