Author | Message | Time |
---|---|---|
Jaquio | I seen a topic on here, and the source page to download is down. So I went ahead and almost started making one, but then already ran into a problem. You know how some packet parsers in Visual Basic use the copymemory(Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long)) well would you really need to do that in PHP to do things like make a dword an such? Or would there be another way of doing it? I am converting this to php. [code] Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal numbytes As Long) Public Function Clear() strBuffer = vbNullString End Function Public Function ClearData() strBuff = vbNullString End Function Public Function GetData() As String GetData = strBuff End Function Public Function InsertATString(Data As String) strBuffer = strBuffer & Data & Chr(&HA) End Function Public Function InsertBYTE(Data As Integer) strBuffer = strBuffer & Chr(Data) End Function Public Function InsertBytes(Data As String) Dim i As Long Dim enqueueer As String For i = 1 To Len(Data) Step 3 enqueueer = enqueueer & Chr(Val("&h0" & Mid(Data, i, 2))) Next i strBuffer = strBuffer & enqueueer End Function Public Function InsertData(Data As String) strBuffer = strBuffer & Data End Function Public Function InsertDWORD(Data As Long) strBuffer = strBuffer & MakeDWORD(Data) End Function Public Function InsertDWORDArray(Data() As Long) Dim i As Integer For i = LBound(Data) To UBound(Data) Step 1 strBuffer = strBuffer & MakeDWORD(Data(i)) Next i End Function Public Function InsertNonNTString(Data As String) strBuffer = strBuffer & Data End Function Public Function InsertNonNTStringArray(Data() As String) Dim i As Integer For i = LBound(Data) To UBound(Data) Step 1 strBuffer = strBuffer & Data(i) Next i End Function Public Function InsertNTString(Data As String) strBuffer = strBuffer & Data & Chr(0) End Function Public Function InsertWORD(Data As Integer) strBuffer = strBuffer & MakeWORD(Data) End Function Public Function MakeDWORD(Value As Long) As String Dim Result As String * 4 CopyMemory ByVal Result, Value, 4 MakeDWORD = Result End Function Function MakeWORD(Value As Integer) As String Dim Result As String * 2 CopyMemory ByVal Result, Value, 2 MakeWORD = Result End Function Public Function rATString() As String On Error Resume Next rATString = Left(strBuff, InStr(strBuff, Chr(&HA)) - 1) strBuff = Mid(strBuff, Len(rATString) + 2) End Function Public Function rBYTE() As Byte rBYTE = Asc(Left(strBuff, 1)) strBuff = Mid(strBuff, 2) End Function Public Function rDWORD() As Long Dim lReturn As Long, strTMP As String strTMP = Left(strBuff, 4) Call CopyMemory(lReturn, ByVal strTMP, 4) rDWORD = lReturn strBuff = Mid(strBuff, 5) End Function Public Function rFILETIME(Optional QWORD As Boolean = False) As String Dim strFT() As String, strTMP As String If Not QWORD Then strFT = Split(rNTString & Space(1), Space(1)) If strFT(0) > 2147483647 Then strFT(0) = (strFT(0) - 4294967296#) If strFT(1) > 2147483647 Then strFT(1) = (strFT(1) - 4294967296#) Else ReDim strFT(0 To 1) strFT(1) = rDWORD strFT(0) = rDWORD End If rFILETIME = strFT(0) & Space(1) & strFT(1) End Function Public Function rNonNTString() As String rNonNTString = Left(strBuff, 4) strBuff = Mid(strBuff, 5) End Function Public Function rNTString() As String On Error Resume Next rNTString = Left(strBuff, InStr(strBuff, Chr(&H0)) - 1) strBuff = Mid(strBuff, Len(rNTString) + 2) End Function Public Function rVOID(Leng As Integer) As String If Len(strBuff) < Leng Then Leng = Len(strBuff) rVOID = Left(strBuff, Leng) strBuff = Mid(strBuff, Leng + 1) End Function Public Function rWORD() As Long Dim lReturn As Long, strTMP As String strTMP = Left(strBuff, 2) Call CopyMemory(lReturn, ByVal strTMP, 2) rWORD = lReturn strBuff = Mid(strBuff, 3) End Function Public Function SendBNCSPacket(PacketID As Byte) If frmMain.wskBNet.State <> sckConnected Then: Exit Function Debug.Print "Sent:" & GetPacketName(PacketID, "BNCS") & "(" & Hex(PacketID) & ")" frmMain.wskBNet.SendData Chr(&HFF) & Chr(PacketID) & MakeWORD(Len(strBuffer) + 4) & strBuffer Clear End Function Public Function SendBNLSPacket(PacketID As Byte) If frmMain.wskBNLS.State <> sckConnected Then: Exit Function frmMain.wskBNLS.SendData MakeWORD(Len(strBuffer) + 3) & Chr(PacketID) & strBuffer Clear End Function Public Function SendRPacket(PacketID As Byte) If frmMain.wskRealm.State <> sckConnected Then: Exit Function frmMain.wskRealm.SendData MakeWORD(Len(strBuffer) + 3) & Chr(PacketID) & strBuffer Clear End Function Public Function SetData(Data As String) strBuff = Data End Function [/code] | November 5, 2006, 9:29 AM |
rabbit | pack() | November 5, 2006, 12:37 PM |
Jaquio | [quote author=rabbit link=topic=15981.msg160771#msg160771 date=1162730257] pack() [/quote] Heh, sorry for bothering everyone. Didn't know there was a function like that. Also, does anyone think this is really gonna work.. O_o | November 5, 2006, 1:53 PM |
rabbit | I made a [rather bad] PHP bot way back, but it did work for a little bit (it exploded after a minute or so, and you couldn't chat, but eh?). | November 5, 2006, 3:21 PM |
FrOzeN | tonton from StealthBot.net posted one he made along with the source. http://www.stealthbot.net/board/index.php?showtopic=6244&st=20 Maybe that can help you, hopefully I didn't just cause you to leak of that. :-\ | November 5, 2006, 3:30 PM |
Jaquio | Nah, I don't use other peoples stuff if anything I learn from it, if I ever do use bits of peoples code I always put the author in the source and whatnot. This however I can't remember who wrote (I converted from VB) I found it on these forums somewhere though. [code] <?php global $strBuffer; global $strBuff; Function Clear($V){ global $strBuffer; $strBuffer = "$V"; } Function ClearData($V){ global $strBuff; $strBuff = "$V"; } Function GetData(){ global $strBuff; return $strBuff; } Function InsertATString($Data){ global $strBuffer; $strBuffer = $strBuffer.$Data.Chr(10); } Function InsertByte($Data){ global $strBuffer; $strBuffer = $strBuffer.Chr($Data); } //Function InsertBytes($Data) Function InsertData($Data){ global $strBuffer; $strBuffer = $strBuffer.$Data; } Function InsertDWORD($Data){ global $strBuffer; $strBuffer = $strBuffer.MakeDWORD($Data); } Function InsterNonNTString($Data){ global $strBuffer; $strBuffer = $strBuffer.$Data; } Function InsertNTString($Data){ global $strBuffer; $strBuffer = $strBuffer.$Data.Chr(0); } Function InsertWORD($Data){ global $strBuffer; $strBuffer = $strBuffer.MakeWORD($Data); } Function Left($String, $Length){ //Remember Length starts from 0 not 1. return substr($String, 0, $Length); } Function MakeDWORD($Value){ return pack("V*", $Value); } Function MakeWORD($Value){ return pack("v*", $Value); } Function Mid($String, $Start, $Length){ //Remember Start and Length start from 0 not 1. return substr($String, $Start, $Length); } Function rBYTE(){ global $strBuff; return ord(Left($strBuff, 0)); $strBuff = Mid($strBuff, 1); } Function rDWORD(){ global $strBuff; return MakeDWORD(Left($strBuff, 3)); $strBuff = Mid($strBuff, 4); } Function rFILETIME($QWORD){ if($QWORD == "false"){ $strFT = split(chr(32), rNTString().chr(32)); if($strFT[0] > 2147483647){ $strFT[0] = $strFT[0] - 4294967296; } if($strFT[1] > 2147483647){ $strFT[1] = $strFT[1] - 4294967296; } } else { $strFT[1] = rDWORD; $strFT[0] = rDWORD; } return $strFT[0].chr(32).$strFT[1]; } Function rNonNTString(){ global $strBuff; return Left($strBuff, 3); $strBuff = Mid($strBuff, 4); } Function rNTString(){ //rNTString = Left(strBuff, InStr(strBuff, Chr(&H0)) - 1) //strBuff = Mid(strBuff, Len(rNTString) + 2) global $strBuff; return "Got to find a replacement for InStr."; } Function rVOID($Length){ global $strBuff; if(strlen($strBuff) < $Length){ $Length = strlen($strBuff); } return Left($strBuff, $Length); $strBuff = Mid($strBuff, $Length + 1); } Function rWORD(){ global $strBuff; return MakeWORD(Left($strBuff, 2)); $strBuff = Mid($strBuff, 2); } ?> [/code] What would be a good replacement for rNTString anyone know? Just took a look at the source code, boy is it confusing... lol will take some time to figure out what does what. Thanks | November 5, 2006, 4:00 PM |
rabbit | Whoever wrote that sucks horribly at PHP, and is a leecher (as proven by the fact they use pack() but don't have a clue about strpos() and substr()). I'm guessing by the horrible conventions that "r" means "remove". It's easy: [code]$nullpos = strpos($databuff, '\x0', $pos); $ret = substr($databuff, $pos, $nullpos); $pos = $nullpos; return $ret;[/code] Rough, but should work. | November 5, 2006, 7:23 PM |
Jaquio | I wrote that to the best of my knowledge, I am sorry I did it the best I could. Thanks for that though perhaps I could re-do it thanks for information. I converted it from that class file I posted above. | November 5, 2006, 8:37 PM |
rabbit | HAH! I misinterpreted. I thought you said you found that. I guess it makes sense that strpos() and substr() aren't there but pack() is (since I told you about it) :P Sorry. | November 5, 2006, 9:56 PM |
Jaquio | Ohh, yea I did say I found it but I was trying to say I found the Visual Basic version of it. Heh, so the strpos() and substr() does that replace all the pack()'s in there? Or what, I think I misunderstood what you posted not sure if it was for just the rntstring or for all of them. As of now I used it this way. [code] Function InStr($Start, $String){ $nullpos = strpos($Start, $String, $pos); return substr($Start, $pos, $nullpos + 1); $pos = $nullpos; } [/code] Probably a bad thing? | November 6, 2006, 12:25 AM |
rabbit | $pos = $nullpos won't trigger! Putting code after a return does nothing :P Also, never use VB function names ever anywhere. | November 6, 2006, 2:42 AM |
Jaquio | Ohh alright, thanks. I will fix that in all my functions as well as renaming them I just left them like they were because I can't come up with anything better but I will think and maybe I will. | November 6, 2006, 3:11 AM |
JoeTheOdd | Here's the sorry reminants of my attempt. Enjoy, or be discusted. Your choice. :) | November 6, 2006, 3:38 AM |
Jaquio | [quote author=Joe[x86] link=topic=15981.msg160854#msg160854 date=1162784314] Here's the sorry reminants of my attempt. Enjoy, or be discusted. Your choice. :) [/quote] If it's alright with you, could I use that pbuffer.php? It works a lot better then my shitty converted vb code. Lol, as well as that debugOutput function you(or someone else?) ported from iago. | November 7, 2006, 4:11 PM |