Warcraft II Forum

Warcraft II => Mods & Development => Topic started by: Igognito on May 07, 2018, 10:50:34 AM

Title: Lat Trick Bot
Post by: Igognito on May 07, 2018, 10:50:34 AM
Hello all,

a well known problem we have on the server is that many of us are unable to host games.
Recently, an idea come to my mind and I'm planning to explore it.

I'm thinking of making a Lat trick Bot.
The idea is that the Bot will do the Nx(N-1) combinations that we need for everybody to be able to host.

The way I'm planning to do so is by assuming that the Channel is one big game.

Do I know how to do it? Certainly not! I just have the idea for now and know that with some implementation work everything can be done :-D

So what is this post: This is a recruiting post!
For @AHB, @tupac and other PvPGN know hows to join up with me and help!

Cheers
@iL, We also are going to need your help! For starters it is possible that what I want to do might need to alter the code of the PvPGN server. If so I might need your help to set up a developer server and then you might need to upgrade to the new server.
Title: Re: Lat Trick Bot
Post by: iL on May 08, 2018, 09:14:45 AM
The idea is that the Bot will do the Nx(N-1) combinations that we need for everybody to be able to host.

I'd attach it to status, file: http://server.war2.ru/status/status_public4.dat (http://server.war2.ru/status/status_public4.dat)
It updates in real-time when the game being hosted, players join, leave, etc.
So you need Nx*1 combinations and in only a moment when the game is being hosted.
So that would be enough to implement lat trick for only ones who've been hosted the game right last moment. Also you can check "port_isopen" parameter. If "port_isopen":"1", you don't need lat trick at all.

For starters it is possible that what I want to do might need to alter the code of the PvPGN server. If so I might need your help to set up a developer server and then you might need to upgrade to the new server.

Well, i'd prefer to edit and update the code myself, but yes, i think i can share that code to you to let you make changes if you need that.
And yes, i think we can setup a developer server for our modifications.
Title: Re: Lat Trick Bot
Post by: Igognito on May 08, 2018, 10:38:29 AM
The idea is that the Bot will do the Nx(N-1) combinations that we need for everybody to be able to host.

I'd attach it to status, file: [url]http://server.war2.ru/status/status_public4.dat[/url] ([url]http://server.war2.ru/status/status_public4.dat[/url])
It updates in real-time when the game being hosted, players join, leave, etc.
So you need Nx*1 combinations and in only a moment when the game is being hosted.
So that would be enough to implement lat trick for only ones who've been hosted the game right last moment. Also you can check "port_isopen" parameter. If "port_isopen":"1", you don't need lat trick at all.

For starters it is possible that what I want to do might need to alter the code of the PvPGN server. If so I might need your help to set up a developer server and then you might need to upgrade to the new server.

Well, i'd prefer to edit and update the code myself, but yes, i think i can share that code to you to let you make changes if you need that.
And yes, i think we can setup a developer server for our modifications.


While it is still very early to discuss such details...
I can tell you that doing lat trick the moment someone hosts wont work.
Until the whole procedure is executed and ports are open (takes a small time for that) people will have already tried to enter and failed.

On the other hand, if we have a flag that tells me who requires the lat trick, that I can certainly use!

What we actually need is that the channel is handled as an open game. Then slowly the channel does the necessary connections.
Some possible problems is that players channel latency might increase a bit.

For those that have noticed, now that I connect by using a 4G network when I join a game I'm shown with red bars. I also create a small lag peek. It takes a few seconds for the red bars and lag to disappear. This occurs because the me x N port opening process that happens automatically when u join a game. This behavior exactly I want to add in channel.

X = excluded usernames (bots, chat only accounts etc...)
N = port_is_open:1 ; port_forced_open:1
M = port_is_open:0

Upon init of bot;
We need M*(M+N) combinations...
and mark this M as port_forced_open:1

When someone leaves the channel we mark: port_forced_open:0
When someone enters the channel we run the init again. Or every now and then (if we see it causes problems to run often)...

Furthermore, we need to keep the connections open or have that port_forced_open expire.

About the code of PvPGN...

