Skip to content

Instantly share code, notes, and snippets.

@Davnit
Created February 15, 2018 23:35
Show Gist options
  • Save Davnit/49eb4aa7157ca3410fc095760d86731a to your computer and use it in GitHub Desktop.
Save Davnit/49eb4aa7157ca3410fc095760d86731a to your computer and use it in GitHub Desktop.
botnet discord hook for stats updates
' Packet 0x06 S>C INFO
' (UINT32) Bot ID
' (UINT32) Database access flags [v4 c1]: 1 = read; 2 = write; 4 = restricted access
' (UINT32) Administrative capabilities [v4 c1]: ZTFF
' (UINT32) IP address of the bot being described [v4 c1 A]
' (NTSTRING) Bot name [MAX 20]
' (NTSTRING) Bot channel
' (UINT32) Bot server IP
' (NTSTRING) account name [v2 MAX 16]
' (NTSTRING) database [v3]
Sub Recv_BNS_INFO(Packet)
Dim BotID, AccessFlags, AdminFlags, IP, BotName, BotChannel, BotServerIP, AccountName, DatabaseName
Dim UserObj
BotNet_PrintDebug "Received BNS_INFO"
If Packet.Length = 4 Then
BN_GotUserList = True
End If
BotID = Packet.GetDword()
If BotNet_State(STATE_SVERSION) >= BN_SERVERLEVEL_4 Then
If BotNet_State(STATE_CVERSION) >= BN_CLIENTLEVEL_1 Then
AccessFlags = Packet.GetDword()
AdminFlags = Packet.GetDword()
If ZTFF_HasAnyFlags(BotNet_State(STATE_ADMINFLAGS), "ACL") Then
IP = NetworkToAddress(Packet.GetDword())
End If
End If
End If
BotName = Packet.GetString()
BotChannel = Packet.GetString()
BotServerIP = NetworkToAddress(Packet.GetDword())
If BotNet_State(STATE_SVERSION) >= BN_SERVERLEVEL_2 Then
AccountName = Packet.GetString()
End If
If BotNet_State(STATE_SVERSION) >= BN_SERVERLEVEL_3 Then
DatabaseName = Packet.GetString()
End If
Set UserObj = New BotNetUserClass
Call UserObj.Init(BotID, BotName, BotChannel, BotServerIP, AccountName, DatabaseName, AccessFlags, AdminFlags, IP)
BotNet_PrintDebug "Update user #" & BotID & ": " & UserObj.GetFullString()
If DatabaseName = "BNETDocs" And BN_GotUserList Then
If Not BN_Users.Exists(BotID) Then
ExecuteDiscordHook StringFormat("{0} has joined the BotNet {1}.", UserObj.GetFullName(), UserObj.GetInfoString())
Else
ExecuteDiscordHook StringFormat("User {0} is now {1}.", UserObj.GetFullName(), UserObj.GetInfoString())
End If
End If
Set BN_Users.Item(BotID) = UserObj
If BotNet_State(STATE_SELFBOTID) = 0 Then
Call BotNet_SetState(STATE_SELFBOTID, BotID)
Call BotNet_PrintWelcome()
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment