#! /usr/bin/perl # Cogito,ergo sum. #$SIG{INT} = 'IGNORE'; # cause we're penetrating and proud of what we've created system("clear"); # defining constants $HOME = "/ram"; #change at will $temp = "$HOME/find.db"; $wanted_temporary = "$HOME/$search.grepdat"; $grep = "$HOME/grep-search.grep"; $cheatcode = "iamacheater"; &check_database; # must be placed here to check existence of find.db &delete_stuff; # reading from standart input while ($ARGV[0] =~ /^(-.*)/ && shift) { if ($1 eq "-s") { $search = shift; # reads all ascii values &main; } elsif ( $1 eq "-old") { &main_selo; } elsif ( $1 eq "-no"){ $search = shift; &main_without_options; } elsif ( $1 eq "-i") { &info_author; } elsif ( $1 eq "-v") { &version; } elsif ( $1 eq "-h") { &usage; } elsif ( $1 eq "-cheat") { $cheat = shift; if ( $cheat eq $cheatcode ) { &master_brains; } else { print "better make up your mind again,cheater!\n"; exit; }; } else { warn "bad option: $1\n"; &usage; }; }; print "enter $0 -h for help\n"; # prints message if user entered garbage at shell prompt sub main { print "you searched for $search in $HOME/find.db: \n"; system ("grep $search $temp >> $wanted_temporary"); system ("grep -n $search $wanted_temporary >> $grep"); system ("cat $grep"); &menu_choice; chomp( $ll = ); if ($ll eq "0" ) { # change to something like below &delete_stuff; #exit; &menu; } elsif ($ll eq "sos") { print "enter the word you look for: \n"; chomp ($search = ); &delete_stuff; &main; } else { &delete_stuff; exit; }; open( FILEH,"<$wanted_temporary") or die "this: $! failture sucks!\n"; do { $line = ; $countline++; } until $countline eq $ll; close FILEH or print "couldn`t close FILEH: $! \n"; system("less $line"); &delete_stuff; &menu; }; sub main_loop { system ("cat $grep"); &menu_choice; chomp( $ll = ); if ($ll eq "0" ) { # change to something like below &delete_stuff; #exit; &menu; } elsif ($ll eq "sos") { print "enter the word you look for: \n"; chomp ($search = ); &delete_stuff; &main; } else { &delete_stuff; exit; }; open( FILEH,"< $wanted_temporary") or die "this : $! failture sucks!\n"; do { $line = ; $countline++; } until $countline eq $ll; close FILEH or print "couldn`t close FILEH: $! \n"; system("less $line"); &menu; }; sub main_selo { system("clear"); print "#########################################################\n"; print "# tool for locating files and looking at them #\n"; print "# written by Sebastian Enger #\n"; print "#########################################################\n"; print "locate what?\n"; chomp ( $search = ); &main_without_options; }; sub main_without_options { print "you searched for $search in $HOME/find.db: \n"; system ("grep $search $temp >> $wanted_temporary"); system ("grep -n $search $wanted_temporary >> $grep"); system ("cat $grep"); print "\nwhich line you wanna see?\n"; chomp( $ll = ); open( FILEH,"< $wanted_temporary") or die "this : $! failture sucks!\n"; do { $line = ; $countline++; } until $countline eq $ll; close FILEH or print "couldn`t close FILEH: $! \n"; system("less $line"); &delete_stuff; }; sub menu { print " ###############################################################\n"; print "### ###\n"; print "### Do you want to: ###\n"; print "### take a look at some $search related stuff [ 1 ] ###\n"; print "### search for some other stuff [ 2 ] ###\n"; print "### quit this program [ 3 ] ###\n"; print "### Moving options: ###\n"; print "### copy selected file to home directory [ 4 ] ###\n"; print "### copy file to folder of your choice [ 5 ] ###\n"; print "### Delete options: ###\n"; print "### delete selected file [ 6 ] ###\n"; print "### ###\n"; print " ###############################################################\n"; chomp ( $choice = ); if ( $choice eq 1) { &main_loop; } elsif ( $choice eq 2) { &delete_stuff; &main; } elsif ( $choice eq 4) { &delete_stuff; &move_home; } elsif ( $choice eq 5) { &delete_stuff; &move_other; } elsif ( $choice eq 6) { &delete_stuff; &delete_selected; } elsif ( $choice eq 3) { &delete_stuff; exit; } else { print "Command not found\n"; &delete_stuff; &menu; }; }; sub menu_choice { print "\"0\" ---> continue\n"; print "\"sos\" ---> search for some other stuff!\n"; print "\"exit\" ---> quit\n"; print "\nwhich line you wanna see?\n"; }; sub delete_stuff { unlink "$grep"; unlink "$wanted_temporary"; }; sub move_home { print "you chose to copy \"$line\" to $HOME : \n"; print "enter a name for the file [eg. readme.foo ]: \n"; chomp ($filename = ); $save_path = "$HOME/file.tmp"; # does anybody know a smarter solution? open (FILE,"<$line") or print "nothing done: $!\n"; @content = ; close FILE; open (FILE,">$save_path") or print "nothing done: $!\n"; print FILE @content; close FILE; system("mv $save_path $HOME/$filename"); system("ls -l $HOME"); }; sub move_other { # possible weakness: attacker can write to disk with your user authority print "enter the path to copy \"$line\" to [eg. /home/foobar/stuff ]: \n"; chomp ($move_path = ); print "enter a name for the file [eg. foo.bar ]\n"; chomp ($filename = ); $tmp_path = "$HOME/file.tmp"; open (FILE,"<$line") or print "nothing done: $!\n"; @content = ; close FILE; open (FILE,">$tmp_path") or print "nothing done: $!\n"; print FILE @content; close FILE; system("mv $tmp_path $move_path/$filename"); system("ls -lh $move_path"); }; sub delete_selected { print "delete $line ?\n"; print "other answers than [ y ] are ignored\n"; chomp ($answer = ); if ($answer eq "y" ) { system("rm -rf $line"); } else { print "command $answer ignored!\n"; &menu; }; }; sub check_database { open (WORDL,"<$temp") or &hint; if ( -M WORDL >= 7.0 ) { print "wordlist older than 7 days,I suggest an update.\n"; close WORDL or print "something bad happened: $! \n"; &update_database; }; }; sub hint { print "Warning database does not exist.I need one in order to work correctly!\n"; &update_database; }; sub update_database { print "so should I make a new data base?[ yes|no ]\n"; chomp( $answer = ); if ( $answer eq "yes" ) { unlink "$temp"; # just to be sure its erased system ("find / *.* >> $temp"); &main_selo; } elsif ( $answer eq "no" ) { &main_selo; } else { print "Command not found: quit now! \n"; exit; }; }; sub info_author { print "version $0 written by Sebastian Enger and last modified on 11|18|2001.\n"; print "for any hints,comments,questions mail to 'neo_se\@hotmail.com'.\n"; }; sub version { print "version $0 last modified on 11|18|2001\n"; print "$0 partly rewritten on 07|13|2001 now accepting arguments\n"; print "$0 - 388 lines of pure perl code\n"; print "do you know what selo stands for?\n"; print "just guess it: \n"; chomp ($guess = ); $correct_answer = "search and look"; if ( $guess eq $correct_answer) { &master_brains; } elsif ( $guess ne $correct_answer) { print "$guess is the wrong answer!\n"; exit; } else { print "you should make up your mind about that question!\n"; exit; }; }; sub master_brains { %einstein = ( "\"I know not with what weapons World War III will be fought, but WorldWar IV will be fought with sticks and stones.\"" => "1", "\"Man usually avoids attributing cleverness to somebody else -- unless it is an enemy.\"" => "2", "\"Everything should be made as simple as possible, but not simpler.\"" => "3", "\"If the facts don't fit the theory, change the facts.\"" => "4", "\"Handle niemals gegen das Gewissen ,auch wenn es der Staat fordert!\"" => "5", "\"Wenn Du ein glückliches Leben führen willst,verbinde es mit einem Ziel,nicht aber mit Menschen oder Dingen.\"" => "6", "\"Gleichungen sind wichtiger für mich,weil die Politik für die Gegenwart,eine Gleichung dagegen für die Ewigkeit ist.\"" => "7", "\"Phantasie ist wichtiger als Wissen.\"" => "8", "\"Was ich über das Buch zu sagen habe , steht in dem Buch!\"" => "9", "\"Nur wer nicht sucht,ist vor Irrtum sicher.\"" => "10", "\"Die besten Dinge im Leben sind nicht die,die man für Geld bekommt.\"" => "11", "\"Jede Erinnerung ist gefärbt durch das jetztige So_sein,also durch einen trügerischen Blickpunkt.\"" => "12", "\"Falls Gott die Welt geschaffen hat, war seine Hauptsorge sicherlich nicht, sie so zu machen, daß wir sie verstehen könnnen.\"" => "13", "\"Ich denke, daß die freie Entfaltung des einzelnen Menschen und seiner Fähigkeiten letzten Endes das einzige berechtigte Ziel politischen Strebens ist.\"" => "14", "\"Ich habe meine Sache hier getan.\"" => "15", "\"Versuche nicht, ein erfolgreicher,sondern ein wertvoller Mensch zu werden.\"" => "16"); %linux_rules = ( "\"Avoid the Gates of Hell. Use Linux \"" => "1", "\"Fatal Error: Found [MS-Windows] System -> Repartitioning Disk for Linux...ee\"" => "2", "\"In most countries selling harmful things like drugs is punishable.Then howcome people can sell Microsoft software and go unpunished?\"\n\t\t\t\t -- Hasse Skrifvars" => "3", "\"The nice thing about Windows is - It does not just crash, it displays a dialog box and lets you press 'OK' first.\"\n\t\t\t\t -- Arno Schaefer's" => "4", "\"...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and the Evil).\"\n\t\t\t\t -- Matt Welsh" => "5", "\"We all know Linux is great...it does infinite loops in 5 seconds.\"\n\t\t\t\t -- Linus Torvalds" => "6", "\"`When you say \"I wrote a program that crashed Windows\", people just stare at you blankly and say \"Hey, I got those with the system, *for free*\".'\"\n\t\t\t\t -- Linus Torvalds" => "7", "\"Why use Windows, since there is a door?\"\n\t\t\t\t -- Andre Fachat" => "8", "\"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise.\"\n\t\t\t\t -- Larry Wall" => "9", "\"Geht im PC die Uhrzeit krumm, berechnet sie ein PENTIUM.\"" => "10", "\"Windows tm : Keyboard not connected! Press F1 to continue!\"" => "11", "\"Don't jail the curious,just give freedom.\"" => "12", "\"So right now the only vendor that does such a stupid thing is Microsoft.\"\n\t\t\t\t -- Linus Torwalds" => "13", "\"Sending all processes the TERM signal.\"" => "14", "\"What cannot be done with LINUX , is not worth being done at all.\"\n\t\t\t\t -- Sebastian Enger" => "15", "\"Windows tm - Plug and Pray compatible!\"" => "16", "\"If you do not succeed the first time ,redefine success!\"" => "17", "\"There is more than one way to do it!\"\n\t\t\t\t -- Larry Wall" => "18", "\"No one is born a master , but some are born to be masters.\"" => "19", "\"you may stop this individual , but you can't stop us all ...\"\n\t\t\t\t -- The Mentor" => "20", ); $rand_randomizer = int(rand(2))+1; if ( $rand_randomizer eq 1 ) { $random = int(rand(15))+1; while ( ($key, $value) = each(%einstein) ) { if ( $value eq $random) { print "$key\n\t\t\t\t -- Albert Einstein\n"; }; }; } elsif ( $rand_randomizer eq 2 ) { $random = int(rand(19))+1; while ( ($key, $value) = each(%linux_rules) ) { if ( $value eq $random) { print "$key\n"; }; }; }; }; sub usage { print "Usage: $0 [ -s thing_to_search ]\n"; print "Options:\n"; print " -s searches for something \n"; print " -no searches for something hiding the option menu \n"; print " -ndb creates new database for user \n"; print " -old starts selo in old fashion style without arguments \n"; print " -i information about the author \n"; print " -v prints version information \n"; print " -h prints this help message \n"; print "\nwritten by Sebastian Enger \n"; print "\nif you are hacking \$my code send an example of your one to neo_se\@hotmail.com\n"; print "that is the only thing you must do\n"; exit; }; &delete_stuff;