|
Joined: Jul 2005
Posts: 40
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2005
Posts: 40 |
I want to use null byte in mirc.. is it possible ?
I must send this info with tcp/ip:
The command packet format consists of:
* packet size (int) o the number of bytes from the start of the requestid to the end of string2 (including the null byte). It must be at least 10. * request id (int) * SERVERDATA_EXECCOMMAND / SERVERDATA_AUTH (int) o SERVERDATA_AUTH is currently 3 o SERVERDATA_EXECCOMMAND is currently 2 * string1 (is the command to run). * string2 must be null ("");
For RCON connections the first command must be a SERVERDATA_AUTH command. If a SERVERDATA_EXECCOMMAND command is sent prior to successful authentication then a SERVERDATA_AUTH_RESPONSE response packet with the failure condition is sent (see the response section for details). The INT's are 32 Bit Little Endian byte order.
j0k3r @ k4s.ch
|
|
|
|
Joined: Sep 2004
Posts: 200
Fjord artisan
|
Fjord artisan
Joined: Sep 2004
Posts: 200 |
bset &bvar 00 sockwrite -<look for the one that says the text is binary> &bvar that should work
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
There isn't a switch for sending a binary variable, instead you just make sure you don't use the -t switch.
New username: hixxy
|
|
|
|
Joined: Jul 2005
Posts: 40
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2005
Posts: 40 |
yes ok but doesn't work ufff...
i've to send: packet size request id SERVERDATA_AUTH string1 string2(must be null)
(http://wikki.kquery.net/index.php/Other:SourceRcon)
on 1:sockopen:rcon: { bset &auth 1 97 115 100 97 115 100 97 115 100 97 115 100 97 00 sockwrite rcon $calc($bvar(&auth,0) + 2) $+ 13 $+ &auth echo -a ...sending... }
on 1:sockread:rcon:{ if ($sockerr > 0) return :nextread sockread &data if ($sockbr == 0) return if (%temp == $null) %temp = - var %i = 0 while (%i <= $bvar(&data,0)) { echo -a %i --> $bvar(&data,%i).text --> $bvar(&data,%i) inc %i } goto nextread }
awww...it doesn't work i dont receive anything.. any idea ?
j0k3r @ k4s.ch
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
You have to add all data to the variable I think, I don't think mIRC lets you send a binary variable as well as normal data.
New username: hixxy
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
Ints are requested, not ascii bytes that match numbers. It should probably look somewhat like this:
bset &requestid 1 0 0 0 1 bset &serverdata 1 0 0 0 3 bset &auth 1 97 115 100 97 115 100 97 115 100 97 115 100 97 0 bset &auth2 1 0 var %packetsize = $calc($bvar(&requestid,0) + $bvar(&serverdata,0) + $bvar(&auth,0) + $bvar(&auth2,0)) bset &size 4 $numtoint(%packetsize) sockwrite rcon &size sockwrite rcon &requestid sockwrite rcon &serverdata sockwrite rcon &auth sockwrite rcon &auth2
Both &auth and &auth2 must end with a 0 as last byte!
Something that might help: ; $numtoint(257) returns 0 0 1 0 alias numtoint { var %1 = $1, %r if (%1 !isnum 0-4294967295) return var %r = $calc(%1 % 256), %1 = $int($calc(%1 / 256)) var %r = $calc(%1 % 256) %r, %1 = $int($calc(%1 / 256)) var %r = $calc(%1 % 256) %r, %1 = $int($calc(%1 / 256)) var %r = $calc(%1 % 256) %r, %1 = $int($calc(%1 / 256)) return %r } ; $inttonum(0 0 1 0) returns 257 alias inttonum { if (!$regex($1-,^(\d+) (\d+) (\d+) (\d+)$)) return return $calc( ((($regml(1) * 256 + $regml(2) ) * 256 + $regml(3) ) * 256 + $regml(4) )) }
|
|
|
|
Joined: Jul 2005
Posts: 40
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2005
Posts: 40 |
Hey, that's nice ! really thx  But, doesn't work :I Awwwwww, i'm hopeless 
alias rcon {
sockopen rcon 82.192.78.16 27025
}
on 1:sockopen:rcon: {
bset &requestid 1 0 0 0 1
bset &serverdata 1 0 0 0 3
bset &auth 1 97 115 100 97 115 100 97 115 100 97 115 100 97 0
bset &auth2 1 0
var %packetsize = $calc($bvar(&requestid,0) + $bvar(&serverdata,0) + $bvar(&auth,0) + $bvar(&auth2,0))
bset &size 1 $numtoint(%packetsize)
echo -a $bvar(&size,1-) $bvar(&requestid,1-) $bvar(&serverdata,1-) $bvar(&auth,1-) $bvar(&auth2,1-)
sockwrite rcon &size
sockwrite rcon &requestid
sockwrite rcon &serverdata
sockwrite rcon &auth
sockwrite rcon &auth2
echo -a ...sending...
}
on 1:sockread:rcon:{
if ($sockerr > 0) return
:nextread
sockread &data
if ($sockbr == 0) return
if (%temp == $null) %temp = -
var %i = 0
while (%i <= $bvar(&data,0)) {
echo -a %i --> $bvar(&data,%i).text --> $bvar(&data,%i)
inc %i
}
goto nextread
}
; $numtoint(257) returns 0 0 1 0
alias numtoint {
var %1 = $1, %r
if (%1 !isnum 0-4294967295) return
var %r = $calc(%1 % 256), %1 = $int($calc(%1 / 256))
var %r = $calc(%1 % 256) %r, %1 = $int($calc(%1 / 256))
var %r = $calc(%1 % 256) %r, %1 = $int($calc(%1 / 256))
var %r = $calc(%1 % 256) %r, %1 = $int($calc(%1 / 256))
return %r
}
btw why bset &size 4 $numtoint(%packetsize) ? i think it's 1 ... (in this exemple the pass is wrong, however the server should respond.. but that's not  )
j0k3r @ k4s.ch
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
You're right it's 1 not 4. But an int (number data type) should be 4 bytes long. It could be because of that little/big endian stuff, so maybe try reversing the different bytes of the int's. 0 0 0 1 -> 1 0 0 0 1 2 3 4 -> 4 3 2 1 What you should do, is download a packet sniffer like ethereal and use that to see what actually gets sent by a standalone rcon client, by your client and by the game server. This way you can determine what the difference is, and if it's really the sending or the receiving that's not working in mIRC. In this case, enable the packet sniffer, un the rcon program and stop the sniffer, then check the log for the connection to the server and see what data is sent, and what it should actually be. I also find the on sockread event handler very strange, I think there's some $bvar problems. Try just writing everything to a file and open that with a hex editor. Make sure to remove or rename the file before each test  sockread &data bwrite rcon.txt -1 -1 &data
|
|
|
|
Joined: Jul 2005
Posts: 40
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2005
Posts: 40 |
With the sniffer:
17 00 00 00 02 00 00 00 03 00 00 00 61 73 64 61 73 64 61 73 64 61 73 64 61 00 00
So what must i do ? :I
thx xD
j0k3r @ k4s.ch
|
|
|
|
Joined: Jul 2005
Posts: 40
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2005
Posts: 40 |
i've modified the script: bset &size 1 %packetsize now with mirc it is:
00000000 17 . 00000001 00 00 00 02 00 00 00 03 61 73 64 61 73 64 61 73 ........ asdasdas 00000011 64 61 73 64 61 00 00 dasda..
and the working must be:
00000000 17 00 00 00 02 00 00 00 03 00 00 00 61 73 64 61 ........ ....asda 00000010 73 64 61 73 64 61 73 64 61 00 00 sdasdasd a..
j0k3r @ k4s.ch
|
|
|
|
Joined: Jul 2005
Posts: 40
Ameglian cow
|
OP
Ameglian cow
Joined: Jul 2005
Posts: 40 |
AHHAHA ! IT WORKS ! WHAHAHA !!!
on 1:sockopen:rcon: {
bset &requestid 1 0 0 0 1 bset &serverdata 1 0 0 0 3 bset &auth 1 0 0 0 97 115 100 97 115 100 97 115 100 97 115 100 97 0 bset &auth2 1 0
set %packetsize $calc($bvar(&requestid,0) + $bvar(&serverdata,0) + $bvar(&auth,0) + $bvar(&auth2,0) - 3)
bset &all 1 %packetsize $bvar(&requestid,1-) $bvar(&serverdata,1-) $bvar(&auth,1-) $bvar(&auth2,1-)
sockwrite rcon &all
}
my only trouble is that i must subtract 3 bytes i think is because of the red text.. but no problem XDDDD
Ty for all !!! (and thx to Ethereal :angel: )
j0k3r @ k4s.ch
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
It's the reverse of what I said: 1 is 00 00 00 01 in bytes, but the bytes are reversed during transport so it becomes 01 00 00 00 258 becomes 02 01 00 00 == 2 + 1*256 + 0*256^2 + 0 * 256^3 alias numtoint { var %1 = $1, %r if (%1 !isnum 0-4294967295) return var %r = $calc(%1 % 256), %1 = $int($calc(%1 / 256)) var %r = %r $calc(%1 % 256), %1 = $int($calc(%1 / 256)) var %r = %r $calc(%1 % 256), %1 = $int($calc(%1 / 256)) var %r = %r $calc(%1 % 256), %1 = $int($calc(%1 / 256)) return %r } alias inttonum { if (!$regex($1-,^(\d+) (\d+) (\d+) (\d+)$)) return return $calc( ((($regml(4) * 256 + $regml(3) ) * 256 + $regml(2) ) * 256 + $regml(1) )) } I colored the output so you know what belongs together: 17 00 00 00 02 00 00 00 03 00 00 00 61 73 64 61 73 64 61 73 64 61 73 64 61 00 00bset &requestid 1 $numtoint(1)bset &serverdata 1 $numtoint(3)bset &auth 1 61 73 64 61 73 64 61 73 64 61 73 64 61 0 0OR bset -t &auth1 1 asdfasdasd; you still need to append the 0 after that text, maybe easiest to just bset &auth2 1 0 0var %len = $calc( 4+ 4+ $len( asdfasdasd) + 1+ 1) bset &len 1 $numtoint(%len)You can use your solution to append everything to one &binvar, but since you have to convert it back to digits, it can get longer than 900 chars very easily. Just using multiple sockwrites should not give a problem. Otherwise, you can use the /bcopy command to copy everything to a single &binvar without the $bvar conversions. Glad it works though 
Last edited by Kelder; 08/08/05 12:46 PM.
|
|
|
|
|