• Welcome to Valhalla Legends Archive.
 

Re: [VB]Handling 0x09

Started by Joe[x86], April 14, 2005, 10:07 PM

Previous topic - Next topic

Joe[x86]

        strIP = Asc(Mid(strTempData, 1, 1)) & "." & _
               Asc(Mid(strTempData, 2, 1)) & "." & _
               Asc(Mid(strTempData, 3, 1)) & "." & _
               Asc(Mid(strTempData, 4, 1))


I suggest using a function, as this is done in many packets, if I'm correct. Its also used in proxy handling, which many bots have.

Public Function DWORDtoIP(DWORD as Long) as String
    Dim IP as String * 11
    For i = 1 to 4
        IP = IP and Asc(Mid(DWORD, i, 1)
    Next i
    DWORDtoIP = IP
End Function

Public Function IPtoDWORD(IP as Long) as Long
    Dim DWORD as String * 4, Splt(0 to 4) as String
    Splt = Split(IP, ".")
    For i = 1 to 4
        DWORD = DWORD and Chr(CLng(Splt(i)))
    Next i
    IPtoDWORD = CLng(DWORD)
End Function
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

UserLoser.

#1
Just use inet_addr and inet_ntoa instead of using much less efficient vb code

Example:
inet_addr(255.255.255.255) = 0xffffffff
unsigned long addr = 0x12345678;
inet_ntoa(*(struct in_addr*)&addr)) = 120.86.52.18

Joe[x86]

Huh? Mind posting a VB code snippet to call the C++ function or whatever it is?
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

Eric


Kp

As a side note, inet_addr is obsolete and should not be used in new code.  You should instead use inet_aton.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

l)ragon

#5
Not to be rude lol but can somone split this into the general forum, and re-lock it for now.
edit: This way if I ever fix anything the post is not like 3 pages away from the original info.
If I could edit my posts while the thread was locked I wouldent have asked for it to be unlocked though I think theres a limit on how much text I can add to it anyways.



The reasons I did that for the IP instead of going with eg. inet_ntoa, was to keep it as simple as possible and to show how to do this manualy (doubt there's many here familiar with the function anyways), which I was going to do with GetLong in the begining but I'm sure noone wanted to see (((b*(2^8))*(2^8))*(2^8)) etc etc etc..
Eventualy you'll probably find more things that could be done better, which should be done at your own discretion.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

MyndFyre

Quote from: l)ragon on April 15, 2005, 03:03 AM
Not to be rude lol but can somone split this into the general forum, and re-lock it for now.
I would have, but I thought you didn't want it locked at the moment.  Topic split.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

l)ragon

Quote from: MyndFyre on April 15, 2005, 03:51 AM
Quote from: l)ragon on April 15, 2005, 03:03 AM
Not to be rude lol but can somone split this into the general forum, and re-lock it for now.
I would have, but I thought you didn't want it locked at the moment.  Topic split.
I was going to complete it the night of my last post to the thread, but I kept getting side tracked with other crap, and at the moment I dont have vb6 installed on this pc, and its about a 36 hour walk from here to get my cd's, so it may be awhile.
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

Joe[x86]

#8
Thanks MyndFyre. Didn't mean to spark a whole big thing, just wanted to make a suggestion.

Hrm, LoRd[nK], I've never really used DLL functions before. Mind giving a bit of help here? I hope I got this right, but I don't know if I did.

Public Declare Function inet_addr Lib Ws2_32.dll (in as String)
'// inet_addr is used as an IPtoDWORD function.

Public Declare Function inet_ntoa Lib Ws2_32.dll (in as String)
'// inet_ntoa is used as a DWORDtoIP function.

Public Function IPtoDWORD(IP as String) as Long
    '// This is used as a wrapper for the inet_addr function, providing an easier to remember name.
    IPtoDWORD = inet_addr(IP)
End Function

Public Function DWORDtoIP(DWORD as Long) as String
    '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name.
    DWORDtoIP = inet_ntoa(DWORD)
End Function
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

l)ragon

Quote from: Joex86] link=topic=11287.msg108685#msg108685 date=1113599999]
Thanks MyndFyre. Didn't mean to spark a whole big thing, just wanted to make a suggestion.

Hrm, LoRd[nK], I've never really used DLL functions before. Mind giving a bit of help here? I hope I got this right, but I don't know if I did.

Public Declare Function inet_addr Lib Ws2_32.dll (in as String)
'// inet_addr is used as an IPtoDWORD function.

Public Declare Function inet_ntoa Lib Ws2_32.dll (in as String)
'// inet_ntoa is used as a DWORDtoIP function.

Public Function IPtoDWORD(IP as String) as Long
    '// This is used as a wrapper for the inet_addr function, providing an easier to remember name.
    IPtoDWORD = inet_addr(IP)
End Function

Public Function DWORDtoIP(DWORD as Long) as String
    '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name.
    DWORDtoIP = inet_ntoa(DWORD)
End Function


Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Private Declare Function inet_ntoa Lib "wsock32.dll" (ByVal addr As Long) As Long
*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*ˆ¨¯¯¨ˆ*^~·.,l)ragon,.-·~^*ˆ¨¯¯¨ˆ*^~·.,¸¸,.·´¯`·.,¸¸,.-·~^*

UserLoser.


Public Function DWORDtoIP(DWORD as Long) as String
    '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name.
    DWORDtoIP = inet_ntoa(DWORD)
End Function


That doesn't work.  inet_ntoa is returning as a Long, or pointer to the string.  See: lstrcpy(A/W)

Joe[x86]

#11
Ooh, thanks. The rest works, provided I make them return longs?

EDIT: Anybody wanna explain the whole Alias thing? I think that way we would only need the wrapper for the second, when we un-pointer-ify the string.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

R.a.B.B.i.T

Quote from: l)ragon on April 15, 2005, 05:50 PM
Quote from: Joex86] link=topic=11287.msg108685#msg108685 date=1113599999]
Thanks MyndFyre. Didn't mean to spark a whole big thing, just wanted to make a suggestion.

Hrm, LoRd[nK], I've never really used DLL functions before. Mind giving a bit of help here? I hope I got this right, but I don't know if I did.

Public Declare Function inet_addr Lib Ws2_32.dll (in as String)
'// inet_addr is used as an IPtoDWORD function.

Public Declare Function inet_ntoa Lib Ws2_32.dll (in as String)
'// inet_ntoa is used as a DWORDtoIP function.

Public Function IPtoDWORD(IP as String) as Long
    '// This is used as a wrapper for the inet_addr function, providing an easier to remember name.
    IPtoDWORD = inet_addr(IP)
End Function

Public Function DWORDtoIP(DWORD as Long) as String
    '// This is used as a wrapper for the inet_ntoa function, providing an easier to remember name.
    DWORDtoIP = inet_ntoa(DWORD)
End Function


Private Declare Function inet_addr Lib "wsock32.dll" (ByVal s As String) As Long
Private Declare Function inet_ntoa Lib "wsock32.dll" (ByVal addr As Long) As Long

such a waste of cycles...

MyndFyre

Quote from: Joex86] link=topic=11287.msg108722#msg108722 date=1113617829]
Ooh, thanks. The rest works, provided I make them return longs?

EDIT: Anybody wanna explain the whole Alias thing? I think that way we would only need the wrapper for the second, when we un-pointer-ify the string.

Alias allows you to define a name for your function that is something other than the export from the DLL.  For example, CopyMemory is actually a declared alias of the DLL function RtlMoveMemory.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.