Hlavní navigace

Názor ke zprávičce Máte problém pamatovat si všechna svá hesla? od kvr - No to je bomba, rozpakovat hesla na disk...

  • Aktualita je stará, nové názory již nelze přidávat.
  • 20. 3. 2007 13:03

    kvr (neregistrovaný)
    No to je bomba, rozpakovat hesla na disk a jeste k tomu do /tmp ;)

    Podobnou hracku uz nejaky patek pouzivam, tar.bz2.gpg se nacte primo do pameti a vypis interaktivni prikazy pro list, vypis atd. :

    #!/usr/bin/perl

    use strict;
    use warnings;

    use FileHandle;
    use IO::Pipe;
    use IO::Zlib;
    use Archive::Tar;

    die "usage: $0 tar-archive (optionally gzip/bzip2-ed and/or gpg-ed)" unless (@ARGV == 1);

    my $infd;
    my $filename = shift @ARGV;

    if ($filename =~ /^(.*)\.gpg/) {
    $infd = IO::Pipe->new();
    $infd->reader("gpgphe -d $filename");
    $filename = $1;
    }
    else {
    $infd = FileHandle->new($filename, "<");
    }

    if ($filename =~ m/^(.*)\.(gz|tgz)$/) {
    $infd = IO::Zlib->new($infd, "rb");
    $filename = $1;
    }
    elsif ($filename =~ m/^(.*)\.bz2$/) {
    pipe(my $rh, my $wh)
    or die "failed to create pipe: $!";
    if (fork() == 0) {
    open(STDIN, "<&", $infd)
    or die "failed to dup to STDIN: $!";
    open(STDOUT, ">&", $wh)
    or die "failed to dup to STDOUT: $!";
    exec("bzip2", "-d");
    }
    else {
    undef $wh;
    $infd = $rh;
    }
    }
    my $tar = Archive::Tar->new($infd, 0);

    foreach my $f (sort({ $a cmp $b } $tar->list_files())) {
    printf("%s\n", $f);
    }
    print("itar\$ ");
    while (<>) {
    next unless (m/^(\S+)\s*(.*?)\s*$/);
    if ($1 eq "l") {
    foreach my $f (sort({ $a cmp $b } $tar->list_files())) {
    if (length($2)) {
    next unless ($f =~ m/$2/);
    }
    printf("%s\n", $f);
    }
    }
    elsif ($1 eq "c") {
    print($tar->get_content($2));
    }
    elsif ($1 eq "s") {
    print("failed: $!\n") unless ($tar->extract_file($2));
    }
    elsif ($1 eq "x") {
    last;
    }
    else {
    print("invalid command: $1\n");
    }
    print("itar\$ ");
    }