regex - How to extract certain words from a "disassembled" file -


i'm doing :

#!/usr/bin/env/perl  open file1, "<exed.exe"; open file2, ">fileinhexadecimal.txt";  binmode file1;  while (<file1>) { $lines = $_; $lines = unpack("h*", $lines); chomp $lines; print file2 "$lines\n"; }  close (file1); close (file2) print "finish\n"; <>; 

after, created other program read ".txt" file search infos.

with script, i'm creating text file containing hexadecimal data of .exe file. great problem :

1- want extract line regexp : /8b55-(.*)-8b55/ (with second script, wasn't posted here)

2 - here problem :

ever file.txt :

8b55-646464-8b558b55-636363-8b55 8b55-656565-8b558b55-666666-8b55 

when run script, script pop these data :

"646464", "656565". 

you still not understanding question. want extract : 646464, 636363, 656565, 666666. script, when found first match, he's jumping next line, don't reading rest.

can how catch matchs ? other example :

8b55-646464-8b55987941651968798779878b55-686868-8b55 8b55-iloveyou-8b55 

here, script catch 646464 , iloveyou. (is missing 686868):/

the real file i'm searching data, big , have lines, bigger example.

i tried use "g" : if ($lines =~ /(.*)/g) {

but not works.

my second script :

i'm trying running script :

#!/usr/bin/perl   open file, "<fileinhexadecimal.txt";  while (<file>) { $lines = $_; if ($lines =~ /8b55-(.*)-8b55/g) { print "-$1\n"; } } close (file)  <>; 

and nothing happens. i'm trying extract sequencial words giant file, , happening this, used 8b55 example. problem same. new idea ? how use code ?

@match = /8b55-(.*?)-8b55/g; print "@match\n";

??? resp , sorry bad english

real question

the line :

8bcee84ec4ffff6a016a2b6a2b686c0100008bcee83cc4ffff6a016a2b6a2b686c0100008bcee82ac4ffff6a016a0e6a0e686d0100008bcee818c4ffff6a016a146a1468f20100008bcee806c4ffff6a006a0e6a0e68700100008bcee8f4c3ffff6a016a1e6a1e6871010000

in line, have 6 data extract.

i use regexp extract :

8bcee8....ffff6a(..)6a(..)6a(..)68(..)(..)0000

on first line, have 3 matchs, on second have 2 matchs , last line have 1 match (8bcee8f4c3ffff6a016a1e6a1e6871010000)

i want extract, practically, \1 \2 \3 \4 , \5. tried using if :

if ($lines =~ /8bcee8....ffff6a(..)6a(..)6a(..)68(..)(..)0000/g) { print "$5$4 $1$2$3" }

but code, can take 1 match per line. , not matchs. understood ? :/ want extract, example, here :

8bcee84ec4ffff6a016a2b6a2b686c010000

i want extract word after 6a, after 6a, after 6a , 4 letters after 68. :/ \o/ advise, iluv u!

in file, there 1000 lines same regexp. want extract these 1000 lines.

does help?

while (<data>) {   print $1, "\n" while /(?<=8b55-)(\w+)(?=-8b55)/g; }  __data__ 8b55-646464-8b558b55-636363-8b55 8b55-656565-8b558b55-666666-8b55 8b55-646464-8b55987941651968798779878b55-686868-8b55 8b55-iloveyou-8b55 

output

646464 636363 656565 666666 646464 686868 iloveyou 

update

this think need full question.

while (<data>) {    while (/8bcee8....ffff6a(..)6a(..)6a(..)68(..)(..)0000/g) {     print join(' ', $1, $2, $3, $4, $5), "\n";   } }  __data__ 8bcee84ec4ffff6a016a2b6a2b686c0100008bcee83cc4ffff6a016a2b6a2b686c0100008bcee82ac4ffff6a016a0e6a0e686d0100008bcee818c4ffff6a016a146a1468f20100008bcee806c4ffff6a006a0e6a0e68700100008bcee8f4c3ffff6a016a1e6a1e6871010000 

output

01 2b 2b 6c 01 01 2b 2b 6c 01 01 0e 0e 6d 01 01 14 14 f2 01 00 0e 0e 70 01 01 1e 1e 71 01 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -