Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e8b466

Browse files
victorhoraFelipe Zimmerle
authored and
Felipe Zimmerle
committed
Refactoring of IIS build scripts
1 parent61bce8d commit1e8b466

File tree

7 files changed

+181
-86
lines changed

7 files changed

+181
-86
lines changed

‎iis/build_dependencies.bat‎

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
1-
:: Thosevariable should be edited as needed.
1+
:: Thosevariables should be edited as needed.
22
:: Use full paths.
33

44
:: General paths
55
@setWORK_DIR=%cd%\dependencies\build_dir
66
@setOUTPUT_DIR=%cd%\dependencies\release_files
77
@setSOURCE_DIR=%USERPROFILE%\Downloads
88

9+
:: Dependencies
10+
@setCMAKE=cmake-3.8.2-win32-x86.zip
11+
@setPCRE=pcre-8.40.zip
12+
@setZLIB=zlib-1.2.11.tar.gz
13+
@setLIBXML2=libxml2-2.9.4.tar.gz
14+
@setLUA=lua-5.3.4.tar.gz
15+
@setCURL=curl-7.54.1.zip
16+
@setAPACHE_SRC=httpd-2.4.27.tar.gz
17+
@setAPACHE_BIN32=httpd-2.4.27-win32-VC11.zip
18+
@setAPACHE_BIN64=httpd-2.4.27-win64-VC11.zip
19+
@setYAJL=yajl-2.1.0.zip
20+
@setSSDEEP=ssdeep-2.13.tar.gz
21+
@setSSDEEP_BIN=ssdeep-2.13.zip
22+
23+
@setCMAKE_DIR=%WORK_DIR%\%CMAKE:~0,-4%\bin
24+
925
:: Aditional paths.
10-
@setPATH=%PATH%;c:\work\cmake-2.8.7-win32-x86\bin;"c:\program files\7-zip"
11-
12-
@setPCRE=pcre-8.33.zip
13-
@setZLIB=zlib-1.2.8.tar.gz
14-
@setLIBXML2=libxml2-2.9.1.tar.gz
15-
@setLUA=lua-5.1.5.tar.gz
16-
@setCURL=curl-7.39.0.zip
17-
@setAPACHE_SRC=httpd-2.4.6.tar.gz
18-
@setAPACHE_BIN32=httpd-2.4.6-win32-VC11.zip
19-
@setAPACHE_BIN64=httpd-2.4.6-win64-VC11.zip
20-
@setYAJL=lloyd-yajl-f4b2b1a.zip
21-
@setSSDEEP=ssdeep-2.10.tar.gz
22-
@setSSDEEP_BIN=ssdeep-2.10.zip
26+
@setPATH=%PATH%;%CMAKE_DIR%;"c:\program files\7-zip"
27+
2328

2429
:: @set VCARGS32="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
2530
:: @set VCARGS64="C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
@@ -45,6 +50,12 @@ call cl 2>&1 | findstr /C:"x64"
4550
@if (%ERRORLEVEL%)== (0)setAPACHE_BIN=%APACHE_BIN64%
4651

4752
@echo Starting with the depdendencies...
53+
@echo # CMake. -%CMAKE%
54+
@call dependencies/build_cmake.bat
55+
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed_cmake
56+
@cd"%CURRENT_DIR%"
57+
58+
4859
@echo # Apache -%HTTPD%/%APACHE24_ZIP%
4960
@call dependencies/build_apache.bat
5061
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed_apache
@@ -129,6 +140,10 @@ call cl 2>&1 | findstr /C:"x64"
129140
@echo Failed to setup%SSDEEP%...
130141
@goto failed
131142

143+
:build_failed_cmake
144+
@echo Failed to setup%CMAKE%...
145+
@goto failed
146+
132147
:failed
133148
@cd%CURRENT_DIR%
134149
@exit /B1

