portzcan

Command-line tool and Zig library for port scanning.

AGPL-3.0 License

Stars
2
Committers
1

portzcan ⚡

Command-line tool and Zig library for port scanning.

Installation

As a command-line tool

Get the source code cloning the repo or downloading it from the Releases page.

Then build it with zig build.

As a library

Fetch the package.

zig fetch --save git+https://github.com/henriquencmt/portzcan

Update your build.zig.

const portzcan = b.dependency("portzcan", .{});
const portzcan_lib = b.addModule("lib", .{ .root_source_file = portzcan.path("lib/portzcan.zig") });

const exe = b.addExecutable(...);

exe.root_module.addImport("portzcan", portzcan_lib);

Usage

As a command-line tool

portzcan [-s] TARGET [PORTS]

Example

portzcan your-target.com 80,443,22

As a library

Example

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

pub fn main() !void {
    var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
    defer arena.deinit();

    const allocator = arena.allocator();

    const addr_list = try std.net.getAddressList(allocator, "your-target.com", 0);

    var addr = addr_list.addrs[0];
    const ports = [_]u16{ 80, 8080, 22, 443 };

    const scanner = portzcan.TcpConnectScanner.init(allocator, &addr, null);   
    try scanner.scan(&ports);
}

Go to the library API reference for further documentation.

Contributing

Contributions of any kind are welcome.