Jump to content

Recommended Posts

OK what im trying to do is unpack some bin2hex data from an xml document and print it into a phpnuke block and i need to be able to apply html formatting to it.

The document being: http://www.pbbans.com/sigs/142.xml

 

The printing part works fine, but I can't seem to get a hex2bin function to unpack the data properly.

 

I've tried quite a few things, this being the latest:

 

//the dreaded function
function hex2bin($hexdata){
for( $i = 0; $i < strlen( $hexdata ); $i += 2 )
eval( '$bindata .= "\x' . substr( $hexdata, $i, 2 ) . '";' );
return $bindata;
}
//get the data and print it
ob_start(); 
include("http://www.pbbans.com/sigs/142.xml");
$output = ob_get_contents();
ob_end_clean(); 
$content = hex2bin($output);

 

BUT it ends up returning this:

 

\x \x <\xGR\xOU\xP_\xNA\xME\x>4g&r6öÇWF–ö<\x/G\xRO\xUP\x_N M>\x \x6g2<\x/G\xRO\xUP\x_T G\x> \x <\xGR\xOU\xP_\xWW\xW>http://www.et-main.com/\x\x \x7wwræWBÖÖ–âæ6öÒ<\x/G\xRO\xUP\x_W\xWW\x_S\xHO\xRT\x> \x <\xHE*\x_A M\xIN\x>4Ö¶fVÆ <\x/Hê _*\xMI\xN>\x \xMakaveli\x \x <\xTO\xTA\xL_\xSE\xRVR\xS>4\x\x \x3<\x/S\xTRê\xMI\xNG\x_SR\xVE\xRS\x> \x <\xTO\xTA\xL_º\xNS\x>3C<\x/T\xOT L\x_B N\xS>\x \x3dd0133d685dfdd6fa3d4053a0ac4205\x \x <\xLA\xST\x_B N\xNE _\xGU\xID\x_E\xIG\xHT\x>63C#<\x/L S\xT_º\xNNí\x_G\xUI _I\xGH\xT>\x \x72.232.53.174:27960\x \x <\xLA\xST\x_B N\xNE _\xNIK\x>4w#e <\x/L S\xT_º\xNNí\x_N\xIC\xK>\x \xMay 06, 2007\x \x\x

Which does have SOME of the information unpacked, but obviously isn't right.

 

Anyone know how I can resolve this? Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/50286-solved-decoding-bin2hex-headaches/
Share on other sites

The data returned is an xml file. Only the data is binhex encoded, the tags are not

[pre]

<stats>

<GROUP_NAME>4672616720536f6c7574696f6e</GROUP_NAME>

<GROUP_TAG>66732e</GROUP_TAG>

<GROUP_WWW>687474703a2f2f7777772e65742d6d61696e2e636f6d2f</GROUP_WWW>

<GROUP_WWW_SHORT>7777772e65742d6d61696e2e636f6d2f</GROUP_WWW_SHORT>

<HEAD_ADMIN>4d616b6176656c69</HEAD_ADMIN>

<ADMIN0>4d616b6176656c69</ADMIN0>

<TOTAL_SERVERS>34</TOTAL_SERVERS>

<STREAMING_SERVERS>33</STREAMING_SERVERS>

<TOTAL_BANS>313436</TOTAL_BANS>

<LAST_BANNED_GUID>3364643031333364363835646664643666613364343035336130616334323035</LAST_BANNED_GUID>

<LAST_BANNED_GUID_EIGHT>6130616334323035</LAST_BANNED_GUID_EIGHT>

<LAST_BANNED_SERVER>37322e3233322e35332e3137343a3237393630</LAST_BANNED_SERVER>

<LAST_BANNED_NICK>477230307659</LAST_BANNED_NICK>

<LAST_BANNED_DATE>4d61792030362c2032303037</LAST_BANNED_DATE>

</stats>

 

[/pre]

 

This function will decode the data (php5)

 

function decodebinhex($hexdata) {
    $res = '';
    $ar = str_split($hexdata,2);
    foreach ($ar as $ch) {
        $res .= chr(hexdec($ch));
    }
    return $res;
}

eg, group name

echo decodebinhex('4672616720536f6c7574696f6e');    // --> Frag Solution

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.