The PvPGN is an open project anyway (https://github.com/pvpgn/pvpgn-server) I will only need the version and a dev server.

When we are done, feel free to check my patch if any. Also by the opportunity I might transfer the Elo in \stats. I somewhere read (https://forums.pvpgn.pro/viewtopic.php?id=1782) that in PvPGN we could even have custom fields shown with \stats. That could be the ideal actual as we do not modify at all the normal functionality just add the Custom ladder info.

Anyhow, I will not be starting this before the 20th. I have to much work :/ But I hope until the 20th I will have got the attention of @AHB, @tupac and possible other bot implementors that might help me with this.
Cheers
Title: Re: Lat Trick Bot
Post by: iL on May 08, 2018, 03:28:30 PM
I can tell you that doing lat trick the moment someone hosts wont work.
Until the whole procedure is executed and ports are open (takes a small time for that) people will have already tried to enter and failed.
Why not?
Someone (with closed port) hosts the game, then bot try to send udp 6112 from host to everybody, then everybody will be able to join, won't they?

I'd say, everything you need (if you're the peer with closed ports) is to run that bot on your side. When you host the game, your comp sends 6112 udp to everyone you need, then they be able to join your game. Other players don't need that lat trick bot at all to let them connect you.

What we actually need is that the channel is handled as an open game. Then slowly the channel does the necessary connections.
Some possible problems is that players channel latency might increase a bit.
I didn't understand an idea, the channel as an open game means interchange between each pair of peers? That depends on client (war2), not a pvpgn server.

Also, to keep lat trick working you have to repeat your init UD packets every period of time. So that traffic can be sufficient. I think that will be a big problem, that's why i think about the ways to not require N(N-1) or M(M+N) combinations...
Title: Re: Lat Trick Bot
Post by: AHB on May 09, 2018, 06:39:59 PM
Thanks for your interest @Igognito

I believe port forward free hosting of War2 games is possible as I discussed here http://forum.war2.ru/index.php/topic,4009.0.html (http://forum.war2.ru/index.php/topic,4009.0.html)

It would not require any modification of PvPGN, it would be an entirely client to client side hack

It is achievable using STUN I believe and has already been implemented in the new Starcraft 2.

I havent spent enough time studying how STUN works to figure it out, but I know it is the key to the puzzle. If someone can put time into this, you can test like this:

1. Study how STUN works
2. Setup a Windows PC behind a public IP and firewall without 6112 forwarded (game host), you'll need to setup VPN or port fwd RDP to get access to Windows
3. Use your Windows PC at secondary public IP and firewall combo without 6112 to try joining the host

From there, on the game host, you would write a program in your language of choice to send some traffic on UDP 6112 over to the person trying to join. From my understanding this would allow them to join your game now, but will probably require further research of how STUN works


After this proof of concept is established and we know it works, here is how we would convert it to production:

1. iL would have to post the IP addresses of every player to the .dat file (currently it doesnt have this). Yeah people might not like that but really who cares, you are giving your IP to everyone when you join a game anyways, the only difference is now you are giving your IP to people you havent joined a game with... this is the only way it is possible to make this trick work

2. The program built for the proof of concept would regularly (every few seconds) check the list of IP addresses of all players, and send traffic to every player UDP 6112 periodically to maintain connections with them.

3. Profit. 23 years of hosting problems fixed forever


(all of the above is basically what iL said, in more words)

I dont know if this is a very scalable solution (lot of traffic as players increase, could overwhelm a consumer router?) but for our small server itd be no problem

I will try to put some time into this. I really think we can do it.

@iL if I solve hosting will you forgive my misdeeds and give me USA-Archer name back lol
Title: Re: Lat Trick Bot
Post by: tupac on May 09, 2018, 09:12:08 PM
I would say unban archer and give him another try.

@Igognito

If I was you i would start reversing war2 when you create a game. Watch all the encrypted traffic, you could make a small program to send and receive UDP traffic. That would emulate the lat trick I think. You would need to explain lat trick well. I also see a human and AI being the fail of this project.

Bot tries to join a game... fails... the bot hosts then everyone joins... not sure exactly how the lat trick is done.

It would be easier having a VPN server. I made one but il firewall was dropping fragmented packets, the fix I heard was MCU at 1500.... haven't had time to confirm that yet. If you would like to try this out I can help you code on the weekends only.
Title: Re: Lat Trick Bot
Post by: AHB on May 09, 2018, 10:06:04 PM
Like @tupac said, good point, might be less work to build VPN as part of the war2 client I bet, that might be another hack around

thanks for the support, I am the longest ban in server history FREE ARCHER 2018 served 3 years for my crimes let me out with community service lol @iL
Title: Re: Lat Trick Bot
Post by: AHB on May 10, 2018, 09:23:51 AM
It is not so simple as sending traffic outbound from client A to all other players on 6112 in order to open 6112 to them:

- NAT does not map outbound connection on 6112 to be public-ip:6112, (otherwise only one person would be able to use web, email etc at a time)
- Instead it chooses a high number port like public-ip:49123 to map to private-ip:6112
- In order to join player A's game, player B's war2 client would have to connect to player A:49132 instead of A:6112 (not sure if this will ever be possible because would require a change to the war2 game itself right?)


this is a good resource:
http://www.brynosaurus.com/pub/net/p2pnat/ (http://www.brynosaurus.com/pub/net/p2pnat/)
Title: Re: Lat Trick Bot
Post by: AHB on May 10, 2018, 09:41:04 AM
A good, simple description of UDP hole punching, I added notes on how we could implement it for war2.ru:


1. User A and User B establish a TCP connection to PvPGN server. Once established, both users send to PvPGN server a port on which they can be contacted. We'll call User A's "Port X" and User B's "Port Y". (this would be a Python program or whatever that gets added to War2Combat and posts public IP and port number to a war2.ru webpage, which collects it and adds to list of user/port combination to dat file)
2. PvPGN server shares the port information of User A with User B, and vice-versa. (iL outputs IP address and port number of all players in JSON format to .dat file, which is then downloaded by Python program embedded in War2Combat)
3. User A sends a UDP packet from Port X to User B on Port Y. User B's firewall will of course reject this packet because it was not expecting it
4. User B sends a UDP packet from Port Y to User A on Port X. User A's firewall will forward this port internally to User A, because User A's firewall just saw a packet leave User A through it out Port X and to User B on Port Y (and because it's UDP, it has no idea that it was rejected), so it assumed that a packet coming from User B on Port Y to User A on Port X is a response packet, so it lets it through.
5. User A sends another UDP packet from Port X to User B on Port Y, and it is also allowed through User B's firewall for the same reason.
6. Users A and B can now send UDP packets back and forth, and Control's participation is no longer needed.

The only thing I dont understand is how would war2 know to connect to a game on port 49000 for example instead of 6112/ is it possible?




Source: https://serverfault.com/questions/425258/does-hole-punching-require-a-udp-rendezvous-server-or-could-it-be-a-tcp-one?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
Title: Re: Lat Trick Bot
Post by: Igognito on May 10, 2018, 11:07:21 AM
@tupac, @AHB, @iL great that I have everyone in this!

and thank you for the brain storming...
I intent on looking to this problem, but I do have limited time my self.

To be honest, I do believe the best is to solve it on the PvPGN server level.
The server knows all ips, all UDP ports.
Also some solutions I have seen from other gaming software is implemented on chat channels.
Example: Voobly
Before the launch a game the open a small chat channel. There all users try to connect with all users (this takes some time) when all connections has established the launch the game.
This behavior I think is what we refer to as the LAT trick. Also war2 does exactly that when u enter in a game.

so the ideal would be that the client can send a UDP packet to a specific ip address.

ps:stopped suddenly will continue
Title: Re: Lat Trick Bot
Post by: AHB on May 10, 2018, 11:28:39 AM
It fundamentally cant be solved at the PvPGN level, actually there is no need to modify pvpgn at all I think. There needs to be a server which receives the port mappings for each client and distributes them to all other clients, however this would be much easier written in PHP with a JSON HTTP output rather than hacking with C++ TCP connections in PvPGN.

On the client side I would prefer Python to make HTTP posts, but whatever will work, eventually that will be compiled into an exe, and added to the War2Combat startup script to run whenever war2 is launched

Here is another good source:

https://steamcommunity.com/app/427520/discussions/4/371919771755670102/


At this point I understand how NAT hole punching works, I'm just not sure how we will get the other war2 clients know to connect to different high number ports rather than 6112 depending on who is hosting?

Currently we know people can change their War2 port, so I guess I just need to understand how the client knows to connect to a host's custom port rather than the default 6112.
Title: Re: Lat Trick Bot
Post by: tupac on May 10, 2018, 11:41:20 AM
It fundamentally cant be solved at the PvPGN level, actually there is no need to modify pvpgn at all I think. There needs to be a server which receives the port mappings for each client and distributes them to all other clients, however this would be much easier written in PHP with a JSON HTTP output rather than hacking with C++ TCP connections in PvPGN.

On the client side I would prefer Python to make HTTP posts, but whatever will work, eventually that will be compiled into an exe, and added to the War2Combat startup script to run whenever war2 is launched

Here is another good source:

https://steamcommunity.com/app/427520/discussions/4/371919771755670102/


At this point I understand how NAT hole punching works, I'm just not sure how we will get the other war2 clients know to connect to different high number ports rather than 6112 depending on who is hosting?

Currently we know people can change their War2 port, so I guess I just need to understand how the client knows to connect to a host's custom port rather than the default 6112.

The anti hack il made could handle that.
Title: Re: Lat Trick Bot
Post by: iL on May 11, 2018, 02:46:22 AM
@iL if I solve hosting will you forgive my misdeeds and give me USA-Archer name back lol

That looks schizophrenic, you hack/ddos the stuff by one hand and make some useful things by another at the same time. It happens every time.
I have no idea about your reasons, but honestly, i'd prefer you to keep far from our server and things.

To be honest, I do believe the best is to solve it on the PvPGN server level.
The server knows all ips, all UDP ports.

Well, if you think to release that on pvpgn - ok, but i don't think i can help you with that pvpgn research. Of course i can integrate your code into server pvpgn or share the current pvpgn source code to you.
But i have no idea to resolve that on pvpgn server level.

But you right, pvpgn knows all the ips and UDP ports.
And: http://server.war2.ru/status/status_public4.dat (http://server.war2.ru/status/status_public4.dat) is a public part. Or course status has private part that also knows all the ips and ports (gets from pvpgn).
So we can share that info to your utility somehow.

So, I think we have different ways to resolve ips and ports. But i see another problem:
Can you firstly make another part? The heart of the project. A program/function to UDP request to the required ip/port from war2 port?
Something like:
int udp_request(char *ip, int port)
{
...
}
I mean, some code calls your function, your function resolves your local war2 outgoing UDP port somehow (maybe get it as a parameter also), then send UDP where required and then you will be able to receive incoming UDP packets to that ip and port.
That's a small step, but would be the main part for the project!

Can be easily tested with you, me and several friends.
So, the test will be easy: i close my ports, you and 2-3 your friends tell me your ips, i host the game, and begin to send UDP to your ips, you try to join.
I'm not sure if you can use UDP port captured by another program (war2), so here's the first problem i see here. Maybe we have to inject that UDP info war2 executable code to let it send packets when that port is already opened for reading/writing by war2? Or we can open UDP on the same interface/same port from another process?

After that part will work perfect, we can analyze traffic and find the way to get all (or all the required) ips and ports.
Title: Re: Lat Trick Bot
Post by: Igognito on May 11, 2018, 11:28:04 AM
There are problems with having bots doing this.
If for each user we need a bot that does the ping it is a problem.

The reason I want to do this at the server level is so that we do not require double logins for each user.
Probably the easiest is to have a bot for each user that knows the ips and does something like this:

for all IP in IPs
  echo "Lat Trick" > /dev/udp/IP/6112
end for

and

netcat -ul 6112

This is something we can try among us. If by both of us doing this the ports open then we have verified that all we need is to send/receive a package...

I was thinking of doing it like that:
The server send a packet to the clients that has encrypted the IP and UDP port of the client to send a package back
then a utility decrypts the ip and udp port and send back a package...

There we are everything is fixed... we just ping pong each other over UDP

now, some programmers could probably listen their outgoing packages and find some ips... but I do not think that is too much of a problem...

worst case scenario someone will use that information for a DOS attack. An average firewall should be able to handle that.
What is dangerous is if the can code inject something to that ip. But I think they shouldn't be able

Full design:

Introduce \lattrick chat command
\lattrick sends to user IP a UDP packet at a port that a custom app listens
the app when it receives the packet starts to listen for encrypted ips
the ping pong starts
when all ips finish the server sends the confirmation message.

the code should be similar with the \ping command code
we just have the pong part going to the ip stated...
Title: Re: Lat Trick Bot
Post by: AHB on May 11, 2018, 12:55:11 PM
@Igognito

Your design:
Although it is one solution, the flaw that I see in your design is it requires user interaction each time before hosting a game. How would the server even know who you want to open ports with? You would have /lattrick <username>? And then the host would have to repeat for each player that he wants to be able to join?

My design:
- No user interaction required, no chat bot commands, runs in background and opens connections to every player so that anyone can host

1. Client A wants to host a game, but is behind NAT with no port forward
2. Client A downloads a list of IP addresses and ports of all other players of the server periodically by downloading HTTP JSON response from war2.ru. Keep in mind this is not a "bot" in the sense of a chat bot, it is a program bundled into War2Combat that runs continuously in the background without user interaction or even knowing about it
3. Client A periodically sends UDP traffic to every single one of those IPs/ports from port 6112, however, his NAT router translates 6112 to a high number port like 49123. The first time traffic is sent, it will be ignored, until the otherside initiates a response (since it is doing the same periodic sending of traffic), after that the two will be able to communicate freely
4. All of those clients that Client A is sending periodic traffic to can now respond on port 49123, and join games on that port, however, they need to know that is the port Client A is listening on so they have to get that info from PvPGN, who is already maintaining this information. (We might need to have a way to update PvPGN with this NAT port, which tells the War2 client which port to join a game on, this is the only step I am unsure how to code)

There is no /lattrick command needed, and definitely no point in encrypting anything. Once you are in a game, you know the IPs of all players right now anyways, it is not secret information, the only difference now is that you will know the IPs of people you arent in a game with as well

Since Client A is sending periodic UDP traffic to every single other player on the server, anyone can join his game without having to run a command, send an IP etc

UDP hole punching example in Python:
https://github.com/dwoz/python-nat-hole-punching

2 clients connect to the server, the server tells each client about the other client's IP and port, then the clients talk to each other over the IP/port
Title: Re: Lat Trick Bot
Post by: AHB on May 11, 2018, 02:20:32 PM
@iL

So I have setup a test environment to start the proof of concept. The first problems I am seeing:

1. My game host is listening on 6112. However, if I make an outbound connection to player 2, I dont know how to obtain the NAT translated port that was opened for that connection this can be solved using a STUN client and connecting to a free STUN server which will give me my external port and external IP. Here is a python library I am working with for this https://github.com/jtriley/pystun
2. Say that I figure out somehow that the outbound port opened to player 2 is port 49222, now how do I get that response traffic to go back to 6112 ... solve this by binding to port 6112 in the UDP python script


here is simple python code to send from each machine to open that connection between them (if we can figure out the above)

import socket

target_host = "1.1.1.1"
target_port = 6112

# create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.bind(('0.0.0.0', 6112))

# send some data
client.sendto("AAABBBCCC",(target_host, target_port))

print "Done!"

Title: Re: Lat Trick Bot
Post by: AHB on May 11, 2018, 02:33:28 PM
This is the best summary of the problem that I have found yet http://resources.infosecinstitute.com/udp-hole-punching (http://resources.infosecinstitute.com/udp-hole-punching)
Title: Re: Lat Trick Bot
Post by: AHB on May 11, 2018, 03:43:49 PM
Here is the code to get NAT info that we need using STUN:

First install pystun with pip install pystun, then:


import stun
interface = "0.0.0.0" # interface to listen on (all)
port = 6112 # port to listen on
nat_type, external_ip, external_port = stun.get_ip_info(interface, port)
print nat_type
print external_ip
print external_port

This will return:
Symmetric NAT
1.1.1.1
30738
Title: Re: Lat Trick Bot
Post by: AHB on May 11, 2018, 03:49:13 PM
Updated Design:

1. Client A wants to host a game but is behind NAT without port forward
2. Client A's War2Combat sends an HTTP GET to war2.ru to grab a list of all player external IPs and ports
3. Client A's War2Combat runs a script to get STUN info -> their nat_type, external_ip, external_port
4. Client A's War2Combat sends an HTTP POST to war.2ru sending its external_ip and external_port and war2.ru server receives this and adds it to the list in #2
5. Client A sends periodic UDP traffic to the ext_ip and ext_port of all other players
6. All other players send periodic traffic to the ext_ip and ext_port of Client A

[ TODO: Somehow client A needs to update PvPGN letting other war2 clients to know to join games using its external port identified in #3, if this occurs in the port setting of war2, my idea is that steps 1-6 take place before even launching war2, then war2 is launched binded to the ext_port discovered?

This is the biggest challenge right now
]

7. Now that Client A has connections opened to all other players, he is able to host and anyone can join



Update .. this STUN idea doesn't work for symetric NAT, which creates a different port mapping for every new connection. Getting a hell of an education on NAT right now, man this is harder than I thought it would be https://networkengineering.stackexchange.com/questions/7781/why-stun-doesnt-work-with-symmetric-nat
Title: Re: Lat Trick Bot
Post by: Igognito on May 14, 2018, 09:32:43 AM
Nice work AHB...

by the way, the \lattrick I was suggesting would do for all other users.
Thus the host does not need to know who will join the game, all users will be able to host.

It is just that I'm triggering it only for the one that is hosting.
Also theoretically you could first host the game and then do \lattrick when someone cant join.

We could modify the message that u receive that no one can join your game: to do: \lattrick

:-P

anyhow, I'm very busy these days until the 20th.
Title: Re: Lat Trick Bot
Post by: iL on May 14, 2018, 09:58:47 AM
Updated Design:
did you try that yourself? It is working for you?

Somehow client A needs to update PvPGN letting other war2 clients to know to join games using its external port identified in #3, if this occurs in the port setting of war2
Well, at least pvpgn knows everything about ports in realtime, also pvpgn shares that info to other parts of project, so there should not be a problem to request that info every moment we need.

Another question: if you host the game (war2 listening UDP on 6112 or w/e port) and then your script tries to bind/send something to that port on the same host. Will that work or returns error like "port is busy"?

this STUN idea doesn't work for symetric NAT
Not a big problem as for me. Maybe i'm wrong, but as understand, symmetric NAT is very rare thing. Even if such hole punching will not cover that several % of clients, other will be happy to have it working.

5. Client A sends periodic UDP traffic to the ext_ip and ext_port of all other players
6. All other players send periodic traffic to the ext_ip and ext_port of Client A
Do we really need both 5 and 6? As i understand, 5 is enough to let others connect to game hosted by client A.
I mean, P.6 requires started lat trick bot on all clients. But would be better if we require lat trick bot only on clients behind NAT.
Why i should start lat trick bot on my computer if my ports are open!

Another problem is potential vulnerability: we have to discover everyones' ip addresses to everyone. Now you can discover someone's ip only if he hosts the game or joins the game (tell me if i'm wrong).
Title: Re: Lat Trick Bot
Post by: iL on May 14, 2018, 10:06:24 AM
Also theoretically you could first host the game and then do \lattrick when someone cant join.
Yes, that was my idea: I'd attach \lattrick instead of that message "your port is closed..." Then it will work automatically and only for clients and at the moment when it's really needed.

What i see as the 1-st step: to try that any way, at least like that python scripts, make sure it works, realise the required timeouts and other technical moments. Then we could think what our next step will be.
I also very busy permanently, so if someone test this, that would be great.
Title: Re: Lat Trick Bot
Post by: iL on May 14, 2018, 11:39:16 AM
Well, installed python under windows on my side, checked by stun via random stun server, got  Nat type: Restric NAT, my real external ip and some kind of port.
Next step: i know my game data port, it's 6112.
My plan, and i need someone's help to test:
1. i start war2 with no uPNP, make sure port is closed
2. you try to join, get error
3. you give me your ip and game data port (most likely 6112)
4. i try udp_client.py or my own script with client.bind to your ip and your port
5. you try to join again.

If i understand steps properly, it should let you join my game.
Title: Re: Lat Trick Bot
Post by: AHB on May 15, 2018, 10:13:33 AM
Hi @iL

A couple things that you said:

1 - Is it a vulnerability to expose IPs?

Well no I dont think it is a problem, you already get everyones IP when you join a game with them, the only difference is now you can get everyones IP without joining a game

2 - Symmetric NAT is rare

I didnt know, I have a pfSense firewall. I will try a new firewall with another type of NAT and see if I can defeat that

3 - Step 5/6 - why do all other players need to respond to UDP?

They don't, I was just imagining a world where no one port forwards anymore and we all host games using the new NAT hosting fix

4 - Will your udp_client.py script work as you said?

No, I dont think so, the problem is that port 6112 isn't going to be opened, 49123 or something like that will be opened publicly and translated to 6112 on the LAN. Your friend will try to join <your-external-ip>:6112 and it will be closed... we have to somehow let PvPGN know to tell other players to join on <your-external-ip>:49123

Possibly this is a Symmetric NAT thing though and maybe your router will rewrite <internal-ip>:6112 -> <external-ip>:6112, in which case I think youd be good


more reading http://www.think-like-a-computer.com/2011/09/16/types-of-nat/ (http://www.think-like-a-computer.com/2011/09/16/types-of-nat/)
Title: Re: Lat Trick Bot
Post by: iL on May 15, 2018, 11:21:04 AM
2 - Symmetric NAT is rare

I didnt know, I have a pfSense firewall. I will try a new firewall with another type of NAT and see if I can defeat that
Something like pf on -BSD systems? Maybe symmetric NAT implemented there by default, i don't know, but it's quite possible. Also some small/medium business uses such type of NAT. We should try.
I meant small hardware home routers all-in-one, as i understand, most of them uses other types of NAT.

Anyways, if we start that UDP hole punching thing we should check how many people uses symmetric NAT or other types.

I have an idea: i'll just try to host the game and then send UDP to server:6112. If i will NOT get a message (port is closed), that means hole punching works fine.

Possibly this is a Symmetric NAT thing though and maybe your router will rewrite <internal-ip>:6112 -> <external-ip>:6112, in which case I think youd be good
Definitely it is. Symmetric NAT is the only type changes outgoing port. At least all other types try to do everything to translate outgoing 6112 to 6112 when NATing.

They don't, I was just imagining a world where no one port forwards anymore and we all host games using the new NAT hosting fix
As i understood, the concept is to do everything to forward existing ports. We should use hole punching ONLY if other ways are not possible.
Title: Re: Lat Trick Bot
Post by: Igognito on May 15, 2018, 12:54:16 PM
1 - Is it a vulnerability to expose IPs?

Well no I dont think it is a problem, you already get everyones IP when you join a game with them, the only difference is now you can get everyones IP without joining a game

Yes it is a vulnerability. Generally, having someone's ip you can try to do several nasty stuff.
Some are easy, others require technical knowledge which probably nobody in this community has.

I would suggest that we encrypt the ips for safety. Our encryption doesn't need to be something special. Just a XOR filter with a random series of numbers. Enough, for the casual malicious user to not be able to get the ip.

The pro hackers, probably wont target us. In general we just need to be protected by DOS attacks etc.

Yes, that was my idea: I'd attach \lattrick instead of that message "your port is closed..." Then it will work automatically and only for clients and at the moment when it's really needed.

You mean to hook it automatically? Run the command to the server and send the data to the client?
That is okay, just keep the message as is so that people that do not have the lattrick utility to know to install it.

maybe using something like this can tell us exactly what happens when we do the lat trick:
https://www.pcwdld.com/best-network-monitoring-tools-and-software (https://www.pcwdld.com/best-network-monitoring-tools-and-software)

Cheerios
Title: Re: Lat Trick Bot
Post by: tupac on May 16, 2018, 06:04:33 AM
1 - Is it a vulnerability to expose IPs?

Well no I dont think it is a problem, you already get everyones IP when you join a game with them, the only difference is now you can get everyones IP without joining a game

Yes it is a vulnerability. Generally, having someone's ip you can try to do several nasty stuff.
Some are easy, others require technical knowledge which probably nobody in this community has.

I would suggest that we encrypt the ips for safety. Our encryption doesn't need to be something special. Just a XOR filter with a random series of numbers. Enough, for the casual malicious user to not be able to get the ip.

The pro hackers, probably wont target us. In general we just need to be protected by DOS attacks etc.

Yes, that was my idea: I'd attach \lattrick instead of that message "your port is closed..." Then it will work automatically and only for clients and at the moment when it's really needed.

You mean to hook it automatically? Run the command to the server and send the data to the client?
That is okay, just keep the message as is so that people that do not have the lattrick utility to know to install it.

maybe using something like this can tell us exactly what happens when we do the lat trick:
https://www.pcwdld.com/best-network-monitoring-tools-and-software (https://www.pcwdld.com/best-network-monitoring-tools-and-software)

Cheerios
No point in encrypting the IP address... anyone can sniff it while hosting or joining a game.
Title: Re: Lat Trick Bot
Post by: iL on May 16, 2018, 08:03:26 AM
No point in encrypting the IP address... anyone can sniff it while hosting or joining a game.
Not for those who just idle in chat with no games playing.

BTW, if you join the game, can anybody get your ip not being joined to that game?
Title: Re: Lat Trick Bot
Post by: AHB on May 16, 2018, 09:19:42 AM
@iL @tupac

Tupac is right, there is no point @iL, no, currently regular users cant get IP of players while idle/chat (admins can with /conn I believe)

But theres a million ways to get people's IP address (play a game with them, get them to click a link in your profile etc), knowing which is not a security issue itself.

Even AES256 encrypted IPs would never be secure because the CLIENT has to decrypt it, so the decryption key is sitting in the binary easily extractable by the user who wants to find out the IPs. Its like doing password checking in javascript (the web user can change to do whatever he wants), you just never do security things in client side code because it would just be a waste of your time.

Title: Re: Lat Trick Bot
Post by: Igognito on May 16, 2018, 09:28:41 AM
Hosting/joining should only expose ip among Host/Joiner.

Don't really know how war2 handles this. But when u join a game I guess your ip is exposed to the host and vice versa.
Also your ip might be exposed to the other players that joined, but technically speaking that might not be necessary. But desirable in case the host drops.

Having a command that exposes all channel's ips is something different.
One could write a utility to use that command and launch a DOS attack against each single ip.
Or even better attempt to take remote control of each single PC behind. While 90% of those would be protected a malicious person might find one open...
And suddenly your PC is at the hands of someone...

Quantity is important here. This is the reason why Blizzard and others hid the ip addresses.
For mass attacks not single directed ones.

At the time of Kali, we would do several form of attacks against other players. Exactly, because we could see the ip.
So I would say it is advisable to protect that...

Is it crucial? Well in most cases people in the community wont bother to look up for it, thus I would say it is not crucial and having a simple strategy should be enough.
Title: Re: Lat Trick Bot
Post by: AHB on May 16, 2018, 10:53:55 AM
I give up, if you guys want to waste your time "encrypting" IPs go ahead, just know it will take less time to defeat the "encryption" than it will to create it. You can't hide IPs AND also distribute them to each client for the program to use them to send UDP traffic to. So if its too big of a concern, then the project should be disbanded

But once again an IP address is not a security issue per se. If you have a remote code execution vulnerability exposed to the internet, you have already given your PC to anyone, there are bots scanning every minute for that, no need for your "secret" IP address to be exposed in an obscure game in order for that to become a problem for you.

DoS is a potential issue I suppose, and yes I remember being stuck in pball games for days, each player with 1/1HP footman, and people had small internet connections then, it was easy to boot them off lol. I dont think its that easy anymore

But like I said, if you want to collect the IP of every war2 player, just host GoW for 2 weeks and auto collect each person who joins. Or post something outrageous in the forum with a link that collects IP each time someone clicks it. The list goes on and on.

Its not a major security concern to give IPs of each player (however there is no need to include username with the IP, so that way you can prevent anyone from targeting others)
Title: Re: Lat Trick Bot
Post by: AHB on May 16, 2018, 11:00:48 AM
I'm pretty busy, like everyone else of course, but I hope I can get some time in the next few weeks to test my PoC. I have to setup 2 windows machines at different locations and get a consumer grade router for the host location with the more common NAT type. Then I can send UDP traffic using the Python snippet of code from one PC to the other and see if the port pops open

I really think we can make this work for most NATs!

It will be a huge accomplishment for us if we can (at least partially) solve a problem thats haunted the game for 20+ years
Title: Re: Lat Trick Bot
Post by: AHB on May 16, 2018, 08:17:50 PM
I found a tutorial for fixing PS4 on pfSense NAT, and after I did that now my games dont lag anymore  :thumbsup:

Now I can also start working on my PoC testing
Title: Re: Lat Trick Bot
Post by: AHB on May 16, 2018, 08:53:41 PM
@iL @tupac @Igognito

oh shit it works!!!!!

UDP hole punching for the win, check this out for proof (notice "your port is closed", but abcde joined my game):

https://ibb.co/hAiOrJ


Here is my simple PoC code in Python (will be updated as we work out next steps)

import socket
import time

# Target host is IP of player you want to be able to join your game
target_host = "1.1.1.1"
target_port = 6112

# create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.bind(('0.0.0.0', 6112))

# send some data
while True:
   client.sendto("AAABBBCCC",(target_host, target_port))
   time.sleep(1)
   print "Sent some data"

Title: Re: Lat Trick Bot
Post by: tupac on May 16, 2018, 09:58:49 PM
@iL @tupac @Igognito

oh shit it works!!!!!

UDP hole punching for the win, check this out for proof (notice "your port is closed", but abcde joined my game):

https://ibb.co/hAiOrJ


Here is my simple PoC code in Python (will be updated as we work out next steps)

import socket
import time

# Target host is IP of player you want to be able to join your game
target_host = "1.1.1.1"
target_port = 6112

# create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.bind(('0.0.0.0', 6112))

# send some data
while True:
   client.sendto("AAABBBCCC",(target_host, target_port))
   time.sleep(1)
   print "Sent some data"


LOL archer just fucking owned hosting. GG no re!
Title: Re: Lat Trick Bot
Post by: tupac on May 16, 2018, 10:02:04 PM
No point in encrypting the IP address... anyone can sniff it while hosting or joining a game.
Not for those who just idle in chat with no games playing.

BTW, if you join the game, can anybody get your ip not being joined to that game?
You can get the hosts Ip even if you didn't join the game. That's how I got blids IP LOL! One of the old bot I used allows you to see the IP of the host without joining I don't even have to sniff it.
Title: Re: Lat Trick Bot
Post by: iL on May 17, 2018, 06:51:35 AM
oh shit it works!!!!!
Good job! Did you start that script after start the game or before it? I mean, if you start the game it uses that UDP socket, will your script be able to use the same socket on the same computer when it's being already used?

I'll try to start such tests when i have time for that, still too busy last evenings...


I really think we can make this work for most NATs!
Most likely we can. I'm just not sure about symmetric nat, maybe that will work for it also, not sure. But for others - should work fine.

You can get the hosts Ip even if you didn't join the game. That's how I got blids IP LOL! One of the old bot I used allows you to see the IP of the host without joining I don't even have to sniff it.
Sure, i see, you don't need to join the game to know IP of the host. And what about IPs of those who join? I should join the game to know their IPs or what?
That inter-player connections is another big and interesting part to understanding. Who is the host (or the main player), who becomes the main when host leaves the game, etc. Maybe we can change that default behavior? That's offtopic here, but also could be interesting questions for future research.
Title: Re: Lat Trick Bot
Post by: AHB on May 17, 2018, 08:38:45 AM
@iL

Yes it works while the game is running, even though it "binds" to the same port. I was wondering the same things - how could two programs bind to one port? but works just fine. I would bet it wouldn't be able to receive data back on that port since it is in use by war2, but we don't need it to receive anyway, only send

I will put up a fake JSON page at war2.info with the info I would need from the server, and begin programming the next steps:

Here is how the program will work

1. Download list of player IPs and ports from HTTP/JSON at war2.ru
2. Request from STUN server to determine external IP, NAT Type
3. Use external IP from STUN request to determine which player I am in the HTTP/JSON list from step 1
4. Bind UDP source to my War2 port # which was discovered in step 3 (this could be 6112, 6113 or whatever, PvPGN will know and tell me)
5. Ping server.war2.ru, backup.war2.ru, server.war2.me, backup.war2.me to get IPs of all servers (will use this to send UDP traffic to them to so that players dont get "port closed" message)
6. Send HTTP/POST to war2.ru with my NAT type, this way we can record and track the percentage of players with "fixable" NAT versus percentage with symmetric NAT
7. If NAT type does not equal symmetric, tthen begin sending periodic UDP traffic to all players in a never ending (until program quits) loop.
8. Periodically will need to refresh the list of IPs in step #1 also

thats it
Title: Re: Lat Trick Bot
Post by: iL on May 17, 2018, 09:05:15 AM
thats it
Looks reasonable.
I small moment: you can get you war2 port as Game Data Port registry parameter (is an integer value). So you don't need stun for that, only for collecting statistics for future.
Title: Re: Lat Trick Bot
Post by: Igognito on May 17, 2018, 09:21:41 AM
@AHB, Great Work!
Title: Re: Lat Trick Bot
Post by: AHB on May 17, 2018, 12:17:07 PM
Ok here is the whole entire thing:

Overview:
- Python client (to be compiled and started with War2Combat)
- PHP and MySQL to save NAT stats (nat_stats.php)
- JSON sample of player IP listing (player_ips.php)

Some Notes:
- nat_stats.php only saves one stat per IP address, and never updates it (unless the row is deleted, then it would update)
- All MySQL queries are sanitized using PDO to bind params
- The python client checks STUN and if it gets symmetric, it quits. Else it will download IPs from website and then send UDP to each of them from its game port which it gets from registry. After blasting every IP with a small UDP packet, it waits 10 seconds then repeats


@iL its up to you now!

Install Instructions:

1. Setup player_ips.php (see source below)
- You will have to populate it with real player IPs, preferably in the format that I gave so that we don't have to change the Python code
- Also, you should have it output all server IPs as well - server.war2.ru, backup that way the server will not send the "port closed" message

2. Create MySQL table for nat_stats.php (see source below)
- I gave you the SQL to run to create the table

3. Add nat_stats.php to war2.ru server (source below)
- You will need to update the username, password, and database name, everything else should be good

4. Update Python script and change the 2 links to war2.info, replace with war2.ru

5.Compile the Python to EXE:
- Download Python 2.7 https://www.python.org/downloads/ (https://www.python.org/downloads/)
- Install pip (package manager) https://pip.pypa.io/en/stable/installing/ (https://pip.pypa.io/en/stable/installing/)
- Install libraries used:
- C:\Python27\Scripts\pip.exe install requests
- C:\Python27\Scripts\pip.exe install pystun
- C:\Python27\Scripts\pip.exe install json
- C:\Python27\Scripts\pip.exe install time
- C:\Python27\Scripts\pip.exe install _winreg
- C:\Python27\Scripts\pip.exe install socket
- (some of these might have already shipped with Python, I forget)
- C:\Python27\Scripts\pip.exe install pyinstaller
Compile to EXE:
- C:\Python27\python.exe udp_hole_punch.py
- EXE will be saved to dist/udp_hole_punch/udp_hole_punch.exe

6. Add new Python EXE to War2Combat and ship the update

7. Profit
- Hosting fixed :D
Python UDP hole punch client -- this can be compiled to EXE and started with War2Combat:

import _winreg
import stun
import requests
import socket
import time
import json

def get_war2_port():
    # Open the key and return the handle object
    hKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\Battle.net\Configuration")
    # Read the value
    try:
      result = _winreg.QueryValueEx(hKey, "Game Data Port")
    # If not found, set to default
    except Exception as e:
      print e
      result = [6112]
    # Return port
    return result[0]

war2_port = get_war2_port()
nat_type, external_ip, external_port = stun.get_ip_info("0.0.0.0", war2_port)
req = requests.get('https://war2.info/nat_stats.php?nat_type=' (https://war2.info/nat_stats.php?nat_type=') + str(nat_type))

if nat_type != "Sytmmetric NAT":
  while True:
    time.sleep(10)
    req = requests.get('https://war2.info/player_ips.php' (https://war2.info/player_ips.php'))
    json_obj = json.loads(req.content)
    player_ip_list = json_obj["player_ips"]
    print player_ip_list
    for player_ip in player_ip_list:
      # Target host is IP of player you want to be able to join your game
      target_host = player_ip

      # create a socket object
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_port))

      # send some data
      client.sendto("For the Alliance", (target_host, war2_port))
      print "Sent data to " + str(player_ip) + " on port " + str(war2_port)




player_ips.php

<?php
// iL, you will have to populate this with actual player IPs for each page load
echo '{"player_ips": ["1.1.1.1", "2.2.2.2", "3.3.3.3"]}';
?>



Create nat_stats table for nat_stats.php, run this SQL:

CREATE TABLE nat_stats (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
ip_address VARCHAR(30) NOT NULL,
nat_type VARCHAR(30) NOT NULL
)




nat_stats.php source:




<?php
$ip_address = $_SERVER['REMOTE_ADDR'];
$nat_type = $_GET["nat_type"];

$servername = "localhost";
$username = "user";
$password = "pass!";
$dbname = "db";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $stmt = $conn->prepare("SELECT * FROM nat_stats WHERE ip_address = :ip_address");
    $stmt->bindParam(':ip_address', $ip_address);
    $stmt->execute();

    // set the resulting array to associative
    $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
    $row = $stmt->fetch();
    $previous_nat_type = $row["nat_type"];
}
catch(PDOException $e) {
    echo "Error: " . $e->getMessage();
}
$conn = null;

// If we have never seen this IP before, save it in the database
if (isset($previous_nat_type)) {
    echo "NAT Type already saved for this IP";
} else {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $stmt = $conn->prepare("INSERT INTO nat_stats(ip_address, nat_type)
    VALUES(:ip_address, :nat_type)");
    $stmt->bindParam(':ip_address', $ip_address);
    $stmt->bindParam(':nat_type', $nat_type);
    $stmt->execute();
    $conn = null;
    echo "Saved NAT Type";
}

?>
Title: Re: Lat Trick Bot
Post by: AHB on May 17, 2018, 02:53:53 PM
Scaling up and Memory usage:

I tested memory consumption with doing this if there were 10,000 players online, and it was fine --

About 1MB memory usage (+12MB which is the Python interpreter, so 13MB), and 0-5% CPU.

Network traffic also is tiny since its just a little UDP packet with 3 words in it.

The only problem was I got an IOError which crashed it, due to printing that many times to the console, so we want to remove the "print" statements before shipping this which fixed the error

But from my testing I think this will work for our tiny server as well as larger pvpgn servers with thousands of players.
Title: Re: Lat Trick Bot
Post by: Lambchops on May 18, 2018, 09:23:13 AM
This all seems pretty complicated, I kind of scanned it.

If you want to do it with this kind of "mass spamming" approach you need 2 things.

1) Server side you need some simple server that will supply a list of currently connected ip addresses:game ports. Nothing else.

2) Client side for the hosting player only, you need some code that gets this list from the server, then sends out a packet or two to every ip address on the list using their game port.

That is all.
Title: Re: Lat Trick Bot
Post by: AHB on May 18, 2018, 09:31:57 AM
@Lambchops

uhhh yeah thats exactly what it does actually lol! ... its not too complicated

3 parts:

1. Python client (runs on client machine who wants to host) - downloads list of IPs and sends UDP traffic to them

you dont need to know the port the other players have for their war2 client, all that matters is that you source the traffic from your own war2 port. This creates an entry in your router that will allow that other players IP to communicate back to you on your war2 port

2. player_ips.php - provides player IPs to Python client
3. nat_stats.php - this is for us to track what types of NAT people are behind because the Python client doesnt work for Symmetric NAT so we are curious to see how many people are actually behind an unfixable Symmetric NAT
Title: Re: Lat Trick Bot
Post by: Lambchops on May 18, 2018, 12:19:50 PM
@Lambchops

uhhh yeah thats exactly what it does actually lol! ... its not too complicated

3 parts:

1. Python client (runs on client machine who wants to host) - downloads list of IPs and sends UDP traffic to them

you dont need to know the port the other players have for their war2 client, all that matters is that you source the traffic from your own war2 port. This creates an entry in your router that will allow that other players IP to communicate back to you on your war2 port

2. player_ips.php - provides player IPs to Python client
3. nat_stats.php - this is for us to track what types of NAT people are behind because the Python client doesnt work for Symmetric NAT so we are curious to see how many people are actually behind an unfixable Symmetric NAT

Ok. Cool.

IDK how any language could not accomplish such a simple task.

I'm quite sure it could be done in python, its a very robust language, perhaps not with the library you want to use. Why not just do it with networking primatives?. This task does not require any fancy network programming at all... also I cant imagine why you would want to use python there are a lot of better options.

I presume you are talking about a complied executable? Personally I do not wish to install python on my machine to run scripts, and most certainly would NOT be running anything that allowed you to collect stats because you are curious behind my firewall. Sorry, but no thank you.
Title: Re: Lat Trick Bot
Post by: AHB on May 18, 2018, 12:33:51 PM
@Lambchops


Sure you could rewrite it with network primitives, whatever language you want, doesnt matter but why would you? You can write it in assembly if you want. But why stop there when you can write machine code for each specific cpu architecture? Python with sockets library is just fine.

It would be compiled to EXE by @iL and shipped with War2Combat as part of autoloader so would start automatically in the background each time war2 starts

It would only collect the NAT type from players that is it... and if you are using War2Combat its already gathering shit from your PC for use for hardware ban, scanning your memory for antihack program and reporting to the server. Nothing malicious that I know of. Dont believe me just do a packet capture next time u start up
Title: Re: Lat Trick Bot
Post by: Lambchops on May 19, 2018, 06:36:40 AM
@Lambchops
Sure you could rewrite it with network primitives, whatever language you want, doesnt matter but why would you? You can write it in assembly if you want. But why stop there when you can write machine code for each specific cpu architecture? Python with sockets library is just fine.

umm.. you were the one who said there was a problem with your python client.

I was suggesting making it simpler not more complex.

"machine code for each specific cpu architecture" are you tripping on peyote right now?


Anyway, if you are willing to do this and you can get iL to help you server side, then cool - when you get it working there are more games hosted. This is a good thing, I would like to see it happen regardless of whether or not I choose to use it.

Any HLL actually adds complexity as a direct consequence of making it appear simpler to the user. AFAIK war2, ce, and the autoloader are all C++ programs (compiled into ML of course). I have no idea why you would want to complicate things by throwing python in the middle, but if that is the way you know how to do it, and you are willing to put in the time to do it then go for it.


I do know there is absolutely no reason for you to introduce an SQL login, however you seem to have contrived a reason anyway. When you remove all reference to this from your code I will be a lot less sceptical about your intentions.


you dont need to know the port the other players have for their war2 client, all that matters is that you source the traffic from your own war2 port.

Have you considered that this is the source of your NAT problems? You are only considering the local routing table for the host, not the address translation for the joining client.

I'm not a NAT expert, but we do know that ANYONE who can join a game can successfully hole-punch regardless of the intervening protocols. That is proven every time they join a game. Just use the right port number, it's only 2 bytes, pretty sure that wont blow your budget  ;)


And quite honestly: if you do just want to do this, but you have just got it a bit muddled up, then PM or discord me and I'll give you what advice I can.

Title: Re: Lat Trick Bot
Post by: AHB on May 19, 2018, 10:11:48 AM
No there is no problem with the Python client, Ive already tested and it works :D :D :D

The only problem is that UDP hole punching doesnt work when behind certain type of NAT, but it is a less common type (we think) so it shouldnt be a problem. But because of that, the Python code checks what type of NAT and doesnt run if it finds that it is a type of NAT that wont work. It also sends simple ping to a PHP script to record what type of NAT so that we can find out if the script is actually helping people or if they are all behind the type of NAT that doesnt work

This program could easily be rewritten in C++, it would just take me a few more hours so I dont feel like it... the "performance boost" isnt worth it when you are talking about a tiny simple program

The Python code already works perfectly... and I even gave all the instructions to compile to exe (its one simple command)

The SQL login needs to be changed by iL to his own username, password, and database, nothing "strange" there. It is simply used to record the stats from the NAT type collector

I wasnt a NAT expert last week but I can honestly say I am basically an expert now. I spent probably a dozen hours reading about the different types of NAT and how they work, so I know exactly why this works for the types of NAT that it does work for, and exactly why it doesnt work for Symmetric NAT type
Title: Re: Lat Trick Bot
Post by: AHB on May 19, 2018, 10:33:35 AM
This was just a crazy idea a month ago :D

http://forum.war2.ru/index.php/topic,4009.0.html (http://forum.war2.ru/index.php/topic,4009.0.html)
Title: Re: Lat Trick Bot
Post by: Lambchops on May 19, 2018, 11:25:32 AM
No there is no problem with the Python client, Ive already tested and it works :D :D :D



the Python client doesnt work for Symmetric NAT so we are curious to see how many people are actually behind an unfixable Symmetric NAT

The only problem is that UDP hole punching doesnt work when behind certain type of NAT,

Much as I would hate to upset your newly achieved expert status, UDP hole punching absolutely works for every single person on the server, regardless of the network protocols in use. If it didn't nobody could join a game. If you can join a game, you can punch a hole.

You are telling me your python client doesn't work, so I believe you, however your assumption that this is because "hole punching doesn't work" seems about as likely as anyone becoming an expert on anything because they read a few articles online last week ;)

but it is a less common type (we think) so it shouldnt be a problem. But because of that, the Python code checks what type of NAT and doesnt run if it finds that it is a type of NAT that wont work. It also sends simple ping to a PHP script to record what type of NAT so that we can find out if the script is actually helping people or if they are all behind the type of NAT that doesnt work

This program could easily be rewritten in C++, it would just take me a few more hours so I dont feel like it... the "performance boost" isnt worth it when you are talking about a tiny simple program

What "performance boost" are you quoting there? I can't see there being any relevant performance boost regardless of the language.

The Python code already works perfectly... and I even gave all the instructions to compile to exe (its one simple command)

Perfectly? I thought you said it was failing with some types of NAT. Isn't that the whole point of this and why you want iL to install a SQL db to collect your curiosity information?

The SQL login needs to be changed by iL to his own username, password, and database, nothing "strange" there. It is simply used to record the stats from the NAT type collector

Oh so YOU don't get a login so you can have SQL access to the DB on the server?.... Whatever, I really don't care, I just wish that once in a while somebody would make some software without trying to back-door data for themselves... oh but its all just friendly white-hat data ... who are you, Google? I don't like it when they do it either.

You don't need to, you just want to. It has nothing to do with hosting and everything to do with you collecting data.

Also I don't actually know who you are Mr "AHB" but I certainly hope that iL has good reason to trust you before he gives you SQL access to his server.

I wasnt a NAT expert last week but I can honestly say I am basically an expert now. I spent probably a dozen hours reading about the different types of NAT and how they work, so I know exactly why this works for the types of NAT that it does work for, and exactly why it doesnt work for Symmetric NAT type


You really should be paying more attention, or are you just being deliberatly obtuce so that you have an excuse to do what you want to? Please supply you "expert" explaination of how people can join games if hole punching doesn't work?

War2 games are peer-to-peer UDP. Unless you have correctly configured your routing/NAT ( in which case you would be able to host anyway ) then the ONLY way people can play games is via hole-punching. All day, every day.

So either you really don't have a clue what you are talking about, or you are hoping that nobody will understand the nerd-speak so you can do whatever it is that you want to do.

Title: Re: Lat Trick Bot
Post by: AHB on May 19, 2018, 01:09:02 PM
@Lambchops

man you talk tooooo much dude. Its really simple and Ive already explained how it works too many times...

@iL understood exactly what it does, and thats all that matters. If he has any questions I will explain further


Put simply UDP hole punching 6112 to allow player to host games works like this - PlayerA downloads list of IPs of all players on the server and sends UDP traffic on 6112 to each of them. In most types of NAT this will open port 6112 to allow responses back only from those IPs.

You seem to misunderstand that this is not a "concept" anymore, it is a "proof of concept", i have proved that it works. It is not up for debate, I dont need help or advice lol


But youre right, I'm just an idiot.

I don't have any understanding of how it works - TCP/IP,  UDP, programming, databases, MySQL/PHP/Python, types of NAT/difference between them, I'm no expert, I'm just the guy who solved a 20+ year old hosting problem after an entire month of dedicated research, trial and error.

Did you really think we all need you to explain how these things work to us? I enjoy some of your posts, but damn you can ramble.

There are alot of us here who are experts in our fields, - programming, network engineering, server ops, @iL @mousEtopher @tupac @{Lance} to name a few and we dont need you to explain all the mysteries of how computers work to us lmao

We all argue sometimes but try to show some respect for each other and put ego aside to further development here which is just a hobby we all do for fun

I hardly even play War2 anymore, and I know how to port forward, so I really dont care if you guys dont implement this, its just for the good of others and the game as a whole. I plan to help some other PvPGN servers implement it too since it solves hosting for all games not just War2
Title: Re: Lat Trick Bot
Post by: Lambchops on May 20, 2018, 10:14:47 AM
man you talk tooooo much dude. Its really simple and Ive already explained how it works too many times...

LOL.

I have been explaining how it works to everyone for years.

This is just a re-hashing of what I have already posted EXCEPT you have built in a back door for yourself.

So how about you post your REAL NAME so everyone knows who is getting SQL access to the server.


I'm just the guy who solved a 20+ year old hosting problem after

... after reading the fix that I posted 2 years ago  ;D
Title: Re: Lat Trick Bot
Post by: AHB on May 20, 2018, 02:16:01 PM
Everyone knows me in in real life here, and anyone with a brain can read the code and see there is no backdoor in it...

Keep telling yourself you solved hosting lol congrats to you
Title: Re: Lat Trick Bot
Post by: Lambchops on May 20, 2018, 09:54:49 PM
Everyone knows me in in real life here, and anyone with a brain can read the code and see there is no backdoor in it...

Keep telling yourself you solved hosting lol congrats to you

Inventing a non-existant excuse for you to have SQL access to the server is a back-door.

So who are you then? Who is "everyone"? Where is "here"?

The threads of  me explaining the problem and the solution to your newb ass are all on this forum. HF with your fantasy that you're not a self-promoting script-kiddie.
Title: Re: Lat Trick Bot
Post by: AHB on May 21, 2018, 09:15:52 AM
You do know that the definition of a script kiddie is someone who uses code that other people write, and cant write their own code right?

So by definition I wrote the code, and you know nothing about programming as youve made apparent, so that would make you a script kiddie lol

I know this is really hard for you to understand, but the part of the PHP code where it says "username=username" and "password=password" is intended to be changed by iL to his own credentials which I wont know what they are, so no I dont have SQL access. Sorry no time to keep explaining how these basic things work.
Title: Re: Lat Trick Bot
Post by: tupac on May 21, 2018, 07:03:18 PM
@AHB @Lambchops

LambChops is our guru, archer is a security expert. I'm friends with you both! We can't let little stuff allow us to destroy ourselves.

We have way too much power together. I see this is a project you both can accomplish together. We can give iL a time limit to install the host fix or we all split up and do our own sever. My bots has been recording everyone stats and etc. Its would be easy to convert all that into my server. I've been working on testing the newest pvpgn with the pvpgn pro people. I had them fix a bug inwhich didn't allow war2 to connect at all. I have designed a php page to allow people to choose icons and create colorful names, and much much more. This version of war2 is highly customized like auto heal, new spells and units. Thanks to @easycompany And Lambchops! There is so much in store for war2. We all need to work together or you all are comming with me.
Title: Re: Lat Trick Bot
Post by: Lambchops on May 22, 2018, 10:45:18 AM
You do know that the definition of a script kiddie is someone who uses code that other people write, and cant write their own code right?

So by definition I wrote the code, and you know nothing about programming as youve made apparent, so that would make you a script kiddie lol

I know this is really hard for you to understand, but the part of the PHP code where it says "username=username" and "password=password" is intended to be changed by iL to his own credentials which I wont know what they are, so no I dont have SQL access. Sorry no time to keep explaining how these basic things work.


Every time you dodge questions, and answer unasked ones just further proves your dishonest intentions.

So you are doing backfilps to include this unnecessary data collection yet you are NOT trying to get access to the results? ROTF ;D

You claim to be a SQL expert yet you pretend that giving you SQL access doesn't open up the sever and everyone's personal data to a range of potential attacks. "Everyone" knows you have already devoted a lot of time to DDOS attacking the server and stealing personal information.

I call bullshit. So just get rid of your little unneeded SQL db, you're not fooling anyone.

@iL if you want to use this approach, just impliment it yourself without the lame hacker's code - you don't need him.
Title: Re: Lat Trick Bot
Post by: AHB on May 22, 2018, 09:47:25 PM
dude you need to chill Mr., read a Berk on how the internets work, U cant get sql access when u give someone some code that filteRs sql injection and the db username and password are changed before being uploaded ... oK?

bEsides the nat stats arent even a necessary component of the program so take it or leave it who cares. you already gave access to install war2combat in your pc so you should know we know much more than just your nat type lmao jeez quit trippin. no need for the nasty Gram
Title: Re: Lat Trick Bot
Post by: tupac on May 23, 2018, 07:24:02 PM
Yall DON'T forgot tupac brought the port changing option to the Warcraft 2 communities attention.
Title: Re: Lat Trick Bot
Post by: AHB on May 23, 2018, 09:44:13 PM
Nice work tupac
Title: Re: Lat Trick Bot
Post by: tupac on May 23, 2018, 10:19:31 PM
Nice work tupac
I actually found it on a StarCraft site and said i bet it works here and it did yay!
Title: Re: Lat Trick Bot
Post by: Lambchops on May 24, 2018, 01:41:13 PM
BAHAHAHAHA

The little noob has put parts of my email address in his post LOLOLOL That's what all the weird capitol letters are in his last post.

ooooo scary, what are you going to do phishing scam me?

Everybody already knows you pulled the SQL db from the server years ago. Then you got locked out because you bragged about it like the little wannabe script kiddie that you are and now you're trying to scam your way back in.

Are you actually trying to threaten me with my email address? ;D ROTF


the nat stats arent even a necessary component of the program so take it or leave it.

DUH. My point EXACTLY. So leave it.

you should know we know much more than just your nat type lmao jeez quit trippin. no need for the nasty Gram

Who is "we"?  .... you and your mom?

Point proven - this guy is a complete dick.
Title: Re: Lat Trick Bot
Post by: iL on May 24, 2018, 05:13:50 PM
Ok here is the whole entire thing:
tried that, looks like not working as is.

nat_type, external_ip, external_port = stun.get_ip_info("0.0.0.0", war2_port)
Not working after you join bnet (returns "blocked").
You should check that before join bnet, then it's fine.
Not a big deal now.

And the big problem:
      # create a socket object
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_port))

      # send some data
      client.sendto("For the Alliance", (target_host, war2_port))
      print "Sent data to " + str(player_ip) + " on port " + str(war2_port)
