6 # Connect to DRAC video redirection port
8 # 2010-01-06 Dobrica Pavlinusic <dpavlin@rot13.org> GPLv3+
13 use Data::Dump qw(dump);
15 my $to = shift @ARGV || die "$0 root:password\@10.0.0.1\n";
17 my ( $user, $password, $ip ) = split(/[:\@]/, $to);
19 warn "# connect $user:$password\@$ip\n";
21 my $ua = LWP::UserAgent->new;
22 $ua->cookie_jar( {} );
24 warn "# logout $ip\n";
25 $ua->get( "https://$ip/cgi-bin/webcgi/logout" );
28 my $response = $ua->get( @_ );
29 if ( $response->header('Content-Type') =~ m{xml} ) {
30 my $xml = XMLin( $response->content );
34 warn $response->content;
35 return $response->content;
41 $ua->post( "https://$ip/cgi-bin/webcgi/login", [
43 password => $password,
46 my $state = get_response( "https://$ip/cgi-bin/webcgi/winvkvm?state=1" );
48 my $vKvmSessionId = $state->{object}->{property}->{vKvmSessionId}->{value} || die "no vKvmSessionId";
50 warn "# vKvmSessionId $vKvmSessionId";
53 my $client = IO::Socket::SSL->new(
56 'SSL_version' => 'SSLv3',
57 'SSL_cipher_list' => 'RC4-MD5'
60 if ( !defined $client ) {
61 die "I encountered a problem: ", IO::Socket::SSL::errstr();
64 print STDERR "Connected to video redirection port $ip:5900!\n";
67 print "SSL cipher: " . $client->get_cipher() . "\n";
68 print "Cert: " . $client->dump_peer_certificate() . "\n";
72 42 45 45 46 01 02 00 d9 20 30 37 31 35 31 62 37
73 62 38 62 64 64 66 32 61 32 64 61 64 37 63 36 30
74 64 62 63 64 37 34 33 32 66 00 00 00 00 00 00 00
75 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
76 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
77 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
78 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
79 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
81 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
83 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
84 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
85 00 00 01 00 00 00 4a 98 00
90 my $out = pack('H*', $dump);
92 my $new = substr($out,0,8) . $vKvmSessionId;
93 $new .= substr($out,length($new));
98 read($client, my $header, 8);
100 my ($beef,$cmd,$len,$w,$h) = unpack('C4nnnn', $header);
102 warn "not BEEF but ",dump($beef) unless $beef eq 'BEEF';
104 read($client, my $packet, $len);
105 warn "# $w $h $len = ", dump( $header, $packet );
114 my $client = IO::Socket::SSL->new("$ip:5900",
115 SSL_key => unpack("H*", $vKvmSessionId),
116 ) || die IO::Socket::SSL::errstr();
120 print $client unpack('H*', "00 00 00 00 01 01 00 10 00 00 00 ae 00 00 00 00") || die $!;
122 #print $client unpack("H*", $vKvmSessionId);
126 read($client, my $in, 16) || die $!;
127 warn "<< ",dump($in);
133 #get_response( "https://$ip/cgi-bin/webcgi/vkvmplugin?os=win&uglocale=en&version=3,1,1,116" );
135 get_response( "https://$ip/cgi-bin/webcgi/winvkvm?state=3" );
137 get_response( "https://$ip/cgi-bin/webcgi/winvkvm?state=0" );
139 $ua->get( "https://$ip/cgi-bin/webcgi/logout" );