| 11 | ) |
| 12 | |
| 13 | func scanFile(binaryPath string, conf map[string]string) (bool, error) { |
| 14 | // Get absolute path |
| 15 | absPath, err := filepath.Abs(binaryPath) |
| 16 | if err != nil { |
| 17 | return false, fmt.Errorf("failed to get absolute path with error: %v", err) |
| 18 | } |
| 19 | |
| 20 | // Replace placeholder with actual file path |
| 21 | cmd := strings.Replace(conf["cmd"], "{{file}}", absPath, -1) |
| 22 | |
| 23 | // Execute the scanner command |
| 24 | output, err := exec.Command("powershell.exe", "-Command", cmd).CombinedOutput() |
| 25 | if runtime.GOOS != "windows" { |
| 26 | return false, fmt.Errorf("program only works on windows") |
| 27 | } |
| 28 | |
| 29 | // Check if the output contains the positive detection |
| 30 | if strings.Contains(string(output), conf["out"]) { |
| 31 | return true, nil |
| 32 | } else { |
| 33 | return false, nil |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | func scanSlice(fileData []byte, conf map[string]string) (bool, error) { |
| 38 | // Create a temp file to scan |