#!/usr/bin/perl -w
#
# Joshua D. Abraham < jabra@spl0it.org
# Sat Apr 25 22:03:47 EDT 2009
#
# Compile a list of all the packages based on section
#
use strict;
use LWP::UserAgent;
use Data::Dumper;

sub info {
    my ( $backtrack_section, $ref ) = @_;
    my ( $package, $section );

    foreach (@$ref) {
        chomp;
        if (/Package: (.*)/) {
            $package = $1;
        }
        elsif ( /Section: (.*)/ and /$backtrack_section/ ) {
            print "$package\n";
            $package = undef;
        }
        else { }
    }

}
my @sections = qw(Enumeration Tunneling Bruteforce
    Spoofing
    Passwords
    Wireless
    Discovery
    Cisco
    Web
    Forensics
    Fuzzers
    Bluetooth
    Misc
    Sniffers
    VOIP
    Debuggers
    Penetration
    Database
    RFID
    Python
    Perl);

my $lwp = LWP::UserAgent->new();

my $r
    = $lwp->get(
    "http://archive.offensive-security.com/dists/pwnsauce/main/binary-i386/Packages"
    );
my @main = split( "\n", $r->content );

$r
    = $lwp->get(
    "http://archive.offensive-security.com/dists/pwnsauce/universe/binary-i386/Packages"
    );
my @universe = split( "\n", $r->content );

$r
    = $lwp->get(
    "http://archive.offensive-security.com/dists/pwnsauce/multiverse/binary-i386/Packages"
    );
my @multiverse = split( "\n", $r->content );

$r
    = $lwp->get(
    "http://archive.offensive-security.com/dists/pwnsauce/restricted/binary-i386/Packages"
    );
my @restricted = split( "\n", $r->content );

foreach my $s (@sections) {
    chomp($s);
    print "BackTrack - $s\n";
    info( $s, \@main );
    info( $s, \@universe );
    info( $s, \@multiverse );
    info( $s, \@restricted );
    print "==========================================\n";
}
