Gor, or Go Replay, is a great tool to replicate traffic from a production system to a test environment. The tool itself comes prebuilt for OSX and Linux however it lacks a Windows build as there aren’t any free CI tools providing a Windows environment. With that in mind, let’s go over the steps to build this great tool on Windows.
Gor is built using the Go Programming Language. Go compiles code to a native binary for your operating system and uses GNU tools to compile so we have to assemble some parts to get this all working. There are nuances in building Windows binaries, especially around a i386/i686 (32-bit) versus amd64 (x86_64 64-bit), so for this build we will focus around using 32-bit versions of tools. Listed below are all the components you need to get Gor built along with the specific versions I tested with.
- go1.6.2.windows-386.msi – Go binary distribution from golang downloads
- WinPcap_4_1_3.exe – WinPcap Driver + DLLs from Download WinPcap for Windows
- WpdPack_4_1_2.zip – WinPcap Developer’s Pack from WinPcap: Developer Resources
- x86-mingw32-build-1.0-sh.tar.gz2 – MinGW minimalist GNU development environment from MinGW
- Git-2.8.4-32-bit.exe – Git for Windows from Downloading Git
- gor-35696a4 – Gor tool commit 35696a4 from gor github
First install mingw. You can follow the mingw getting started document for details but the basics are as follows. MinGW should be installed to
C:MinGW. You will want to set an environment variable to point to
C:MinGWbin. You can do this in your current session by running:
mingw-get you will install gcc. If the command doesn’t work, ensure that the
c:MinGWbin is on the path.
mingw-get install gcc
Go ahead and install WinPcap and enable the service. Once you have that installed you will want to extract the developer pack and copy everything in the
Include directory to
c:MinGWinclude and copy from
Lib the files
libpacket.a libwpcap.a Packet.lib wpcap.lib to
C:MinGWlib (excluding the files from x64). This will ensure that you have the necessary headers and files to build Gor’s raw TCO listener.
Finally, to get everything working together, install Go from the msi using defaults (check go install docs for more details). Ensure go works from the command line and then setup your workspace environment as follows. You may want to setup the GOPATH as a Windows user environment variable.
mkdir %HOMEPATH%workset GOPATH=%HOMEPATH%work
Run the Git installer and make sure git works from the command line.
We are in the homestretch. The steps now are very similar to the gor compilation page.
cd %GOPATH%go get github.com/buger/gorcd src/github.com/buger/gorgo build -ldflags="-extldflags "-static""""