‎iis/build_modsecurity.bat‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set CURRENT_DIR=%cd%
1515
cd ..\apache2
1616
del *.obj *.dll *.lib
1717
del libinjection\*.obj libinjection\*.dll libinjection\*.lib
18-
NMAKE -f Makefile.win APACHE=..\iis\%DEPENDENCIES_DIR%\Apache24 PCRE=..\iis\%DEPENDENCIES_DIR%\pcre LIBXML2=..\iis\%DEPENDENCIES_DIR%\libxml2 LUA=..\iis\%DEPENDENCIES_DIR%\lua\src VERSION=VERSION_IIS YAJL=..\iis\%DEPENDENCIES_DIR%\yajl\build\yajl-2.0.1 SSDEEP=..\iis\%DEPENDENCIES_DIR%\ssdeep CURL=..\iis\%DEPENDENCIES_DIR%\curl IIS_BUILD=yes
18+
NMAKE -f Makefile.win APACHE=..\iis\%DEPENDENCIES_DIR%\Apache24 PCRE=..\iis\%DEPENDENCIES_DIR%\pcre LIBXML2=..\iis\%DEPENDENCIES_DIR%\libxml2 LUA=..\iis\%DEPENDENCIES_DIR%\lua\src VERSION=VERSION_IIS YAJL=..\iis\%DEPENDENCIES_DIR%\yajl\build\%YAJL_DIR% SSDEEP=..\iis\%DEPENDENCIES_DIR%\ssdeep CURL=..\iis\%DEPENDENCIES_DIR%\curl IIS_BUILD=yes
1919
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed
2020

2121
@echo mlogc...
@@ -29,7 +29,7 @@ nmake -f Makefile.win APACHE=..\iis\%DEPENDENCIES_DIR%\Apache24 PCRE=..\iis\%DEP
2929
cd ..\iis
3030
del *.obj *.dll *.lib
3131
nmake -f Makefile.win clean
32-
NMAKE -f Makefile.win APACHE=..\iis\%DEPENDENCIES_DIR%\Apache24 PCRE=..\iis\%DEPENDENCIES_DIR%\pcre LIBXML2=..\iis\%DEPENDENCIES_DIR%\libxml2 LUA=..\iis\%DEPENDENCIES_DIR%\lua\src VERSION=VERSION_IIS YAJL=..\iis\%DEPENDENCIES_DIR%\yajl\build\yajl-2.0.1 SSDEEP=..\iis\%DEPENDENCIES_DIR%\ssdeep CURL=..\iis\%DEPENDENCIES_DIR%\curl
32+
NMAKE -f Makefile.win APACHE=..\iis\%DEPENDENCIES_DIR%\Apache24 PCRE=..\iis\%DEPENDENCIES_DIR%\pcre LIBXML2=..\iis\%DEPENDENCIES_DIR%\libxml2 LUA=..\iis\%DEPENDENCIES_DIR%\lua\src VERSION=VERSION_IIS YAJL=..\iis\%DEPENDENCIES_DIR%\yajl\build\%YAJL_DIR% SSDEEP=..\iis\%DEPENDENCIES_DIR%\ssdeep CURL=..\iis\%DEPENDENCIES_DIR%\curl
3333
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed
3434

3535
cd%CURRENT_DIR%

‎iis/dependencies/build_cmake.bat‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@cd"%WORK_DIR%"
2+
3+
@ifNOT EXIST"%SOURCE_DIR%\%CMAKE%"goto file_not_found
4+
5+
6+
@7z.exe x"%SOURCE_DIR%\%CMAKE%"
7+
@ifNOT (%ERRORLEVEL%)== (0)goto something_went_wrong
8+
9+
@exit /B0
10+
11+
:file_not_found
12+
@echo File not found:%SOURCE_DIR%\%CMAKE%
13+
@goto failed
14+
15+
:something_went_wrong
16+
@echo Something went wrong while unzip CMake files.
17+
@goto failed
18+
19+
:failed
20+
@exit /B1

