Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sfml2 network crash  (Read 3292 times)

0 Members and 2 Guests are viewing this topic.

blizter

  • Newbie
  • *
  • Posts: 7
    • View Profile
sfml2 network crash
« on: February 21, 2011, 04:29:01 pm »
So I have been writing a game server/client with the network part of sfml2. It wrote some nice encryptions mechanisms along with checksum check and messages id checks. All for nothing because if someone resend a packet, without first sending the "length" packet. (I don't know why you are sending 2 packets each time I call send) The server crash. Any script kiddie can crash the server.

Anything I can modify to ignore resent packets, or just not crash ?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sfml2 network crash
« Reply #1 on: February 21, 2011, 04:45:55 pm »
Quote
I don't know why you are sending 2 packets each time I call send

Not two sf::Packet, but two pieces of information, yes. The first one simply contains the size of the second one, which is the data itself.

Quote
Any script kiddie can crash the server

Of course. SFML is not a network engine, it's just a low-level library that provides tools to build your own stuff. If you want improved security, you must write more code.

Quote
Anything I can modify to ignore resent packets, or just not crash ?

Resent packets should work. Can you show me your code that produces the crash?
Laurent Gomila - SFML developer

blizter

  • Newbie
  • *
  • Posts: 7
    • View Profile
sfml2 network crash
« Reply #2 on: February 21, 2011, 04:51:09 pm »
Well it seems if someone resend a packet to "hack" and he doesn't send the first piece of information, the tcpsocket will try to read the packet as if it was that first piece of information "the size". Then it tries to read the second piece of information that isn't there and crash.

This is what I think it does.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sfml2 network crash
« Reply #3 on: February 21, 2011, 05:02:15 pm »
Quote
Well it seems if someone resend a packet to "hack" and he doesn't send the first piece of information.

How? With SFML (sf::Packet or raw data?) ? Or manually, to "simulate" a fake SFML packet?
Laurent Gomila - SFML developer

blizter

  • Newbie
  • *
  • Posts: 7
    • View Profile
sfml2 network crash
« Reply #4 on: February 21, 2011, 05:05:56 pm »
With a third party tool. For this I am using WPEpro. To intercept the packets and resend them/modify to test hacking attempts.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sfml2 network crash
« Reply #5 on: February 21, 2011, 07:49:00 pm »
There are many ways to send corrupted data, actually. sf::Packet is a convenience class, it's not made for security. If you have your own layer of encryption / security / CRC / whatever, then get rid of sf::Packet and send raw data instead.
Laurent Gomila - SFML developer

blizter

  • Newbie
  • *
  • Posts: 7
    • View Profile
sfml2 network crash
« Reply #6 on: February 22, 2011, 05:30:49 pm »
Hey thank you. I got it working using the tcpsocket send(char*) function rather than the send(&Packet) one.

Had to send size of packet by myself but now it can handle packets of invalid size and all.

Thanks, using raw data was what I had to do.