• Welcome to Valhalla Legends Archive.
 

When I send this I get ip banned... Why?

Started by Nub, July 13, 2003, 08:59 PM

Previous topic - Next topic

Nub

I'm trying to learn to send packets and things, and when I try to send a packet to say "the wheels ont he bus go round and round" with this function I get ip banned...
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numBytes As Long)

Public Function blah() As String
Dim data$, final$, result As String * 2
data = "74 68 65 20 77 68 65 65 6c 73 20 6f 6e 74 20 68 65 20 62 75 73 20 67 6f 20 72 6f 75 6e 64 20 61 6e 64 20 72 6f 75 6e 64 00 "

For i = 1 To Len(data)
final = final & Chr("&H" & Left(data, 2))
data = Right(data, Len(data) - 3)
Next i

data = ""
data = data & Chr(&HFF)
data = data & Chr(&HE)
CopyMemory ByVal result, Len(final) + 4, 2
data = data & result
data = data & final
BUFFER = data
End Function

Then I called it like this....

Private sub Command1_Click()
CleanSlateBot1.Send blah
End Sub

Help me...  :'(



UserLoser

No need to insert chr(ff) and chr(e), I believe .Send is for chat messages, and already includes that.

You could just do CleanSlateBot.Send "Hello world!"

Nub

I know that I could just do .send "blah"
The reason im doing it this way though is because I'm trying to learn how to send packets to bnet. Just useing 0x0e (I think) because its easy...

Nub

Quote from: UserLoser on July 13, 2003, 10:49 PM
No need to insert chr(ff) and chr(e), I believe
Wouldn't I need that as part of the packet header?

UserLoser

If you want to send other besides 0x0e, with CleanSlateBot, you'd have to use .BuildPacket.  I've never used it before, so I don't know how to do it.

Nub

Thenks for the help UserLoser

Can anyone help me with .buildpacket?

Camel

I don't think this will help you too much if you're using CSB, but here it is anyways:
Option Explicit

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numBytes As Long)

Public Function MakePacket(ByVal ID As Long, ByVal Data As String) As String
   MakePacket = Chr(&HFF) & Chr(ID) & MKI(Len(Data) + 4) & Data
End Function

Public Function MKI(Value As Integer) As String
   Dim Result As String * 2
   
   CopyMemory ByVal Result, Value, 2
   MKI = Result
End Function

Public Function sendChatPacket(strText As String) As String
   sendChatPacket = MakePacket(&HE, strText & Chr(0))
End Function

Public Function HexToStr(ByVal Hex1 As String) As String
   'I didn't write this function, nor do I use it for non-debugging purposes
   
   Dim strTemp As String, strReturn As String, I As Long
   Hex1 = Replace(Hex1, " ", "")
   If Right(Hex1, 1) = Chr(0) Then Hex1 = Left(Hex1, Len(Hex1) - 1)
   If Len(Hex1) Mod 2 <> 0 Then Exit Function

   Dim Y As String
   For I = 1 To Len(Hex1)
       Y = UCase(Mid(Hex1, I, 1))
       If (Not IsNumeric(Y)) And (Asc(Y) < Asc("A") Or Asc(Y) > Asc("F")) Then
           Exit Function
       End If
   Next

   For I = 1 To Len(Hex1) Step 2
       Dim x As Integer
       Y = Mid(Hex1, I, 2)
       
       x = Val("&H" & Y)
       If x < 0 Or x > 255 Then
           HexToStr = ""
           Exit Function
       End If
       strReturn = strReturn & Chr(x)
   Next I
   HexToStr = strReturn
End Function

Public Function blah() As String
   Dim Data As String, Final As String
   Data = "74 68 65 20 77 68 65 65 6c 73 20 6f 6e 74 20 68 65 20 62 75 73 20 67 6f 20 72 6f 75 6e 64 20 61 6e 64 20 72 6f 75 6e 64 00 "
   
   Final = HexToStr(Data)
   
   blah = sendChatPacket(Final)
End Function

Nub

I think the packet ends up being the same as with my function... The problem still stands for me to send the packet with CSB.
Thanks for the input

Camel

I understand that, but now you don't need that [ugly] code every time you want to send a packet. :)


Eternal

He has a point Nub...it isn't going to win any code beauty contests... ;D
^-----silly Brit
-----------------------------
www.brimd.com

Kp

Quote from: Nub on July 13, 2003, 10:33 PM*waits for help*;D
Barely an hour and a half had passed between you first request and your thread bump.  Have a little more patience, especially when you supply such ugly code.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!