aboutsummaryrefslogtreecommitdiff
path: root/Inject
diff options
context:
space:
mode:
authorroot <root@rbsd.ankarstrom.se>2021-04-23 00:29:32 +0000
committerroot <root@rbsd.ankarstrom.se>2021-04-23 00:29:32 +0000
commitf944b2592d581ddb7e6c7614ea3766328084b682 (patch)
tree6e8c4dd97bc88c49ea0c8ee07ea289793e4d2002 /Inject
downloadApache-Inject-f944b2592d581ddb7e6c7614ea3766328084b682.tar.gz
First commit
Diffstat (limited to 'Inject')
-rw-r--r--Inject/Handler.pm40
1 files changed, 40 insertions, 0 deletions
diff --git a/Inject/Handler.pm b/Inject/Handler.pm
new file mode 100644
index 0000000..adeec57
--- /dev/null
+++ b/Inject/Handler.pm
@@ -0,0 +1,40 @@
+package Apache::Inject::Handler;
+
+use strict;
+use warnings;
+
+use Apache2::RequestRec ();
+use Apache2::RequestUtil ();
+use Apache2::Const qw/OK DECLINED/;
+
+my $doc = qr{
+ (?<head> <head[^>*]>.*?</head>
+ |
+ ( <title[^>]*>.*?</title>
+ | <base[^>]*>
+ | <meta[^>]*>
+ | <link[^>]*>
+ | <object[^>]*>.*?</object>
+ | <style[^>]*>.*?</style> # n.b.
+ | <script[^>]*>.*?</script> # n.b.
+ | <noscript[^>]*>.*?</noscript> # n.b.!
+ )+ )
+ (?<body> .* )
+}xms;
+
+sub handler {
+ my $r = shift;
+
+ return DECLINED if not $r->content_type eq 'text/html';
+
+ my $content = ${$r->slurp_filename};
+ return DECLINED if not $content =~ /$doc/;
+ print $+{head};
+ print "Injection 1\n";
+ print $+{body};
+ print "Injection 2\n";
+
+ return OK;
+}
+
+1;