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:\MinGW\bin. 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:\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
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.