【问题标题】:WhoIs servers are not respondingWhoIs 服务器没有响应
【发布时间】:2014-07-07 15:14:26
【问题描述】:

我正在尝试在 Autoit 中实现一个小脚本,用于检索 Facebook 服务器使用的所有 IP(如 developer page 所说,向 whois.radb.net 查询“-i origin AS32934”),但我不明白为什么 WhoIs 服务器没有响应我的查询。 这是脚本:

Local $host = "whois.radb.net", $query = "-i origin AS32934"
If Ping($host) Then
 $ws = DllOpen("ws2_32.dll")
 TCPStartup()
 $ip = TCPNameToIP($host)
 If @error Then _err("TCPNameToIP", @error)
 Global $socket = TCPConnect($ip, 43)
 If @error Then _err("TCPConnect", @error)
 TCPSend($socket, $query)
 If @error Then _err("TCPSend", @error, 1)
 Local $text = "", $t = TimerInit(), $counter = 0

 While 1
    $recv = TCPRecv($socket, 2048)
    If @error And @error <> -1 Then
        $aRet = DllCall($ws, "int", "WSAGetLastError")
        MsgBox(16,"ERROR", "Function: TCPRecv" & @CRLF & "Last data received: " & $recv & @CRLF & "Winsock error: " & $aRet[0] & @CRLF & "Loop executed " & $counter & " times")
        ExitLoop
    EndIf
    $text &= $recv
    $counter += 1
    If TimerDiff($t) > 4999 Then ExitLoop
 WEnd

 If $text = "" Then
    MsgBox(48, "RESULT", "EMPTY" & @CRLF & "Loop executed " & $counter & " times")
 Else
    MsgBox(0, "RESULT", $text)
 EndIf

 TCPCloseSocket($socket)
 TCPShutdown()
Else
 _err("Ping", @error, 0)
EndIf

Func _err($func, $err, $opt = 2)
    MsgBox(16, "ERROR", "Function: " & $func & @CRLF & "Error: " & $err)
    If $opt = 1 Then TCPCloseSocket($socket)
    If $opt > 0 Then TCPShutdown()
    Exit
EndFunc

输出始终为“RESULT:EMPTY”。 我尝试使用各种查询(例如 whois.verisign-grs.com 使用“=facebook.com”)查询其他 WhoIs 服务,但我没有得到任何回应。 这不是我的网络的问题,因为我已经尝试过 Nirsoft WhoIs 工具广告,它可以工作。 我已经下载了一个嗅探器,这是我启动脚本时的输出:

==================================================
Protocol          : TCP
Local Address     : 192.168.1.101
Remote Address    : 198.108.0.18
Local Port        : 23509
Remote Port       : 43
Remote Host       : whois.radb.net
Service Name      : nicname
Packets           : 5  {5 ; 0}
Data Size         : 17 Bytes  {17 ; 0}
Total Size        : 274 Bytes  {217 ; 57}
Data Speed        : 0.0 KB/Sec
Capture Time      : 07/07/2014 15:18:37:313
Last Packet Time  : 07/07/2014 15:18:45:837
Duration          : 00:00:08.523
==================================================
Content:
-i origin AS32934

好像发了包,但是没有收到包。

【问题讨论】:

    标签: autoit whois


    【解决方案1】:

    我刚刚找到了解决方案:在 TCPSend() 请求的末尾添加一个@crlf

    $query = "-i origin AS32934" & @crlf
    

    【讨论】:

    • 根据 RFC3912,所有 whois 查询必须由 CR 后跟 LF 终止。
    猜你喜欢
    • 2014-06-04
    • 2011-08-22
    • 2017-01-09
    • 2017-01-04
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多