自动tcp连接到服务器

时间:2016-05-02 00:27:37

标签: tcp telnet autoit

我是TCP连接的新手,也是Autoit的新手。

我正在尝试连接到我管理的游戏服务器,以便接收服务器数据(在线播放器,聊天记录等),并在需要时将TelNet命令发送到服务器(禁用播放器,踢球器等)

查看Autoit的TCP功能,我只看到IP和端口信息的位置,但服务器有管理员密码,我不知道如何将密码合并到混合中。

我很感激能够了解如何连接服务器和接收数据。

1 个答案:

答案 0 :(得分:0)

使用IP:端口进行连接,然后与服务器进行通信

这是我写的一个旧脚本,用于通过telnet连接到我的路由器以更改IP。

TCPStartup()
TrayTip("Changing IP adress!", "...connecting...", 10)
$router_IP = "192.168.1.1"
$port = "23" ; standard telnet port

$username = "admin"
$pass = "****"


Dim $ConnectedSocket = -1
$ConnectedSocket = TCPConnect($router_IP, $port)
If $ConnectedSocket = -1 Then
    TrayTip("Changing IP adress!", "Error! Cant connect!", 10)
    Sleep(3000)
    Exit
EndIf
TrayTip("Changing IP adress!", "Connected.", 10)

$old = ""

            $ret = TCPSend($ConnectedSocket, $username & @LF)
            Sleep(2000)
            $ret = TCPSend($ConnectedSocket, $username & @LF)
            Sleep(2000)
            $ret = TCPSend($ConnectedSocket, $username & @LF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP address!", $old, 10)
            Sleep(2000)
            $ret = TCPSend($ConnectedSocket, $pass & @CRLF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP adress!", $old, 10)
            Sleep(2000)
            $ret = TCPSend($ConnectedSocket, "sh" & @CRLF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP adress!", $old, 10)
            Sleep(3000)
            $ret = TCPSend($ConnectedSocket, "ifconfig nas_8_35 down" & @CRLF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP adress!", $old, 10)
            Sleep(10000)
            $ret = TCPSend($ConnectedSocket, "ifconfig nas_8_35 up" & @CRLF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP adress!", $old, 10)
            Sleep(2000)
            $ret = TCPSend($ConnectedSocket, "exit" & @CRLF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP adress!", $old, 10)
            Sleep(2000)
            $ret = TCPSend($ConnectedSocket, "exit" & @CRLF)
            $old &= TCPRecv($ConnectedSocket, 2048)
            TrayTip("Changing IP adress!", $old, 10)
            Sleep(5000)

不记得为什么我发送用户名3次了... 此外,由于你是新手,这些是开始的地方:

Autoit for absolute beginners

Autoit 1-2-3

Autoit Tcp examples and scripts

TELNET

祝你好运!