‎iis/dependencies/build_pcre.bat‎

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,43 @@
1-
cd"%WORK_DIR%"
2-
3-
@ifNOT EXIST"%SOURCE_DIR%\%APACHE_BIN%"goto file_not_found_bin
4-
5-
7z.exe x"%SOURCE_DIR%\%PCRE%"
6-
setPCRE_DIR=%PCRE:~0,-4%
7-
1+
::@if NOT (%ERRORLEVEL%) == (1) Echo "Patch successfull... For more info on patch see: https://vcs.pcre.org/pcre/code/trunk/CMakeLists.txt?r1=1659&r2=1677&view=patch"
2+
3+
cd"%WORK_DIR%"
4+
5+
@ifNOT EXIST"%SOURCE_DIR%\%APACHE_BIN%"goto file_not_found_bin
6+
7+
7z.exe x"%SOURCE_DIR%\%PCRE%"
8+
setPCRE_DIR=%PCRE:~0,-4%
9+
810
move"%PCRE_DIR%""pcre"
9-
11+
12+
@if"%PCRE_DIR%"=="pcre-8.40" (
13+
Echo.&&Echo"PCRE 8.40 found... patching with patch-pcre-8.40.vbs..."
14+
cscript /B /Nologo ../patch-pcre-8.40.vbs
15+
)
16+
1017
cd"pcre"
11-
CMAKE -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=True
12-
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed
13-
NMAKE
14-
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed
15-
cd"%WORK%"
16-
18+
cat CMakeLists.txt| sed"s/PCRE_STATIC_RUNTIME OFF CACHE BOOL/PCRE_STATIC_RUNTIME/g"> CMakeLists.txt.ops
19+
move CMakeLists.txt CMakeLists.txt.old
20+
move CMakeLists.txt.ops CMakeLists.txt
21+
CMAKE -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SHARED_LIBS=True
22+
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed
23+
NMAKE
24+
@ifNOT (%ERRORLEVEL%)== (0)goto build_failed
25+
cd"%WORK%"
26+
1727
copy /y"%WORK_DIR%\pcre\pcre.dll""%OUTPUT_DIR%"
1828
copy /y"%WORK_DIR%\pcre\pcre.pdb""%OUTPUT_DIR%"
1929
copy /y"%WORK_DIR%\pcre\pcre.lib""%OUTPUT_DIR%"
20-
echo"a"
21-
@exit /B0
22-
23-
:file_not_found_bin
24-
@echo File not found:"%SOURCE_DIR%\%PCRE%"
25-
@goto failed
26-
27-
:build_failed
28-
@echo Problems during the building phase
29-
@goto failed
30-
31-
:failed
32-
@exit /B1
30+
copy /y"%WORK_DIR%\pcre\pcre.h.generic""%WORK_DIR%\pcre\pcre.h"
31+
echo"a"
32+
@exit /B0
33+
34+
:file_not_found_bin
35+
@echo File not found:"%SOURCE_DIR%\%PCRE%"
36+
@goto failed
37+
38+
:build_failed
39+
@echo Problems during the building phase
40+
@goto failed
41+
42+
:failed
43+
@exit /B1

‎iis/dependencies/build_yajl.bat‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ nmake
2020

2121
cd"%WORK%"
2222

23-
copy /y"%WORK_DIR%\yajl\build\yajl-2.0.1\lib\yajl.dll""%OUTPUT_DIR%"
24-
copy /y"%WORK_DIR%\yajl\build\yajl-2.0.1\lib\yajl.pdb""%OUTPUT_DIR%"
25-
copy /y"%WORK_DIR%\yajl\build\yajl-2.0.1\lib\yajl.lib""%OUTPUT_DIR%"
26-
copy /y"%WORK_DIR%\yajl\build\yajl-2.0.1\lib\yajl_s.lib""%OUTPUT_DIR%"
23+
copy /y"%WORK_DIR%\yajl\build\%YAJL_DIR%\lib\yajl.dll""%OUTPUT_DIR%"
24+
::copy /y "%WORK_DIR%\yajl\build\%YAJL_DIR%\lib\yajl.pdb" "%OUTPUT_DIR%"
25+
copy /y"%WORK_DIR%\yajl\build\%YAJL_DIR%\lib\yajl.lib""%OUTPUT_DIR%"
26+
copy /y"%WORK_DIR%\yajl\build\%YAJL_DIR%\lib\yajl_s.lib""%OUTPUT_DIR%"
2727

2828
@exit /B0
2929

‎iis/dependencies/howto.txt‎

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,52 @@
1-
WARNING!
1+
The build process for ModSecurityIIS for Windows was a relatively complicated process. Understanding it required advanced knowledge of Windows and Unix environments.
2+
So the build process was refactored to make it easier for users to create their own builds with the automated batch scripts.
23

