2 ##############################################
3 # Script for Secure Linux Project #
4 # Copyright(c) 2005, 2006 by Roland Haeder #
5 ##############################################
7 ##############################################
8 # This software is licensed under the GNU #
9 # General Public License Version 2 or either #
10 # and comes with ABSOLUTELY NO WARRANTY #
11 # neither implied nor explicit. #
12 ##############################################
14 # The purpose of this script is to search for lost/deleted scripts (plain text)
15 # or which you have maybe overwritten by "echo foo>bar" and bar was a very
16 # important 12600 Bytes long script for you.
18 #### Configuration ######
20 # The MEDIUM holding the filesystem where you have deleted/overwritten the
21 # script. This can also be a partition! E.g. /dev/hda
24 # Search string you are looking for. This shall be a string within middle of
25 # The lost file. It shall be unique so you have beeter search results in first
29 # Skipped bytes by dd command
30 # Enter the value which you get from grep command -2048 here and run this
34 # Size in bytes; no exact value here. Give +4096 more for looking around target
38 # The target file we shall write the found data. This *shall better* be
39 # an other drive/partition than MEDIUM. Or else maybe some data could be
40 # overwritten by this command which you also want to restore!
42 # Do *always* enter a filename here (like /var/test.sh; where /var/ is mounted
43 # on other partition as MEDIUM
45 # Self-test, you need "grep" and "dd" for this script!
48 if test "$DD" == "" || test "$GREP" == ""; then
49 echo "$0: Self-test failed! Cannot find dd or grep!"
54 echo "$0: Self-test passed."
57 if test "$SKIP" != "" && test "$SIZE" != ""; then
58 # Output data to TARGET
59 echo -n "$0: Writing $SIZE Bytes to $TARGET... "
60 dd if=$MEDIUM skip=$SKIP bs=1 count=$SIZE > $TARGET
62 # Hint: You may have to experiment a little with SIZE and SKIP until
63 # you find your lost file. But -2048 for SKIP and +4096 for SIZE might
64 # be a good starting point.
65 elif test "$SEARCH" != "" && test "$MEDIUM" != ""; then
66 # Search on MEDIUM for SEARCH. This may take long!
67 echo "$0: Searching for $SEARCH ... This may take loooong . . ."
68 grep --text -b $SEARCH $MEDIUM
71 echo "$0: You have to setup this script ($0) first!"