Jump to content

How create a PROXY in AutoIt ?


rysiora
 Share

Recommended Posts

Want to write a proxy for a game. I change my game ip-to-connect to my own (127.0.0.1) and game connects to my server. The server on PC is exacly like "mediator / middleman ". It connects to the REAL game server. And game sends packets to my "pseudo-server" , then the proxy recevies it and sends to real game server, and from the other way, all packets from real server must go through/over mine proxy.

The good thing of this i s that, i can edit packets before sending them to real server, and before sending to game.

Game --> Proxy --> Game Serv

Game Serv --> Proxy --> Game

Is here anyone who can write a EXAMPLE script for me?

Link to comment
Share on other sites

Here's my code, but it doesn't work as it should - don't know why.

TCPStartUp()

$Socket = TCPConnect("123.123.123.123", 8080);connects to game serv
If $Socket = -1 Then Exit

$Listen = TCPListen("127.0.0.1", 8080, 100);waits for connection on my PC
If $Listen = -1 Then Exit
Global $ConnectedSocket = -1
$RogueSocket = -1

While 1
If $RogueSocket > 0 Then
$Recv = TCPRecv($RogueSocket, 2048)
    If Not @error Then TCPCloseSocket($RogueSocket)
        $RogueSocket = -1
EndIf

If $ConnectedSocket = -1 Then
    $ConnectedSocket = TCPAccept($Listen)
Else
    TrayTip("", "Client Connected", 0, 16)
    $RogueSocket = TCPAccept($Listen)
    $Client = TCPRecv($Socket, 2048)
    If $Client <> "" Then
        TCPSend($ConnectedSocket, $Client)
        GLobal $Client = ""
    EndIf
    $Recv = TCPRecv($ConnectedSocket, 2048)
    If $Recv <> "" Then
        TCPSend($Socket, $Recv)
    ElseIf @error Then
        TrayTip("", "Client Disconnected", 0, 16)
    TCPCloseSocket($ConnectedSocket)
;TCPCloseSocket($Socket)
    $ConnectedSocket = -1
    EndIf
EndIf
WEnd

Func OnAutoItExit()
    If $ConnectedSocket > -1 Then TCPCloseSocket($ConnectedSocket)
    If $Listen > -1 Then TCPCloseSocket($Listen)
    TCPShutDown()
EndFunc
Edited by rysiora
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...