Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - AHB

Pages: 1 [2] 3 4
16
Mods & Development / Re: Lat Trick Bot
« 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

17
Mods & Development / Re: Lat Trick Bot
« 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

18
Mods & Development / Re: Lat Trick Bot
« 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

19
Mods & Development / Re: Lat Trick Bot
« 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

20
Server.War2.ru / Search game reports and user logins
« on: May 18, 2018, 11:55:00 AM »
I am trying to bring back an old site I was working on. Its pretty terrible, but you are able to do a few basic things which people might find entertaining:

1. Search for last time your friend logged in:
https://war2.info/ver1/user.php?user=wretcher

2. Search for game reports of games you played recently:
https://war2.info/ver1/game_search.php

3. Generate screenshot from game you played recently:
https://war2.info/ver1/game_report.php?id=gr_20180517001212_007356


21
Mods & Development / Re: Lat Trick Bot
« 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

22
Mods & Development / War2 Analytics Ver2
« on: May 17, 2018, 08:28:25 PM »
Those of you who remember I made analytics.war2.co a while back

It was a PHP site with the backend powered by Python scrapers, and I started rewriting it to be Python/Flask with VueJS javascript front end a year ago but I never finished it...

If anyone is interested in this project let me know.

I have 30,000+ games neatly parsed, an entire year of data, you can literally find out anything you want. You can ask questions like

“how many times did playerA beat playerB when the game lasted longer than 10 minutes, playerA was orc, playerB finished with less than 3,000 gold, on a Friday night in April”

For those of you who know a bit about databases and SQL, you can check it out yourself!

https://war2.info/addy.php
username: public
password: public

23
Mods & Development / Re: Lat Trick Bot
« 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.

24
Mods & Development / Re: Lat Trick Bot
« 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/
- Install pip (package manager) 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=' + 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:
      # 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";
}

?>

25
Mods & Development / Re: Lat Trick Bot
« 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

26
Mods & Development / Re: Lat Trick Bot
« 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"


27
Mods & Development / Re: Lat Trick Bot
« 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

28
Mods & Development / Re: Lat Trick Bot
« 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

29
Mods & Development / Re: Lat Trick Bot
« 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)

30
Mods & Development / Re: Lat Trick Bot
« 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.


Pages: 1 [2] 3 4