gh0st-00p

Cobra-Installer-0.3.pl

Dec 27th, 2011
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 20.04 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #All Copyrights reserved by gh0st and BlackBuntu community 2012.
  3. #Program has been written by gh0st for BlackBuntu users only !!
  4. #Eventualy program will run on other OS's such as BackTrack or Pentoo.
  5. #License: GNU GPL
  6. use warnings;
  7. use strict;
  8. use Data::Dumper;
  9. use Term::ANSIColor;
  10. use Gtk2;
  11. use IO::Handle;
  12. use constant TRUE => 1;
  13. use constant FALSE => 0;
  14. use constant WEEK => 9;
  15. use constant TWODAYS => 8;
  16. use constant DEFAULT => 7;
  17. my $program_name = "cobra-installer";
  18. my $clear = 'clear';
  19. my @pen_dirs = ('backdoors', 'database', 'forensics', 'passwords', 'scanners', 'tunneling', 'windows-binaries', 'bluetooth', 'enumeration', 'fuzzer', 're', 'sniffers', 'voip', 'wireless', 'cisco', 'exploits', 'misc', 'rfid', 'spoofing', 'web');
  20. my $pentest_dir = '/pentest/';
  21. my $rand_dir;
  22. my @perl_dir = ('/usr/lib/perl5/','/usr/lib/perl5/Gtk2/');
  23. my @check = `ls`;
  24. my $check;
  25. my $option;
  26. #-----------------------------------------------------------------------
  27. #-----------------------Important Parameters----------------------------
  28. #-----------------------------------------------------------------------
  29. my $auto_update;
  30. my $update_time;
  31. my $reboot;
  32. my $launch;
  33. #-----------------------------------------------------------------------
  34. #-----------------------------------------------------------------------
  35. my $sl = 'sleep 1.5';
  36. my $content;
  37. my $copyright_header = q {-----------*COPYRIGHTS*-----------};
  38. my $copyright = q {
  39. Do not attempt to install this product
  40. on software which was not created
  41. for pentration purpose, failure to
  42. comply those agrements will result
  43. in messing your computer up.
  44. };
  45. my $cobra = q {
  46.                           __      
  47.            ---_ ...... _/_ -      
  48.           /  .      ./ .'*\ \    
  49.          : '         /__-'   \.  
  50.         /                      )
  51.       _/                  >   .'
  52.      /   .   .       _.-" /  .'  
  53.     \           __/"     /.'/|  
  54.        \ '--  .-" /     //' |\|  
  55.         \|  \ | /     //_ _ |/|  
  56.          `.  \:     //|_ _ _|\|  
  57.         | \/.    //  | _ _ |/|  
  58.          \_ | \/ /    \ _ _ \\\  
  59.              \__/      \ _ _ \|\
  60. };
  61. system($clear);
  62. #-----------------------------------------------------------------------
  63. #This bit needs to be trashed after completing gtk 2 step
  64. #&popout;
  65. #exit;
  66. #&installation;
  67. # call to popout was created for debug purpose
  68. #-----------------------------------------------------------------------
  69. my $login = (getpwuid $>);
  70. die "Please run this application as root" if $login ne 'root';
  71. sub install {
  72.    system ('sleep 7');    
  73.    system ($clear);
  74.    print color 'bold black';
  75.    print "First let's check your distro ... \n \n";
  76.    print "Checking pentest dir avaiblity";
  77.    system($sl);
  78.    opendir(IMD, $pentest_dir) or die ("Error1: The pentest folder do not exist, aborting ...");
  79.    print colored ('    [done]'."\n" => 'bold green');
  80.    print color 'bold black';
  81.    print "Selecting random folder";
  82.    system($sl);
  83.    my $rand_dir = int(rand(20)) or die ("Error2: Cannot randomize folders, aborting ...");    
  84.    print colored ('        [done]'."\n" => 'bold green');
  85.    print color 'bold black';
  86.    print "Accesing chosen folder";
  87.    system($sl);
  88.    opendir(IMD, $pentest_dir.$pen_dirs[$rand_dir]) or die ("Error3: Folder not found, aborting ...");
  89.    print colored ('        [done]'."\n" => 'bold green');
  90.    print color 'bold black';
  91.    print 'Alright, you have got a pentest distro, lets continue ...'."\n \n";
  92.    system ('sleep 5');
  93.    print 'Initializing Gtk2 Api for Perl 5 detection system ...'."\n";
  94.    system($sl);
  95.    print 'Checkig for Perl 5 enviroment';
  96.    system($sl);
  97.    opendir(IMD, $perl_dir[0]) or die ("Error 4: Missing perl 5 folder, aborting ...");
  98.    print colored ('        [done]'."\n" => 'bold green');
  99.    print color 'bold black';
  100.    print 'Searching for Gtk2 libraries';
  101.    system($sl);
  102.    opendir(IMD, $perl_dir[1] || &installation);
  103.    print colored ('        [done]'."\n" => 'bold green');
  104.    system($sl);
  105.    system($sl);
  106.    system($clear);
  107.    print color 'reset';
  108.    &popout;
  109.    #If want to use that one below just change $perl_dir value into 0 above :D
  110.    #U may ask why have a done this fancy piece of code below.
  111.    #Well, I didn't know that 'or' operator can be used in this situation yeah i know fail ...
  112.    #foreach(@check) {
  113.    #    $check = @check;
  114.    #    if ($check =~ m/^.G?(g)tk2.$/) {
  115.    #        print '        [done]'."\n";
  116.    #        print 'Aye, Aye we can move on into installtion i guess';
  117.    #        &popout;
  118.    #    } else {
  119.    #        print '        [failure]'."\n";
  120.    #        system($clear);
  121.    #        print 'Switching to Gtk2 installation module, please wait'."\n";
  122.    #        system('sleep 3');
  123.    #        &installation;
  124.    #    }
  125.    #}
  126.  
  127. }
  128. sub welcome {
  129.    if ($_[0] == '1') {
  130.        system($clear);
  131.        print color 'bold green';
  132.        print 'Hey, thanks for installing me but before we start i need to check'."\n";
  133.        print 'Have you really got Blackbuntu or other pentesting distro, so lets go ...'."\n";
  134.        print color 'reset';
  135.    }
  136.    if ($_[0] == '2') {
  137.        system ($clear);
  138.        system ($sl);
  139.        print color 'bold green';
  140.        print "Program $program_name was created specially for BlackBuntu linux community, by gh0st.\n";
  141.        print "Just to keep tools, patches etc. up to date \n";
  142.        print "For more info please visit blackbuntu.com or gh0st-community.webuda.com. \n";
  143.        print color 'reset';
  144.    }
  145.    if ($_[0] == '3') {
  146.        print color 'bold green on_black';
  147.        print $cobra;
  148.        print color 'reset';
  149.        print color 'bold black on_cyan';
  150.        print "Hello and welcome in $program_name . \n";
  151.        print "What would you like to do now ? \n";
  152.        print color 'reset'."\n";
  153.        print colored ('[1]' => 'bold green on_black').colored ('Install program on my hard drive'."\n" => 'bold cyan on_black');
  154.        print colored ('[2]' => 'bold green on_black').colored ('See the credits, and something about us'."\n" => 'bold cyan on_black');
  155.        print colored ('[3]' => 'bold green on_black').colored ('Just go out '."\n" => 'bold cyan on_black');
  156.        print color 'bold cyan';
  157.        print "Pick a corresponding number to a choosen option \n";
  158.        print "And insert it, here --> ";
  159.    }
  160. }
  161. sub popout {
  162.    # This Function needs to be rewritten soon after installer release and inserted
  163.    #into loop
  164.    sub delete_event
  165.    {
  166.        my $window = shift;
  167.        Gtk2->main_quit;
  168.        print Dumper (@_);
  169.        return TRUE;
  170.    }
  171.    sub save_options {
  172.        no warnings;
  173.        my @settings;
  174.        for (my @settings=undef; @settings=($_[0], $_[1]); @settings==($_[0], $_[1])) {
  175.            print;
  176.        }
  177.        return TRUE;
  178.        use warnings "all";
  179.    }
  180.    Gtk2->init || die ('Error 5:'."$!");
  181.    # Declaring important variables
  182.    my $window = Gtk2::Window->new('toplevel');    
  183.    my $box = Gtk2::VBox->new (FALSE, 0); # Change Vbox with H to get it horizantally
  184.    my $label = Gtk2::Label->new ($copyright_header.$cobra.$copyright);
  185.    my $table = Gtk2::Table->new (1, 2, TRUE);
  186.    my $button1 = Gtk2::Button->new ('Agree');
  187.    my $button = Gtk2::Button->new ('Disagree');
  188.    #$box = Gtk2::Pack::add($table);
  189.    #-------------------------------------------------------------------
  190.    #calling functions for already declared variables
  191.    $window->set_title ('BlackBuntu Cobra Update Installer Terms and Agreements ...');
  192.    $window->set_border_width(20);
  193.    $window->set_resizable(TRUE);
  194.    $box->pack_start($label, TRUE, TRUE, 0);
  195.    $box->pack_start($table, TRUE, TRUE, 0);
  196.    #Gtk2::Box::pack_start(box, child, expand, fill, padding)
  197.    $window->signal_connect (destroy => \&delete_event);
  198.    $button->signal_connect (clicked => \&delete_event);
  199.    $button1->signal_connect (clicked => sub {$window->destroy; &pw2;});
  200.    $table->attach_defaults($button, FALSE, TRUE, FALSE, TRUE);
  201.    $table->attach_defaults($button1, TRUE, 2, FALSE, TRUE);
  202.    #GTK2 main quit above needs to be replaced with call to function what
  203.    #leads to proper installer
  204.    #Cancel button needs to be added
  205.    #-------------------------------------------------------------------
  206.    #Putting shit together and start displaying it
  207.    $window->add($box);
  208.    $box->show;
  209.    $label->show;
  210.    $button->show;
  211.    $button1->show;
  212.    $table->show;
  213.    $window->show_all;
  214.    Gtk2->main;
  215.    #-------------------------------------------------------------------
  216.    #-------------------------------------------------------------------
  217.    # The xpm_label_box() function could be used to pack
  218.    # images and labels into any widget that can be a container.
  219.    #The Gtk2::Button widget has the following signals:
  220.    #pressed - emitted when pointer button is pressed within Gtk2::Button widget
  221.    #released - emitted when pointer button is released within Gtk2::Button widget
  222.    #clicked - emitted when pointer button is pressed and then released within Gtk2::Button widget
  223.    #enter - emitted when pointer enters Gtk2::Button widget
  224.    #leave - emitted when pointer leaves Gtk2::Button widget
  225.    #http://gtk2-perl.sourceforge.net/doc/gtk2-perl-tut/ch-ButtonWidget.html
  226.    sub pw2 {  
  227.        #killing window above needs more attetnion
  228.        #Gtk2->init || die ('Error 5:'."$!");
  229.        #Gtk2::Widget->destroy;
  230.        &delete_event;
  231.        my $window = Gtk2::Window->new('toplevel');
  232.        my $box = Gtk2::VBox->new(FALSE, 0);
  233.        my $content = "Program $program_name will now attempt to install \n itself on your hard drive. \n If you have got any concerns about it please contact \n us on our offcial website \n And for more info please make sure that you checked \n out our documentation \n";
  234.        my $label = Gtk2::Label->new($cobra.$content);
  235.        my $table = Gtk2::Table->new(1, 2, TRUE);
  236.        my $button = Gtk2::Button->new('Cancel');
  237.        my $button1 = Gtk2::Button->new('Install');
  238.        my $label1 = 'Would you like to update this program automaticly';
  239.        my $checkbutton = Gtk2::CheckButton->new_with_label($label1);
  240.        my $radiob1 = Gtk2::RadioButton->new (undef, "Every Login ".q{[recomended]});
  241.        my $radiob2 = Gtk2::RadioButton->new_with_label($radiob1->get_group, "Every 2 days");
  242.        my $radiob3 = Gtk2::RadioButton->new_with_label_from_widget($radiob2, "Every week");
  243.        my $ad = q{How often would you like receive our updates ?}."\n";
  244.        my $additional_note = Gtk2::Label->new($ad);
  245.        my $separator = Gtk2::HSeparator->new;
  246.        #---------------------------------------------------------------
  247.        #Calling and placing functions up
  248.        #---------------------------------------------------------------
  249.        $window->set_title('Install preparation');
  250.        $window->set_border_width(20);
  251.        $window->set_resizable(TRUE);
  252.        #Gtk2::Box::pack_start(box, child, expand, fill, padding)
  253.        $box->pack_start($label, 1, 1, 0);
  254.        $box->pack_start($checkbutton, 1, 1, 0);
  255.        $box->pack_start($separator, FALSE, TRUE, 0);
  256.        $box->pack_start($additional_note, 1, 1, 0);
  257.        $box->pack_start($radiob1, 1, 1, 0);
  258.        $box->pack_start($radiob2, 1, 1, 0);
  259.        $box->pack_start($radiob3, 1, 1, 0);
  260.        $box->pack_start($table, 1, 1, 0);
  261.        $window->signal_connect(destroy => \&delete_event);
  262.        $button->signal_connect(clicked => \&delete_event);
  263.        $button1->signal_connect(clicked => sub {$window->destroy; &gtk_install;});
  264.        $checkbutton->signal_connect(clicked => sub {
  265.            $auto_update = TRUE
  266.            });
  267.        $radiob1->signal_connect(clicked => sub { $update_time = DEFAULT;});
  268.        $radiob2->signal_connect(clicked => sub { $update_time = TWODAYS;});
  269.        $radiob3->signal_connect(clicked => sub { $update_time = WEEK;});
  270.        #$radiob1->set_active(TRUE);
  271.        Gtk2::ToggleButton::set_active($radiob3, TRUE);
  272.        Gtk2::ToggleButton::set_active($radiob2, TRUE);
  273.        Gtk2::ToggleButton::set_active($radiob1, TRUE);
  274.        $radiob1->can_default(TRUE);
  275.        $radiob1->grab_default;
  276.        $table->attach_defaults($button, FALSE, TRUE, FALSE, TRUE);
  277.        $table->attach_defaults($button1, TRUE, 2, FALSE, TRUE);
  278.        #---------------------------------------------------------------
  279.        #Adding funtions together and displaying them
  280.        #---------------------------------------------------------------
  281.        $window->add($box);
  282.        $box->show;
  283.        $label->show;
  284.        $checkbutton->show;
  285.        $additional_note->show;
  286.        $radiob1->show;
  287.        $radiob2->show;
  288.        $radiob3->show;
  289.        $button->show;
  290.        $button1->show;
  291.        $table->show;
  292.        $window->show_all;
  293.        Gtk2->main;
  294.        #---------------------------------------------------------------
  295.        #End of window
  296.        #---------------------------------------------------------------
  297.        return FALSE;
  298.        sub gtk_install {
  299.            sub destroy_progress {
  300.                my $window = shift;
  301.                Gtk2->main_quit;
  302.            }
  303.            #Glib::Source->remove($window);
  304.            my $checklabel = "Would you like to restart your computer afterwards ?";
  305.            my $checklabel1 = "Would you like to launch this program after this reboot";
  306.            my $window = Gtk2::Window->new('toplevel');
  307.            my $box = Gtk2::VBox->new(FALSE, 0);
  308.            my $label = Gtk2::Label->new($cobra);
  309.            my $table = Gtk2::Table->new(1, 2, TRUE);
  310.            my $button = Gtk2::Button->new("Cancel");
  311.            my $button1 = Gtk2::Button->new("Finish");
  312.            my $separator = Gtk2::HSeparator->new;
  313.            my $checkbox = Gtk2::CheckButton->new_with_label($checklabel);
  314.            my $checkbox1 = Gtk2::CheckButton->new_with_label($checklabel1);
  315.            my $progressbar = Gtk2::ProgressBar->new;
  316.            #-----------------------------------------------------------
  317.            # Listing operations while installing
  318.            # 1.) Opening /etc/init.d
  319.            # 2.) Dumping Payload to directory
  320.            # 3.) Opening /usr/bin/
  321.            # 4.) Putting payload into current directory
  322.            # 5.) Passing parameters to programs
  323.            #-----------------------------------------------------------
  324.            $progressbar->set_text("installing $program_name");
  325.            #Gtk2::ProgressBar->set_orientation($progressbar, 'GTK_PROGRESS_RIGHT_TO_LEFT');
  326.            $window->set_title('Installing ...');
  327.            $window->set_border_width(20);
  328.            $window->set_resizable(TRUE);
  329.            #Gtk2::Box::pack_start(box, child, expand, fill, padding)
  330.            $box->pack_start($label, 1, 1, 0);
  331.            $box->pack_start($separator, FALSE, TRUE, 0);
  332.            $box->pack_start($progressbar, 1, 1, 0);
  333.            $box->pack_start($checkbox, 1, 1, 0);
  334.            $box->pack_start($checkbox1, 1, 1, 0);
  335.            $box->pack_start($table, 1, 1, 0);
  336.            $window->signal_connect(destroy => \&delete_event);
  337.            $button->signal_connect(clicked => \&destroy_progress);
  338.            $button1->signal_connect(clicked => \&destroy_progress);
  339.            $checkbox->signal_connect(clicked => sub {$reboot=TRUE;});
  340.            $checkbox1->signal_connect(clicked => sub {$launch=TRUE;});
  341.            $table->attach_defaults($button, FALSE, TRUE, FALSE, TRUE);    
  342.            $table->attach_defaults($button1, TRUE, 2, FALSE, TRUE);
  343.            #-----------------------------------------------------------
  344.            $window->add($box);
  345.            $box->show;
  346.            $label->show;
  347.            $progressbar->show;
  348.            $checkbox->show;
  349.            $checkbox->show;
  350.            $button->show;
  351.            $button1->show;
  352.            $table->show;
  353.            $window->show_all;
  354.            &installer;
  355.            sub installer {
  356.                #-----------------------------------------------------------
  357.                #----------------------Install methods----------------------
  358.                #-----------------------------------------------------------
  359.                my $rv;
  360.                my $pin = 'Cobra-init.pl';
  361.                my $pn = 'Cobra-update.pl';
  362.                # Variables and code below needs optimazing
  363.                my $payload = '#!/usr/bin/perl';
  364.                my @inst_exec = ('cd /etc/init.d', 'touch '.$pin.' && echo "'.$payload.'" > '.$pin, 'cd /usr/bin/', 'touch '.$pn.' && echo "'.$payload.'" > '.$pn);
  365.                my $new_val;
  366.                foreach (@inst_exec) {
  367.                    system $_;
  368.                    $rv = FALSE;
  369.                    $new_val = $progressbar->get_fraction() + 0.20;
  370.                    $progressbar->set_fraction($new_val);
  371.                    $rv = TRUE;
  372.                    die "Cannot proceed any further" if $rv eq FALSE;
  373.                }
  374.                $new_val = $progressbar->get_fraction() + 0.20;
  375.                $progressbar->set_fraction($new_val);
  376.            }
  377.            }
  378.            }
  379.            Gtk2->main;
  380.    #-------------------------------------------------------------------
  381.    #Program never really should get there
  382.    return FALSE;
  383.    0;
  384. }
  385. sub installation {
  386.    my @gtk2_down = 'http://sourceforge.net/projects/gtk2-perl/files/Gtk2/1.224/Gtk2-1.224.tar.gz';
  387.    my @wget = 'wget --accept=*.tar.gz --quiet '.@gtk2_down;
  388.    #See hak5 here 10x08.2 for more quick way od downloading and extracting files
  389.    my @commands = ('tar -zxvf Gtk2-*.tar.gz && cd Gtk2-1.224','perl Makefile.pl' =>'make' =>'make test' =>'make install');
  390.    my @removing = ('cd ../', 'rm Gtk2*.tar.gz', 'rm -r -f Gtk2-1.224*');
  391.    print 'Error 6: No Gtk2 libraries, launching installation module'."\n";
  392.    system($sl);
  393.    system ($clear);
  394.    print color 'bold cyan';
  395.    print "The installation of gtk module will start in sec .... \n";
  396.    print "In order to continue install insert y and press enter if not press n \n";
  397.    print colored ("*Warning* \n" => 'bold red on_black');
  398.    print color 'bold red';
  399.    print "Other letters than y will cancel installation process, anyway :D \n";
  400.    print "Just don't worry mate i'll take care of every step from now on \n";
  401.    print "Enjoy, and make sure that yours internet connection is on \n";
  402.    print color 'reset';
  403.    system($clear);
  404.    foreach(@wget) {
  405.        system ($clear);
  406.        print colored ('Downloading Gtk2 libraries ...' => 'bold green on_black');
  407.        system ($sl);
  408.        system ($_);
  409.        print colored ('        [done]' => 'bold green on_black');
  410.        print "\n";
  411.        # Checking if will be here
  412.    }
  413.    foreach (@commands, @removing) {
  414.        system ($clear);
  415.        print colored ('Installing Gtk2 libraries ...' => 'bold green on_black');
  416.        system ($sl);
  417.        system ($_);
  418.        #checking if will be add later
  419.        
  420.    }
  421.    print colored ('        [done]' => 'bold green on_black');
  422.    print "\n";
  423.    #Continuing code
  424. }
  425. sub opstart {
  426.    if ($_[0] == 1) {
  427.        &welcome(1);
  428.        &install;
  429.    }
  430.    if ($_[0] == 2) {
  431.        &welcome(2);
  432.        exit;
  433.    }
  434.    if ($_[0] == 3) {
  435.        return FALSE;
  436.        exit;
  437.    } elsif ($_[0] != 1..3) {
  438.        system($clear);
  439.        system('sleep 3');
  440.        print "Are you sure you didn't mispelled something ? \n";
  441.        return FALSE;
  442.        0;
  443.    }
  444. }
  445. sub trash {
  446.    my $variable;
  447.    $variable=$_[0];
  448.    while ($variable==undef) {
  449.    # Shouldn't go any further than one pass
  450.    $variable=shift;    
  451.    }
  452. }
  453. sub payload {
  454.    #Here destination of payload can be specified
  455.    #And Here the payload can programed
  456.    #But as you can see nothing is currently linked to it         YET
  457.    #So what's the point of keeping that function you may ask
  458.    #So the point of it is pretty obvious
  459.    #Symbolic meaning just to point out that there is
  460.    #Something like that available.
  461. }
  462. &welcome('3');
  463. print color 'bold green on_black';
  464. chomp ($option = <STDIN>);
  465. print color 'reset';
  466. &opstart($option);
  467. __END__
Advertisement
Add Comment
Please, Sign In to add comment