causes disconnect after i join the game, build TH and then building the farm or barracks (checked twice).
I still didn't try to host the game as i didn't get real list of ips.

My player_ips.php is: {"player_ips": ["45.33.94.234", "2.2.2.2", "3.3.3.3"]}

I think my router becomes confused about too many outgoing UDP from the same port to different addresses or w/e.

Also, i changed Game Data Port to 6113 to not reconfigure nat redirections on my router. Here's my code then:
Code: [Select]
war2_client_port = 6113
war2_remote_port = 6112
...
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_client_port))
      client.sendto("For the Alliance", (target_host, war2_remote_port))
Title: Re: Lat Trick Bot
Post by: Lambchops on May 24, 2018, 07:10:06 PM
Ok here is the whole entire thing:
tried that, looks like not working as is.

nat_type, external_ip, external_port = stun.get_ip_info("0.0.0.0", war2_port)
Not working after you join bnet (returns "blocked").
You should check that before join bnet, then it's fine.
Not a big deal now.

And the big problem:
      # create a socket object
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_port))

      # send some data
      client.sendto("For the Alliance", (target_host, war2_port))
      print "Sent data to " + str(player_ip) + " on port " + str(war2_port)
causes disconnect after i join the game, build TH and then building the farm or barracks (checked twice).
I still didn't try to host the game as i didn't get real list of ips.

