From f5e162e2e285810df9ef4779a5a79ed5da808943 Mon Sep 17 00:00:00 2001 From: heuzef Date: Tue, 6 Feb 2018 17:44:40 +0100 Subject: [PATCH] init --- conf/keywords.cfg | 2 + defacement_check.pl | 73 +++++++++++++++++++++++++++ sitemap/sitemap_example.com.xml | 4 ++ sitemap/sitemap_www.firewall-services.com.xml | 12 +++++ 4 files changed, 91 insertions(+) create mode 100644 conf/keywords.cfg create mode 100644 defacement_check.pl create mode 100644 sitemap/sitemap_example.com.xml create mode 100644 sitemap/sitemap_www.firewall-services.com.xml diff --git a/conf/keywords.cfg b/conf/keywords.cfg new file mode 100644 index 0000000..87331b2 --- /dev/null +++ b/conf/keywords.cfg @@ -0,0 +1,2 @@ +hack +hacked diff --git a/defacement_check.pl b/defacement_check.pl new file mode 100644 index 0000000..baedf92 --- /dev/null +++ b/defacement_check.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl -w +use strict; +use XML::Simple; +use Data::Dumper; + +# Date +use POSIX qw(strftime); +my $date = strftime "%d/%m/%Y %H:%M", localtime; + +# Functions +sub uniq { + my %seen; + grep !$seen{$_}++, @_; +} + +print "\033[33m \nDEFACEMENT CHECK [" . $date . "]\n\nSearching for suspects ...\n"; +print "FOUND \t\t=> URLs\n"; + +# Import config +my @search; +my $keywords = 'conf/keywords.cfg'; +if (open(my $f, '<:encoding(UTF-8)', $keywords)) { + while (my $row = <$f>) { + chomp $row; + push @search, $row; + } +} else { + warn "Could not open file '$keywords' $!"; +} + +# Open XML files +my @files = glob( "sitemap/*.xml" ); +my $file; + +foreach $file (@files) +{ + my $xml = new XML::Simple (KeyAttr=>[]); + my $url; + my $data = $xml->XMLin($file); + + foreach $url (@{$data->{url}}) + { + my $survey = $url->{loc}; + # Create a user agent object + use LWP::UserAgent; + my $ua = LWP::UserAgent->new; + # Create a request + my $req = HTTP::Request->new(GET => $survey); + # Pass request to the user agent and get a response back + my $res = $ua->request($req); + my $site = $res->content; + + my @found; + my $total_found = 0; + + foreach my $s (@search) { + foreach (grep(/$s/i, split(/\n/, $site))) { + push @found, $_; + } + } + + # Results + foreach (uniq(@found)) { + $total_found++; + # print $total_found . " : " . $_ . "\n"; # VERBOSE MODE + } + if ($total_found == 0) { + print "\033[32m" . $total_found . "\t\t=> " . $survey. "\n"; + } else { + print "\033[31m" . $total_found . "\t\t=> " . $survey. "\n"; + } + } +} diff --git a/sitemap/sitemap_example.com.xml b/sitemap/sitemap_example.com.xml new file mode 100644 index 0000000..8b3f7e6 --- /dev/null +++ b/sitemap/sitemap_example.com.xml @@ -0,0 +1,4 @@ + +http://example.com/ +http://example.com/test + diff --git a/sitemap/sitemap_www.firewall-services.com.xml b/sitemap/sitemap_www.firewall-services.com.xml new file mode 100644 index 0000000..313ef84 --- /dev/null +++ b/sitemap/sitemap_www.firewall-services.com.xml @@ -0,0 +1,12 @@ + +http://www.firewall-services.com/ +http://www.firewall-services.com/clubs-entreprises.html +http://www.firewall-services.com/contact.html +http://www.firewall-services.com/espace-presse.html +http://www.firewall-services.com/formations.html +http://www.firewall-services.com/index.html +http://www.firewall-services.com/nos-competences.html +http://www.firewall-services.com/passeport.html +http://www.firewall-services.com/plan.html +http://www.firewall-services.com/prolibre.html +