Skip to content

Commit 6b88bfa

Browse files
committed
Add AdminBotFuckeryCommand for islanti
1 parent 7cbb88a commit 6b88bfa

4 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using Atlasd.Battlenet.Protocols.Game.Messages;
2+
using Atlasd.Daemon;
3+
using Atlasd.Localization;
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
9+
namespace Atlasd.Battlenet.Protocols.Game.ChatCommands
10+
{
11+
/**
12+
* [3/6/2023 5:39:55 PM] islanti: *resurrects author of miragechat to patch msgbox. carl starts disconnecting everybody with post-enterchat auth_check failure
13+
* [3/6/2023 5:41:48 PM] islanti: have no comb through my code to find all instances of voluntary disconnect and verify it is within-sequence
14+
* [3/6/2023 5:41:58 PM] islanti: *to comb
15+
*/
16+
class AdminBotFuckeryCommand : ChatCommand
17+
{
18+
public AdminBotFuckeryCommand(byte[] rawBuffer, List<string> arguments) : base(rawBuffer, arguments) { }
19+
20+
public override bool CanInvoke(ChatCommandContext context)
21+
{
22+
return context != null && context.GameState != null && context.GameState.ActiveAccount != null;
23+
}
24+
25+
public override void Invoke(ChatCommandContext context)
26+
{
27+
var t = Arguments.Count == 0 ? "" : Arguments[0]; // target
28+
string r; // reply
29+
30+
if (t.Length == 0 || !Battlenet.Common.GetClientByOnlineName(t, out var target) || target == null)
31+
{
32+
r = Resources.UserNotLoggedOn;
33+
foreach (var line in r.Split(Environment.NewLine))
34+
new ChatEvent(ChatEvent.EventIds.EID_ERROR, context.GameState.ChannelFlags, context.GameState.Client.RemoteIPAddress, context.GameState.Ping, context.GameState.OnlineName, line).WriteTo(context.GameState.Client);
35+
return;
36+
}
37+
38+
Arguments.RemoveAt(0); // remove target
39+
// Calculates and removes (target+' ') from (raw) which prints into (newRaw):
40+
RawBuffer = RawBuffer[(Encoding.UTF8.GetByteCount(t) + (Arguments.Count > 0 ? 1 : 0))..];
41+
var type = string.Join(' ', Arguments);
42+
43+
if (string.IsNullOrEmpty(type))
44+
{
45+
r = Resources.AdminBotFuckeryCommandInvalid;
46+
foreach (var line in r.Split(Environment.NewLine))
47+
new ChatEvent(ChatEvent.EventIds.EID_ERROR, context.GameState.ChannelFlags, context.GameState.Client.RemoteIPAddress, context.GameState.Ping, context.GameState.OnlineName, line).WriteTo(context.GameState.Client);
48+
return;
49+
}
50+
51+
var realmName = Settings.GetString(new string[] { "battlenet", "realm", "name" }, Resources.Battlenet);
52+
var targetEnv = new Dictionary<string, string>()
53+
{
54+
{ "accountName", target.Username },
55+
{ "channel", target.ActiveChannel == null ? "(null)" : target.ActiveChannel.Name },
56+
{ "game", Product.ProductName(target.Product, true) },
57+
{ "host", Settings.GetString(new string[] { "battlenet", "realm", "host" }, "(null)") },
58+
{ "localTime", target.LocalTime.ToString(Common.HumanDateTimeFormat).Replace(" 0", " ") },
59+
{ "name", target.OnlineName },
60+
{ "onlineName", target.OnlineName },
61+
{ "realm", realmName },
62+
{ "realmTime", DateTime.Now.ToString(Common.HumanDateTimeFormat).Replace(" 0", " ") },
63+
{ "realmTimezone", $"UTC{DateTime.Now:zzz}" },
64+
{ "user", target.OnlineName },
65+
{ "username", target.OnlineName },
66+
{ "userName", target.OnlineName },
67+
};
68+
var env = targetEnv.Concat(context.Environment);
69+
70+
SID_AUTH_CHECK.Statuses status = type.ToLowerInvariant().Replace(" ", string.Empty) switch
71+
{
72+
"bannedkey" => SID_AUTH_CHECK.Statuses.GameKeyBanned,
73+
"bannedkey2" => SID_AUTH_CHECK.Statuses.GameKeyBanned | SID_AUTH_CHECK.Statuses.GameKeyExpansion,
74+
"inusekey" => SID_AUTH_CHECK.Statuses.GameKeyInUse,
75+
"inusekey2" => SID_AUTH_CHECK.Statuses.GameKeyInUse | SID_AUTH_CHECK.Statuses.GameKeyExpansion,
76+
"invalidkey" => SID_AUTH_CHECK.Statuses.GameKeyInvalid,
77+
"invalidkey2" => SID_AUTH_CHECK.Statuses.GameKeyInvalid | SID_AUTH_CHECK.Statuses.GameKeyExpansion,
78+
"invalidversion" => SID_AUTH_CHECK.Statuses.InvalidVersion,
79+
"success" => SID_AUTH_CHECK.Statuses.Success,
80+
"toonew" => SID_AUTH_CHECK.Statuses.VersionTooNew,
81+
"tooold" => SID_AUTH_CHECK.Statuses.VersionTooOld,
82+
"wronggamekey" => SID_AUTH_CHECK.Statuses.GameKeyProductMismatch,
83+
"wronggamekey2" => SID_AUTH_CHECK.Statuses.GameKeyProductMismatch | SID_AUTH_CHECK.Statuses.GameKeyExpansion,
84+
_ => SID_AUTH_CHECK.Statuses.InvalidVersion,
85+
};
86+
87+
new SID_AUTH_CHECK().Invoke(new MessageContext(target.Client, MessageDirection.ServerToClient, new Dictionary<string, dynamic>(){
88+
{ "status", status }, { "info", Array.Empty<byte>() }
89+
}));
90+
91+
r = Resources.AdminBotFuckeryCommand;
92+
foreach (var kv in env) r = r.Replace("{" + kv.Key + "}", kv.Value);
93+
foreach (var line in r.Split(Battlenet.Common.NewLine))
94+
new ChatEvent(ChatEvent.EventIds.EID_INFO, context.GameState.ChannelFlags, context.GameState.Client.RemoteIPAddress, context.GameState.Ping, context.GameState.OnlineName, line).WriteTo(context.GameState.Client);
95+
}
96+
}
97+
}

src/Atlasd/Battlenet/Protocols/Game/ChatCommands/AdminCommand.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public override void Invoke(ChatCommandContext context)
3838
case "announce":
3939
case "broadcast":
4040
new AdminBroadcastCommand(RawBuffer, Arguments).Invoke(context); return;
41+
case "botfuckery":
42+
new AdminBotFuckeryCommand(RawBuffer, Arguments).Invoke(context); return;
4143
case "channel":
4244
case "chan":
4345
case "ch":

src/Atlasd/Localization/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Atlasd/Localization/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@
126126
<data name="AddFriendEmptyTarget" xml:space="preserve">
127127
<value>Who do you want to add?</value>
128128
</data>
129+
<data name="AdminBotFuckeryCommand" xml:space="preserve">
130+
<value>Sent spoofed SID_AUTH_CHECK result to {user}.</value>
131+
</data>
132+
<data name="AdminBotFuckeryCommandInvalid" xml:space="preserve">
133+
<value>Invalid parameters for SID_AUTH_CHECK.</value>
134+
</data>
129135
<data name="AdminClanListCommand" xml:space="preserve">
130136
<value>Registered clans:</value>
131137
</data>

0 commit comments

Comments
 (0)