3-
Building ModSecurityIIS on Windows is a relatively complicated process. Understanding it requires advanced knowledge of Windows and Unix environments.
4-
Using the same versions of libraries as listed below is strongly recommended.
4+
* build_release.bat -> The main build script that calls all the others to have a working release
5+
* build_msi.bat -> Creates the MSI self-installer for easy deploy / removal / distribution
56

7+
* build_dependencies.bat -> Sets (and downloads if needed) all required dependencies
8+
* build_modsecurity.bat -> Builds ModSecurity (requires all depenedencies being set)
9+
10+
* download_files.bat -> Downloads all required dependencies to the default Downloads folder
11+
** This script is disabled by default. If you want to enable it, uncomment the "@call download_files.bat" line on build_dependencies.bat
12+
13+
The dependencies folder also includes a set o batch scripts which sets each dependency
14+
on its own. These scripts are called by the build_dependencies.bat script.
15+
16+
Using the same versions of libraries as listed below is recommended.
617
--------------------------------------
7-
Tested on:
8-
9-
Windows 7 x64
10-
Vistual Studio 2010 Ultimate SP1
11-
IIS enabled/installed
12-
13-
cmake 2.8.7
14-
curl 7.24.0
15-
apache 2.2.22 or apache 2.4.3
16-
libxml2 2.7.7
17-
lua 5.1.5
18-
pcre 8.30
19-
zlib 1.2.7
20-
7-Zip
18+
Compilation Prerequisites:
19+
20+
* Windows 7 x86_x64 (Should work on newer versions of Windows too)
21+
* Vistual Studio 2013 Express (Other versions should work, but you need to set the correct path for vcvars.bat scripts)
22+
* IIS enabled/installed
23+
* 7-Zip
24+
2125
--------------------------------------
2226

23-
1. Create working directory c:\work and drop directory c:\drop
24-
2. Sync SVN ModSecurity branch to c:\work\mod_security
25-
3. Copy files from c:\work\mod_security\iis\winbuild to c:\work
26-
4. Download and install cmake (unpack to c:\work\cmake-2.8.7-win32-x86)
27-
5. Download and install 7-Zip
28-
6. Adjust paths in c:\work\init.bat accordingly if needed
29-
7. Download curl, apache, libxml2, lua, pcre and zlib, place them in zip files in c:\work
30-
31-
curl-7.24.0.zip
32-
httpd-2.2.22-win32-src.zip or (httpd-2.4.3.zip (source) and httpd-2.4.3-win32.zip + httpd-2.4.3-win64.zip (binaries))
33-
libxml2-2.7.7.zip
34-
lua-5.1.5.zip
35-
pcre-8.30.zip
36-
zlib-1.2.7.zip
37-
38-
Modify c:\work\build.bat accordingly (if other versions were used)
39-
40-
8. Open cmd.exe window, go to c:\work and run buildall.bat
41-
9. When done, the binaries, lib and pdb files should appear under c:\drop\x86 (32-bit) and c:\drop\amd64 (64-bit)
42-
10. Open the VS ModSecurity IIS installer project
43-
11. Copy new binaries to the installer's x86 and amd64 directories
44-
12. Build installer from within VS
27+
The latest versions of ModSecurity dependencies known to work well are the following:
28+
29+
cmake-3.8.2-win32-x86
30+
pcre-8.40 (patch required and included on file "patch-pcre-8.40.vbs")
31+
zlib-1.2.11
32+
libxml2-2.9.4
33+
lua-5.3.4
34+
curl-7.54.1
35+
httpd-2.4.27 (bin-VC11)
36+
yajl-2.1.0
37+
ssdeep-2.13
38+
39+
--------------------------------------
40+
41+
1. Create working directory (e.g. c:\work) and drop the latest clone from ModSecurity's 2.x Github (https://github.com/SpiderLabs/ModSecurity/archive/v2/master.zip)
42+
2. Make sure the prerequisites mentioned above are all set
43+
3. If you haven't download the dependency files before, uncomment the "@call download_files.bat" line on build_dependencies.bat to have them downloaded prior
44+
4. Open a command prompt (cmd.exe) and head to the "iis" folder inside ModSecurity tree working directory (e.g. cd c:\work\ModSecurity\iis)
45+
5. If you need to modify anything (e.g. paths, versions etc), carefully edit the batch files.
46+
6. Run build_release.bat
47+
7. When done, the binaries, lib and pdb files should appear under c:\work\ModSecurity\iis\release\x86 (32-bit) and c:\work\ModSecurity\iis\release\amd64 (64-bit)
48+
* At this point, if you had a previous installation of ModSecurity and would like to test you can place the x86 files to "C:\Windows\SysWOW64\inetsrv" and x64 files to "C:\Windows\System32\inetsrv"
49+
50+
8. If all went well, you can build the MSI installer by running the build_msi.bat script.
51+
52+
* The built installable package places the files to the correct folders, automatically configures the ModSecurity IIS native module and configures web.config to enable ModSecurity for all IIS sites.