My player_ips.php is: {"player_ips": ["45.33.94.234", "2.2.2.2", "3.3.3.3"]}

I think my router becomes confused about too many outgoing UDP from the same port to different addresses or w/e.

Also, i changed Game Data Port to 6113 to not reconfigure nat redirections on my router. Here's my code then:
Code: [Select]
war2_client_port = 6113
war2_remote_port = 6112
...
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_client_port))
      client.sendto("For the Alliance", (target_host, war2_remote_port))

It is very simple.

WC2 worked before NAT. WC2 works over NAT. There is no problem there.
You don't need STUN. This is just the noob getting excited about stuff he read online that he doesn't actually understand.

You don't need to reverse the NAT address translation, just allow NAT to function the way it is designed.

You only need to send packets from host before game starts.

You only need to send packets to people in the channel.

That is all.
Title: Re: Lat Trick Bot
Post by: AHB on May 24, 2018, 07:29:56 PM
@iL

Thanks for checking it out! I know we are close. Just ignore @Lambchops hes a dumbass

I think I see your problem ! I think it is because you are sending traffic to the REMOTE port. The "remote port" variable should actually be your LOCAL port, not remote port.

I know its confusing but there is a reason -- you need to send traffic to the remote host:local port, that way the connection is opened for the remote host to reply on your LOCAL port. They dont need to reply on their own port. Also, the traffic we are sending them we dont care that they dont ever receive it, we are just tricking out own firewall (not theirs) make sense? Try again with that and let me know if it works

