in reply to how to extract original string from binary files?

Hi swapy345,

The data looks to me like, since binary not human readable. ...

We're humans too, and we can't read it either ;-)

Please use a tool like hexdump or Data::Dumper (with $Data::Dumper::Useqq=1;) if you want to show a representative sample of your data.

Regards,
-- Hauke D

Replies are listed 'Best First'.
Re^2: how to extract original string from binary files?
by swapy345 (Initiate) on May 19, 2016 at 15:48 UTC
    Any feedback on http://search.cpan.org/~mhx/Convert-Binary-C-0.76/lib/ +Convert/Binary/C.pm ? Regards, Swapnil

      Convert::Binary::C seems like an ill fit for your situation. It is most usable when you want to pack (or unpack) data according a given C structure and you want to match the alignment that the C compiler has applied to the structure.

      So far, you have not shown us that you already have the existing C structure. Because of that, I can only advise against using this module. Maybe you want to look at pack and perlpacktut instead.

        Hi Corion,

        Thanks for reply. I have posted hex dump & code I am using.



        Regards,
        Swapnil

        Hi Corion,

        Thanks for your reply. One more input: Binary is created using C & C header file isn't available with me. So could we parse binary C source if header isn't available?



        Regards,


        Swapnil

Re^2: how to extract original string from binary files?
by swapy345 (Initiate) on May 19, 2016 at 15:13 UTC

    Hi Haukex,

    Could I get email id? So that I can email the binary file. It is urgent on my side to solve the issue.I thought my solution would work but it not.

    Regards,

    Swapnil

      Hi Swapnil,

      For various reasons I think it's best to just continue working via this site, that way everyone can learn from this thread. I already mentioned two ways you can convert your binary data to a format you can post here, to add more examples to that list there's A simple hex dump in pure Perl and various Windows tools available.

      However, posting your binary data here won't help much if we don't know what format the file is in - the file format is actually much more important than the binary data. I see you've tried to describe it in the root node, but it's difficult to read, try using <code> tags.

      Regards,
      -- Hauke D

        Hi Haukex,

        Please check the hex dump of binary. 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 ) 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 012345678 +9ABCDEF 00000000 41 52 52 41 59 28 30 78 - 31 65 62 64 63 66 30 30 ARRAY(0x1 +ebdcf00 00000010 29 sharing code as well. #!/usr/bin/perl #use Data::Hexdumper; open(FH, '<:raw', "binary1.txt") or die "help"; #open(FH1, "test1.txt"); binmode FH; #binmode FH1; use Encode qw/encode decode/; use Data::Dumper; use Data::HexDump; while ( (read (FH, $buffer, 256)) != 0 ) { $hex = unpack("H*", $buffer); $hex .= ' ' x ( length($hex) < 48 ? 48 - length($hex) : 0 ); push @rec, "$hex $_"; print "\n"; print HexDump \@rec; } close (FH); If site provide browse option it would be great help! :) Regards, Swapnil