cryptocode

joined 1 year ago
MODERATOR OF
 

From the README:

zig-router

Straightforward HTTP-like request routing.


Project is tested against zig 0.12.0-dev.2341+92211135f

Sample

const router = @import("zig-router");

const MyJsonBody = struct {
    float: f32,
    text: []const u8,
    number_with_default: u32 = 42,
};

fn putJson(body: MyJsonBody) !Response {
    log.info("float: {}", .{body.float});
    log.info("text: {s}", .{body.text});
    log.info("number_with_default: {}", .{body.number_with_default});
    return .{ .body = "ok" };
}

const MyPathParams = struct {
    id: []const u8,
    bundle: u32,
};

fn getDynamic(params: MyPathParams) !Response {
    log.info("id: {s}", .{params.id});
    log.info("bundle: {}", .{params.bundle});
    return .{};
}

const MyQuery = struct {
    id: []const u8 = "plz give me a good paying stable job",
    bundle: u32 = 42,
};

fn getQuery(query: MyQuery) !Response {
    log.info("id: {s}", .{query.id});
    log.info("bundle: {}", .{query.bundle});
    return .{};
}

fn getError() !void {
    return error.EPIC_FAIL;
}

fn onRequest(arena: *std.heap.ArenaAllocator, request: Request) !void {
    router.Router(.{
        router.Decoder(.json, router.JsonBodyDecoder(.{}, 4096).decode),
    }, .{
        router.Route(.PUT, "/json", putJson, .{}),
        router.Route(.GET, "/dynamic/:id/paths/:bundle", getDynamic, .{}),
        router.Route(.GET, "/query", getQuery, .{}),
        router.Route(.GET, "/error", getError, .{}),
    }).match(arena.allocator(), .{
        .method = request.method,
        .path = request.path,
        .query = request.query,
        .body = .{ .reader = request.body.reader() }
    }, .{ arena.allocator() }) catch |err| switch (err) {
        error.not_found => return .{ .status = .not_found },
        error.bad_request => return .{ .status = .bad_request },
        else => return err,
    };
}

Depend

build.zig.zon

.zig_router = .{
  .url = "https://github.com/Cloudef/zig-router/archive/{COMMIT}.tar.gz",
  .hash = "{HASH}",
},

build.zig

const zig_router = b.dependency("zig_router", .{}).module("zig-router");
exe.root_module.addImport("zig-router", zig_router);
 

Budoux for Zig (and C)

Original library from Google: https://github.com/google/budoux

 

zat is a syntax highlighting cat like utility.

It uses tree-sitter and supports for vscode themes.

 

From the README:

Z-labs blog post - Running BOFs with 'bof-launcher' library

Introduction

Cobalt Strike 4.1 released on 25 June 2020, introduced a novel (for that time) capability of running so called Beacon Object Files - small post-ex capabilities that execute in Beacon, parse arguments, call a few Win32 APIs, report output, and exit. Since that time BOFs became very popular and the demand to launch/execute them in other environments than Cobalt Strike's Beacon has emerged.

Purpose

We at Z-Labs saw a big potential in BOFs and decided to extend its capabilities, versatility and usefulness even further. That's how this project came to live.

bof-launcher is an open-source library for loading, relocating and launching BOFs on Windows and UNIX/Linux systems. It's an alternative to Trustedsec's COFFLoader and ELFLoader with some very interesting features:

  • Fully compatibile with Cobalt Strike's Beacon. Can compile and run every BOF available at Cobalt Strike Community Kit and every other open-source BOF that adheres to generic BOF template.
  • Distributed as a fully standalone library with zero dependency (it does not even use libc).
  • Fully integrable with programs written in C/C++ and/or Zig progamming languages.
  • Adds capability to write BOFs in Zig programming language - which is a low-level langauge with a goal of being a "better C". All the features of the language and rich standard library can be used in BOFs (hash maps and other data structures, cross-platform OS layer, http, networking, threading, crypto and more).
  • Asynchronous BOF execution - capability to launch more time-consuming BOFs in a separate thread.
  • BOF process injection - capability to launch more risky BOFs (i.e. privilege escalation exploits) by injecting it to a new process.
  • Seamless support for either Windows COFF and UNIX/Linux ELF formats.
  • ARM and AARCH64 support on Linux.
  • Used in our cli4bofs tool that allows for running BOF files directly from a filesystem.
  • Very flexible and efficient API allowing for so called BOF chaining.
 

From the README:

A simple pretty printer for arbitrary data structures in Zig⚡️

Designed to inspect deeply-nested and recursive tree structures.

 

From the README:

zbind generates TypeScript bindings for calling Zig code compiled to native code or Wasm, in Node.js or Bun or browsers.

Example Zig code lib/main.zig:

const std = @import("std");
const zbind = @import("zbind");

pub fn hello(name: []const u8) void {
    std.debug.print("Hello, {s}!\n", .{ name });
}

pub fn main() void {}

comptime {
    zbind.init(@This());
}
 

FROM THE README:

zcached is a nimble and efficient in-memory caching system resembling databases like Redis. This README acts as a comprehensive guide, aiding in comprehension, setup, and optimal utilization.

zcached aims to offer rapid, in-memory caching akin to widely-used databases such as Redis. Its focus lies in user-friendliness, efficiency, and agility, making it suitable for various applications requiring swift data retrieval and storage.

Crafted using Zig, a versatile, modern, compiled programming language, zcached prides itself on a zero-dependency architecture. This unique feature enables seamless compilation and execution across systems equipped with a Zig compiler, ensuring exceptional portability and deployment ease.

 

Supports:

  • OpenGL 1.0 through 3.1
  • OpenGL 3.2 through 4.6 (Compatibility/Core profile)
  • OpenGL ES 1.1 (Common/Common-Lite profile)
  • OpenGL ES 2.0 through 3.2
  • OpenGL SC 2.0
 

Minimal Terraform HTTP backend in Zig

 

Server-side framework for Zig, relying heavily on dependency injection.

The code has been extracted from Ava PLS which has been using it for a few months already, and I'm using it in one other project which is going to production soon, so it's not just a toy, it actually works.

 

Zine is a static site generator written in Zig. Check out the linked Github page for examples and docs.

 

From the README:

bork

A TUI chat client tailored for livecoding on Twitch, currently in alpha stage.

Main features

  • Displays Twitch emotes in the terminal, including your own custom emotes!
  • Understands Twitch-specific concepts (subcriptions, gifted subs, ...).
  • Displays badges for your subs, mods, etc.
  • Supports clearing chat and deletes messages from banned users.
  • Click on a message to highlight it and let your viewers know who you're relpying to.
view more: ‹ prev next ›