This "MSWord text recover" was written somenight when one my friend give to me HDD destroed (FAT tables) by virus and ask me about recovering text information from MSWord document on this HDD.
I'm working on Linux, so I'm don't mount this HDD at all (mount can't work without FAT tables :-) ) and run my script with /dev/hdb device as parameter.
Variables $START and $BLOCK must be corrected to fit your needs. ;-)
This script prints found text chains (English and Russian) to STDOUT.
#!/usr/bin/perl
$pid = open FILTER,"|-";
die unless defined $pid;
if ($pid) {
open WORD, $ARGV[0] or die "Can't read $ARGV[0]\n";
$START = 000000000;
$BLOCK = 100000000;
sysseek WORD, $START, 0;
while (sysread(WORD, $_, 10240)) {
while ( /\G (.*?) (?:
((?:[\020-\117]\04)+) |
((?:[\10\12\040-\177]\00)+)
) /xgs ) {
($junk,$russian,$english) = ($1,$2,$3);
$russian=~s/\04//g;
$russian=~tr/\020-\117/\300-\377/;
$english=~s/\00//g;
print FILTER $russian,$english;
print FILTER "\n" if length($junk)
}
last if sysseek(WORD,0,1)>$START+$BLOCK;
}
close FILTER;
} else {
while(<STDIN>) {
print unless /^.{0,3}$/ || /(.)\1\1/;
}
}
WBR, Alex.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.