Jump to content

How To Fix P2P BashPanel and DB Account Bug


Evor

Recommended Posts

Hello folks.

 

Today i will show you have to solve some more or less serious bugs.

 

P2P BASHPANEL:


First of all, well mentioned bashpanel.

The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP.

First of all, let's talk about what P2P connections are.
P2P is a way for all cores to communicate with each other.
The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge).
The fix is really simple and already implemented, but was unnecessarliy commented out.

Let's find: (in main.cpp)
 

if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

As we see, p2p is deafult for the PublicIP, but above that, we can see:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)

and that's the way how it should look. 
To apply it, simply make it look like this:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
//if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

instead of:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
	if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

First bug fixed.

 

Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports.

DB Account BUG:

Let's move on.

When DB port is Publicly available, user, which knows the account id, can simply use it.

To fix it, let's make a "brute" fix, another way (using older revisions) is to write:

BIND_IP: 127.0.0.1

in ur config file, but let's fix it more quietly. 

Simply move to ClientManager.cpp in DB, and change it like so:
from:

if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
		strlcpy(szBindIP, "0", sizeof(szBindIP));

to:

if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
		strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP));

That's it. Fixed.

 

Kind regards.

  • Good 2
  • Love 10
Link to comment
Share on other sites

Hello folks.

 

Today i will show you have to solve some more or less serious bugs.

 

P2P BASHPANEL:

First of all, well mentioned bashpanel.

The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP.

First of all, let's talk about what P2P connections are.

P2P is a way for all cores to communicate with each other.

The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge).

The fix is really simple and already implemented, but was unnecessarliy commented out.

Let's find: (in main.cpp)

 

if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

As we see, p2p is deafult for the PublicIP, but above that, we can see:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)

and that's the way how it should look. 

To apply it, simply make it look like this:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
//if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

instead of:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
	if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

First bug fixed.

 

Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports.

DB Account BUG:

Let's move on.

When DB port is Publicly available, user, which knows the account id, can simply use it.

To fix it, let's make a "brute" fix, another way (using older revisions) is to write:

BIND_IP: 127.0.0.1

in ur config file, but let's fix it more quietly. 

Simply move to ClientManager.cpp in DB, and change it like so:

from:

if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
		strlcpy(szBindIP, "0", sizeof(szBindIP));

to:

if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
		strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP));

That's it. Fixed.

 

Kind regards.

ohhh

 

friend can i join to my windows server with my local ip 192.168.x.x or localhost with bind_ip of config channel1 ?

 

if that possible with this u are awesome

 

i will check it

 

please look here and reply to me please:

 

 

so my players connecting with bind_ip of config file from channel 1 but i cant join then with me local ip to my server

 

that both connect will possible with this ?

Link to comment
Share on other sites

Hello folks.

 

Today i will show you have to solve some more or less serious bugs.

 

P2P BASHPANEL:

First of all, well mentioned bashpanel.

The main cause of this bug is the fact, that game is opening the connection on the Public IP instead of Internal IP.

First of all, let's talk about what P2P connections are.

P2P is a way for all cores to communicate with each other.

The main problem is that, whenever core receives a P2P packet, it doesn't check, if the sender is another core. That's a problem, becouse u can spoof the packet (for ex. using Infinity BashPanel, or simply any packet forge).

The fix is really simple and already implemented, but was unnecessarliy commented out.

Let's find: (in main.cpp)

 

if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

As we see, p2p is deafult for the PublicIP, but above that, we can see:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)

and that's the way how it should look. 

To apply it, simply make it look like this:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
//if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

instead of:

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
	if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

First bug fixed.

 

Another way (for older revisions) is to use IPFW or other PacketFilters managers to block WAN connection on P2P ports.

DB Account BUG:

Let's move on.

When DB port is Publicly available, user, which knows the account id, can simply use it.

To fix it, let's make a "brute" fix, another way (using older revisions) is to write:

BIND_IP: 127.0.0.1

in ur config file, but let's fix it more quietly. 

Simply move to ClientManager.cpp in DB, and change it like so:

from:

if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
		strlcpy(szBindIP, "0", sizeof(szBindIP));

to:

if (!CConfig::instance().GetValue("BIND_IP", szBindIP, 128))
		strlcpy(szBindIP, "127.0.0.1", sizeof(szBindIP));

That's it. Fixed.

 

Kind regards.

so i tested with all arguments that just for close bind_ip or active

 

so still cant connect my server with my local ip adress but players can join with bind_ip channel1

Link to comment
Share on other sites

  • 1 year later...

I did that and the only thing I made was to cause socket_tcp_bind error every time I try to turn the channels on. I undid the p2p proccess and still... And before you ask yes I have my server's IP at all CONFIG files (BIND_IP)... So what can I do to fix this?

EDIT: To undo it and work, you have to perform a full build (gmake all) and not just a game build (/game/src && gmake -j20). The reason is unknow, it just works this way :P I also tried full build with @Evor's fix but that didn't work...

Link to comment
Share on other sites

  • 1 year later...

with this

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
	if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

 

i have this error with start server

start.sh: ./game_ch1_1: Text file busy
start.sh: ./game_ch1_2: Text file busy

 

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...
On 8/30/2017 at 12:54 AM, Tallywa said:

with this

// if internal ip exists, p2p socket uses internal ip, if not use public ip //if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET) if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)


// if internal ip exists, p2p socket uses internal ip, if not use public ip
	//if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
	if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

 

i have this error with start server

start.sh: ./game_ch1_1: Text file busy
start.sh: ./game_ch1_2: Text file busy

 

Just change like this

// if internal ip exists, p2p socket uses internal ip, if not use public ip
	if ((p2p_socket = socket_tcp_bind(*g_szInternalIP ? g_szInternalIP : g_szPublicIP, p2p_port)) == INVALID_SOCKET)
	//if ((p2p_socket = socket_tcp_bind(g_szPublicIP, p2p_port)) == INVALID_SOCKET)

i know it's older answer but perhaps some users will need this even is written above.

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.