Skip to content

Commit

Permalink
some adjusts from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
htrgouvea committed Jan 28, 2021
1 parent 49a5a85 commit 58edc02
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions nozaki.pl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env perl

package Nozaki::Core {
use 5.018;
use strict;
use warnings;
use Find::Lib "./lib";

package Nozaki::Core {
use JSON;
use 5.018;
use strict;
use warnings;
use Find::Lib "./lib";
use Engine::Fuzzer;
use Functions::Helper;
use Parallel::ForkManager;
Expand All @@ -16,9 +16,9 @@ package Nozaki::Core {
my ($endpoint, $methods, $agent, $headers, $accept, $timeout, $return, $payload, $json, $delay, $exclude) = @_;

my $fuzzer = Engine::Fuzzer -> new (
useragent => $agent,
timeout => $timeout,
headers => $headers
useragent => $agent,
timeout => $timeout,
headers => $headers
);

my @verbs = split (/,/, $methods);
Expand All @@ -37,23 +37,23 @@ package Nozaki::Core {
$result -> {Response}, $result -> {Length}
);

print $printable . "\n";
print $printable, "\n";
sleep($delay);
}
}

sub main {
my ($cl_opt) = @_;
my ($arguments) = @_;
my ($target, $return, $payload, %headers, $accept, $json, $exclude);
my $agent = "Nozaki CLI / 0.2.1";
my $agent = "Nozaki CLI / 0.2.2";
my $delay = 0;
my $timeout = 10;
my $wordlist = "wordlists/default.txt";
my $methods = "GET,POST,PUT,DELETE,HEAD,OPTIONS,TRACE,PATCH,PUSH";
my $tasks = 10;

Getopt::Long::GetOptionsFromArray (
$cl_opt,
$arguments,
"A|accept=s" => \$accept,
"u|url=s" => \$target,
"w|wordlist=s" => \$wordlist,
Expand All @@ -67,43 +67,45 @@ package Nozaki::Core {
"H|header=s%" => \%headers,
"T|tasks=i" => \$tasks,
"e|exclude=s" => \$exclude,
) or die ( return Functions::Helper -> new() );
);

if ($target) {
my @resources;

for my $list (glob($wordlist)) {
open (my $file, "<$list") || die "$0: Can't open $list";

return Functions::Helper -> new() unless $target && $wordlist;

my @resources;
for my $list (glob($wordlist))
{
open (my $file, "<$list") || die "$0: Can't open $list";

while (<$file>) {
chomp ($_);
push @resources, $_;
while (<$file>) {
chomp ($_);
push @resources, $_;
}

close ($file);
}
close ($file);
}

my $threadmgr = Parallel::ForkManager -> new($tasks);
my $threadmgr = Parallel::ForkManager -> new($tasks);

$threadmgr -> set_waitpid_blocking_sleep(0);
THREADS:
$threadmgr -> set_waitpid_blocking_sleep(0);
THREADS:

for (@resources) {
my $endpoint = $target . $_;
$threadmgr -> start() and next THREADS;

fuzzer_thread($endpoint, $methods, $agent, \%headers, $accept, $timeout, $return, $payload, $json, $delay, $exclude);

$threadmgr -> finish();
}
for (@resources) {
my $endpoint = $target . $_;
$threadmgr -> start() and next THREADS;
fuzzer_thread($endpoint, $methods, $agent, \%headers, $accept, $timeout, $return, $payload, $json, $delay, $exclude);
$threadmgr -> finish();
}

$threadmgr -> wait_all_children();
$threadmgr -> wait_all_children();

return 0;
}
return 0;
}

exit main(\@ARGV) unless caller;
return Functions::Helper -> new();
}

exit main(\@ARGV) unless caller;
}

1;

0 comments on commit 58edc02

Please sign in to comment.