line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim:set sw=4 ts=4 sts=4 ft=perl expandtab: |
2
|
|
|
|
|
|
|
package Mojolicious::Plugin::ZipBomb; |
3
|
1
|
|
|
1
|
|
737
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
1
|
|
|
1
|
|
637
|
use File::Share ':all'; |
|
1
|
|
|
|
|
24657
|
|
|
1
|
|
|
|
|
427
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub register { |
9
|
1
|
|
|
1
|
1
|
64
|
my ($self, $app, $conf) = @_; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
3
|
my @methods = qw(any); |
12
|
1
|
50
|
|
|
|
6
|
@methods = @{$conf->{methods}} if $conf->{methods}; |
|
1
|
|
|
|
|
4
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
2
|
for my $route (@{$conf->{routes}}) { |
|
1
|
|
|
|
|
3
|
|
15
|
2
|
|
|
|
|
547
|
for my $method (@methods) { |
16
|
2
|
|
|
|
|
14
|
$app->routes->$method($route, \&_drop_bomb); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _drop_bomb { |
22
|
2
|
|
|
2
|
|
33927
|
my $c = shift; |
23
|
|
|
|
|
|
|
|
24
|
2
|
|
|
|
|
9
|
my $bomb = dist_file('Mojolicious-Plugin-ZipBomb', '42.zip'); |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
600
|
$c->res->headers->content_encoding('gzip'); |
27
|
|
|
|
|
|
|
|
28
|
2
|
50
|
|
|
|
52
|
$c->res->headers->content_type('text/html') if ($c->app->mode eq 'production'); |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
28
|
$c->reply->file($bomb); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
__END__ |