onionscan/scans/check_exif.go

41 lines
934 B
Go
Raw Normal View History

2016-04-10 00:04:22 +00:00
package scans
import (
"fmt"
"github.com/s-rah/onionscan/config"
2016-04-10 00:04:22 +00:00
"github.com/s-rah/onionscan/report"
"github.com/xiam/exif"
2016-04-27 00:47:00 +00:00
"io"
2016-04-10 00:04:22 +00:00
"strings"
)
func CheckExif(scan Scanner, page string, status int, contents string, report *report.OnionScanReport, osc *config.OnionscanConfig) {
2016-04-10 00:04:22 +00:00
if status == 200 {
reader := exif.New()
_, err := io.Copy(reader, strings.NewReader(contents))
// exif.FoundExifInData is a signal that the EXIF parser has all it needs,
// it doesn't need to be given the whole image.
if err != nil && err != exif.ErrFoundExifInData {
// We don't care if we fail
return
}
err = reader.Parse()
if err != nil {
// We don't care if we fail
return
}
if len(reader.Tags) > 0 {
report.AddExifImage(page)
for name, val := range reader.Tags {
osc.LogInfo(fmt.Sprintf("\t \033[091mAlert!\033[0m Found Exif Tag%s: %s\n", name, val))
2016-04-10 00:04:22 +00:00
report.AddExifTag(name, val)
}
}
}
}