Like this

war2_client_port = 6113
# war2_remote_port = 6112 -- this is not needed at all
...
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_client_port))
      client.sendto("For the Alliance", (target_host, war2_client_port))

Title: Re: Lat Trick Bot
Post by: iL on May 25, 2018, 04:29:14 AM
You don't need STUN. This is just the noob getting excited about stuff he read online that he doesn't actually understand.
Of course STUN is not something necessary, it's just an option to check the NAT type. Not a big deal as i said.

You don't need to reverse the NAT address translation, just allow NAT to function the way it is designed.

You only need to send packets from host before game starts.

You only need to send packets to people in the channel.
That will be a plan for future, as a 1-st step it's easier to send packets all the time.

And it causes disconnect, no idea why, but that's unacceptable behavior even if i sent them in wrong time and to wrong ips.

I think I see your problem ! I think it is because you are sending traffic to the REMOTE port. The "remote port" variable should actually be your LOCAL port, not remote port.

I know its confusing but there is a reason -- you need to send traffic to the remote host:local port, that way the connection is opened for the remote host to reply on your LOCAL port. They dont need to reply on their own port. Also, the traffic we are sending them we dont care that they dont ever receive it, we are just tricking out own firewall (not theirs) make sense? Try again with that and let me know if it works
I didn't understan your logic, well:
my Game Data Port is 6113, your Game Data Port is 6112, my external ip is 1.1.1.1, your external ip is 2.2.2.2
I host the game behind NAT on my local computer internal ip 192.168.1.1:6113, i need to make you connect from your 2.2.2.2:6112 to my 1.1.1.1:6113.
How to do that? I apply lat trick: send UDP packet to the opposite side: from my 192.168.1.1:6113 to 2.2.2.2:6112, right?
Then my (full cone) NAT translates it: you receive packet from my 1.1.1.1:6113 to 2.2.2.2:6112. Also my router keeps temporary rule: to wait answers to that packet.
When you try to connect from your 2.2.2.2:6112 to my 1.1.1.1:6113, my router thinks it's the answer to that packet and NAT's it to my internal host: 192.168.1.1:6113, right?

