How is this possible

Discussion in 'Spigot Help' started by alexhackers, Jul 10, 2018.

  1. upload_2018-7-10_14-55-57.png

    This server is a big server, and when ping it appears normal ping, but in the list of servers it appears 0-1ms, as it is possible? exist method to manipulate the ping that appears?
     
  2. joehot200

    Supporter

    Perhaps they have some sort of CDN? Just a theory, of course. That said, 1ms is extremely low. I would be sceptical if the ping was truly 1ms.
     
    • Winner Winner x 1
  3. only appears, but is a fake ping
     
  4. Maybe it is a fake list of players, they simulate that there is 1 player online called 1ms, just a theory btw.
     
  5. [​IMG]
    [​IMG]

    Requires TinyProtocol, but may work with ProtocolLib too.
    Code (Text):

    package com.mrpowergamerbr.changingserverlistpingwow;

    import io.netty.channel.Channel;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class PingChanger extends JavaPlugin {
       private Class<?> pingClass = Reflection.getClass("{nms}.PacketStatusOutPong");
       private Class<?> serverInfoClass = Reflection.getClass("{nms}.PacketStatusOutServerInfo");

       private boolean hackyHackyHacky = false;

       @Override
       public void onEnable() {
          new TinyProtocol(this) {
             @Override
             public Object onPacketOutAsync(Player receiver, Channel channel, Object packet) {
                if (hackyHackyHacky) {
                   return super.onPacketOutAsync(receiver, channel, packet);
                }
                System.out.println(packet.getClass().getSimpleName());
                if (serverInfoClass.isInstance(packet)) {
                   System.out.println("is a info class boi");
                   try {
                      Object pong = pingClass.newInstance();

                      synchronized (this) {
                         hackyHackyHacky = true;
                         System.out.println("sending our lil original packet");
                         this.sendPacket(channel, packet);
                         System.out.println("then we are going to surprise the client with the pong packet, surprise!!!");
                         this.sendPacket(channel, pong);
                         hackyHackyHacky = false;
                      }
                   } catch (Exception e) {
                      e.printStackTrace();
                   }
                }
                return super.onPacketOutAsync(receiver, channel, packet); // we are going to send them ourselves
             }
          };
       }
    }
     
    One of the server developers said that it was something "so big that needed to mess around with Netty" and bs like that, so I decided to figure it out myself.

    Yes, the code I shared is hacky, but this is just a proof of concept proving that yes, it is possible, and that's why you shouldn't rely on Minecraft's ping.

    If you can't understand this code, it is fairly simple: When sending the server info packet (the one that has the server MOTD, player count, etc), send the pong packet (doesn't matter the value, the client doesn't use that) right after the server info packet.

    The client will receive the server info packet, process it and then process the pong packet soon after.

    Test IP (I probably won't keep it online for much longer): mc.perfectdreams.net:25561

    The test server is running 1.12.2 (but because the server has ProtocolSupport, you can ping it with your favorite Minecraft version), also, if the ping doesn't show up as "0ms" or "1ms", keep refreshing, my code sucks so sometimes it doesn't return the "fake" ping.

    kthxbye, have fun!
     
    • Winner Winner x 2
  6. joehot200

    Supporter

    @MrPowerGamerBR I love how you worked this out yourself. What sources did you use to discover that's how the server ping worked?
     
  7. Decompiled 1.8.8 client source code (via Minecraft Coder Pack, I analyzed the "OldServerPinger.java" class) and wiki.vg.

    How I found this out? A few hours messing around with that, tried changing the value sent by the pong packet (doesn't matter, the client doesn't use it at all)...

    Then I remembered that the packets are processed sync by the client, and the ping packet is sent right after the MOTD info packet, so what would happen if I sent the pong packet right after the server sent the MOTD info packet? After all, the packets are sent and received async, but the packets are processed sync, the ping packet is sent right after the MOTD info packet is processed by the client, so, if we sent both at the same time, the client would process the MOTD info and the next packet (the pong) would be already in the queue.

    And that's the result! I will post a Bukkit/Bungee plugin later implementing this (of course, way better than the code I posted... That thing sucks but that's because it was just a proof of concept)
     
    • Like Like x 2