_headers->{'content-encoding'} = 'amz-1.0';
$aws_headers->{'content-type'} = 'application/json; charset=UTF-8';
$aws_headers->{'host'} = $self->host;
$aws_headers->{'x-amz-
Amazon::PAApi5::Signature->new(
'ACCESS_KEY',
'SECRET_KEY',
$payload->to_json({
Keywords => 'Perl',
SearchIndex => 'All',
ItemCount =>
}
=back
=head2 JSON Methods
=over 4
=item TO_JSON
This method will be called by the JSON encoder to convert the object
to a hashref which is encodable as JSON.
=cut
sub TO_JSON {
my $self =
le (including JSON/XML/JavaScript), append
# character set to the content type
$content_type .= '; charset=' . $self->charset
if $content_type =~ m!^(text/|application/(json|xml|javascri
qw(import);
our $VERSION = 1.30;
use File::Spec ();
use File::Basename qw(basename);
use JSON qw(encode_json);
my sub qwac( $s ) {grep{/./} map{split /\s+/} map{s/#.*//r} split/\v+/ , $s;};
our @E
.
reply_file # Send file and exit.
reply_html # Send HTML reply and exit.
reply_json # Send JSON reply and exit.
set_header # Add or overwrite headers.
cexec # CGI exec comman
};
sub reply_json {
my ($hashref) = signature(1,0,@_);
$header{'Content-Type'} = 'application/json; charset=utf-8';
rcheck;
print_headers;
print encode_json($hashref);
ce
s the communication between Taco clients
and servers.
=cut
package Alien::Taco::Transport;
use JSON;
use strict;
our $VERSION = '0.003';
=head1 METHODS
=over 4
=item new(in => $input, out => $
ndles and instantiates a JSON processor object.
=cut
sub new {
my $class = shift;
my %opts = @_;
my $json = new JSON();
$json->convert_blessed(1);
$json->ascii(1);
if (exis
ts $opts{'filter_single'}) {
$json->filter_json_single_key_object(@{$opts{'filter_single'}});
}
binmode $opts{'in'}, ':encoding(UTF-8)';
binmode $opts{'out'}, ':encoding(UTF-8)';
output_mode => [ qw(json|xml) ],
apikey => [ qw(apikey) ],
uri => [ qw(shodan_uri) ],
},
attributes_default => {
output_mode => 'json',
ssl_verify =
require_modules => {
'Metabrik::Network::Address' => [ ],
'Metabrik::String::Json' => [ ],
'Metabrik::String::Xml' => [ ],
},
};
}
sub myip {
my $self = shif
-info?key='.$apikey) or return;
my $content = $resp->{content};
my $sj = Metabrik::String::Json->new_from_brik_init($self) or return;
my $decoded = $sj->decode($content) or return;
retur
$self = shift;
filter_struct(shift, sub {
my $x = shift;
blessed($x) and not JSON::is_bool($x);
},
sub {
my $nn = my $n = ++ $self->{'nobject'};
$self->{'o
> [ qw(apikey) ],
output_mode => [ qw(json|xml) ],
},
attributes_default => {
ssl_verify => 0,
output_mode => 'json',
},
commands => {
check
_domains => [ qw(ipv4_address) ],
},
require_modules => {
'Metabrik::String::Json' => [ ],
'Metabrik::String::Xml' => [ ],
},
};
}
sub check_resource {
my $s
$self->log->verbose("check_resource: returned code [$code]");
my $sj = Metabrik::String::Json->new_from_brik_init($self) or return;
my $decode = $sj->decode($content) or return;
return
heck/[IP]/json?key=[API_KEY]&days=[DAYS]
#
$self->get(
'https://www.abuseipdb.com/check/'.$ip.'/json?key='.$api_key.'&days='.$days
) or return;
my $r = $self->content('json');
#
# https://www.abuseipdb.com/report/json?key=[API_KEY]&category=[CATEGORIES]&comment=[COMMENT]&ip=[IP]
#
$self->get(
'https://www.abuseipdb.com/report/json?key='.$api_key.'&category='.$cate
gory.
'&comment='.$comment.'&ip='.$ip
) or return;
return $self->content('json');
}
1;
__END__
=head1 NAME
Metabrik::Api::Abuseipdb - api::abuseipdb Brik
=head1 COPYRIGHT AND LICENSE
rd) ], # Inherited
ssl_verify => [ qw(0|1) ], # Inherited
output_mode => [ qw(json|xml|csv) ],
count => [ qw(number) ],
offset => [ qw(number) ],
},
a
localhost:8089',
username => 'admin',
ssl_verify => 0,
output_mode => 'json',
count => 1000, # 0 means return everything
offset => 0, # 0 means return ev
rn;
my $r = $self->get($uri) or return;
my $headers = $r->{headers};
# Taken from apps.json from Wappalyzer
my @headers = qw(
IBM-Web2-Location
X-Drupal-Cache
X-Powered
identify, 'xml';
}
elsif ($subset =~ /^\s*{\s+["a-zA-Z0-9:]+\s+/) {
push @$identify, 'json';
}
elsif ($string =~ /^[a-zA-Z0-9+]+={1,2}$/) {
push @$identify, 'base64';
}
e
de => [ qw(json|xml) ],
},
attributes_default => {
uri => 'https://localhost:8089',
username => 'admin',
ssl_verify => 0,
output_mode => 'json',
}
category => [ qw(uri) ],
},
require_modules => {
'Metabrik::String::Json' => [ ],
'Metabrik::String::Xml' => [ ],
},
};
}
sub category {
my $self =
categorization')
or return;
my $content = $r->{content};
my $sj = Metabrik::String::Json->new_from_brik_init($self) or return;
my $decode = $sj->decode($content) or return;
# Exam
rd) ], # Inherited
ssl_verify => [ qw(0|1) ], # Inherited
output_mode => [ qw(json|xml|csv) ],
count => [ qw(number) ],
offset => [ qw(number) ],
},
a
localhost:8089',
username => 'admin',
ssl_verify => 0,
output_mode => 'json',
count => 1000,
offset => 0,
},
commands => {
search => [
n;
my $output_mode = $self->output_mode;
if ($output_mode ne 'xml'
&& $output_mode ne 'json'
&& $output_mode ne 'csv') {
return $self->log->error("get_results: output_mode not sup
is {
host => "$redis_host"
key => "logstash"
data_type => "list"
codec => json
}
}
output {
if "_grokparsefailure" in [tags] {
null {}
}
if [type] == "exampl
,
output_mode => [ qw(json|xml) ],
},
attributes_default => {
hostname => 'localhost',
port => 8888,
output_mode => 'json',
},
commands => {
ndlers post_handlers|OPTIONAL) ],
},
require_modules => {
'Metabrik::String::Json' => [ ],
'Metabrik::String::Xml' => [ ],
},
};
}
sub start {
my $self = shi
tp->mount('/' => { path => $root });
my $se;
if ($self->output_mode eq 'json') {
$se = Metabrik::String::Json->new_from_brik_init($self) or return;
}
elsif ($self->output_mode eq 'x
fy => [ qw(0|1) ], # Inherited
output_mode => [ qw(json|xml) ],
},
attributes_default => {
output_mode => 'json',
},
commands => {
reset_user_agent =
,
require_modules => {
'Metabrik::String::Xml' => [ ],
'Metabrik::String::Json' => [ ],
},
};
}
sub content {
my $self = shift;
my ($output_mode) = @_;
my $
}
my $sm;
$output_mode ||= $self->output_mode;
if ($output_mode eq 'json') {
$sm = Metabrik::String::Json->new_from_brik_init($self) or return;
}
elsif ($output_mode eq 'xml') {
host => "127.0.0.1"
data_type => "list"
key => "logstash"
codec => json
congestion_interval => 1
congestion_threshold => 20000000
# Batch proc
_events => 50
batch_timeout => 5
}
}
else {
stdout {
codec => json
}
}
}
EOF
;
my $ft = Metabrik::File::Text->new_from_brik_init($self) or return;
$
ng_from_json_file => [ qw(index type file) ],
update_mapping_from_json_file => [ qw(file index type) ],
put_template => [ qw(name template) ],
put_template_from_json_file =>
[ qw(file name|OPTIONAL) ],
update_template_from_json_file => [ qw(file name|OPTIONAL) ],
get_settings => [ qw(index|indices_list|OPTIONAL name|names_list|OPTIONAL) ],
put_
L) ],
export_as_csv => [ qw(index size|OPTIONAL callback|OPTIONAL) ],
export_as_json => [ qw(index size|OPTIONAL callback|OPTIONAL) ],
import_from => [ qw(format input index
},
require_modules => {
'Metabrik::Devel::Git' => [ ],
'Metabrik::String::Json' => [ ],
'Metabrik::String::Xml' => [ ],
},
require_binaries => {
p
->repo;
my $cmd = $repo.'/bin/search.py -o json -p '.$cpe;
my $json = $self->capture($cmd) or return;
if (@$json <= 0 || (@$json == 1 && $json->[0] eq 'undef')) {
return $self->log->e
e: invalid response: ".join('', @$json));
}
my $sj = Metabrik::String::Json->new_from_brik_init($self) or return;
my @results = ();
for my $this (@$json) {
my $r = $sj->decode($thi