So, you offer to send packet from my 192.168.1.1:6113 to your 2.2.2.2:6113? Though your client listens on 2.2.2.2:6112? Looks senseless for me.

Another idea:
We open the socket:  client.bind(('0.0.0.0', war2_client_port))
Also, war2 client opens the same socket.

Who will receive packets incoming to war2_client_port? Our script or war2? Who will be more lucky?
Maybe we should close our socket right after we sent our packets?
What do you think about that?

Not a guarantee (as we can get packets while sending packets), but should become much better as for me.
Code: [Select]
...
      client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      client.bind(('0.0.0.0', war2_client_port))
      client.sendto("For the Alliance", (target_host, war2_remote_port))
      client.close() # or how to write that on python, i don't know it's syntax

UPDATE:
just got that:
Socket close is not closing the socket immediately or something like that, it goes into the TIME_WAIT instead: https://stackoverflow.com/questions/22549044/why-is-port-not-immediately-released-after-the-socket-closes
They say about SO_REUSEADDR, but that is not we need. Our task is not to catch even sinlge packet destined to war2.
How to do that? I'm not so good in network technologies. I'd say the proper way is to inject into war2 network functions. Or probably to listen our Game Data Port and copy all these traffic to war2 process (also, how to do that?)
UPDATE2:
additional info:
socket abort should guarantee to free the socket immediately. Depends on OS/language. Sometimes you have to set "linger off" or w/e and then repeat close.
Not sure if it's actual for UDP, maybe for TCP only.

