Advertisement
LukeP21

Untitled

Aug 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. sub generate_payloads
  2. {
  3. # OMG THIS PART WAS ANNOYING TO CREATE!
  4. my %hash;
  5. # Yes this count is necessary Luke, don't delete it again!
  6. my $count = '0';
  7. foreach my $i (@characters_array)
  8. {
  9. $hash{$count} = \@{$i};
  10. $count++
  11. }
  12. my @keys = sort keys %hash;
  13. my @test_array;
  14. # product { my $test_string = join(',', map {"$_[$_]"} 0 .. $#keys), "\n"; push @test_array, $test_string } @hash { @keys };
  15. product { my $test_string = join(',', map {"$_[$_]"} 0 .. $#keys), "\n"; push @test_array, $test_string } @hash { @keys };
  16.  
  17. # Probably extremely slow but this is the only way i could think of doing this, if anyone knows better send it to me.
  18. # $temp_payload =~ s{ (?: , [^,]*){$j} \K , }{$middle}xeg;
  19. print "@middle_marker_locations\n";
  20. foreach my $i (@test_array)
  21. {
  22. my @temp_payload = split(',', $i);
  23. my @temp_payload_2;
  24. my $count = 0;
  25. foreach my $j (@temp_payload)
  26. {
  27. print "$count\n";
  28. if ( $count ~~ @middle_marker_locations )
  29. {
  30. push @temp_payload_2, $middle;
  31. push @temp_payload_2, $j;
  32. $count++;
  33. }
  34. else
  35. {
  36. push @temp_payload_2, $j;
  37. $count++;
  38. }
  39. }
  40. my $payload = join('', map { "$_" } @temp_payload_2);
  41. my $payload = $prefix . $payload . $suffix;
  42. push @payloads, $payload;
  43. }
  44.  
  45. foreach my $j (@payloads)
  46. {
  47. print "$j\n";
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement