diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 573f6e0..c6b1e0d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -11,7 +11,7 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 - name: Build run: make build diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 071ce77..cd95295 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,8 +10,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 - id: get_version run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) - name: Install dependencies diff --git a/README.md b/README.md index f6ccc0d..65e44ac 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ As this tool use the [VirusTotal API](https://developers.virustotal.com/v3.0/ref ### Installing the tool -For installing the tool you can download one the [pre-compiled binaries](https://github.com/VirusTotal/vt-cli/releases) we offer for Windows, Linux and Mac OS X, or alternatively you can compile it yourself from source code. For compiling the program you'll need Go 1.14.x or higher installed in your system and type the following commands: +For installing the tool you can download one the [pre-compiled binaries](https://github.com/VirusTotal/vt-cli/releases) we offer for Windows, Linux and Mac OS X, or alternatively you can compile it yourself from source code. To compile the program you'll need [Go 1.14.x or higher installed in your system](https://go.dev/doc/install) and type the following commands: ```sh $ git clone https://github.com/VirusTotal/vt-cli @@ -35,11 +35,21 @@ $ export PATH=$PATH:$GOBIN ``` #### Mac OS + For Mac OS users, there's a [brew formula](https://formulae.brew.sh/formula/virustotal-cli) available. Please note this is not maintained by VirusTotal. + ```sh $ brew install virustotal-cli ``` +#### Windows + +For Windows uses, there's a [Winget manifest](https://github.com/microsoft/winget-pkgs/tree/master/manifests/v/VirusTotal/vt-cli) available. Please note this is not maintained by VirusTotal. + +```powershell +winget install VirusTotal.vt-cli +``` + ### A note on Window's console If you plan to use vt-cli in Windows on a regular basis we highly recommend you to avoid the standard Windows's console and use [Cygwin](https://www.cygwin.com/) instead. The Windows's console is *very* slow when printing large amounts of text (as vt-cli usually does) while Cygwin performs much better. Additionally, you can benefit of Cygwin's support for command auto-completion, a handy feature that Window's console doesn't offer. In order to take advantage of auto-completion make sure to include the `bash-completion` package while installing Cygwin. diff --git a/cmd/cmd.go b/cmd/cmd.go index 61f5e55..76fb95d 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -110,6 +110,12 @@ func addVerboseFlag(flags *pflag.FlagSet) { "verbose output") } +func addSilentFlag(flags *pflag.FlagSet) { + flags.BoolP( + "silent", "s", false, + "Silent or quiet mode. Do not show progress meter") +} + func addHumanFlag(flags *pflag.FlagSet) { flags.BoolP( "human", "H", false, diff --git a/cmd/scan.go b/cmd/scan.go index 805e737..2d181bd 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -77,6 +77,7 @@ type fileScanner struct { printer *utils.Printer showInVT bool waitForCompletion bool + password string } func (s *fileScanner) Do(path interface{}, ds *utils.DoerState) string { @@ -100,7 +101,13 @@ func (s *fileScanner) Do(path interface{}, ds *utils.DoerState) string { } defer f.Close() - analysis, err := s.scanner.ScanFile(f, progressCh) + var analysis *vt.Object + if s.password != "" { + analysis, err = s.scanner.ScanFileWithParameters( + f, progressCh, map[string]string{"password": s.password}) + } else { + analysis, err = s.scanner.ScanFile(f, progressCh) + } if err != nil { return err.Error() } @@ -173,6 +180,7 @@ func NewScanFileCmd() *cobra.Command { scanner: client.NewFileScanner(), showInVT: viper.GetBool("open"), waitForCompletion: viper.GetBool("wait"), + password: viper.GetString("password"), printer: p, cli: client} c.DoWithStringsFromReader(s, argReader) @@ -182,6 +190,7 @@ func NewScanFileCmd() *cobra.Command { addThreadsFlag(cmd.Flags()) addOpenInVTFlag(cmd.Flags()) + addPasswordFlag(cmd.Flags()) addWaitForCompletionFlag(cmd.Flags()) addIncludeExcludeFlags(cmd.Flags()) cmd.MarkZshCompPositionalArgumentFile(1) @@ -308,3 +317,9 @@ func addWaitForCompletionFlag(flags *pflag.FlagSet) { "wait", "w", false, "Wait until the analysis is completed and show the analysis results") } + +func addPasswordFlag(flags *pflag.FlagSet) { + flags.StringP( + "password", "p", "", + "Password of the protected file") +} diff --git a/cmd/vt.go b/cmd/vt.go index 61e41fd..dacf5a9 100644 --- a/cmd/vt.go +++ b/cmd/vt.go @@ -62,6 +62,7 @@ func NewVTCommand() *cobra.Command { addFormatFlag(cmd.PersistentFlags()) addHostFlag(cmd.PersistentFlags()) addProxyFlag(cmd.PersistentFlags()) + addSilentFlag(cmd.PersistentFlags()) addVerboseFlag(cmd.PersistentFlags()) cmd.AddCommand(NewAnalysisCmd()) diff --git a/go.mod b/go.mod index e158a29..2c040ce 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/VirusTotal/vt-cli go 1.14 require ( - github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee + github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f github.com/briandowns/spinner v1.7.0 github.com/cavaliercoder/grab v2.0.0+incompatible github.com/dustin/go-humanize v1.0.0 diff --git a/go.sum b/go.sum index 7f33849..edf30d7 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee h1:JDhi0dS8y9QLMJZA7ezLyXHxYaMlyzX6MDkq0SSc304= github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= +github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f h1:49xl3zKS625gxmIRCfmwkXcTzB4cr4FcayRw/RcxhZs= +github.com/VirusTotal/vt-go v0.0.0-20230717142150-8431ff2cc00f/go.mod h1:u1+HeRyl/gQs67eDgVEWNE7+x+zCyXhdtNVrRJR5YPE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= diff --git a/utils/do.go b/utils/do.go index e0a338e..8892c57 100644 --- a/utils/do.go +++ b/utils/do.go @@ -22,6 +22,7 @@ import ( vt "github.com/VirusTotal/vt-go" "github.com/briandowns/spinner" "github.com/plusvic/go-ansi" + "github.com/spf13/viper" ) // Coordinator coordinates the work of multiple instances of a Doer that run @@ -115,7 +116,7 @@ func (c *Coordinator) DoWithItemsFromChannel(doer Doer, ch <-chan interface{}) { // stdout is being redirected to a file and we don't want escape sequences // in the output, in that case print only the final results from the doers, // without any progress indication. - if color.NoColor { + if color.NoColor || viper.GetBool("silent") { go c.printResultsOnly() } else { go c.printProgressAndResults()