Ssekirya Cosmah

Mar 12, 2026 • 2 min read

Stealth Systems Programming: Port Scanning with Project Lwanga

Lwanga programming Language is built for scenarios where you need zero dependencies and a minimal binary footprint. By bypassing libc and using direct LLVM-optimized syscalls, we can create security tools that are both tiny and harder to hook by standard EDR/AV solutions.

Here is how a basic TCP connect scanner looks in Lwanga. It uses the syscall keyword to interact with the kernel network stack.

The Implementation:

// Lwanga Port Scanner Logic

// Demonstrating direct syscall usage for socket (41) and connect (42)

fn main() -> u64 {

let socket_fd: i64;

let result: i64;

// 1. Create a TCP Socket

// socket(AF_INET: 2, SOCK_STREAM: 1, IPPROTO_IP: 0)

unsafe {

socket_fd = syscall(41, 2, 1, 0);

}

if (socket_fd < 0) {

return 1;

}

// 2. Prepare Connection

// Targeting 127.0.0.1 (0x0100007f) on Port 80 (0x5000 in big-endian)

// Syscall 42: connect(fd, sockaddr_ptr, addrlen)

unsafe {

result = syscall(42, socket_fd, addr_struct_ptr, 16);

}

if (result == 0) {

// Port is open - handle success

let success_msg: str = "Port 80 is open\n";

unsafe { syscall(1, 1, success_msg, 16); }

}

// 3. Close & Exit

unsafe { syscall(3, socket_fd); }

return 0;

}

Why this matters for Security Tooling:

  • No Library Hooking: Most security monitors watch for libc calls. Lwanga bypasses this layer entirely.

  • Compact Binaries: Because there is no runtime, the resulting binary for a scanner like this is under 10KB, making it ideal for memory-resident payloads.

  • Naked Control: You handle the memory layout of the sockaddr struct yourself, ensuring exactly what hits the wire.

Explore & Contribute

We are looking for maintainers who want to help expand our syscall library and optimize the LLVM backend for security-specific use cases.

Feedback Request: Does the unsafe block feel too restrictive for low-level work, or is the safety-vs-control balance right for your red-teaming workflow?

Join Ssekirya on Peerlist!

Join amazing folks like Ssekirya and thousands of other builders on Peerlist.

peerlist.io/

It’s available... this username is available! 😃

Claim your username before it's too late!

This username is already taken, you’re a little late.😐

1

8

0