Guest User

Untitled

a guest
Nov 16th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. use Net::SSH::Perl;
  6.  
  7. my ($hostname, $username, $password, $port, $command) = ("bandit.labs.overthewire.org", "bandit0", "bandit0", "2220", "");
  8.  
  9. sub next_level {
  10. my ($user) = @_;
  11. $user =~ s/(d+)z/ $1 + 1 /e;
  12. return $user;
  13. }
  14.  
  15. sub bandit_level {
  16. my ($pass, $user, $c) = @_;
  17. my $ssh = Net::SSH::Perl->new("$hostname", port=>$port, debug=>0);
  18. $ssh->login("$user","$pass");
  19. my ($stdout, $stderr, $exit) = $ssh->cmd("$c");
  20. my $new_pass = $stdout;
  21. return $new_pass;
  22. }
  23.  
  24. sub read_file {
  25. my %hash;
  26. open CONFIG, "commands.txt" or die;
  27. while (my $line = <CONFIG>) {
  28. chomp $line;
  29. my ($lvl, $cmd) = split /:/, $line;
  30. $hash{$lvl} = $cmd;
  31. }
  32. close CONFIG;
  33. return %hash;
  34. }
  35.  
  36. my %hash = read_file;
  37. my $bandit_count = scalar(keys %hash);
  38.  
  39. while ($bandit_count-- > 0)
  40. {
  41. print "$username:$passwordn";
  42. $command = $hash{$username};
  43. $password = bandit_level($password, $username, "$command");
  44. chomp $password;
  45. $password =~ s/s//g;
  46. $username = next_level($username);
  47. }
Add Comment
Please, Sign In to add comment