Skip to content

Latest commit

 

History

History
83 lines (52 loc) · 2.08 KB

README.md

File metadata and controls

83 lines (52 loc) · 2.08 KB

Notes for Nim and offensive security Nim

Nim for offensive security.

Dockerfile for Windows compilation environment

# Use the nimlang/nim image as the base image
FROM nimlang/nim

# Update the package lists and install mingw-w64
RUN apt-get update && apt-get install -y mingw-w64

# Clean up APT when done
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Define the working directory
WORKDIR /usr/src/app

# Copy the current directory contents into the container at /usr/src/app
#COPY . .

# Install winim package
RUN nimble install winim

# Define the command to run the Nim compiler by default
CMD ["nim", "--version"]

then

docker build -t nim-mingw .

Compile for Linux:

docker run --rm -v /dir/path/to/program:/usr/src/app -w /usr/src/app nimlang/nim nim c -r program.nim

or

docker run --rm -v /dir/path/to/program:/usr/src/app -w /usr/src/app nim-mingw:latest nim c -r program.nim

Hint: if you want extra stealth-ness, compile with --app:gui

Compile for Windows:

docker run --rm -v /dir/path/to/program:/usr/src/app -w /usr/src/app nim-mingw:latest nim c -d:mingw program.nim

Documentation

To cross-compile for Windows from Linux or macOS using the MinGW-w64 toolchain:

nim c -d:mingw myproject.nim
# nim r also works, running the binary via `wine` or `wine64`:
nim r -d:mingw --eval:'import os; echo "a" / "b"'

Use --cpu:i386 or --cpu:amd64 to switch the CPU architecture.

The MinGW-w64 toolchain can be installed as follows:

apt install mingw-w64   # Ubuntu
yum install mingw32-gcc
yum install mingw64-gcc # CentOS - requires EPEL
brew install mingw-w64  # OSX

Pracical learning

Docker

Offensive security