// TODO test public static void floodPackets(string address, int port, int count) { Program.connect(address, port); for (int i = 0; i < count; i++) { if (Program.sock != null) { if (!Program.sock.Connected) { Program.connect(address, port); } } else { Program.connect(address, port); } int x = r.Next(10); Console.Write(x); if (x == 1) { Packets.handshake0x00(address, port, 1); } else if (x == 2) { Packets.handshake0x00(address, port, 2); } else if (x == 3) { Packets.chatMessage0x01(randomUser(30)); } else if (x == 4) { // might crash us Packets.keepalive0x00(); } else if (x == 5) { Packets.loginStart0x00(randomUser(10)); } else if (x == 6) { Packets.request0x00(); } else { Packets.handshake0x00(address, port, 1); } } }
static void Main(string[] args) { Console.WriteLine("Usage example: 5.104.104.45 25565 InstanceLabs password"); Console.WriteLine("Leave password empty for offline mode."); bool cmd = false; String address = "127.0.0.1"; String portstr = "25565"; int port = 25565; String username = ""; String password = ""; if (args.Length > 3) { address = args[0]; portstr = args[1]; port = Convert.ToInt32(portstr); username = args[2]; password = args[3]; cmd = true; } else if (args.Length > 2 && args.Length < 4) { address = args[0]; portstr = args[1]; port = Convert.ToInt32(portstr); username = args[2]; password = ""; cmd = true; } bool menu = true; while (menu) { if (cmd) { login(address, port, username, password); while (sock.Connected) { // send message Packets.chatMessage0x01(Console.ReadLine()); } return; } Console.Write("Server > "); address = Console.ReadLine(); if (address == "") { address = "127.0.0.1"; } Console.Write("Port > "); portstr = Console.ReadLine(); if (portstr == "") { portstr = "25565"; } port = Convert.ToInt32(portstr); connect(address, port); getServerInfo(address, port); Console.Write("Connect? (y/n) "); if (Console.ReadLine().ToLower().StartsWith("y")) { // connect Console.Write("Username > "); username = Console.ReadLine(); Console.Write("EMail (leave empty if you still have an unmigrated account) > "); string email = Console.ReadLine(); Console.Write("Passord (leave empty for offline mode) > "); password = Console.ReadLine(); Console.WriteLine(Util.loginSession(username, email, password)); login(address, port, username, password); while (sock.Connected) { // send message Packets.chatMessage0x01(Console.ReadLine()); } } } }