-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.win32
81 lines (65 loc) · 2.45 KB
/
Dockerfile.win32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
FROM ubuntu as dep-base
# Download necessary Windows C Compiler
RUN apt-get update -y && \
apt-get install -y build-essential git mingw-w64 gcc-multilib gcc-mingw-w64 autoconf automake libtool libmagic-dev libssl-dev
# NOTE: OPENSSL INSTALLATION
# Download open ssl for lcrypto lib Win64 without docs
RUN git clone --depth 1 -b openssl-3.0.0 https://github.com/openssl/openssl.git openssl/
WORKDIR /openssl
RUN ./Configure --cross-compile-prefix=i686-w64-mingw32- mingw shared && \
make && \
make install_sw
WORKDIR /
## NOTE: JANSSON INSTALLATION
RUN export CC=i686-w64-mingw32-gcc
RUN export CONFIGFLAGS=--host=i686-w64-mingw32
RUN echo "Build and install Jansson" \
&& git clone https://github.com/akheron/jansson \
&& cd jansson \
&& autoreconf -vi --force \
&& ./configure --host=i686-w64-mingw32 CC=i686-w64-mingw32-gcc \
&& make \
# && make check \
&& make install
WORKDIR /
# NOTE: YARA INSTALLATION
# Installs YARA Win32
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y make gcc pkg-config flex bison
RUN git clone --depth 1 --branch v4.2.0 https://github.com/VirusTotal/yara.git yara32
# NOTE: TODO: ADDING CUSTOM YARA EXTENSION
# Add libyara to ldconfig
RUN echo "/usr/local/lib" >> /etc/ld.so.conf
RUN ldconfig
RUN cd yara32 && \
./bootstrap.sh && \
CC=i686-w64-mingw32-gcc CFLAGS=-I/usr/local/include CONFIGFLAGS=--host=i686-w64-mingw32 LDFLAGS='-L/usr/local/lib' ./configure --host=i686-w64-mingw32 --with-crypto --disable-magic --enable-cuckoo && \
cd libyara && \
make && \
make install && \
make check
FROM golang:1.17 as final
RUN apt-get update -y && \
apt-get install -y build-essential mingw-w64 gcc-multilib gcc-mingw-w64 automake
# Copy Syso File
COPY --from=dep-base /usr/local/ /usr/local/
# Get dependancies - will also be cached if we won't change mod/sum
WORKDIR /go/src/project/scanner
COPY src/go.mod .
COPY src/go.sum .
RUN go mod download
# BUILD SYSO FILE
COPY src/winres/ /go/src/project/scanner/winres
WORKDIR /go/src/project/scanner/
RUN go install github.com/tc-hib/go-winres@latest
RUN go-winres make
# Load Scanner
COPY src/ /go/src/project/scanner/
# Compile for Windows32
RUN CGO_ENABLED="1" \
CGO_CFLAGS="-I/usr/local/include"\
CGO_LDFLAGS='-L/usr/local/lib/ -lyara -lws2_32 -lgdi32 -ljansson -lcrypto'\
GOARCH="386"\
GOOS="windows"\
CC="i686-w64-mingw32-gcc"\
go build -tags yara_no_pkg_config -ldflags '-w -extldflags "-static"' -o /go/bin/scanner_windows32.exe