0

I have problem using Chrome DevTools SetTimeZoneOverrideCommand according to IP timezone. But when I check in Whoer.net still shows is system time.

In here have 3 problem:

  1. I using in selenium proxy is Rotate Proxy so is that posiible maintain same proxy by usin other function to check IP?

  2. SetTimeZoneOverride cannot change spoof my system same as IP timezone time.

  3. In Whoer.net is that possible change that DNS route


Imports System
Imports System.IO
Imports System.Text.RegularExpressions
Imports OpenQA.Selenium
Imports OpenQA.Selenium.Chrome
Imports Zu.ChromeDevTools

Module Program
    Sub Main(args As String())
        Console.WriteLine("Current IP: " & GetCurrentIP())


        Dim browser_option As New ChromeOptions
        Dim NewUAC As String = Random_UAC()
        browser_option.AddArgument("user-agent=" & NewUAC)
        browser_option.AddArgument("--window-size=800,600")
        browser_option.AddArgument("--incognito")
        browser_option.AddArgument("--disable-infobars")
        browser_option.AddArgument("--disable-blink-features=AutomationControlled")

        Dim Proxy As New Proxy With {
        .Kind = ProxyKind.Manual,
        .IsAutoDetect = False,
        .HttpProxy = "p.webshare.io:9999",
        .SslProxy = "p.webshare.io:9999"}
        browser_option.Proxy = Proxy

        Dim driverService = ChromeDriverService.CreateDefaultService
        driverService.HideCommandPromptWindow = True
        Dim browser As New ChromeDriver(driverService, browser_option)

        browser.Navigate.GoToUrl("https://whoer.net")
        Dim CurrentIP As String
        Dim sHTML As String = browser.PageSource

        CurrentIP = Mid(sHTML, sHTML.IndexOf("<strong data-clipboard-target=" & Chr(34) & ".your-ip" & Chr(34) & " class=" & Chr(34) & "your-ip" & Chr(34) & ">") + 59, 20)
        CurrentIP = Regex.Match(CurrentIP, "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b").ToString
        Threading.Thread.Sleep(5000)

        Console.WriteLine("Changed IP: " & CurrentIP)
        Console.WriteLine("Current Loc: " & Get_TimeZone_GeoLocation(CurrentIP))

        Dim CurrentGeo() As String
        CurrentGeo = Get_TimeZone_GeoLocation(CurrentIP).Split(",")
        Dim ChromeGeoLocation As New Zu.ChromeDevTools.Emulation.SetGeolocationOverrideCommand
        ChromeGeoLocation.Latitude = CurrentGeo(0)
        ChromeGeoLocation.Longitude = CurrentGeo(1)
        ChromeGeoLocation.Accuracy = 1
        Dim ChromeTimeZone As New Zu.ChromeDevTools.Emulation.SetTimezoneOverrideCommand
        ChromeTimeZone.TimezoneId = CurrentGeo(2)



        browser.Navigate.GoToUrl("https://whoer.net")

    End Sub

    Function GetCurrentIP() As String
        Dim DetectAddress As String = "https://whoer.net"
        Dim CurrentIP As String

        Dim objHttpRequest As System.Net.HttpWebRequest
        Dim objHttpResponse As System.Net.HttpWebResponse
        Dim objProxy As New System.Net.WebProxy
        objHttpRequest = System.Net.HttpWebRequest.Create(DetectAddress)
        objHttpResponse = objHttpRequest.GetResponse
        Dim objStrmReader As New StreamReader(objHttpResponse.GetResponseStream)
        Dim sHTML As String
        sHTML = objStrmReader.ReadToEnd()

        CurrentIP = Mid(sHTML, sHTML.IndexOf("<strong data-clipboard-target=" & Chr(34) & ".your-ip" & Chr(34) & " class=" & Chr(34) & "your-ip" & Chr(34) & ">") + 59, 20)
        CurrentIP = Regex.Match(CurrentIP, "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b").ToString

        Return CurrentIP
    End Function

    Function Get_TimeZone_GeoLocation(ByVal CurrentIP As String) As String
        Dim DetectAddress As String = "http://ip-api.com/csv/" & CurrentIP
        Dim CurrentLocation As String

        Dim objHttpRequest As System.Net.HttpWebRequest
        Dim objHttpResponse As System.Net.HttpWebResponse
        objHttpRequest = System.Net.HttpWebRequest.Create(DetectAddress)
        objHttpResponse = objHttpRequest.GetResponse
        Dim objStrmReader As New StreamReader(objHttpResponse.GetResponseStream)
        Dim sHTML As String
        sHTML = objStrmReader.ReadToEnd()
        Dim sHTML_Item() As String
        sHTML_Item = sHTML.Split(",")
        CurrentLocation = sHTML_Item.Length
        Dim latitude, longitude, timezone As String
        latitude = sHTML_Item(7)
        longitude = sHTML_Item(8)
        timezone = sHTML_Item(9)
        CurrentLocation = latitude & "," & longitude & "," & timezone


        Return CurrentLocation

    End Function

    Function Random_UAC() As String
        Dim strUACs As String = IO.File.ReadAllText("UAC_List.txt")
        Dim strUAC_Split As String()
        strUAC_Split = strUACs.Split(vbCrLf)
        Dim n As Integer = strUAC_Split.Length
        Dim RandomUAC As Integer
        RandomUAC = Math.Ceiling(Rnd() * n) - 1
        'Console.WriteLine(RandomUAC & " - " & strUAC_Split(RandomUAC))

        Return strUAC_Split(RandomUAC)
    End Function

End Module
wOxxOm
  • 65,848
  • 11
  • 132
  • 136
SampoValo
  • 21
  • 4
  • You may want to use browser add-on/extension for this. There's probably a few different ones available. This all boils down to hiding location. – pcalkins May 19 '21 at 20:41
  • I also think about to added Spoof Timzone Extension. But I use selenium to plug on I don't know how to change the default to "Update timezone everytime open browser" option. – SampoValo May 21 '21 at 03:54
  • If the extension is compatible with Selenium I think you can add it... never tried myself, but maybe check this thread: https://stackoverflow.com/questions/25557533/open-a-chrome-extension-through-selenium-webdriver-using-python/62679438 – pcalkins May 21 '21 at 17:08

0 Answers0