‎iis/download_files.bat‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
::@set CMAKE=cmake-3.8.2-win32-x86.zip
3+
::@set PCRE=pcre-8.40.zip
4+
::@set ZLIB=zlib-1.2.11.tar.gz
5+
::@set LIBXML2=libxml2-2.9.4.tar.gz
6+
::@set LUA=lua-5.3.4.tar.gz
7+
::@set CURL=curl-7.54.1.zip
8+
::@set APACHE_SRC=httpd-2.4.27.tar.gz
9+
::@set APACHE_BIN32=httpd-2.4.27-win32-VC11.zip
10+
::@set APACHE_BIN64=httpd-2.4.27-win64-VC11.zip
11+
::@set YAJL=yajl-2.1.0.zip
12+
::@set SSDEEP=ssdeep-2.13.tar.gz
13+
::@set SSDEEP_BIN=ssdeep-2.13.zip
14+
15+
:: BITSAdmin refuses to download YAJL from GitHub URL
16+
:: @set YAJL_URL=https://github.com/lloyd/yajl/archive/%YAJL:~-9%
17+
@setYAJL_URL=http://http.debian.net/debian/pool/main/y/yajl/yajl_2.1.0.orig.tar.gz
18+
19+
@setCMAKE_URL=https://cmake.org/files/v3.8/%CMAKE%
20+
@setPCRE_URL=https://ftp.pcre.org/pub/pcre/%PCRE%
21+
@setZLIB_URL=https://zlib.net/%ZLIB%
22+
@setLIBXML2_URL=http://xmlsoft.org/sources/%LIBXML2%
23+
@setLUA_URL=https://www.lua.org/ftp/%LUA%
24+
@setCURL_URL=http://curl.askapache.com/download/%CURL%
25+
@setAPACHE_SRC_URL=https://www.apache.org/dist/httpd/%APACHE_SRC%
26+
@setAPACHE_BIN_URL=https://www.apachelounge.com/download/VC11/binaries
27+
@setSSDEEP_URL=https://downloads.sourceforge.net/project/ssdeep/ssdeep-2.13
28+
29+
bitsadmin.exe /transfer"Downloading dependencies..."%CMAKE_URL%%SOURCE_DIR%\%CMAKE%%PCRE_URL%%SOURCE_DIR%\%PCRE%%ZLIB_URL%%SOURCE_DIR%\%ZLIB%%LIBXML2_URL%%SOURCE_DIR%\%LIBXML2%%LUA_URL%%SOURCE_DIR%\%LUA%%CURL_URL%%SOURCE_DIR%\%CURL%%APACHE_SRC_URL%%SOURCE_DIR%\%APACHE_SRC%%APACHE_BIN_URL%/%APACHE_BIN32%%SOURCE_DIR%\%APACHE_BIN32%%APACHE_BIN_URL%/%APACHE_BIN64%%SOURCE_DIR%\%APACHE_BIN64%%YAJL_URL%%SOURCE_DIR%\%YAJL%%SSDEEP_URL%/%SSDEEP%%SOURCE_DIR%\%SSDEEP%%SSDEEP_URL%/%SSDEEP_BIN%%SOURCE_DIR%\%SSDEEP_BIN%
30+
31+
32+
@ifNOT (%ERRORLEVEL%)== (0)goto :failed_to_download
33+
@exit /B0
34+
35+
:failed_to_download
36+
@echo.&&echo Failed to download dependency files... Try again or manually download the files to%SOURCE_DIR% and comment"@call download_files.bat" from build_dependencies.bat
37+
@goto failed
38+
39+
:failed
40+
@exit /B1
41+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp