6 sub extractlastcipherblock {
7 my(@bytes_last_two, @bytes_last_three, @bytes, $len, @iv);
9 # print "LAST2: $lastPacketLine2";
10 # print "LAST3: $lastPacketLine3";
11 @bytes_last_two = split(/\s+/,$lastPacketLine2);
12 @bytes_last_three = split(/\s+/,$lastPacketLine3);
15 shift @bytes_last_two;
16 shift @bytes_last_three;
18 # get rid of text at right
20 pop @bytes_last_three;
22 @bytes = (@bytes_last_three, @bytes_last_two);
24 # now skip the last 12 bytes as the AUTH MAC.
25 # sizes halved because bytes are presented as 16-items
27 # print "EXTRACT: ".($len-9)."-".($len-6)." of ",join('|',@bytes)."\n";
28 @cbcbytes = @bytes[($len-9)..($len-6)];
30 $cbc = join('',@cbcbytes);
31 $myiv= $first4IV.$last4IV;
33 # print "MyIV: ".$myiv." LastCBC: $cbc\n";
36 print $packetHead." IV PREDICTED\n";
38 print $packetHead." IV PROBABLY RANDOM\n";
43 $lastthree = $lasttwo;
47 if(/^\d*\.\d*\.\d*\.\d* \> \d*\.\d*\.\d*\.\d*\: ESP/) {
50 # save the lines of the previous packet
51 $lastPacketLine2 = $lasttwo;
52 $lastPacketLine3 = $lastthree;
68 @bytes=split(/\s+/,$_);
69 $first4IV = $bytes[7].$bytes[8];
75 @bytes=split(/\s+/,$_);
76 $last4IV = $bytes[1].$bytes[2];
79 &extractlastcipherblock;