Sign in to follow this  
Followers 0

Compiling Barnyard2 on Windows for Windows using Cygwin


Windows Intrusion Detection System - Companion Add-On Tutorial

ids.gif

Compiling Barnyard2 on Windows using the Cygwin UNIX emulator

Written by: Michael E. Steele



Introduction

This tutorial is a simple to understand, step-by-step tutorial for Compiling Barnyard2 on Windows using the Cygwin UNIX emulator for MySQL/PostgreSQL database support.

Copyright Notice

This document is Copyright © 2002-2019 Michael Steele. All rights reserved. Permission to distribute this document is hereby granted providing that distribution is electronic, in it's original form, no money is involved, and this copyright notice is maintained. Other requests for distribution will be considered.

Use the information in this document at your own risk. Michael Steele disavows any potential liability of this document. Use of the concepts, examples, and/or other content of this document are entirely at your own risk.

This guide is written in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

All copyrights are owned by their owners, unless specifically noted otherwise. Third party trademarks or brand names are the property of their owners. Use of a term in this document should not be regarded as affecting the validity of any trademark or service mark. Naming of particular products or brands should not be seen as endorsements.

Support Questions and Help

All support questions related to this specific tutorial MUST be directed to the specific forum for which this Windows Intrusion Detection System (WinIDS) tutorial resides!

By request, there is a premium fee service available for one on one support.

If you have not acquired this tutorial directly from the winsnort.com website, then you most likely do not have the latest revision of this tutorial!

How to use this guide

It is important when asked to 'Open a CMD window with Administrator privileges' it is done, or the install will fail.

It is also important when asked to 'Close a CMD window' it is done, or the install will fail.

Note: The user installing this tutorial MUST be a member of the Administrators group.

Note: If the User Account Control dialog box appears at ANY time during this install ALWAYS left-click 'Yes' to continue, or the install will fail.

Instructions on starting a command prompt as an Administrator

In the Windows Search box, type cmd, and then press CTRL+SHIFT+ENTER.

Operating System and Configuration Setup

  • I'm using Windows XP Pro (SP3) 32bit, but any Version of Windows with the latest service pack installed will do.

All 'WinIDS - xxbit Software Support Packs' comes furnished with a pre-compiled version of Barnyard2.

This tutorial gives two option on compiling Barnyard2 on Windows using the Cygwin UNIX emulator. for MySQL database support (Automatically or Manually).

1) There is a scripted process that will, if setup properly, automatically compile Barnyard2 into an executable..

The scripted process isn't anything fancy. It compiles Barnyard2 leaving the assimilated, and compressed 'barnyard2-xxx-2.1.14-build337.zip' file in the root of drive 'D:\'.

2) The option to manually do a step-by-step compile is also available..

The manual install will give the installer some basic functions of how the Unix environment works as it uses Cygwin, which is a Unix-like environment and command-line interface for Microsoft Windows.

This tutorial will run on ANY modern Microsoft Windows operating system, and comes assimilated with all the necessary files to compile barnyard2 on Windows. This tutorial, and the automated script both deal with hard coded paths.


Prepping for the Windows Intrusion Detection System (WinIDS) Tutorial


Downloading and extracting the 'WinIDS - Barnyard2 Software Development Pack'

It is imperative to only use the files included in the 'WinIDS - Barnyard2 Software Development Pack' below. These files have been thoroughly tested, and found compatible with all the supported Windows Intrusion Detection Systems (WinIDS) tutorials.
dload.png Download The 'WinIDS - Barnyard2 Software Development Pack' to a temporary location.

Open File Explore and navigate to the location of the 'winids-b2sdp.zip' file, right-click the 'winids-b2sdp.zip' file, highlight and left-click 'Extract all...', in the 'Files will be extracted to this folder:' dialog box type 'd:\temp' (less the outside quotes), left-click and uncheck the 'Show extracted files when complete' radio box, left-click extract, in 'Password:' dialog box type 'w1nsn03t.c0m' (less the outside quotes), left-click 'OK', and eXit File Explorer.

How to compile Barnyard2 on Windows using the Cygwin UNIX emulator for MySQL/PostgreSQL database support


The automated process for compiling Barnyard2 on Windows using the Cygwin UNIX emulator

There are four 32/64bit automated scripts to pick from.

Depending on the processors architecture and the database required select the appropriate script below!
  • Barnyard2 x86 with PostgreSQL database support -> go-p-cygwin_x86.bat
  • Barnyard2 x64 with PostgreSQL database support -> go-p-cygwin_x64.bat
  • Barnyard2 x86 with MySQL database support -> go-m-cygwin_x86.bat
  • Barnyard2 x64 with MySQL database support -> go-m-cygwin_x64.bat
Open a CMD window with Administrator privileges and type 'd:\temp\go-...' (less the outside quotes), and tap the 'Enter' key.

Note: It will take about 1 hour for the automated process to complete!
At the CMD prompt type 'exit' (less the outside quotes), and tap the 'Enter' key.

The assimilated, and compressed 'barnyard2-xxx-2.1.14-build337.zip' file can be found in the root of drive 'D:\'.

The manual process for compiling Barnyard2 on Windows using the Cygwin UNIX emulator

Installing Cygwin

Depending on the processors architecture, install the appropriate support file below!
32bit Windows Compile Only: Open an explorer window and navigate to the 'd:\temp' folder. Double left-click the 'setup-x86.exe' file running the Cygwin installer, and close the explorer window.

64bit Windows Compile Only: Open an explorer window and navigate to the 'd:\temp' folder. Double left-click the 'setup-x64.exe' file running the Cygwin installer, and close the explorer window.

The 'Cygwin Setup' page opens, left-click 'Next'

At the 'Cygwin Setup - Choose Installation Type' leave the default 'Install from Internet' selected, and left-click 'Next'.

The 'Cygwin Setup - Choose Installation Directory' page opens. In the 'Select Root Install Directory' dialog box type 'd:\cygwin' (less the outside quotes), and left-click 'Next'.

The 'Cygwin Setup - Select Local Package Directory' page opens. In the 'Select Local Package Directory' dialog box type 'd:\cygwin\downloads' (less the outside quotes), and left-click 'Next'.

An error message will appear stating 'Directory d:\cygwin\downloads does not exist, would you like me to create it?', left-click 'Yes'.

The 'Cygwin Setup - Select Connection Type' page opens, left-click 'Next'.

The 'Cygwin Setup - Choose Download Site(s)' page appears. There will be a list of package download sites under 'Choose A Download Site'. Left-click highlighting 'http://cygwin.mirrors.hoobly.com', and left-click 'Next'.

The 'Cygwin Setup' page appears and the default packages will be installed.

Installing required Cygwin packages

The 'Cygwin Setup - Select Packages' page appears. Under 'Select Packages, and to the right of 'View' left-click and select 'Full'.

In the 'Search' dialog type 'unzip. Under 'Package' to the right of 'unzip' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'zip'. Under 'Package' to the right of 'zip' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'bison'. Under 'Package' to the right of 'bison' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'automake'. Under 'Package' to the right of 'automake' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'cmake'. Under 'Package' to the right of 'cmake' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'gcc-core'. Under 'Package' to the right of 'gcc-core' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'gcc-g++'. Under 'Package' to the right of 'gcc-g++' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'libtool'. Under 'Package' to the right of 'libtool' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'make'. Under 'Package' to the right of 'make' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'libreadline-devel'. Under 'Package' to the right of 'libreadline-devel' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'zlib'. Under 'Package' to the right of 'zlib' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'zlib-devel'. Under 'Package' to the right of 'zlib-devel' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'perl'. Under 'Package' to the right of 'perl' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'patch'. Under 'Package' to the right of 'patch' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'libgmp-devel'. Under 'Package' to the right of 'libgmp-devel' left-click the down arrow, and left-click selecting the latest stable version.

