I looked all over this forum for about ~2 hours last night. I tried alll the code, and I did everything to make it work. I really need to know how to create an effective anti flood method, I looked all night last night searching for one!! (The requireddelay by Adron did not work, it always returned an extremely large number (or very small one..)).
Quote from: laurion on March 25, 2005, 09:05 AM
I looked all over this forum for about ~2 hours last night. I tried alll the code, and I did everything to make it work. I really need to know how to create an effective anti flood method, I looked all night last night searching for one!! (The requireddelay by Adron did not work, it always returned an extremely large number (or very small one..)).
It should be a number in milliseconds. Those tend to be very large...
Too large for the timer. I'm using VB 6 by the way
Quote from: laurion on March 25, 2005, 09:44 AM
Too large for the timer. I'm using VB 6 by the way
Maybe it's not the actual time to wait, but instead the time when it wants you to send the message, which could be a significantly larger number.
What's too large? More than 1 minute? I think with Blizzard's new flood protection scheme, there are some times when you are required to wait more than a minute before sending something else would be safe.
Ok I tried doing
Public Sub Send(Text As String)
frmMain.Text3.Text = Text
Dim delay As Double
delay = (((Len(Text) * 15 + 1700) / 1000) + 1) * 1000
SetTimer frmMain.hWnd, &H0, delay, SendProc
End Sub
Public Function SendProc()
If frmMain.Text3.Text = "" Then Exit Function
With PBuffer
.InsertNTString frmMain.Text3.Text
.SendPacket &HE
End With
If Left(Text, 1) = "/" Then
RTBAdd Text3.Text & vbNewLine, vbTeal
Else
RTBAdd "<", vbWhite, MyName, vbCyan, "> " & frmMain.Text3.Text & vbNewLine, vbWhite
End If
End Function
But it seemed to have No effect on the delay of what I was sending. I got that delay thing from a post from Noodlez. And Spht, I dont really understand what you mean..
edit: besides didnt some1 say that Adron's VB anti flood is outdated and will no longer work, it is missing one part?
Quote from: laurion on March 25, 2005, 09:05 AM
I looked all over this forum for about ~2 hours last night. I tried alll the code, and I did everything to make it work. I really need to know how to create an effective anti flood method, I looked all night last night searching for one!! (The requireddelay by Adron did not work, it always returned an extremely large number (or very small one..)).
This is much of the problem nowadays in bot development. Many users are simply searching for code that works or code they can modify. Why not create code that works on your own? Many the things you search now are out of phase and simply will not work perfectly. I can understand you using whatever you find as a reference, I mean why reinvent the wheel? The information you may have found can probably give you insight for what you
need to do. Perhaps modifying code isn't enough anymore, I think people should actually try to invent something on their
own with information they find here. The time you probably took to search for something that works is wasted time you could've used to create something new and effective that you would've understood.
If you want to create an effective method, do it.
I don't know how to go about doing that..
+1 to networks though, you are right, that is correct. and I know I probably need to learn more VB before i try to write an anti flood. yea thats prob the problem
IIRC, the current anti-flood rules are not publicly posted. The code available on the forum is close, but won't cover you reliably.
Well, this may not answer your question, but you can have a look at my (Java) code if you want. I designed it to be easy to understand, so maybe you can learn enough to implement it on your own (it should be obvious what I'm doing). I actually designed the algorithm myself, based on what I thought Adron's was doing (although I never really understood Adron's).
http://www.javaop.com/javaop2/src/AntiFlood/src/PluginMain.java
Look at the getDelay() function. If you want to get ideas from that, let me know if there's anything you don't understand.
Quote from: iago on March 25, 2005, 01:58 PM
Well, this may not answer your question, but you can have a look at my (Java) code if you want. I designed it to be easy to understand, so maybe you can learn enough to implement it on your own (it should be obvious what I'm doing). I actually designed the algorithm myself, based on what I thought Adron's was doing (although I never really understood Adron's).
http://www.javaop.com/javaop2/src/AntiFlood/src/PluginMain.java
Look at the getDelay() function. If you want to get ideas from that, let me know if there's anything you don't understand.
thanks for offering to help but I know no Java lol. But hey, you have SentPackets in there..is that the new part of the aglithorim? :-X
It's pretty straight forward to port that.
Quote from: laurion on March 25, 2005, 02:11 PM
Quote from: iago on March 25, 2005, 01:58 PM
Well, this may not answer your question, but you can have a look at my (Java) code if you want. I designed it to be easy to understand, so maybe you can learn enough to implement it on your own (it should be obvious what I'm doing). I actually designed the algorithm myself, based on what I thought Adron's was doing (although I never really understood Adron's).
http://www.javaop.com/javaop2/src/AntiFlood/src/PluginMain.java
Look at the getDelay() function. If you want to get ideas from that, let me know if there's anything you don't understand.
thanks for offering to help but I know no Java lol. But hey, you have SentPackets in there..is that the new part of the aglithorim? :-X
There is no "the algorithm" -- it varies depending on who wrote it. This is just MY implementation, which is based (loosely) on Adron's.
I base it on 2 factors: the number of packets recently sent and the total number of bytes recently sent.
The function you need is very straight forward. Here is a stripped down version with some comments I added for you:
public long getDelay(String text, Object data)
{
// Increment the number of sent bytes by the length of the text
sentBytes += text.length();
// Increment the number of packets
sentPackets++;
long requiredDelay = 0;
// Find the required delay
requiredDelay += perByte * sentBytes;
requiredDelay += perPacket * sentPackets;
// If we've waited long enough (the packet should be sent out immediately), then reset everything
if(firstMessage + requiredDelay + totalDelay < System.currentTimeMillis())
{
firstMessage = System.currentTimeMillis();
requiredDelay = 0;
sentBytes = text.length();
sentPackets = 1;
totalDelay = requiredDelay;
return 0;
}
// Increase the total delay
totalDelay += requiredDelay;
// Find out what time in the future to send it (based on the current time)
long timeSinceFirst = System.currentTimeMillis() - firstMessage;
// Return the amount of time we need to wait
return requiredDelay - timeSinceFirst + totalDelay;
}
What's missing in iago's compared to mine is that if you don't send anything for a while, you gain some "credits" that you can use to send several messages in a row later. But then, all that is the old flood protection algorithm.
Quote from: Adron on March 25, 2005, 03:24 PM
What's missing in iago's compared to mine is that if you don't send anything for a while, you gain some "credits" that you can use to send several messages in a row later. But then, all that is the old flood protection algorithm.
That's the part of yours that confused me, so I didn't do it. :)
Can you explain on a high level how you do that? Like, how long = how many tokens, type thing?
Quote from: iago on March 25, 2005, 03:25 PM
That's the part of yours that confused me, so I didn't do it. :)
Can you explain on a high level how you do that? Like, how long = how many tokens, type thing?
Hmm, let's see. I like to think of it like this:
Every 10 milliseconds or so, you gain a credit, up to a maximum of 600 credits.
When you send a message, you're charged a base amount of 200 credits plus an additional 1 credit per character in the message.
If you don't have enough credits to send a message when you want to, you'll have to wait until you do.
The numbers are just approximates, I think I had more exact values for them.
Ah, cool. I am kind of doing it the same way, except with no "600 point limit", just with being charged for each byte/packet. I'll have to look into your way :)
how bout that anti-flood -.-
Quote from: laurion on March 25, 2005, 11:48 PM
how bout that anti-flood -.-
Seems to me that there has been given more than enough information (from Adron and myself) to implement it yourself. I'm actually probably going to implement Adron's tomorrow. If I get it working well, I'll post it here :)
Quote from: iago on March 26, 2005, 12:29 AM
Seems to me that there has been given more than enough information (from Adron and myself) to implement it yourself. I'm actually probably going to implement Adron's tomorrow. If I get it working well, I'll post it here :)
Remember that they added a new level of flood protection though. Mine is valid for a low number of messages, up to say .. 30? If you keep sending messages you'll run into the next level flood protection.
Quote from: Adron on March 26, 2005, 07:02 AM
Quote from: iago on March 26, 2005, 12:29 AM
Seems to me that there has been given more than enough information (from Adron and myself) to implement it yourself. I'm actually probably going to implement Adron's tomorrow. If I get it working well, I'll post it here :)
Remember that they added a new level of flood protection though. Mine is valid for a low number of messages, up to say .. 30? If you keep sending messages you'll run into the next level flood protection.
I think your messages have to be over 67 bytes for that though? Unsure, but I have stuff in place just in case, since it's never come up for me.
I took a stab at implementing Adron's algorithm. This is a fairly stripped down version of the class:
private long lastSent = System.currentTimeMillis();
private int credits;
.....
public void activate()
{
credits = Integer.parseInt(out.getLocalSettingDefault(getName(), "starting credits", "200"));
}
......
public Properties getSettingsDescription()
{
Properties p = new Properties();
p.put("debug", "This will show the current delay and the current number of credits each message, in case you want to find-tune it.");
p.put("prevent flooding", "It's a very bad idea to turn this off -- if you do, it won't try to stop you from flooding.");
p.put("cost - packet", "This is the amount of credits 'paid' for each sent packet.");
p.put("cost - byte", "WARNING: I don't recommend changing ANY of the settings for anti-flood. But if you want to tweak, you can. This is the number of credits 'paid' for each byte.");
p.put("cost - byte over threshold", "This is the amount of credits 'paid' for each byte after the threshold is reached.");
p.put("starting credits", "This is the number of credits you start with.");
p.put("threshold bytes", "This is the length of a message that triggers the treshold (extra delay).");
p.put("max credits", "This is the maximum number of credits that the bot can have.");
p.put("credit rate", "This is the amount of time (in milliseconds) it takes to earn one credit.");
return p;
}
public Properties getDefaultSettingValues()
{
Properties p = new Properties();
p.put("debug", "false");
p.put("prevent flooding", "true");
p.put("cost - packet", "200");
p.put("cost - byte", "12");
p.put("cost - byte over threshold", "20");
p.put("starting credits", "200");
p.put("threshold bytes", "65");
p.put("max credits", "600");
p.put("credit rate", "10");
return p;
}
........
public long getDelay(String text, Object data)
{
if(out.getLocalSettingDefault(getName(), "prevent flooding", "true").equals("false"))
return 0;
boolean debug = Boolean.parseBoolean(out.getLocalSettingDefault(getName(), "debug", "false"));
int packetCost = Integer.parseInt(out.getLocalSettingDefault(getName(), "cost - packet", "200"));
int byteCost = Integer.parseInt(out.getLocalSettingDefault(getName(), "cost - byte", "12"));
int byteOverThresholdCost = Integer.parseInt(out.getLocalSettingDefault(getName(), "cost - byte over threshold", "20"));
int thresholdBytes = Integer.parseInt(out.getLocalSettingDefault(getName(), "threshold bytes", "65"));
int maxCredits = Integer.parseInt(out.getLocalSettingDefault(getName(), "max credits", "600"));
int creditRate = Integer.parseInt(out.getLocalSettingDefault(getName(), "credit rate", "10"));
// Add the credits for the elapsed time
if(credits < maxCredits)
{
credits += (System.currentTimeMillis() - lastSent) / creditRate;
if(credits > maxCredits)
{
if(debug)
out.systemMessage(DEBUG, "Maximum anti-flood credits reached (" + maxCredits + ")");
credits = maxCredits;
}
}
lastSent = System.currentTimeMillis();
// Get the packet's "cost"
int thisByteDelay = byteCost;
if(text.length() > thresholdBytes)
byteCost = byteOverThresholdCost;
int thisPacketCost = packetCost + (thisByteDelay * text.length());
if(debug)
out.systemMessage(DEBUG, "Cost for this packet = " + thisPacketCost);
// Check how long this packet will have to wait
int requiredDelay = 0;
// If we can't "afford" the packet, figure out how much time we'll have to wait
if(thisPacketCost > credits)
requiredDelay = (thisPacketCost - credits) * thisByteDelay;
// Deduct this packet from the credits
credits -= thisPacketCost;
if(debug)
out.systemMessage(DEBUG, "Remaining credits: " + credits + "; Delay: " + requiredDelay);
System.out.println(requiredDelay);
return requiredDelay;
}
So far, it seems to be working pretty good. I sent 250 packets of each of a variety of lengths, and it seemed to hold up (after tweaking the perByte time to 12 instead of 10). And it's much faster than my old implementation :)
Option Explicit
'Original class created by iago
'Ported to VB6 by Networks
'
'http://www.zeroforce.net
'http://www.x86labs.org
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private lastSent As Long
Private Credits As Long
Private byteCost As Integer
Private Const packetCost As Integer = 200
Private Const byteOverThresholdCost As Integer = 20
Private Const thresholdBytes As Integer = 65
Private Const maxCredits As Integer = 600
Private Const creditRate As Integer = 10
Private Sub Class_Initialize()
Credits = 200
byteCost = 12
lastSent = GetTickCount()
End Sub
Public Function getDelay(ByVal strText As String) As Long
'Add credits for elasped time
If (Credits < maxCredits) Then
Credits = Credits + ((GetTickCount() - lastSent) / creditRate)
If (Credits > maxCredits) Then
'Maximum anti-flood credits reached
Credits = maxCredits
End If
End If
lastSent = GetTickCount()
'Get the packet's "cost"
Dim thisByteDelay As Integer
thisByteDelay = byteCost
If (Len(strText) > thresholdBytes) Then
byteCost = byteOverThresholdCost
End If
Dim thisPacketCost As Integer
thisPacketCost = packetCost + (thisByteDelay * Len(strText))
'Check how long this packet will have to wait
Dim requiredDelay As Long
requiredDelay = 0
'If we can't "afford" the packet, figure out how much time we'll have to wait
If (thisPacketCost > Credits) Then
requiredDelay = (thisPacketCost - Credits) * thisByteDelay
End If
'Deduct this packet from the credits
Credits = Credits - thisPacketCost
getDelay = requiredDelay
End Function
Ported to Visual Basic 6.0. Have fun kids.
I was porting it for my bot then I fell asleep. :P
Blaze, where is the perByte//BytesPerMS or w/e u wanna call it in that/? Using the one that you ported blaze, it does not work very well with repeated short messages.