sap-vpn.pl
changeset 12 8cd92042fb8b
parent 11 16e6b1683c63
child 13 ddf323751753
equal deleted inserted replaced
11:16e6b1683c63 12:8cd92042fb8b
   216 
   216 
   217         ohshit "login failed with http code @{[$response->message]}\n"
   217         ohshit "login failed with http code @{[$response->message]}\n"
   218           unless $response->is_success;
   218           unless $response->is_success;
   219 
   219 
   220         $response = $response->as_string;
   220         $response = $response->as_string;
       
   221 	# ? $cookies->set_cookie(0, MRHSession => $sessionid, "/", $opt_host, 443, 1, 0, 10, 0, {});
   221     }
   222     }
   222 
   223 
   223   # We can then parse the response for the MRHSession Cookie, which contains our
   224   # We can then parse the response for the MRHSession Cookie, which contains our
   224   # SessionID.  In this example, we print out the SessionID in order to verify
   225   # SessionID.  In this example, we print out the SessionID in order to verify
   225   # that our log in attempt worked.
   226   # that our log in attempt worked.
   226 
   227 
   227     $response =~ /MRHSession=(\w+);/;
   228     $response =~ /MRHSession=(\w+);/;
   228     $sessionid = $1;
   229     $sessionid = $1;
   229     verbose "% session id ${sessionid}\n";
   230     verbose "% session id ${sessionid}\n";
   230 
   231 
   231     $cookies->set_cookie(0, MRHSession => $sessionid, "/", $opt_host, 443, 1, 0, 10, 0, {});
       
   232     #warn $cookies->as_string;
       
   233 
   232 
   234 ###
   233 ###
   235 ### STEP 3 :: Create the SSL VPN tunnel.
   234 ### STEP 3 :: Create the SSL VPN tunnel.
   236 ###
   235 ###
   237 
   236 
   238     verbose "% creating the ssl tunnel\n";
   237     verbose "% creating the ssl tunnel\n";
   239 
   238 
   240    # Now that we are authenticated and have a valid SessionID, we must request
   239    # Now that we are authenticated and have a valid SessionID, we must request
   241    # specific pages/objects in order to initiate a SSL VPN tunnel.  Before we do
   240    # specific pages/objects in order to initiate a SSL VPN tunnel.  Before we do
   242    # this, let's determine the resource locator for our Network Access favorite.
   241    # this, let's determine the resource locator for our Network Access favorite.
   243     #if (!$use_lwp) {
   242     if (!$use_lwp) {
   244     if (1) {
       
   245         $request = "GET /vdesk/vpn/index.php3?outform=xml HTTP/1.0\r\n"
   243         $request = "GET /vdesk/vpn/index.php3?outform=xml HTTP/1.0\r\n"
   246           . "Cookie: MRHSession=${sessionid}\r\n" . "\r\n";
   244           . "Cookie: MRHSession=${sessionid}\r\n" . "\r\n";
   247         $response = qx(echo "${request}" | ${openssl} 2>/dev/null);
   245         $response = qx(echo "${request}" | ${openssl} 2>/dev/null);
   248     }
   246     }
   249     else {
   247     else {
   262  print X $response;
   260  print X $response;
   263 
   261 
   264     $response =~ /${opt_name}[^\n]+\n[^Z]+Z=\d+,(\d+)/;
   262     $response =~ /${opt_name}[^\n]+\n[^Z]+Z=\d+,(\d+)/;
   265     $favorite = $1;
   263     $favorite = $1;
   266     verbose "% favorite ${favorite}\n";
   264     verbose "% favorite ${favorite}\n";
   267 
       
   268     exit;
       
   269 
   265 
   270     # We're all set!  Let's visit the necessary pages/objects to notify FirePass
   266     # We're all set!  Let's visit the necessary pages/objects to notify FirePass
   271     # that we wish to open a SSL VPN tunnel.
   267     # that we wish to open a SSL VPN tunnel.
   272     foreach my $uri ("/vdesk/", "/vdesk/vpn/connect.php3?Z=0,${favorite}",) {
   268     foreach my $uri ("/vdesk/", "/vdesk/vpn/connect.php3?Z=0,${favorite}",) {
   273         $request = "GET ${uri} HTTP/1.0\r\n"
   269         $request = "GET ${uri} HTTP/1.0\r\n"