如何测试代理背后的互联网连接?

时间:2015-05-02 10:18:49

标签: powershell batch-file vbscript proxy cmd

我有这个vbscript适用于 Windows 7 32位无代理

为了改进它,我寻求这个解决方案:如何测试代理后面的互联网连接? 解决方案可能是 VBScript或Powershell或Batch ,就像我找到一种方法来检查我是否连接在代理服务器之后!

当我在代理

之后改进它的代码片段

如果有一个技巧来检查当我在代理后面时我是否已连接到互联网这是我的问题?

import sqlite3 as lite
import pandas as pd

con = lite.connect("project_warmest.db")

with con:
    cur = con.cursor()
    cur.execute("DROP TABLE IF EXISTS cities;")
    cur.execute("DROP TABLE IF EXISTS weather;")
    cur.execute("CREATE TABLE cities (name text, region text)")
    cur.execute("CREATE TABLE weather (city text, warm_month text, average_high integer)")

    cur.execute("INSERT INTO cities VALUES('Istanbul', 'Marmara')")
    cur.execute("INSERT INTO cities VALUES('Ankara', 'Ic Anadolu')")
    cur.execute("INSERT INTO cities VALUES('Izmir', 'Ege')")
    cur.execute("INSERT INTO cities VALUES('Antalya', 'Akdeniz')")
    cur.execute("INSERT INTO cities VALUES('Bursa', 'Marmara')")

    cur.execute("INSERT INTO weather VALUES('Istanbul', 'July',24)")
    cur.execute("INSERT INTO weather VALUES('Ankara', 'July',21)")
    cur.execute("INSERT INTO weather VALUES('Izmir', 'July',27)")
    cur.execute("INSERT INTO weather VALUES('Antalya', 'August',30)")
    cur.execute("INSERT INTO weather VALUES('Bursa', 'July',23)")
    cur.execute("SELECT city FROM weather INNER JOIN cities ON name = city WHERE warm_month = 'July'")

    rows = cur.fetchall()
    cols = [desc[0] for desc in cur.description]
    df = pd.DataFrame(rows, columns = cols)

print "The cities that are warmest in July are: %s, " %df.iloc[0]["city"]

漏洞代码:

If CheckConnection = true then
    Msgbox "i'm connected to internet",vbinformation+vbSystemModal,"Check connection to internet"
Else
    Msgbox "i'm not connected to internet",vbCritical+vbSystemModal,"Check connection to internet"
End if
'***************************************************************************
Function CheckConnection()
    CheckConnection = False
        strComputer = "smtp.gmail.com"
        Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery _
        ("select * from Win32_PingStatus where address = '" & strComputer & "'")
        For Each objStatus in objPing
            If objStatus.Statuscode = 0 Then
                MyLoop = False
                CheckConnection = True
                Exit Function
            End If
        Next
End Function
'******************************************************************************

1 个答案:

答案 0 :(得分:1)

如果您的意思是本地计算机的设置,您可以查询注册表:

REG QUERY "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v  ProxyEnable

如果值为0x1,则设置代理。您还可以通过同一位置的ProxyServer值检查代理值。更多信息here

您可以检查外部IP是否与内部IP地址相同。 这使用winhttpjs.bat

for /f "skip=1 tokens=* delims=" %%a in ('winhhttpjs.bat "http://www.telize.com/ip" -saveTo con') do (
    set "ip=%%a"
)
ipconfig| find "%ip%" || (
  echo not real IP/proxy
)