Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Explanation of Proxies and how they work [Archive] - Forums

PDA

View Full Version : Explanation of Proxies and how they work



ExpertMace
04-12-2007, 11:50 AM
Hello,

I'm writing this to give new programmers out there an easy way to understand how a proxy works.

The proxy itself is like a middle man between the true tibia server and your tibia client. The proxy is made up of four componants, two sets of server and client sockets. With one set, you sort out the login procedures ect. And with the other you use for the game.

-----------------------------------------------------------------------------------------------------------

Below is how the componants work in the game:

http://img254.imageshack.us/img254/3746/tibiaproxiesexplainedzy4.png

When the Client sends a packet:

1. Client sends the packet e.g player moves his char up a square sending a packet.

2. Your Server componant recieves this packet.

3.Your Client componant then sends it to the real server.

When the Server sends a packet:

1. Real server sends a packet to your computer (e.g updating somthing).

2. Your Client componant recieves this data from the real server.

3. Your Server componant sends the data to the players client.

-----------------------------------------------------------------------------------------------------------

That is basically how the proxy works. Using this programmers may send packets using the componants, look for a certain packet and edit it and also send packets to the client insted of to the server,

When the packets are recieved it's custom to have a log, with all the incoming and outgoing packets displayed unencrypted. Therefore when a packet is recieved, it should be decrypted using XTea and then added to the list.

Hopefully this gives some of you who have not looked into proxies before an insight into the workings of a tibia proxy.

Mace.

OsQu
04-12-2007, 08:14 PM
This is really good. It do it job very good. (Explaining how proxy work in general)

Really good job o/
(And about that picture: Picture tells more than thousands words they said. Just translated it straight from finnish lol :D)

Grob
04-12-2007, 10:03 PM
Hopefully this gives some of you who have not looked into proxies before an insight into the workings of a tibia proxy.

I know how a proxy work in general but I have never programmed one and I must say this didn't clear much up. Do you change the ip address inside the Tibia client before logging in?

And wouldn't it be easier to somehow just write a packet to tibias send buffer in memory and then call its' encryption/send functions?

*DEAD*
06-03-2007, 03:26 AM
Thats a good representation of how a proxy works, but that much i did manage to figure out on my own. What id like to know, and im sure many others, is as follows:

1) wtf is a socket, i dont know anything about networking, and im sure most other noobs like me wanting to make a simple bot dont know anything about clients/servers either.
2) how do you "trick" the server into connecting to your fake client, and how do you trick the client into connecting to your fake server
3) a code example would be an utter godsend. Ive tried looking at blackd's, but i couldnt seem to figure out where his proxy code actually started. No matter what programming language its in, as long as the example only contains the proxy itself and is well documented, im sure we can go off and figure out how to do it in whatever language we want to, I just really need to see how its done.

ExpertMace
06-03-2007, 09:44 AM
True, I didn't go into much detail. I'll update my post soon.

Mace.

Ruud
06-03-2007, 10:31 AM
@*DEAD*: I will try to explain it in a short story.

A socket can act like a server and a client. Mostly in a proxy you use 2 or 4 sockets.
If you use 4 sockets you'll have these sockets: LoginClient,LoginServer,GameClient,GameServer.

First thing you must to to let a proxy work is writing the local IP of your pc to the memory of the tibia client(127.0.0.1). Now the LoginServer socket should be enabled on your program.

When you enter an account and password it will now connect to the LoginServer socket. You want this packet to be delivered on the Real tibia server so we enable the LoginClient socket. Now you'll have to send that incoming packet from the LoginServer socket to the LoginClient socket.

The Real tibia server will send a packet back containing the character list etc. Most proxy's don't send that packet directly to the client again but they will edit the IP's of the worlds and save the ips in the program and rewrite that IP's in the packet to 127.0.0.1.

Now that modified packet is send to the Client. So you'll see a character list like normal. If you now select a character you will connect to the GameServer Socket on the proxy program. The IP address on your GameClient socket should be the IP adres of the world you are connecting to. Because the packet send from the client to your program is RSA encrypted it is impossible to decrypt it. But you saved all the IP's from the character list in an array or something. You can read the tibia-memory to check wich character is choosen and then select the right IP adres for it for the GameClient socket.

Now the gameclient acts like a Client. All packets coming from the server go to the gameclient socket, then you can analize or modify packets and send them to the Real Tibia client. The same can be done the other way around.

Now the shorter version of this story:

- Write 127.0.0.1 to the TibiaClient memory
- Redirect the LoginPacket from the LoginServer to the LoginClient.
- Decrypt the incoming packet from the login-server and change the IP's from the game server, Encrypt it again and send it trough the LoginServer socket to the tibia client.
- Redirect the packet coming from the TibiaClient trought the GameServer socket to the GameClient socket to the right IP of the gameworld.
- Now packets come in and out like this:

Server -> Client:
GameServer -> GameClient socket -> analyze/modifying packets -> GameServer socket -> TibiaClient

Client -> Server
TibiaClient -> GameServer socket -> analyze/modifying packets -> GameClient socket -> GameServer

I hope this is what you meant.


~Yours,

Ruud

*DEAD*
06-03-2007, 04:56 PM
Awesome explanation. Again code would be a godsend, but thats the next best thign.

Ruud
06-03-2007, 05:13 PM
Awesome explanation. Again code would be a godsend, but thats the next best thign.

What language? There is a delphi proxy open source available on the forum and I think there is an VB example to.

*DEAD*
06-04-2007, 03:46 AM
Hmm, sorry guess i should have searched. I personally use C, but anything will do i guess.

L4K
08-24-2007, 07:57 PM
Mace, i need 4 winsocks?

ExpertMace
08-24-2007, 08:30 PM
4 winsocks is a good idea. 2 to be used to handle the login processes and 2 for the game processes :)

Mace.

L4K
08-24-2007, 08:37 PM
u use vb6? can u send me your msn :D ? i have many questions about proxys

ty alot ;)

OsQu
08-24-2007, 09:26 PM
L4K why don't you just get that free version of Blackd Proxy (dunno if it's in 8.00, but I have it for 7.92 at least) and check from that how proxys work.. It's coded with vb6.

L4K
08-25-2007, 03:49 AM
I have the FreeBlackD and i'm studying, but he have manys complex and big codes.

Only explain me this:

Client <-> WinSock1 <-> WinSock2 <-> WinSock3 <-> WinSock4 <-> Server

How each WinSock work? If i understand this the rest is more "easy"

I think WinSock1 receives the packets from Client and WinSock4 From Server, but i dont know what is the function of WinSock3 and WinSock4.

I'm completely newby in relation of how proxys works, any little help is great for me :)

Thx

OsQu
08-25-2007, 06:44 AM
Well I tried once study proxy from he's code and I noticed that same thing too (it's pretty complex code), so because I don't know almost nothing making proxy I can only quess. But I think that one 2 winsocks are used when logging in (one fro client, one for server) so those are connected to the logging server. And then the another two are used in gameplay. Again one for client, and one for server, and those ones are connected to the game server.

L4K
08-25-2007, 01:44 PM
THX OsQu!

you dont have ideia how you help me! :D

Zyphrus
08-27-2007, 08:32 AM
Very good tutorial Mace :)

Cameri
08-27-2007, 01:50 PM
I have the FreeBlackD and i'm studying, but he have manys complex and big codes.

Only explain me this:

Client <-> WinSock1 <-> WinSock2 <-> WinSock3 <-> WinSock4 <-> Server

How each WinSock work? If i understand this the rest is more "easy"

I think WinSock1 receives the packets from Client and WinSock4 From Server, but i dont know what is the function of WinSock3 and WinSock4.

I'm completely newby in relation of how proxys works, any little help is great for me :)

Thx

In general, proxys work like this, sitting in the middle of connections, where proxy here I do NOT mean a socket, this could be three people, one at the end being the server or cook, one in the middle taking the plate (waitress), and the client sitting at the other end waiting for his meal.

Server <-> Proxy <-> Client
Now if you want to make a proxy for Tibia, in my opinion the best way is to use four Winsock components, two clients and two servers, that is, one client and one server sockets for the login server, and one client and server sockets for the game server.

Let me explain things a little better: there are several ports in your computer on which connections can be established. For a single port, you can have a socket listening for incoming connections. In another analogy, you could see this "server socket" as the guy at the dock waiting for boats to stop by. He will handle the situation and make arrangements such as hooking your boat to the dock (accept the connection), etc. Sometimes there is a third "Server socket" guy to whom the connection is passed, but that's out of the scope of my explanation. Now, in that same port, there's the boat, who I will call the "client socket"... see... they are all sockets...

For Tibia cheats, a proxy could be decomposed to this:



=================================================
| Your Proxy Application |
=================================================
| |
Tibia Login Server <====> Login Client Socket |
| /\ || |
| || || |
| ----------------------- --------------------- |
| | Packet Manipulation | | Packet Generation | |
| ----------------------- --------------------- |
| || || || |
| || || =================== |
| || || || |
| || \/ \/ |
| Login Server Socket <===========================> Tibia Client
| | /\
|---/\----\/----/\---\/---/\----\/----/\---\/---| ||
| | ||
Tibia Game Server <====> Game Client Socket | ||
| /\ || | ||
| || || | ||
| ----------------------- --------------------- | ||
| | Packet Manipulation | | Packet Generation | | ||
| ----------------------- --------------------- | ||
| || || || | ||
| || || ==================== | ||
| || || || | ||
| || \/ \/ | ||
| Game Server Socket <====================================
| |
=================================================

L4K
08-31-2007, 06:00 PM
Wow!!
I Love U Cameri! =****