Setting Up
In this guide, we will be setting up our exploit project
In this guide, we will be setting up our exploit project
Let's set up the project!
First we shall create a folder with the name of our exploit. I'll call it examploit
mkdir examploit
Now let's go ahead and initialize it
cd examploit && zig init
Now you will see 2 files and a folder. Delete src/root.zig and edit build.zig accordingly.
After you have done that let's edit main.zig and try printing hello world.
const std = @import("std");
pub fn main(init: std.process.Init) !void {
// Create a buffer for writer, we don't want to spam syscalls that's slow af
var stdout_buffer: [1024]u8 = undefined;
// Create writer
var stdout_writer = std.Io.File.stdout().writer(init.io, &stdout_buffer);
// get the writer interface
const stdout = &stdout_writer.interface;
// print stuff, you can mix words in format string but I like to keep it separate
try stdout.print("{s}{X}{c}", .{ "Hello World! I write ", 195936478, '\n' });
// don't forget to flush the buffer
try stdout.flush();
}
Now compile and run it with:
zig build run
Notice: by default this runs in DEBUG mode which can be slow, you can use ReleaseFast mode instead with:
zig build -Doptimize=ReleaseFast run
If the code ran successfully, you should get the message "Hello World! I write BADC0DE"