我试图在Autoit中实现一个小脚本来检索Facebook服务器使用的所有IP(查询" -i origin AS32934"到whois.radb.net,developer page说),但我不明白为什么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
输出始终为&#34; RESULT:EMPTY&#34;。 我试图通过各种查询查询其他WhoIs服务(例如whois.verisign-grs.com与&#34; = facebook.com&#34;)但我没有得到回应。 这对我的网络来说不是问题,因为我尝试过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
似乎已发送数据包但未收到数据包。
答案 0 :(得分:0)
我刚刚找到解决方案:在TCPSend()请求结束时添加@crlf
$query = "-i origin AS32934" & @crlf