Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Shuffles characters around

  • Loading branch information...
commit 430a6a5a7c3b919ae4e72b556e5be30e9d61d117 1 parent c9f8781
@wireghoul authored
Showing with 44 additions and 0 deletions.
  1. +44 −0 charjumble.pl
View
44 charjumble.pl
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+# Will shuffle through all possible letter combinations.
+# Ie: steak becomes kstea, kseat, teaks, seatk, atsek, etc
+
+use strict;
+use warnings;
+
+my @lines;
+our $password;
+
+if (! $ARGV[0]) {
+ print "Usage $0 <password, - or filename>\n";
+} elsif ($ARGV[0] eq '-') {
+ @lines = <STDIN>;
+} elsif ( -e $ARGV[0] ) {
+ open my $ifh, '<', $ARGV[0];
+ @lines = <$ifh>;
+ close $ifh;
+} else {
+ push @lines, $ARGV[0];
+}
+chomp(@lines);
+foreach $password (@lines) {
+ &munge('', split //, $password);
+}
+
+# Recursive iterator function
+sub munge {
+ my ($word, @chars) = @_;
+ my @previous;
+ if (! scalar(@chars) ) {
+ print "$word\n";
+ return;
+ }
+ # Shifting the first cell in array to avoid splice causing an off by one bug
+ my $nword = $word.$chars[0];
+ @previous = splice(@chars,0,1);
+ &munge ($nword, @chars);
+ for (my $i=0;$i<scalar(@chars);$i++) {
+ my $nword = $word.$chars[$i];
+ @previous = splice(@chars,$i,1, @previous);
+ &munge ($nword, @chars);
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.