#!/usr/bin/perl -w
# c0ded by:  ragnarox  (ragnarox@phedz.org)
# [r00tabega.security.labs]  -  Digital Gangstah Initiative
#
# phedz.org && r00tabega.com
# 
# This program r0x0zm my nut0rz..  If you are a console kiddie like me then you
# will definetly love it.  You hate popping up IE or Nutscrape every time you
# want to get a one of the new files recently added to r00tabega?  Well you 
# call stop all that poppycock right now.  Load this bastard up and you can d/l
# any of the new files added.  I am already in the process of porting it to X
# windows... And hey, I might even be lame enough to do an MS win version.  
# Doubtful though... OUT
#
# greetz:  muh niggaz, bansh33, Tutor, ashmodi, sku||, e-dub, axtrex, sys-edit,
#	   mosthated, cl0wn, skream9, deano, mindphasr, digital-9, fly, 
#	   ytracker, zenomorph, and all you other sluts out there..


use IO::Socket;


# l33t0 variables
# ---------------
$news = "news.html";
$server = "www.r00tabega.com";
$file = "new-files.shtml";

system ("clear");

print "Files Grabber - r00tabega.com\n";
#print "\n\tLatest News = n\n";
#print "\tLatest Files = f\n\n";

#print "\n\nPlease enter your choice [n,f]: ";
#chomp($choice = <STDIN>);

#if($choice eq 'n') {
#	&get_news;
#}

#if($choice eq 'f') {
#	&get_files;
#	}
#if($choice eq '') {
#	print "Choose an option!\n";
#}

&get_files;

# Grab Latest Files From r00tabega.com
# ------------------------------------
sub get_files {
$remote_files = IO::Socket::INET->new(Proto=>"tcp",PeerAddr=>$server,PeerPort=>"80",Reuse=>1) or die "Can't connect to $server\n";

$remote_files->autoflush(1);
print $remote_files "GET /$file HTTP/1.0\n\n";
system("clear");
while (<$remote_files>) {
	@newfiles = <$remote_files>;
	@other = @newfiles;
	print "Latest Files .: [r00tabega.security.labs] :.\n";
	print "--------------------------------------------\n\n";
	#	foreach $line (@newfiles) {
	#		@new = split(/>/,$line);
	#	}
		for($c=7;$c<@newfiles;++$c) {
			$newfiles[$c] =~ s/<a href=\"http:\/\/www.r00tabega.com\/cgi-bin\/archive.pl\?\/home\/bansh33//g;
			$newfiles[$c] =~ s/\">/\//g;
			$newfiles[$c] =~ s/<\/a>|<br>//g;
	#		print $newfiles[$c];
		}
	

	for($a=7;$a<@other;++$a) {
		$other[$a] =~ s/<([^>]|\n)*>//g;
		$other[$a] =~ s/<!--(.|\n)*-->//g;
		print ".: [$a] -  $other[$a]";
	}
	print "\n--------------------------------------------\n\n";
	print "\nChoose a file to download [\#]: ";
	
	$newarg = <STDIN>;

	if($newarg eq "\n") {
		print "\nYour must choose a file!\n";
		print "ragnarox\@phedz.org\n";
	}
	
	elsif($newarg > 0) { 
	$d_l = IO::Socket::INET->new(Proto=>"tcp",PeerAddr=>$server,PeerPort=>"80",Reuse=>1) or die "Can't connect to $server\n";
	$d_l->autoflush(1);
	print $d_l "GET $newfiles[$newarg] HTTP/1.0\n\n";
#	while(<$d_l>) {
		print "Downloading $newfiles[$newarg]"; 
		@getfile = <$d_l>;
		print "DONE!  [r00tabeg.com]\n";
#		print "@getfile\n";
			$cur_name = $other[$newarg];
			open(HAXORFILE,">$cur_name");
				for($h=0;$h<@getfile;++$h) {
					print HAXORFILE $getfile[$h];
				}
			close(HAXORFILE);
#	}
	close $d_l;
	}

#	print "\nby: ragnarox\@phedz.org\n";
    }
close $remote_files;
}

# Grab Latest News From r00tabega.com
# -----------------------------------
#sub get_news {
#$remote_news = IO::Socket::INET->new(Proto=>"tcp",PeerAddr=>$server, PeerPort=>"80", Reuse=>1) or die "Can't connect to $server\n";
#
#$remote_news->autoflush(1);
#
#print $remote_news "GET /$news HTTP/1.0\n\n";
#
#while (<$remote_news>) { 
#	@new=<$remote_news>;
#	system("clear");
#	for($x=7;$x<@new;++$x) {
#		$new[$x] =~ s/<([^>]|\n)*>//g;
#		$new[$x] =~ s/\n|Posted|by/\n/g;
#		print "$new[$x]";
#	}
#    }
#close $remote_news;
#}
