VirusTotal/vt-cli

error - gzip: invalid header

israel9905 opened this issue · 10 comments

Hi, I downloaded the tool, and when I try to insert an API it gives me an error every time:

gzip: invalid header

Hello @israel9905,

Can you post the exact commands you were using? Providing more details to replicate the problem would be very helpful for us.

Thanks!

Regards,
Marta

In Linux:
When I enter an ip address, and an API it gives the error

1

in Windows:
when I use the vt init command, it asks for the API, and after I put it in, it gives this error

2

Hello @israel9905,

vt-cli uses vt-go under the hood, which communicates with our API by setting a Accept-Encoding: gzip header and golang's gzip library to decompress the response.

Are you able to gzip decompress files using go? You can try this snippet to check it out: https://pkg.go.dev/compress/gzip#example-package-WriterReader

Regards,
Marta

I did not understand, I would love for a more detailed explanation, thanks

Hello @israel9905,

The command client you're using does requests to VirusTotal and expects the response in gzip format. I asked you to test golang's gzip example to check if there's a problem in your go install: https://pkg.go.dev/compress/gzip#example-package-WriterReader

Regards,
Marta

Okay, how do I check the command? Am I copying what is in the link to the terminal?

Hello @israel9905,

Let's change the direction of the troubleshooting. Execute the following commands on your kali:

┌──(root㉿ca8358c70858)-[/]
└─# curl -o source.zip -L https://github.com/VirusTotal/vt-cli/archive/refs/tags/0.10.2.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  236k    0  236k    0     0   240k      0 --:--:-- --:--:-- --:--:--  240k

┌──(root㉿ca8358c70858)-[/]
└─# unzip -q source.zip 

┌──(root㉿ca8358c70858)-[/]
└─# cd vt-cli-0.10.2/

┌──(root㉿ca8358c70858)-[/vt-cli-0.10.2]
└─# make install
go install -ldflags "-X github.com/VirusTotal/vt-cli/cmd.Version=" github.com/VirusTotal/vt-cli/vt
go: downloading github.com/spf13/cobra v1.1.3
go: downloading github.com/mitchellh/go-homedir v1.1.0
go: downloading github.com/spf13/viper v1.7.1
go: downloading github.com/VirusTotal/vt-go v0.0.0-20220413144842-e010bf48aaee
go: downloading github.com/briandowns/spinner v1.7.0
go: downloading github.com/cavaliercoder/grab v2.0.0+incompatible
go: downloading github.com/dustin/go-humanize v1.0.0
go: downloading github.com/fatih/color v1.7.0
go: downloading github.com/gobwas/glob v0.2.3
go: downloading github.com/gosuri/uitable v0.0.4
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213
go: downloading github.com/plusvic/go-ansi v0.0.0-20180516115420-9879244c4340
go: downloading github.com/fsnotify/fsnotify v1.4.7
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading github.com/magiconair/properties v1.8.1
go: downloading github.com/mitchellh/mapstructure v1.1.2
go: downloading github.com/pelletier/go-toml v1.6.0
go: downloading github.com/spf13/cast v1.3.0
go: downloading github.com/spf13/afero v1.2.2
go: downloading github.com/spf13/jwalterweatherman v1.1.0
go: downloading github.com/subosito/gotenv v1.2.0
go: downloading gopkg.in/ini.v1 v1.51.0
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/mattn/go-colorable v0.1.2
go: downloading github.com/mattn/go-isatty v0.0.10
go: downloading github.com/thedevsaddam/gojsonq/v2 v2.5.2
go: downloading github.com/cpuguy83/go-md2man/v2 v2.0.0
go: downloading golang.org/x/sys v0.0.0-20191028164358-195ce5e7f934
go: downloading golang.org/x/text v0.3.2
go: downloading github.com/mattn/go-runewidth v0.0.5
go: downloading github.com/russross/blackfriday/v2 v2.0.1
go: downloading github.com/shurcooL/sanitized_anchor_name v1.0.0

┌──(root㉿ca8358c70858)-[/vt-cli-0.10.2]
└─# make build
go build -ldflags "-X github.com/VirusTotal/vt-cli/cmd.Version=" -o ./build/vt ./vt/main.go

┌──(root㉿ca8358c70858)-[/vt-cli-0.10.2]
└─# ./build/vt init

██╗   ██╗██╗██████╗ ██╗   ██╗███████╗████████╗ ██████╗ ████████╗ █████╗ ██╗
██║   ██║██║██╔══██╗██║   ██║██╔════╝╚══██╔══╝██╔═══██╗╚══██╔══╝██╔══██╗██║
██║   ██║██║██████╔╝██║   ██║███████╗   ██║   ██║   ██║   ██║   ███████║██║
╚██╗ ██╔╝██║██╔══██╗██║   ██║╚════██║   ██║   ██║   ██║   ██║   ██╔══██║██║
 ╚████╔╝ ██║██║  ██║╚██████╔╝███████║   ██║   ╚██████╔╝   ██║   ██║  ██║███████╗
  ╚═══╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝   ╚═╝    ╚═════╝    ╚═╝   ╚═╝  ╚═╝╚══════╝

VirusTotal Command-Line Interface: Threat Intelligence at your fingertips.

Enter your API key: sdshdsdjkdhjkasasd
Wrong API key: sdshdsdjkdhjkasasd

You need to install the Go compiler (instructions here: https://go.dev/doc/install).

Thanks!

Regards,
Marta

Hello @israel9905,

I followed the exact same steps on this docker image: https://hub.docker.com/r/kalilinux/kali-rolling

I needed the following additional steps to install dependencies:

┌──(root㉿98876253b324)-[/]
└─# apt update && apt install unzip curl make
Get:1 http://kali.download/kali kali-rolling InRelease [30.6 kB]
Get:2 http://kali.download/kali kali-rolling/non-free amd64 Packages [213 kB]
[...]

┌──(root㉿98876253b324)-[/]
└─# curl -o go.tar.gz -L https://go.dev/dl/go1.18.3.linux-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    75  100    75    0     0    198      0 --:--:-- --:--:-- --:--:--   198
100  135M  100  135M    0     0  3777k      0  0:00:36  0:00:36 --:--:-- 4948k

┌──(root㉿98876253b324)-[/]
└─# tar -xf go.tar.gz 

┌──(root㉿98876253b324)-[/]
└─# mv go /usr/local/go

┌──(root㉿98876253b324)-[/]
└─# export PATH=$PATH:/usr/local/go/bin

Can you do the same steps on the docker image? I feel there's something wrong on your environment and the docker image is the best way to test a 100% clean environment from scratch.

Regards,
Marta

Still having this issue on my arch machine... I feel like "just use docker" isn't a real solution lol

Edit: Running
export GOBIN=go env GOPATH/bin
export PATH=$PATH:$GOBIN

Fixed it despite me making a symlink of the binary to my bin folder