开发者

Extracting strings from binary file using regex and converting to ASCII -- Using Perl

Trying to figure out how to extract a string off characters from a binary file and convert them to ascii. The characters are a barcode, which is preceded by a constant string of text. My thought is to figure out what the HEX pattern is for the string constant string and extract the string based on that, then convert the HEX to ASCII.

Problem is I don't know how get perl to "read" the file, or "see" what it's seeing. Meaning 开发者_StackOverflow社区that if the file was a text file, might do something like this - Perl: extracting data from text using regex - but I don't know how to figure out what the binary pattern I'm targeting is; that said, I've posted one view of this data here: Extracting “plaintext” header from HEX file using Perl

How do I do this in Perl?


Here's one easy way to do it:

perl -nlwe "print for m/\w{2,}/g" < bla.exe

That'll print all strings composed of \w{2,}, i.e. legacy word characters exclusively, and at least two of them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