-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
68 lines (51 loc) · 1.44 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"flag"
"log"
"os"
"time"
"github.com/common-nighthawk/go-figure"
"github.com/briandowns/spinner"
"github.com/fatih/color"
"github.com/gugadev/virusgotal/requests"
"github.com/gugadev/virusgotal/utils"
)
func main() {
var FileUtils utils.Files
var Console utils.Console
// console outs
green := color.New(color.FgGreen).Add(color.Bold)
white := color.New(color.FgWhite).Add(color.Bold)
whiteUnderline := color.New(color.FgWhite).Add(color.Bold, color.Underline)
ascii := figure.NewFigure("VirusGotal", "graffiti", false)
// spin
spin := spinner.New(spinner.CharSets[39], 200*time.Millisecond)
// arguments
key := flag.String("key", "Your VT API Key", "Ex.: dg2nfng304ngdjng234fng4tfnfjn34")
path := flag.String("file", "Path of the file", "/home/janedoe/suspectfile.ext")
flag.Parse()
if key == nil {
log.Fatal("You need to provide your VirusTotal API key")
os.Exit(-1)
}
if path == nil {
log.Fatal("You need to provide the file path")
os.Exit(-1)
}
// open the file to send to VT
file := FileUtils.Open(*path)
fileStat, _ := file.Stat()
Console.Clear()
ascii.Print()
green.Print("\nScanning file ")
white.Printf("%s ", fileStat.Name())
spin.Start()
// upload and scan the file
scan := requests.Upload(*key, file)
spin.Stop()
whiteUnderline.Print("\n\nScan results:\n\n")
// get the report
report := requests.GetReport(*key, scan.Resource)
// show the report into a table
report.Show()
}