In the 'Search' dialog type 'libedit-devel'. Under 'Package' to the right of 'libedit-devel' left-click the down arrow, and left-click selecting the latest stable version.

MySQL Compile Only: In the 'Search' dialog type 'libmariadb-devel'. Under 'Package' to the right of 'libmariadb-devel' left-click the down arrow, and left-click selecting the latest stable version.

MySQL Compile Only: In the 'Search' dialog type 'mariadb-common'. Under 'Package' to the right of 'mariadb-common' left-click the down arrow, and left-click selecting the latest stable version.

At the bottom right left-click 'Next'.

The 'Cygwin Setup - Review and confirm changes' page opens, left-click 'Next'.

The 'Cygwin Setup - Progress' page opens displaying the default packages being installed along with their dependencies. The progress is displayed at the top left, and this could take several minutes to complete.
At the 'Cygwin Setup - Installation Status and Create Icons', left-click 'Finish'.

Installing the support programs

On the desktop double left-click the 'Cygwin Terminal' icon to open the Cygwin Terminal Window

At the Cygwin CMD prompt type 'unzip /cygdrive/d/temp/barnyard2-master.zip -d /cygdrive/d/cygwin' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'mv /cygdrive/d/cygwin/barnyard2-master /cygdrive/d/cygwin/source' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'unzip /cygdrive/d/temp/WpdPack_4_1_2.zip -d /cygdrive/d/cygwin' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp -Rf /cygdrive/d/cygwin/WpdPack/Lib/* /cygdrive/d/cygwin/lib' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp -Rf /cygdrive/d/cygwin/WpdPack/Include/* /cygdrive/d/cygwin/usr/include' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'unzip /cygdrive/d/temp/includes.zip -d /cygdrive/d/cygwin/usr/include' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'perl -pi -e 's/`ref_system_id`/ref_system_id/g;' /cygdrive/d/cygwin/source/src/output-plugins/spo_database_cache.h' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt 'mv /cygdrive/d/cygwin/lib/libwpcap.a /cygdrive/d/cygwin/lib/libpcap.a' (less the outside quotes), and tap the 'Enter' key.

Prepping MySQL support for Barnyard2

Skip this section if PostgreSQL is the database option to be compiled for the Windows Intrusion Detection System (WinIDS)!

It is important to be compiling Barnyard2 with the same version of the database that is running on the Windows Intrusion Detection System (WinIDS)!
At the Cygwin CMD prompt type 'tar -zxvf /cygdrive/d/temp/mysql-8.0.16.tar.gz -C /cygdrive/d/cygwin' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'perl -pi -e 's/AND NOT WIN32/AND WIN32/g' /cygdrive/d/cygwin/mysql-8.0.16/configure.cmake' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'sed -i '1s/^/SET(CMAKE_LEGACY_CYGWIN_WIN32=1)\n/' /cygdrive/d/cygwin/mysql-8.0.16/CMakeLists.txt' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cd /cygdrive/d/cygwin/mysql-8.0.16' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cmake . -DWITH_EDITLINE=system -DINSTALL_MYSQLTESTDIR=' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'make mysqlclient && make install' (less the outside quotes), and tap the 'Enter' key.

Prepping PostgreSQL support for Barnyard2

Skip this section if MySQL is the database option to be compiled for the Windows Intrusion Detection System (WinIDS)!

It is important to be compiling Barnyard2 with the same version of the database that is running on the Windows Intrusion Detection System (WinIDS)!
At the Cygwin CMD prompt type 'tar -zxvf /cygdrive/d/temp/postgresql-10.8.tar.gz -C /cygdrive/d/cygwin' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cd /cygdrive/d/cygwin/postgresql-10.8' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type './configure' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'make && make install' (less the outside quotes), and tap the 'Enter' key.

Assimilating the Barnyard2 executable, and the support files

At the Cygwin CMD prompt type ' mkdir /cygdrive/d/barnyard2' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type ' mkdir /cygdrive/d/barnyard2/etc' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type ' mkdir /cygdrive/d/barnyard2/schemas' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/source/schemas/create* /cygdrive/d/cygwin/barnyard2/schemas' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/usr/local/bin/barnyard2.exe /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/usr/local/etc/barnyard2.conf /cygdrive/d/cygwin/barnyard2/etc' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygz.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygwin1.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

32bit Windows Compile Only: At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cyggcc_s-1.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygstdc++-6.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

MySQL Compile Only: At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygmariadb-3.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

MySQL Compile Only: At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygcrypto-1.1.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

MySQL Compile Only: At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygiconv-2.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

MySQL Compile Only: At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/bin/cygssl-1.1.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

PostgreSQL Compile Only: At the Cygwin CMD prompt type 'cp /cygdrive/d/cygwin/usr/local/pgsql/lib/cygpq.dll /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

Creating the final compressed Barnyard2

At the Cygwin CMD prompt type 'cd /cygdrive/d/cygwin/barnyard2' (less the outside quotes), and tap the 'Enter' key.

32bit Windows Compile Only: At the Cygwin CMD prompt type 'zip -r /cygdrive/d/barnyard2-x86-2.1.14-build337.zip .' (less the outside quotes), and tap the 'Enter' key.

64bit Windows Compile Only: At the Cygwin CMD prompt type 'zip -r /cygdrive/d/barnyard2-x64-2.1.14-build337.zip .' (less the outside quotes), and tap the 'Enter' key.

At the Cygwin CMD prompt type 'exit' (less the outside quotes), and tap the 'Enter' key.

Cleaning up the Barnyard2 compile process

Open a CMD window with Administrator privileges and type 'rmdir /S /Q d:\cygwin' (less the outside quotes), and tap the 'Enter' key.

At the CMD prompt type 'RMDIR /S /Q "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Cygwin"' (less the outside quotes), and tap the 'Enter' key.

At the CMD prompt type 'del %PUBLIC%\Desktop\Cygwin*' (less the outside quotes), and tap the 'Enter' key.

At the CMD prompt type 'exit' (less the outside quotes), and tap the 'Enter' key.

The assimilated, and compressed 'barnyard2-xxx-2.1.14-build337.zip' file can be found in the root of drive 'D:\'.

In Conclusion

Congratulations, you have just completed compiling your very own copy of Barnyard2 for Windows, using the Cygwin UNIX emulator for Windows, on windows, for either the MySQL, or PostgreSQL database.

I hope this tutorial has been helpful to you. Please feel free to provide feedback, both issues you experienced and recommendations that you might have. The goal of this tutorial was not just for you to compile Barnyard2, but to understand how all the parts work together, and get a deeper understanding of all the components, so that you can troubleshoot, modify, and update your Windows Intrusion Detection System (WinIDS) with confidence.

Optional Companion Documents

Be SURE to check out the available 'Companion Add-on Documents' to enhance the Windows Intrusion Detection System (WinIDS) experience.

Updating the Windows Intrusion Detection Systems (WinIDS) Major components


Debugging Installation errors

Check the Event Viewer as most of the support programs will throw FATAL errors into the Windows Application log.

General tutorial issues

For general problem issues that pertain to this specific tutorial, left-click the community support button at the top of this tutorial, or manually navigate to the correct community support forum pertaining to this specific tutorial.

Feedback

I would love to get feedback from you about this tutorial. Any recommendations, or ideas, please leave feedback HERE.

Michael E. Steele | Microsoft Certified System Engineer (MCSE)
Email Support: support@winsnort.com
Snort: Open Source Network IDS - www.snort.org