extracting data from the exe files

This commit is contained in:
2024-06-18 18:33:24 +03:00
parent 2d05843c28
commit aa41b83964
3 changed files with 66 additions and 17 deletions

14
go.mod
View File

@@ -3,14 +3,28 @@ module main
go 1.22.3 go 1.22.3
require ( require (
github.com/barasher/go-exiftool v1.10.0 // indirect
github.com/dsoprea/go-exif v0.0.0-20230826092837-6579e82b732d // indirect
github.com/dsoprea/go-exif/v3 v3.0.1 // indirect
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/google/uuid v1.6.0 // indirect github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd // indirect
github.com/saferwall/pe v1.5.3 // indirect
github.com/secDre4mer/pkcs7 v0.0.0-20240322103146-665324a4461d // indirect
golang.org/x/net v0.0.0-20221002022538-bcab6841153b // indirect
golang.org/x/sys v0.19.0 // indirect golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.50.9 // indirect modernc.org/libc v1.50.9 // indirect
modernc.org/mathutil v1.6.0 // indirect modernc.org/mathutil v1.6.0 // indirect

View File

@@ -261,6 +261,7 @@ func upload() http.Handler {
fn,_:=os.OpenFile("Data/"+filename, os.O_CREATE, 0666) fn,_:=os.OpenFile("Data/"+filename, os.O_CREATE, 0666)
fn.Write(fileBytes) fn.Write(fileBytes)
fn.Close() fn.Close()
getParamsFromExif("Data/"+filename)
})} })}
// index creates an HTTP handler that serves the main page with data from the database. // index creates an HTTP handler that serves the main page with data from the database.

View File

@@ -1,19 +1,27 @@
package main package main
import( import (
"fmt" "fmt"
"log"
"regexp"
"os"
"os/exec"
"strconv" "strconv"
) )
type packages struct{ // packages struct represents a package with its details.
Id string type packages struct {
Name string Id string
Version string Name string
Version string
ExtraCommand *string ExtraCommand *string
Tag string Tag string
Warning bool Warning bool
Element *elements Element *elements
} }
// ConvertStringsToPackage converts a slice of strings to a packages struct.
// It returns an error if the input slice does not have exactly 6 elements or if the Warning value cannot be parsed as a boolean.
func ConvertStringsToPackage(strs []string) (packages, error) { func ConvertStringsToPackage(strs []string) (packages, error) {
var pkg packages var pkg packages
if len(strs) != 6 { if len(strs) != 6 {
@@ -34,18 +42,44 @@ func ConvertStringsToPackage(strs []string) (packages, error) {
Warning: warning, Warning: warning,
}, nil }, nil
} }
// elements struct represents the elements of a the webpage.
type elements struct { type elements struct {
Title string Title string
Header string Header string
Help string Help string
Packagename string Packagename string
Packageversion string Packageversion string
Allow string Allow string
Warning string Warning string
Explain string Explain string
} }
// DownloadElements struct represents the elements to be downloaded.
type DownloadElements struct { type DownloadElements struct {
ID string ID string
Version *string Version *string
Counter int Counter int
} }
// Printer struct is an empty struct. Its purpose is not clear from the provided code.
type Printer struct{}
// getParamsFromExif extracts EXIF parameters from a file at the given path using the exiftool command.
// It returns a map where the keys are the EXIF parameter names and the values are the corresponding EXIF parameter values.
func getParamsFromExif(path string) map[string]string{
exiftool := os.Getenv("exiftool")
e,_ := exec.Command(exiftool, "-f", path).Output()
tags:=make(map[string]string)
spliter:=regexp.MustCompile(`\r?\n`)
crop:=spliter.Split(string(e),-1)
head := regexp.MustCompile(`\s+:\s`)
for _,c := range crop{
if(len(c)>1){
data:=head.Split(c,-1)
log.Println("My Raw Data: ", c)
tags[data[0]]=data[1]}
}
log.Println(tags)
return tags
}