|
| 1 | + |
| 2 | +# Installing _FastFinder_ on Windows |
| 3 | + |
| 4 | +_FastFinder_ is design for Windows platform but it's a little bit tricky because it's strongly dependant of go-yara and CGO. Here's a little step by step guide: |
| 5 | + |
| 6 | +## Before installation |
| 7 | + |
| 8 | +All the installation process will be done with msys2/mingw terminal. In order to avoid any error, you have to ensure that your installation directories don't contains space or special characters. I haven't tested to install as a simple user, I strongly advise you to install everything with admin privileges on top of your c:\ drive. |
| 9 | + |
| 10 | +For the configurations and examples below, my install paths are: |
| 11 | + |
| 12 | +* GO: c:\Go |
| 13 | +* GOPATH: C:\Users\myuser\go |
| 14 | +* Msys2: c:\msys64 |
| 15 | +* Git: c:\Git |
| 16 | + |
| 17 | +## Install msys2 and dependencies: |
| 18 | + |
| 19 | +First of all, note that you won't be able to get _FastFinder_ working if the dependencies are compiled with another compiler than GCC. There is currently some problems with CGO when external libraries are compiled with Visual C++, so no need to install Visual Studio or vcpkg. |
| 20 | + |
| 21 | +* Download msys2 [from the official website](https://www.msys2.org/) and install it |
| 22 | +* there, you will find two distincts binaries shorcut "MSYS2 MSYS" and "MSYS2 MinGW 64bits". Please launch this second one. |
| 23 | +* install dependencies with the following command line: `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-pkg-config base-devel openssl-devel` |
| 24 | +* add environment variables in mingw terminal: `export PATH=$PATH:/c/Go/bin:/c/msys64/mingw64/bin:/c/Git/bin` |
| 25 | + |
| 26 | +## Download and compile libyara |
| 27 | + |
| 28 | +It's strongly advised NOT to clone VirusTotal's YARA repository but to download the source code of the latest release. If you compile libyara from the latest commit, it could generate some side effects when linking this library with _FastFinder_ and GCO. |
| 29 | + |
| 30 | +* download latest VirusTotal release source code [from here](https://github.com/VirusTotal/yara/releases) |
| 31 | +* unzip the folder in a directory without space and special char |
| 32 | +* in mingw terminal, go to yara directory (backslash have to be replace with slash eg. cd c:/yara) |
| 33 | +* compile and install using the following command: `./bootstrap.sh &&./configure && make && make install` |
| 34 | + |
| 35 | +## Configure your OS |
| 36 | + |
| 37 | +With this step, you won't need to use mingw terminal anymore and you will be able to use Go to install _FastFinder_ and compile your projects directly from Windows cmd / powershell. |
| 38 | + |
| 39 | +Make sure you have the following as system environment variables (not user env vars). If not, create them: |
| 40 | +``` |
| 41 | +GOARCH=<your-architecture> (eg. amd64) |
| 42 | +GOOS=windows |
| 43 | +CGO_CFLAGS=-IC:/msys64/mingw64/include |
| 44 | +CGO_LDFLAGS=-LC:/msys64/mingw64/lib -lyara -lcrypto |
| 45 | +PKG_CONFIG_PATH=C:/msys64/mingw64/lib/pkgconfig |
| 46 | +``` |
| 47 | +You also need C:\msys64\mingw64\bin in your system PATH env vars. |
| 48 | + |
| 49 | +Make sure you have got the following user environment var (not system var): |
| 50 | + |
| 51 | + GOPATH=%USERPROFILE%\go |
| 52 | + |
| 53 | +Note that paths must be written with slashs and not backslash. As already said, don't use path with spaces or special characters. |
| 54 | + |
| 55 | +## Download, Install and compile FastFinder |
| 56 | +Now, from Windows cmd or Powershell, you can install _FastFinder_: `go get github.com/codeyourweb/fastfinder` |
| 57 | +Compilation should be done with: `go build -tags yara_static -a -ldflags '-extldflags "-static"' .` |
0 commit comments