Building Gor (Go Replay) on Windows

Joseph LawsonJune 8, 2016

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.

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:\MinGW\bin. You can do this in your current session by running:

set PATH=%PATH%;C:\MinGW\bin

Next using mingw-get you will install gcc. If the command doesn’t work, ensure that the c:\MinGW\bin 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:\MinGW\include and copy from Lib the files libpacket.a libwpcap.a Packet.lib wpcap.lib to C:\MinGW\lib (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%\work
set 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/gor
cd src/github.com/buger/gor
go build -ldflags="-extldflags \"-static\""

After that, you should have a working gor.exe in your project directory! You can now use Gor in your Windows environment. Enjoy testing with live data!

gor.exe --input-raw :8080 --output-stdout

ProTip

If you plan to test gor.exe by calling it locally, ie localhost, 127.0.0.1 or even the external ip, ensure that you Install Microsoft Loopback Adapter or you won’t see the traffic unless you test from another remote machine. This is also covered in Wireshark’s Loopback capture setup.




More blog articles:


Let's do a project together!

We provide tailored search, discovery and analytics solutions using Solr and Elasticsearch. Learn more about our service offerings