Anyways, we have to control every socket function succeeded. In our situation you can never be sure your client.bind or sendto succeeded.
@AHB, can you add checking all the possible return errors in your code?
Something like:
Code: [Select]
      try:
        client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
      except Exception as e:
        print e
      try:
        client.bind(('0.0.0.0', war2_client_port))
      except Exception as e:
        print e
Fix the code plz, i'm not good in programming and don't know python at all.
Title: Re: Lat Trick Bot
Post by: iL on May 25, 2018, 05:03:57 AM
One more: i didn't try to host the game from internal ip behind NAT. What i just tried is to join and play the game from NAT'ed network.
Usually i can't host with closed ports, but i can join and play.
When i tried to join and play after running udp_hole_punch.exe, i got disconnected after about 1-2 min after game start.
Tried twice.
Then i stopped udp_hole_punch.exe, tried next time, and played successfully.
So, the problem is not related to wrong ports or w/e, it means udp_hole_punch.exe crashes existing connections.
Title: Re: Lat Trick Bot
Post by: AHB on May 25, 2018, 08:57:32 AM
@iL

Your definition of how remote port and local port is correct actually, you are right that is how it works.

So we are able to port forward now, but possibly the problem is that Python is intercepting packets destined for War2 causing the game to disconnect. I will have to think about this...

My first idea is to try changing the "binding" IP address. 0.0.0.0 means to listen on all interfaces, but we don't actually want to listen on any interfaces.. not sure what to do. I will keep testing


I can add error checking so that if a socket fails it keeps trying instead of crashing
Title: Re: Lat Trick Bot
Post by: AHB on May 25, 2018, 09:08:36 AM
@iL

I updated the code below to shutdown and close the socket each time. From what I read, shutdown will fix that TIME_WAIT issue, releasing it immediately.

I also implemented a basic error check, and will skip to the next player in the list if an error occurs instead of crashing out

Let me know if this works for you. I will test also

import _winreg
import stun
import requests
import socket
import time
import json

def get_war2_port():
    # Open the key and return the handle object
    hKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, "Software\Battle.net\Configuration")
    # Read the value
    try:
      result = _winreg.QueryValueEx(hKey, "Game Data Port")
    # If not found, set to default
    except Exception as e:
      print e
      result = [6112]
    # Return port
    return result[0]

war2_port = get_war2_port()
nat_type, external_ip, external_port = stun.get_ip_info("0.0.0.0", war2_port)
req = requests.get('https://war2.info/nat_stats.php?nat_type=' + str(nat_type))

if nat_type != "Sytmmetric NAT":
  while True:
    time.sleep(10)
    req = requests.get('https://war2.info/player_ips.php')
    json_obj = json.loads(req.content)
    player_ip_list = json_obj["player_ips"]
    print player_ip_list
    for player_ip in player_ip_list:
      try:
        # Target host is IP of player you want to be able to join your game
        target_host = player_ip

        # create a socket object
        client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        client.bind(('0.0.0.0', war2_port))

        # send some data
        client.sendto("For the Alliance", (target_host, war2_port))
        client.shutdown()
        client.close()
        print "Sent data to " + str(player_ip) + " on port " + str(war2_port)
      except Exception as e:
        print e

Title: Re: Lat Trick Bot
Post by: iL on May 25, 2018, 10:27:44 AM
My code (with local and remote ports and debug prints):

Code: [Select]
...
    for player_ip in player_ip_list:
      try:
        # Target host is IP of player you want to be able to join your game
        target_host = player_ip

        # create a socket object
        client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        client.bind(('0.0.0.0', war2_client_port))

        # send some data
        client.sendto("For the Alliance", (target_host, war2_remote_port))
        print "Shutting down socket"
        client.shutdown()
        print "Closing socket"
        client.close()
        print "Sent data to " + str(player_ip) + " from port" + str(war2_client_port) + " on port " + str(war2_remote_port)
      except Exception as e:
        print e

Stdout:
Code: [Select]
getting ips
[u'45.33.94.234', u'2.2.2.2', u'3.3.3.3']
Shutting down socket
shutdown() takes exactly one argument (0 given)
[Errno 10048] Обычно разрешается только одно использование адреса сокета (протокол/сетевой адрес/порт)
Shutting down socket
shutdown() takes exactly one argument (0 given)
getting ips
[u'45.33.94.234', u'2.2.2.2', u'3.3.3.3']
[Errno 10048] Обычно разрешается только одно использование адреса сокета (протокол/сетевой адрес/порт)
Shutting down socket
shutdown() takes exactly one argument (0 given)
[Errno 10048] Обычно разрешается только одно использование адреса сокета (протокол/сетевой адрес/порт)
getting ips
[u'45.33.94.234', u'2.2.2.2', u'3.3.3.3']
...
Sorry for russian windows, that means soemting like:
"Usually only 1 usage of socket address allowed (protocol/network address/port)".

No idea what command it related to.
Title: Re: Lat Trick Bot
Post by: AHB on May 25, 2018, 10:32:09 AM
client.shutdown(socket.SHUT_RDWR)

shuts down read and write on the socket
Title: Re: Lat Trick Bot
Post by: iL on May 25, 2018, 10:39:01 AM
client.shutdown(socket.SHUT_RDWR)
Well, no errors now.
I'll check how it will work on the server
Title: Re: Lat Trick Bot
Post by: iL on May 25, 2018, 11:20:36 AM
Adding real list of ips:
1. @AHB, can you update your script to add port to each ip into that json?
like that:
{"player_ips": [{"ip":"1.2.3.4","port":"6112"},{"ip":"5.6.7.8","port":"6112"}]}

2. my stuff becomes to know UDP port only when player hosts the game. Looks like there's no way to know Game Data port from the server side until he hosts the game.
Now let's suppose some fixed value (like 6112 or w/e) for every client.

So, for future, our logic should be more complicated. Looks like we have to read game data port for each client or check the port from hosted game.
Sad, but looks like there's no way to know UDP port for original client with no lat bots even if his ports are fine.

I mean, lets consider:
- i'm good old player with all ports forwarded/configured, i have no problems with hosting games at all. And my port is modified, not 6112. Everything works for me. I don't want to run any additional software on my side.
- you have problems with ports forwarding, you want to use UDP hole punch to host the game.
You have no way to know my Game Data Port if i didn't host the game. You have to enforce me to run some kind of software to send my port to you.
Title: Re: Lat Trick Bot
Post by: AHB on May 25, 2018, 12:01:21 PM
@iL

I dont think we need to know the remote player's port at all, just send from your own port, then your router will hold open the connection from your local port to the external IP and allow a response back from external IP to  your game port

Say remote host has port 6113, but person hosting the game has port 6112:

Host sends a packet to remote-host:6112 (it doesnt know that remote player port is actually 6113)
Hosts router opens a connection and listens for player to respond on port 6112
Player's router receives the packet, sees that it is for port 6112 and not 6113, so it drops it and ignores it
Player's War2 client knows to join the host's game on his port, 6112, because pvpgn told him that
So Player sends traffic to Host on port 6112
Host's router has a connection open to Player already on port 6112, so it allows the response traffic to come through

Do you see that we dont need to know the remote port? Only use the local game port as both the source and destination
Title: Re: Lat Trick Bot
Post by: AHB on May 25, 2018, 12:06:08 PM
The program is already working the way that I described (not knowing the remote port):


This is the code that is sending data to the wrong port for the player, but it should still trick his router to allow that player to join the game :)
 client.sendto("For the Alliance", (target_host, war2_port))
Title: Re: Lat Trick Bot
Post by: Lambchops on May 25, 2018, 07:40:05 PM
That will be a plan for future, as a 1-st step it's easier to send packets all the time.

And it causes disconnect, no idea why, but that's unacceptable behavior even if i sent them in wrong time and to wrong ips

This is actually a good sign. Causing the disconnect means that the packets are ending up where they should be... --> they are going to the WC2 client.

Of course at this point what you are making is a disc-bot, because you are sending the client rubbish packets - in this case "For the Alliance" which is clearly causing a problem for the client.

I discussed this in September 2016 when I first posted this solution:
The packets can be anything. Null packets would probably work fine, whatever, as long as it doesn't crash the client with garbage, its all good. We have then done our “lat trick” between the host and the joining client which is the only one not already being done. End of hosting issues forever. GG

I can quite easily help you with code that will let you detect when the client is hosting a game, and not in the channel or in game, that is very simple.

It will be up to you to make sure that your address list has ONLY the players in the channel, not those in games, otherwise you could possibly disconnect other people playing or contribute to game lag.

Sending out packets all the time to everyone is a bad idea, for a lot of reasons, not the least of which is that you are opening up your own firewall to everyone on the server for no reason. People could drop-hack you from games while they are in the channel or worse.

-- edit --

Do you see that we dont need to know the remote port? Only use the local game port as both the source and destination

Which is the reason you can't get it to work through symmetric NAT. Why not just do it properly?


I think just standard 'socket' 'connect' and 'sendto' etc. should do it for anything I've been talking about..

I'm a bit busy working on another project right now, but when I get some spare time I'll fix it for you if the 'expert' hasn't worked it out by then ;)
Title: Re: Lat Trick Bot
Post by: Lambchops on May 25, 2018, 08:21:14 PM
@iL

Your definition of how remote port and local port is correct actually, you are right that is how it works.

So we are able to port forward now, but possibly the problem is that Python is intercepting packets destined for War2 causing the game to disconnect. I will have to think about this...

My first idea is to try changing the "binding" IP address. 0.0.0.0 means to listen on all interfaces, but we don't actually want to listen on any interfaces.. not sure what to do. I will keep testing


I can add error checking so that if a socket fails it keeps trying instead of crashing

@AHB

Dear noob. You are not listening on any interfaces. That would require using the 'listen()' API ;D

The reason the person that you copied this code from used bind(0.0.0.0,port) is to associate the local port number with the socket, while sendto() sets the remote port...

Have you worked out what you copy/pasted yet?  #GodlyExpert  #ROTF


Title: Re: Lat Trick Bot
Post by: Lambchops on May 26, 2018, 12:07:48 AM
@iL

Shouldn't really be spending time on this, but here's a quick dll to help.

it exports 2 functions
Code: [Select]
BOOL hosting(void)
returns TRUE if local player is host and in pre-game lobby.

BOOL send_packet(CHAR* addr, int local_port, int remote_port)
sends your "For The Alliance" packet.

this way you can do something like:

Code: [Select]
if(hosting()){
    send_packet("111.222.3.44",6112,6114);
}


Havn't thoroughly tested it yet but it should work ok I think.

I can PM you the C++ source code if you want. (don't want to post it here or scrubs might use it to make hacks).


Title: Re: Lat Trick Bot
Post by: AHB on May 26, 2018, 11:34:27 AM
@Lambchops once again you talk way too much and neither of us have time to keep reading your meaningless replies while we are solving hosting

You "knew" the solution 2 years ago yet never programmed it. Why? Because either you dont actually understand the solution or you don;t know how to program. Probably both.

Why dont you quick talking and go set up a pvpgn server, write the proof of concept, and actually do something useful? Oh wait because you cant. You cant even write psuedo code lol that is a joke

If we want to only send packets to people in channels, that is easy to do. I would just add a few lines to make a request to the server status page and parse it out. The only problem with that is that we would have to tie IP addresses to usernames which isnt exactly desirable, so if we can find a way to not do it that way, it would be better. One solution would be to have iL rewrite player_ips.php to only output IP Addresses of players who in a channel, but that would be some work on the backend that I'm not sure he has time for at the moment

But dont worry about it iL and I have it covered
Title: Re: Lat Trick Bot
Post by: Lambchops on May 26, 2018, 02:49:05 PM
You "knew" the solution 2 years ago yet never programmed it. Why?


Because I didn't have time to do it properly and wouldn't bother using a crappy mass-spamming approach like the one you are attempting to use. I did discuss this approach and why it was not a good idea. All of this is published on this forum, as I'm sure you know.

You could just say "thanks" when I yet again explain things or fix stuff for you (no charge).

Seriously grow up.

Try this:

(http://forum.war2.ru/index.php?action=dlattach;topic=4069.0;attach=2269)


You know I would actually help you a lot more.
Title: Re: Lat Trick Bot
Post by: Lambchops on May 26, 2018, 03:02:07 PM
One solution would be to have iL rewrite player_ips.php to only output IP Addresses of players who in a channel

Yes this is what I just said on this page, it has to happen. The client side of the problem I have already coded for you in the dll above. Excatly who do you think you're convincing?.... I doubt your mom reads this forum ;D
Title: Re: Lat Trick Bot
Post by: AHB on May 26, 2018, 04:16:12 PM
Actually wrong, I came up with it on my own while hacking an IP camera and that is how I learned about UDP hole punching and was the inspiration for the program:

http://forum.war2.ru/index.php/topic,4009.0.html (http://forum.war2.ru/index.php/topic,4009.0.html)

but nice try

By the way here was your response saying it is impossible:

"""There are many ways this could be accomplished, but they all involve some reasonably tricky mods and/or additions to the wc2 exe... one day maybe...""""

"one day maybe" well guess that day is today thanks to my dedicated research and terrible programming skills, neat huh?
Title: Re: Lat Trick Bot
Post by: Lambchops on May 26, 2018, 05:45:47 PM
Actually wrong, I came up with it on my own while hacking an IP camera and that is how I learned about UDP hole punching and... blah blah

LOL. Bullshit

That exact link you just quoted is you making one post about STUN because you found an article about it online, so I replied to your post and explained why it wouldn't work, what had to be done to make it work, and even posted a link to my original thread supplying pages of detailed explainations about the entire thing.

 .... then you went away for a month and came back saying you had just spent a month becoming an "expert" by researching it online. But you never noticed anything I posted and just "came up with it"?

Next you make this post with some shitty snippets of code that you have copy/pasted that you don't even understand, the only thing you do understand is that you want SQL access so you can keep running your noobish little SQL scripting hacks on the server.

;D Hysterics... wipe that brown drool of your chin noob.

"one day maybe" well guess that day is today thanks to my dedicated research and terrible programming skills, neat huh?

pffff you are using the sort of mass spamming that is just going to cause problems, you can't even get it to stop crashing, it still doesnt work, and I provided a well written alternative that doesn't crash or fail plus detects hosting in a couple of hours.

I was refering to doing it properly. The approach you are attempting to use might barely work with the fixes I have told you that you need ONLY because there are very few people using the server. In any real environment with a busy server it would definately fail and cause issues for most users and even their families once you spammed their home routers up with rubbish.
Title: Re: Lat Trick Bot
Post by: Lambchops on May 26, 2018, 06:15:37 PM
So, for future, our logic should be more complicated. Looks like we have to read game data port for each client or check the port from hosted game.
Sad, but looks like there's no way to know UDP port for original client with no lat bots even if his ports are fine.

This is why at the least you should have the clients registering their details with the server when they enter the channel.....

actually you should have the clients telling the server when they are trying to join a game, then the server frowarding the address/port to the host so the host can punch a hole.

^ this is how it should be done. Not just spamming everyone all the time and hoping it works.
Title: Re: Lat Trick Bot
Post by: iL on May 27, 2018, 05:00:20 PM
Tried in different options:
repeated UDP packets to all players every 10 sec, 1 single ip to every player, nobody can join my game hosted from unforwarded 6113.

If i keep repeating packets to every player, i can't join any game (i get lat).
If i stop lat trick bot, i still can't join until i restart war2.

What does it mean?
How windows handle that packets? Maybe windows send "answer" to the application sent the request? That is my next idea.
Otherwise i have no explanation what happens.
@Lambchops, i'll try your dll, but i almost sure that will not help as you open sockets the same way as a python script.

I'd say we have to inject sending packets into war2 process somehow.
Title: Re: Lat Trick Bot
Post by: easycompany on May 27, 2018, 05:25:15 PM
should people that cant port foreward ..should they even be allowed to game? lance had his bots guess he is gone again.. well carry on

maybe everyone needs thier own device to get to the internet..i know yall on a mission but dsl sucks with 2 users..be better if 1 used the 56k part..
Title: Re: Lat Trick Bot
Post by: Lambchops on May 27, 2018, 05:54:11 PM

@Lambchops, i'll try your dll, but i almost sure that will not help as you open sockets the same way as a python script.

I'd say we have to inject sending packets into war2 process somehow.

Slightly different. You will notice that you can start my dll after wc2 is already started, but you must open the python script before wc2 so it takes precedence. This is not desirable.

I am using the windows API networking primatives. All networking ends up using these functions regardless of the source.
Just because python methods have the same name like "sendto" does not mean that they are the same - the paramaters are different so python is simplifying things behing the scenes before passing them to the API functions. I don't know how close to a 1:1 translation the python methods are, and I don't really need to know as I wouldn't bother using them.

And yes this is a bad way to be doing this, as I have said. It's unlikely to work without causing problems/glitches, but you are trying it out, so I am trying to help.

I have documented the correct way to do this many times, it is only the script-kiddie making noise that is confusing the issue.

Have sent a PM with more specific information.






Title: Re: Lat Trick Bot
Post by: iL on May 28, 2018, 11:02:06 AM
lance had his bots guess he is gone again.. well carry on
Lance released his bot as opensource, anyone can host it. The only thing required is windows hosting.

Slightly different.
Anyway, need to check your functions, maybe they will work better.
I'll try that when i have time.
All current tries made me impossible to join anyone's game, also nobody can join my one.
Title: Re: Lat Trick Bot
Post by: iL on May 28, 2018, 03:24:19 PM
Well, checked your things another way:
Changed all the socket code to Lampchops code:

Code: [Select]
    for player_ip in player_ip_list:
      try:
        # Target host is IP of player you want to be able to join your game
        target_host = player_ip
        # send some data
        os.system("hostholecmd.exe " + str(player_ip) + " " + str(war2_client_port) + " " + str(war2_remote_port))
      except Exception as e:
        print e
    time.sleep(10)

Nothing changed:
my port (war2_client_port) is 6113, not forwarded, remote port is 6112.
Then i hosted the game, then started that script with loop for chat players only, and... they wasn't able to join.
Then i stopped my loop and wasn't able to join any  game until rejoin bnet with war2.

Any other ideas what to do?
Title: Re: Lat Trick Bot
Post by: iL on May 29, 2018, 04:07:02 AM
oh shit it works!!!!!

UDP hole punching for the win, check this out for proof (notice "your port is closed", but abcde joined my game):
I still didn't reach such progress with that UDP Hole thing.
How you reach that? When you sent UDP to abcde? After you host the game? Or before you host the game? Or before you joined BNET? Or when?

Maybe the problem is related to non-standart port somehow. Next step from my side is to stop portforward on router and change port to 6112.

But it doesn't work for me when i send UDP from 6113 to 6112 (even when i send packets once and right atfer hosting the game). I send UDP to 3-5 active players in chat (including one who tried to join).

Also after sending such UDP from my side i haven't been able to join until rejoin bnet on war2.

What's rejoin BNET from networking side? Looks like BNET part is a separate process inside war2 application. It's being restarted when i rejoin bnet? So it closes and recreates all the sockets again or what?

I still think proper way is to use BNET part of war2 to send UDP packets to peers.
Then war2 send packet, so war2 will receive it back. Works fine when you manually try to join someone's game and then he can join your game.

Title: Re: Lat Trick Bot
Post by: AHB on May 29, 2018, 08:31:15 AM
Well luckily it sounds like @Lambchops has everything figured out so I will stop contributing and we can all let him show us how its done!
Title: Re: Lat Trick Bot
Post by: iL on May 29, 2018, 09:34:19 AM
Well luckily it sounds like @Lambchops has everything figured out so I will stop contributing and we can all let him show us how its done!
Well, python script is better for research purposes (quick development) to test how to make it work.
C++ code is better for production. That will be a small birany code with minimal required to work properly. Also that C++ code will be included into final application. But we need experiments before release production.

So, both ways are useful.
But no one is functional right now for me.
Title: Re: Lat Trick Bot
Post by: Lambchops on May 30, 2018, 01:12:41 AM
Well luckily it sounds like @Lambchops has everything figured out so I will stop contributing and we can all let him show us how its done!

LOL don't let my stop you, son. Only trying to help. I'm a bit occupied right now with another project (that I am being paid for ;) ) but I've been meaning to fix this issue for a while now so maybe I'll do that next.