Valhalla Legends Forums Archive | Battle.net Bot Development | Adron's Flood Protection

AuthorMessageTime
FuZe
I looked up Adron's Flood protection in documents, and the delay that I get is wayyy too long. Has anyone gotten this to work?
July 27, 2003, 10:40 PM
Camel
This code is a little old, but should still be quite functional.

https://davnit.net/bnet/vL/phpbbs/index.php?board=17;action=display;threadid=1256;start=msg9485#msg9485

[quote author=Camel link=board=17;threadid=1256;start=0#msg9485 date=1052439484]
chat.bas:

[code]Option Explicit

Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long

Public LastChat As Long, TimerID As Long
Dim SendBuf As String, LastChatLen As Integer
Public Const AntiIdleTimerID As Long = 0

Public Sub DelQueue()
SendBuf = ""
If TimerID Then
KillTimer frmMain.hwnd, 1
TimerID = 0
End If
LastChat = 0
If frmMain.SCK.State = sckConnected Then SendText "queue flushed"
End Sub

Private Sub CheckSend(Optional ForceTimerUse As Long = 0)
Dim delay As Long

#If DEBUG_ Then
delay = 0
#Else
delay = LastChatLen 'CVI(Mid(sendbuf, 3, 2))
delay = delay * 15 + 2700
#End If

delay = (delay + LastChat) - GetTickCount
If delay < 0 Then delay = 0

delay = delay + ForceTimerUse

If delay > 0 Then
If TimerID <> 0 Then KillTimer frmMain.hwnd, TimerID
TimerID = SetTimer(frmMain.hwnd, 2, delay, AddressOf SendQueue)
Else
SendQueue
End If
End Sub

Public Sub SendQueue()
If TimerID <> 0 Then
'debug.assert false
KillTimer frmMain.hwnd, TimerID '1
TimerID = 0
End If

If Not frmMain.SendChatOK Then
'if its disconnected, clear buffer
If frmMain.SCK.State = sckConnected Then
CheckSend 1000 'start another timer
Else

End If
Else
If Len(SendBuf) > 0 Then
Dim plen As Integer
plen = CVI(Mid(SendBuf, 3, 2))

LastChat = GetTickCount
LastChatLen = plen - 4

If frmMain.SCK.State = sckConnected Then
'Dim strText As String
'strText = Mid(SendBuf, 5, plen - 5)
'strText = Left(strText, InStr(1, strText, Chr(0)) - 1)

On Error GoTo error

frmMain.SCK.SendData Left(SendBuf, plen)
If Mid(SendBuf, 5, 1) <> "/" Then
UserChats MyName, Mid(SendBuf, 5, plen - 5), GetFlags(MyName, MyFlags) 'frmMain.Script.Run("GetFlags", MyName, MyFlags)
Else
'Addtext ColInfo, "SENDING COMMAND: " & Mid(SendBuf, 5, plen - 5) & vbCrLf, True
End If

SendBuf = Right(SendBuf, Len(SendBuf) - plen)
ResetAntiIdle
Else
Debug.Assert False
SendBuf = ""
End If
End If

If Len(SendBuf) > 0 Then CheckSend
End If

Exit Sub
error:
Addtext ColAnError, "Error in SendQueue(): " & ERR.Number & " - " & ERR.Description & vbCrLf, True
End Sub

Public Sub SendText(strText As String, Optional WhisperBack As String = "", Optional ForceTimerUse As Long, Optional DontChange As Boolean = False, Optional SkipUTF8Encode As Boolean = False)
Const m = 200

#If DEBUG_ <> 0 Then
If InStr(strText, Chr(0)) <> 0 Then Debug.Assert False
#End If

If Not SkipUTF8Encode Then strText = UTF8Encode(strText)

If DontChange Then GoTo sendnow

If InStr(strText, "%ver%") Then strText = Replace(strText, "%ver%", version)
If InStr(strText, "%running%") Then strText = Replace(strText, "%running%", GetTime(GetTickCount - StartTime))
If InStr(strText, "%connected%") Then strText = Replace(strText, "%connected%", GetTime(GetTickCount - LogTime))
If InStr(strText, "%uptime%") Then strText = Replace(strText, "%uptime%", GetTime(GetTickCount))
strText = Replace(strText, "%channel%", Channel)
strText = Replace(strText, "%server%", frmSetup.SAddr)
If InStr(strText, "%mp3%") Then strText = Replace(strText, "%mp3%", winamp.GetSongTitle(False))
If InStr(strText, "%mp3full%") Then strText = Replace(strText, "%mp3full%", winamp.GetSongTitle(True))
If InStr(strText, "%cpu%") Then strText = Replace(strText, "%cpu%", GetCPUInfo)

If (WhisperBack = MyName) And (MyName <> "") Then
Addtext D2LtYellow, strText & vbCrLf, True
Exit Sub
End If

If (Left(strText, 1) <> "/") And (WhisperBack <> "") Then
strText = "/m " & WhisperBack & " " & strText
End If

Dim s() As String
s = Split(strText, " ", 2)

If Not MyFlags And 2 Then
Select Case s(0)
Case "/kick", "/ban"
Addtext ColAnError, "WARNING: Supressing command due to lack of ops (use /quote to override): " & strText & vbCrLf, True
Exit Sub
End Select
End If

Select Case GetID
Case "VD2D", "PX2D"
If (Left(strText, 1) = "/") And (InStr(1, strText, " ") > 0) Then
Dim Name As String
Name = s(1)
If InStr(1, Name, " ") Then Name = Left(Name, InStr(1, Name, " ") - 1)

If (InStr(Name, "*") = 0) Then
Select Case s(0)
Case "/w", "/m", "/msg", "/whisper", "/whois", "/kick", "/ban", "/unban", "/designate", "/ignore", "/squelch", "/unignore", "/unsquelch"
strText = s(0) & " *" & s(1)
End Select
End If
End If
End Select

sendnow:

SendBuf = SendBuf & MakePacket(&HE, Left(strText, m) & Chr(0))
CheckSend ForceTimerUse
End Sub

Public Sub ResetAntiIdle()
KillTimer frmMain.hwnd, AntiIdleTimerID
SetTimer frmMain.hwnd, AntiIdleTimerID, frmSetup.IdleTime, AddressOf AntiIdle
End Sub

Public Sub AntiIdle()
If frmSetup.Idle <> "" Then SendText frmSetup.Idle
End Sub[/code]
[/quote]
July 27, 2003, 10:51 PM
DarkMinion
And with all that crap, you can still flood off.

*claps*
July 27, 2003, 10:58 PM
FuZe
[code]
unsigned long tick = GetTickCount();
if(lasttick - tick > sentbytes * msperbyte)
sentbytes = 0;
else
sentbytes -= (lasttick-tick) / msperbyte;
lasttick = tick;
[/code]

I think one of the reasons I get such a high number is because the first lasttick-tick will be a huge number since lasttick will = 0 and tick will equal whatever milliseconds. How would I go about bypassing this?
July 27, 2003, 11:38 PM
Maddox
[quote author=DarkMinion link=board=17;threadid=2105;start=0#msg16186 date=1059346706]
And with all that crap, you can still flood off.

*claps*
[/quote]

And notice Adron's flood protection is in C++ not VB.
July 28, 2003, 12:13 AM
Camel
Eh, nobody explicitly said C so I assumed it was VB. Oh well.

And DM, what? I havnt flooded off in...well I can't remember that long ago. I automatically flush the queue if I get a 'that user is not logged on' message from battle.net. That prevents virtually all floodbots from doing any damage.
July 28, 2003, 1:05 AM
FuZe
[quote author=Maddox link=board=17;threadid=2105;start=0#msg16191 date=1059351195]
[quote author=DarkMinion link=board=17;threadid=2105;start=0#msg16186 date=1059346706]
And with all that crap, you can still flood off.

*claps*
[/quote]

And notice Adron's flood protection is in C++ not VB.
[/quote]

I changed his to vb
[code]
Private Function RequiredDelay(ByVal Bytes As Long) As Long


Static lastTick As Long
Static sentBytes As Long
Const perPacket = 200
Const msPerByte = 10
Const maxBytes = 600
Dim Tick As Long

Tick = GetTickCount()

If lastTick - Tick > sentBytes * msPerByte Then
sentBytes = 0
Else
sentBytes = sentBytes - (lastTick - Tick) / msPerByte
End If
lastTick = Tick
If sentBytes + perPacket + Bytes > maxBytes Then
RequiredDelay = (sentBytes + perPacket + Bytes - maxBytes) * msPerByte
Exit Function
End If
sentBytes = sentBytes + perPacket + Bytes
RequiredDelay = 0






End Function[/code]

o yeh and I did see groks vb version but I just wanted to change it by myself..
July 28, 2003, 1:18 AM
Adron
[quote author=FuZe- link=board=17;threadid=2105;start=0#msg16189 date=1059349124]
I think one of the reasons I get such a high number is because the first lasttick-tick will be a huge number since lasttick will = 0 and tick will equal whatever milliseconds. How would I go about bypassing this?
[/quote]

You could initialize lasttick to GetTickCount() when starting.
You could have a special case for lasttick = 0.

I think there's a bug with sign somewhere in my posted code. Something that should be a small positive number comes out a small negative or huge positive number. Look on the forum for exact details, I'm pretty sure someone pointed out in a post not too long ago.

July 28, 2003, 5:39 PM
UserLoser
Warcraft III has a flood protection on it that will never allow you to flood off on it. Couldn't someone who *knows how* to disassemble just find out and use the method that the game uses?
July 29, 2003, 7:25 PM
MesiaH
i bet i could flood off via the war3 client.
July 29, 2003, 7:30 PM
UserLoser
I'd like to see that ;D
July 29, 2003, 8:58 PM
Kp
[quote author=UserLoser link=board=17;threadid=2105;start=0#msg16394 date=1059506711]
Warcraft III has a flood protection on it that will never allow you to flood off on it. Couldn't someone who *knows how* to disassemble just find out and use the method that the game uses?[/quote]Making a flood protection algorithm that keeps you from flooding and making one that doesn't become a pain to use are different things. The former could be achieved by simply imposing some large delay between every message and tacking on several seconds for each message beyond the first. After a while, you wouldn't be able to talk - but you'd never flood. :p
July 29, 2003, 9:50 PM
Camel
you could text in short bursts, too...
July 29, 2003, 10:26 PM

Search