| 1 | ####################################################################### | ||
| 2 | # Created on: December 14, 2006 | ||
| 3 | # Package: HoneyClient::Agent::Driver::ActiveContent | ||
| 4 | # File: ActiveContent.pm | ||
| 5 | # Description: A driver for handling various forms of | ||
| 6 | # active content found in web pages. Calls | ||
| 7 | # the appropriate handler based on the type | ||
| 8 | # of content that was input, and returns a | ||
| 9 | # list of URLs that were contained within | ||
| 10 | # the content. | ||
| 11 | # | ||
| 12 | # CVS: $Id: ActiveContent.pm 696 2007-07-19 02:21:10Z kindlund $ | ||
| 13 | # | ||
| 14 | # @author jpuchalski | ||
| 15 | # | ||
| 16 | # Copyright (C) 2007 The MITRE Corporation. All rights reserved. | ||
| 17 | # | ||
| 18 | # This program is free software; you can redistribute it and/or | ||
| 19 | # modify it under the terms of the GNU General Public License | ||
| 20 | # as published by the Free Software Foundation, using version 2 | ||
| 21 | # of the License. | ||
| 22 | # | ||
| 23 | # This program is distributed in the hope that it will be useful, | ||
| 24 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 25 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 26 | # GNU General Public License for more details. | ||
| 27 | # | ||
| 28 | # You should have received a copy of the GNU General Public License | ||
| 29 | # along with this program; if not, write to the Free Software | ||
| 30 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| 31 | # 02110-1301, USA. | ||
| 32 | # | ||
| 33 | # | ||
| 34 | ####################################################################### | ||
| 35 | |||
| 36 | =pod | ||
| 37 | |||
| 38 | =head1 NAME | ||
| 39 | |||
| 40 | HoneyClient::Agent::Driver::ActiveContent - Perl module that extracts | ||
| 41 | information from various forms of active content, such as SWF Flash | ||
| 42 | movies. Currently the information returned is a list of URLs that | ||
| 43 | were embedded in the active content. | ||
| 44 | |||
| 45 | =head1 VERSION | ||
| 46 | |||
| 47 | This documentation refers to HoneyClient::Agent::Driver::ActiveContent | ||
| 48 | version 0.1. | ||
| 49 | |||
| 50 | =head1 SYNOPSIS | ||
| 51 | |||
| 52 | use HoneyClient::Agent::Driver::ActiveContent; | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | =head1 DESCRIPTION | ||
| 57 | |||
| 58 | =cut | ||
| 59 | |||
| 60 | package HoneyClient::Agent::Driver::ActiveContent; | ||
| 61 | |||
| 62 | use strict; | ||
| 63 | use warnings; | ||
| 64 | use Carp (); | ||
| 65 | |||
| 66 | ####################################################################### | ||
| 67 | # Module Initialization # | ||
| 68 | ####################################################################### | ||
| 69 | |||
| 70 | BEGIN { | ||
| 71 | require Exporter; | ||
| 72 | our (@ISA, @EXPORT, @EXPORT_OK, $VERSION); | ||
| 73 | |||
| 74 | # Set our package version. | ||
| 75 | $VERSION = 0.1; | ||
| 76 | |||
| 77 | @ISA = qw(Exporter HoneyClient::Agent::Driver); | ||
| 78 | |||
| 79 | # Symbols to export by default | ||
| 80 | @EXPORT = qw(); | ||
| 81 | |||
| 82 | # Items to export into callers namespace by default. Note: do not export | ||
| 83 | # names by default without a very good reason. Use EXPORT_OK instead. | ||
| 84 | # Do not simply export all your public functions/methods/constants. | ||
| 85 | |||
| 86 | # Symbols to export on request | ||
| 87 | @EXPORT_OK = qw(process); | ||
| 88 | } | ||
| 89 | our (@EXPORT_OK, $VERSION); | ||
| 90 | |||
| 91 | ####################################################################### | ||
| 92 | |||
| 93 | use Log::Log4perl qw(:easy); | ||
| 94 | |||
| 95 | # Include the Flash content processing module | ||
| 96 | use HoneyClient::Agent::Driver::ActiveContent::Flash qw(extract); | ||
| 97 | |||
| 98 | # Include Data Dumper API | ||
| 99 | use Data::Dumper; | ||
| 100 | |||
| 101 | our $LOG = get_logger(); | ||
| 102 | |||
| 103 | |||
| 104 | ####################################################################### | ||
| 105 | # Private Methods Implemented # | ||
| 106 | ####################################################################### | ||
| 107 | |||
| 108 | =pod | ||
| 109 | |||
| 110 | =head1 PRIVATE METHODS | ||
| 111 | |||
| 112 | None. | ||
| 113 | |||
| 114 | =cut | ||
| 115 | |||
| 116 | ####################################################################### | ||
| 117 | # Public Methods Implemented # | ||
| 118 | ####################################################################### | ||
| 119 | |||
| 120 | =pod | ||
| 121 | |||
| 122 | =head1 PUBLIC METHODS | ||
| 123 | |||
| 124 | =head2 HoneyClient::Agent::Driver::ActiveContent->isActiveContent() | ||
| 125 | |||
| 126 | =over 4 | ||
| 127 | |||
| 128 | Checks to see if a particular input file contains a type of active content | ||
| 129 | that we are interested in processing. | ||
| 130 | |||
| 131 | =back | ||
| 132 | |||
| 133 | =begin testing | ||
| 134 | |||
| 135 | # Do testing here | ||
| 136 | |||
| 137 | =end testing | ||
| 138 | |||
| 139 | =cut | ||
| 140 | |||
| 141 | sub isActiveContent { | ||
| 142 | # Extract arguments. | ||
| 143 | my %args = @_; | ||
| 144 | |||
| 145 | # Log resolved arguments. | ||
| 146 | $LOG->debug(sub { | ||
| 147 | # Make Dumper format more terse. | ||
| 148 | $Data::Dumper::Terse = 1; | ||
| 149 | $Data::Dumper::Indent = 0; | ||
| 150 | Dumper(\%args); | ||
| 151 | }); | ||
| 152 | |||
| 153 | # Make sure an input file is defined | ||
| 154 | unless (defined($args{'file'})) { | ||
| 155 | $LOG->fatal("No input file provided!"); | ||
| 156 | Carp::croak "Error: No input file provided!"; | ||
| 157 | } | ||
| 158 | |||
| 159 | # Make sure a URL is defined | ||
| 160 | unless (defined($args{'url'})) { | ||
| 161 | $LOG->fatal("No URL provided!"); | ||
| 162 | Carp::croak "Error: No URL provided!"; | ||
| 163 | } | ||
| 164 | |||
| 165 | return ($args{'file'}->filename =~ /\.swf$/); | ||
| 166 | } | ||
| 167 | |||
| 168 | =pod | ||
| 169 | |||
| 170 | =head2 HoneyClient::Agent::Driver::ActiveContent->process() | ||
| 171 | |||
| 172 | =over 4 | ||
| 173 | |||
| 174 | Processes the given input file by calling the appropriate extraction | ||
| 175 | handler. | ||
| 176 | |||
| 177 | =back | ||
| 178 | |||
| 179 | =begin testing | ||
| 180 | |||
| 181 | # Do testing here | ||
| 182 | |||
| 183 | =end testing | ||
| 184 | |||
| 185 | =cut | ||
| 186 | |||
| 187 | sub process { | ||
| 188 | # Extract arguments. | ||
| 189 | my %args = @_; | ||
| 190 | |||
| 191 | # Log resolved arguments. | ||
| 192 | $LOG->debug(sub { | ||
| 193 | # Make Dumper format more terse. | ||
| 194 | $Data::Dumper::Terse = 1; | ||
| 195 | $Data::Dumper::Indent = 0; | ||
| 196 | Dumper(\%args); | ||
| 197 | }); | ||
| 198 | |||
| 199 | # Make sure an input file is defined | ||
| 200 | unless (defined($args{'file'})) { | ||
| 201 | $LOG->fatal("No input file provided!"); | ||
| 202 | Carp::croak "Error: No input file provided!"; | ||
| 203 | } | ||
| 204 | |||
| 205 | # Make sure a base URL is defined | ||
| 206 | unless (defined($args{'url'})) { | ||
| 207 | $LOG->fatal("No URL provided!"); | ||
| 208 | Carp::croak "Error: No URL provided!"; | ||
| 209 | } | ||
| 210 | |||
| 211 | # Pass the file to the appropriate content type module | ||
| 212 | # Note: We need to account for URLs, where there's additional data | ||
| 213 | # at the end of the file name. Like, in the case of video.google.com: | ||
| 214 | # http://video.google.com/googleplayer.swf?docid=.... | ||
| 215 | if ($args{'file'}->filename =~ /\.swf/) { | ||
| 216 | return HoneyClient::Agent::Driver::ActiveContent::Flash::extract(%args); | ||
| 217 | } else { | ||
| 218 | Carp::croak "Error: Input file does not contain a known resource!\n"; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | 1; | ||
| 223 | |||
| 224 | =pod | ||
| 225 | |||
| 226 | =head1 AUTHORS | ||
| 227 | |||
| 228 | Jeff Puchalski, E<lt>jpuchalski@mitre.orgE<gt> | ||
| 229 | |||
| 230 | =head1 COPYRIGHT & LICENSE | ||
| 231 | |||
| 232 | Copyright (C) 2007 The MITRE Corporation. All rights reserved. | ||
| 233 | |||
| 234 | This program is free software; you can redistribute it and/or | ||
| 235 | modify it under the terms of the GNU General Public License | ||
| 236 | as published by the Free Software Foundation, using version 2 | ||
| 237 | of the License. | ||
| 238 | |||
| 239 | This program is distributed in the hope that it will be useful, | ||
| 240 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 241 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 242 | GNU General Public License for more details. | ||
| 243 | |||
| 244 | You should have received a copy of the GNU General Public License | ||
| 245 | along with this program; if not, write to the Free Software | ||
| 246 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
| 247 | 02110-1301, USA. | ||
| 248 | |||
| 249 | =cut |