K
K
Kirill Vasiliev2015-07-10 22:37:24
iOS
Kirill Vasiliev, 2015-07-10 22:37:24

How to open safari from captiveportal popup?

Greetings.
This video shows the process of entering the hotspot
, you can see how the "stub" opens, it opens when the content is not equal to success.
Accordingly, the question is, how did they manage to open safari automatically?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OCTAGRAM, 2017-01-19
@OCTAGRAM

Watch your hands:

21:23:25 GET "captive.apple.com" /hotspot-detect.html HTTP/1.0 302 0 - "CaptiveNetworkSupport-346 wispr" - - - "http://captive.apple.com/hotspot-1.html"
21:23:25 GET "captive.apple.com" /hotspot-1.html HTTP/1.0 403 86 - "CaptiveNetworkSupport-346 wispr" - - - -
21:23:26 GET "captive.apple.com" /hotspot-detect.html HTTP/1.1 200 467 - "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Mobile/14C92" - - - -
21:23:26 GET "captive.apple.com" /hotspot-detect.html HTTP/1.0 200 68 - "CaptiveNetworkSupport-346 wispr" - - - -
21:23:28 GET "captive.apple.com" /hotspot-2.html HTTP/1.1 302 0 - "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0 Mobile/14C92 Safari/602.1" - - - "http://мой-URL"

The first two answers are to show wispr such a bad thing that he wants to intervene. wispr ends with "wispr" on both Mac OS X and iOS. Immediately 403 or 200 without Success somehow doesn’t work very well, but 302 does, but since 302, then something needs to be answered at a different address. Then CNS is launched (no Safari), and a page is given to it, on which there is Success and a script that, through the floorseconds will create a normal (without _blank) link with an absolute URL (which is with a two) and click on it with a click(). When a page is served on a stateful server, this computer is marked. Either following the link, or Success and code 200 on the page, or it’s just done every time after the first opening, until you figure it out, some of this forces you to make another wispr request, and this time the most usual Success is given to the marked computer, and when the link is followed in half a second, CNS will already be in the “Done” state and will direct the transition to the real Safari, and close itself. When a link is found to be opened by real Safari, the mark from the computer is reset.
It happens that it gets stuck in CNA, but after increasing the delay by a second, it seems to have returned to normal.
with AWS.Status;
with AWS.Response;

package Worker_Echoes.Apple.Captive is

   function Service (Request : AWS.Status.Data)
     return AWS.Response.Data;

end Worker_Echoes.Apple.Captive;

with Ada.Strings.Fixed;

with AWS.URL;
with AWS.Messages;

with Worker_Echoes.Protected_Strings;
with Worker_Echoes.Config;

package body Worker_Echoes.Apple.Captive is

   use AWS;
   use all type AWS.Messages.Status_Code;

   Last_CNA_CNS_Peername : Protected_Strings.Protected_String;

   -------------
   -- Service --
   -------------

   function Service (Request : Status.Data) return Response.Data is
      URL_Object : constant URL.Object := Status.URI (Request);
      URL_String : constant String := URL.URL (URL_Object);
      User_Agent : constant String := Status.User_Agent (Request);
   begin
      if User_Agent'Length >= 6 and then User_Agent (User_Agent'Last - 5 .. User_Agent'Last) = " wispr" then
         if Last_CNA_CNS_Peername.Get = Status.Peername (Request) then
            return Response.Build
              (Status_Code => S200,
               Content_Type => "text/html; charset=utf-8",
               Message_Body => "<HTML><HEAD><TITLE>Success</TITLE></HEAD><BODY>Success</BODY></HTML>");
         elsif URL_String = "http://captive.apple.com/hotspot-1.html" then
            return Response.Build
              (Status_Code => S200,
               Content_Type => "text/html; charset=utf-8",
               Message_Body => "<HTML><HEAD></HEAD><BODY></BODY></HTML>");
         else
            return Response.URL ("http://captive.apple.com/hotspot-1.html");
         end if;
      elsif Ada.Strings.Fixed.Index (User_Agent, "Safari") = 0 then
         Last_CNA_CNS_Peername.Set (Status.Peername (Request));

         -- 1. Not sure if intact "<BODY>Success</BODY>" matters, but probably yes.
         -- 2. There was no delay previously, thus A had to be created before BODY is processed.
         --    Now it's possible to click A with id, but touching working code was avoided.
         return Response.Build
           (Status_Code => S200,
            Content_Type => "text/html; charset=utf-8",
            Message_Body => "<HTML><HEAD><SCRIPT>" &
                               "window.setTimeout (function () {" &
                                  "var A = document.createElement (""a"");" &
                                  "A.setAttribute (""href"", ""http://captive.apple.com/hotspot-2.html"");" &
                                  "var Body = document.getElementsByTagName (""body"");" &
                                  "if (Body.length > 0) {" &
                                     "Body = Body [0];" &
                                  "} else {" &
                                     "Body = document.createElement (""body"");" &
                                     "document.getElementsByTagName (""html"") [0].appendChild (Body);" &
                                  "}" &
                                  "Body.appendChild (A);" &
                                  "A.click ();" &
                               "}, 1000);" &
                            "</SCRIPT>" &
                            "<STYLE>body { display: none; }</STYLE>" &
                            "<TITLE>Success</TITLE></HEAD><BODY>Success</BODY></HTML>");
      else
         Protected_Strings.Reset (Last_CNA_CNS_Peername, Status.Peername (Request)); -- reset if matches
         return Response.URL (Config.Get_Target_URL);
      end if;
   end Service;

end Worker_Echoes.Apple.Captive;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question