mIRC Home    About    Download    Register    News    Help

Print Thread
#91927 27/07/04 05:56 PM
Joined: Jul 2004
Posts: 15
H
Pikka bird
OP Offline
Pikka bird
H
Joined: Jul 2004
Posts: 15
I'm working on a socket script that is translating binary information on network connections. Two of the bytes are 27 88. I know by there position in the packet that it's the port number 7000. Could someone please tell me the math necessary to translate the 27 88 to 7000.

Great appreciation in advance. laugh


- HumbleSage
"i don't know what this randomizer is thinking" - LEET
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Without getting into details, you can view "27 88" as a base-256 system (except that we don't use extra symbols for numbers greater than 9, but decimal representations). Having this in mind, you can calculate the port using
$calc((27 * 256) + 88) = $calc(27 * 256 + 88)
You can make an alias if you like:
Code:
alias calcport return $calc($replace($1,$chr(32),* 256 +))
$calcport(27 88) returns "7000".


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Jul 2004
Posts: 15
H
Pikka bird
OP Offline
Pikka bird
H
Joined: Jul 2004
Posts: 15
Works like a champ qwerty. thanks. smile


- HumbleSage
"i don't know what this randomizer is thinking" - LEET
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
It's also possible to use $bvar in this way:

//bset &var 1 [color:blue]127 0 0 1 27 88 | echo IP: $longip($bvar(&var,1).nlong)

//bset &var 1 127 0 0 1 27 88 | echo Port: $bvar(&var,5).nword[/color]


Link Copied to Clipboard