diff options
| author | Gabriel Schneider <[email protected]> | 2026-06-08 22:36:33 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-06-08 23:05:25 -0300 |
| commit | bfeefd0cbdbdd7e2b1712253ac81e3e8ba09283b (patch) | |
| tree | 7687391929b1cc90000c00d8e64d06c22387a10e | |
| parent | 34de4c7fa3a740eed14bd58b778728942bf0b005 (diff) | |
| download | codenomicon-main.tar.gz codenomicon-main.zip | |
| -rw-r--r-- | .gdb_history | 13 | ||||
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | README | 10 | ||||
| -rw-r--r-- | build.zig | 35 | ||||
| -rw-r--r-- | build.zig.zon | 4 | ||||
| -rw-r--r-- | build/frida-gum.zig | 175 | ||||
| -rw-r--r-- | src/gloves.zig | 74 | ||||
| -rw-r--r-- | src/shock.zig | 13 | ||||
| -rw-r--r-- | tmp | bin | 61772 -> 0 bytes |
9 files changed, 22 insertions, 304 deletions
diff --git a/.gdb_history b/.gdb_history deleted file mode 100644 index 013a8e1..0000000 --- a/.gdb_history +++ /dev/null @@ -1,13 +0,0 @@ -c -r -si -ni -n -r -s -ni -s -r -r -s -finish @@ -6,3 +6,5 @@ zig-pkg zig-out *a.out .claude +.gdb_history +tmp @@ -0,0 +1,10 @@ +the CODENOMICON contains the most scary, powerful and mischevious creatures: + +ELFO: prints your ELF files using capstone, similar to objdump but worse. it's +already alive! + + +SHOCK: it has the potential of thousands of thunderstorms, but right now can't +even lift your arms hairs with static electricity. this may be butchered for +parts in the future. right now is not alive at all, it's mostly only potential. + @@ -1,20 +1,21 @@ const std = @import("std"); -const frida = @import("build/frida-gum.zig"); const capstone = @import("build/capstone.zig").capstone; pub fn build(b: *std.Build) !void { - const target = b.standardTargetOptions(.{}); + // A plain native build links against the host's glibc CRT objects + // (/usr/lib/crt1.o). Recent toolchains emit `.sframe` unwind sections whose + // R_X86_64_PC64 relocations Zig 0.16's self-hosted ELF linker cannot yet + // handle, producing "unhandled relocation type" link errors. By defaulting + // to an explicit-ABI (but otherwise native) target, Zig builds and links + // its own bundled CRT instead, sidestepping the issue while keeping native + // CPU/OS tuning. An explicit `-Dtarget=` still overrides this default. + const target = b.standardTargetOptions(.{ + .default_target = .{ .abi = b.graph.host.result.abi }, + }); const optimize = b.standardOptimizeOption(.{}); const vaxis_dep = b.dependency("vaxis", .{}); - const gloves_module = b.createModule(.{ - .root_source_file = b.path("src/gloves.zig"), - .target = target, - .optimize = optimize, - .link_libc = true, - }); - const elfo = b.addExecutable(.{ .name = "elfo", .root_module = b.createModule(.{ @@ -42,27 +43,12 @@ pub fn build(b: *std.Build) !void { .target = target, }); - const frida_lib = frida.gum_stalker(b, .{ - .optimize = optimize, - .target = target, - }); - - frida_lib.step.dependOn(&capstone_lib.step); - frida_lib.root_module.linkLibrary(capstone_lib); - b.installArtifact(capstone_lib); - b.installArtifact(frida_lib); elfo.root_module.linkLibrary(capstone_lib); elfo.root_module.addImport("capstone", capstone_lib.root_module); - const gloves = b.addExecutable(.{ - .name = "gloves", - .root_module = gloves_module, - }); - b.installArtifact(elfo); - b.installArtifact(gloves); const opt_gdb = b.option(bool, "gdb", "Run executable under gdb") orelse false; const comp_opts = b.addOptions(); @@ -130,7 +116,6 @@ pub fn build(b: *std.Build) !void { const run_steps = [_]struct { *std.Build.Step, *std.Build.Step.Compile }{ .{ test_step, unit_tests }, .{ b.step("elfo", "See the pretty elfo!"), elfo }, - .{ b.step("gloves", "See the pretty gloves!"), gloves }, .{ b.step("shock", "SHOCK something!"), shock }, }; diff --git a/build.zig.zon b/build.zig.zon index bb04c17..5171448 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -6,10 +6,6 @@ .url = "git+https://github.com/capstone-engine/capstone?ref=6.0.0-Alpha6#484857da5dc67f7d0e0a01c36b0ebc37a349e0fd", .hash = "N-V-__8AAI-jMgXy8ymEREsD2WbO6CpmH9mIpULsgYu3r56r", }, - .@"frida-gum" = .{ - .url = "git+https://github.com/frida/frida-gum.git#7804914181117f05d20d3b143f7c13935658777f", - .hash = "N-V-__8AAFeo1AEV9-c5BwB6KQi5gLoDP-sj6d2duyERG2u-", - }, .vaxis = .{ .url = "git+https://github.com/rockorager/libvaxis.git#a367b89da09bfe5e1b628501940de5b4f858f5f3", .hash = "vaxis-0.6.0-BWNV_HHwCQB451KS7A8SMykALblPmGwHnzSfiJHjN3_9", diff --git a/build/frida-gum.zig b/build/frida-gum.zig deleted file mode 100644 index dfee7de..0000000 --- a/build/frida-gum.zig +++ /dev/null @@ -1,175 +0,0 @@ -const std = @import("std"); - -pub fn gum_stalker(b: *std.Build, opts: struct { - target: std.Build.ResolvedTarget, - optimize: std.builtin.OptimizeMode, -}) *std.Build.Step.Compile { - const dep = b.dependency("frida-gum", .{}); - const capstone_dep = b.dependency("capstone", .{}); - - // stub gumenumtypes.h — normally generated by gnome.mkenums - const wf = b.addWriteFiles(); - _ = wf.add("gum/gumenumtypes.h", - \\#ifndef __GUM_ENUM_TYPES_H__ - \\#define __GUM_ENUM_TYPES_H__ - \\#include <glib-object.h> - \\G_BEGIN_DECLS - \\GType gum_elf_type_get_type (void) G_GNUC_CONST; - \\#define GUM_TYPE_ELF_TYPE (gum_elf_type_get_type ()) - \\GType gum_elf_osabi_get_type (void) G_GNUC_CONST; - \\#define GUM_TYPE_ELF_OSABI (gum_elf_osabi_get_type ()) - \\GType gum_elf_machine_get_type (void) G_GNUC_CONST; - \\#define GUM_TYPE_ELF_MACHINE (gum_elf_machine_get_type ()) - \\GType gum_elf_source_mode_get_type (void) G_GNUC_CONST; - \\#define GUM_TYPE_ELF_SOURCE_MODE (gum_elf_source_mode_get_type ()) - \\G_END_DECLS - \\#endif - ); - - // C-only module (translate-c can't handle GLib's _Pragma macros) - const c_mod = b.createModule(.{ - .target = opts.target, - // .optimize = opts.optimize, - .optimize = .Debug, - .link_libc = true, - }); - - // include paths for C source compilation - c_mod.addIncludePath(dep.path("")); - c_mod.addIncludePath(dep.path("gum")); - c_mod.addIncludePath(dep.path("gum/arch-x86")); - c_mod.addIncludePath(dep.path("gum/arch-arm")); - c_mod.addIncludePath(dep.path("gum/arch-arm64")); - c_mod.addIncludePath(dep.path("gum/arch-mips")); - c_mod.addIncludePath(dep.path("gum/backend-linux/include")); - c_mod.addIncludePath(dep.path("gum/backend-elf")); - c_mod.addIncludePath(dep.path("gum/backend-posix")); - c_mod.addIncludePath(dep.path("libs")); - c_mod.addIncludePath(dep.path("libs/gum/heap")); - c_mod.addIncludePath(dep.path("libs/gum/prof")); - c_mod.addIncludePath(capstone_dep.path("include/capstone")); - c_mod.addIncludePath(capstone_dep.path("include")); - c_mod.addIncludePath(wf.getDirectory()); - - // system libraries - c_mod.linkSystemLibrary("glib-2.0", .{}); - c_mod.linkSystemLibrary("gobject-2.0", .{}); - - // config defines — replaces meson's config.h + add_project_arguments - // platform / arch - c_mod.addCMacro("HAVE_LINUX", "1"); - c_mod.addCMacro("HAVE_I386", "1"); - c_mod.addCMacro("HAVE_ELF", "1"); - c_mod.addCMacro("HAVE_GLIBC", "1"); - // frida-gum options - c_mod.addCMacro("GUM_STATIC", "1"); - c_mod.addCMacro("GUM_USE_SYSTEM_ALLOC", "1"); - c_mod.addCMacro("FRIDA_VERSION", "\"16.x\""); - // compiler feature detection - c_mod.addCMacro("HAVE_SYNC_LOCK", "1"); - c_mod.addCMacro("HAVE_CLEAR_CACHE", "1"); - c_mod.addCMacro("HAVE_CLTZ", "1"); - c_mod.addCMacro("HAVE_POPCOUNT", "1"); - c_mod.addCMacro("HAVE_PACK_PRAGMA", "1"); - // system headers - c_mod.addCMacro("HAVE_ELF_H", "1"); - c_mod.addCMacro("HAVE_LINK_H", "1"); - c_mod.addCMacro("HAVE_STDINT_H", "1"); - c_mod.addCMacro("HAVE_SYS_AUXV_H", "1"); - c_mod.addCMacro("HAVE_ASM_PRCTL_H", "1"); - c_mod.addCMacro("HAVE_SYS_USER_H", "1"); - // system functions / types - c_mod.addCMacro("HAVE_MADVISE", "1"); - c_mod.addCMacro("HAVE_LONG_DOUBLE", "1"); - c_mod.addCMacro("HAVE_LONG_LONG_INT", "1"); - c_mod.addCMacro("HAVE_UNSIGNED_LONG_LONG_INT", "1"); - c_mod.addCMacro("HAVE_PTHREAD_ATTR_GETSTACK", "1"); - c_mod.addCMacro("HAVE_PTHREAD_SETNAME_NP", "1"); - // NOTE: HAVE_FRIDA_GLIB omitted — system GLib lacks frida's patches - // capstone compat (frida-gum uses capstone 5 type names) - c_mod.addCMacro("CAPSTONE_ARM_COMPAT_HEADER", "1"); - c_mod.addCMacro("CAPSTONE_AARCH64_COMPAT_HEADER", "1"); - c_mod.addCMacro("CAPSTONE_SYSTEMZ_COMPAT_HEADER", "1"); - // GLib / compiler flags - c_mod.addCMacro("_GNU_SOURCE", "1"); - c_mod.addCMacro("G_LOG_DOMAIN", "\"Frida\""); - c_mod.addCMacro("GLIB_VERSION_MIN_REQUIRED", "GLIB_VERSION_2_56"); - c_mod.addCMacro("G_DISABLE_DEPRECATED", ""); - - // core + arch writers (unconditional in upstream meson) - c_mod.addCSourceFiles(.{ - .root = dep.path("gum"), - .files = &.{ - "gum.c", - "gumapiresolver.c", - "gumbacktracer.c", - "gumcloak.c", - "gumcodeallocator.c", - "gumcodesegment.c", - // gumdarwingrafter.c and gumdarwinmodule.c omitted (darwin only) - "gumelfmodule.c", - "gumeventsink.c", - "gumexceptor.c", - "gumheapapi.c", - "guminterceptor.c", - "guminvocationcontext.c", - "guminvocationlistener.c", - "gumkernel.c", - "gumleb.c", - "gumlibc.c", - "gummemory.c", - "gummemorymap.c", - "gummetalarray.c", - "gummetalhash.c", - "gummoduleapiresolver.c", - "gummodulemap.c", - "gumprintf.c", - "gumprocess.c", - "gumthreadregistry.c", - "gummodule.c", - "gummodulefacade.c", - "gummoduleregistry.c", - "gumreturnaddress.c", - "gumspinlock.c", - "gumstalker.c", - "gumswiftapiresolver.c", - // arch writers (x86 only — arm/arm64/mips need frida's capstone fork) - "arch-x86/gumx86writer.c", - "arch-x86/gumx86relocator.c", - "arch-x86/gumx86reader.c", - // x86 backend - "arch-x86/gumx86backtracer.c", - "backend-x86/gumcpucontext-x86.c", - "backend-x86/gumprocess-x86.c", - "backend-x86/guminterceptor-x86.c", - "backend-x86/gumstalker-x86.c", - // linux + posix backend - "backend-linux/gummemory-linux.c", - "backend-posix/gummemory-posix.c", - "backend-linux/gumprocess-linux.c", - "backend-linux/gumthreadregistry-linux.c", - "backend-linux/gummoduleregistry-linux.c", - "backend-linux/gummodule-linux.c", - "backend-posix/gumtls-posix.c", - "backend-posix/gumexceptor-posix.c", - "backend-posix/gummemoryaccessmonitor-posix.c", - // elf backend - "backend-elf/gummodule-elf.c", - "backend-elf/gummoduleregistry-elf.c", - }, - }); - - // x86 assembly glue - c_mod.addAssemblyFile(dep.path("gum/backend-x86/gumstalker-x86-glue.S")); - - const stalker_lib = b.addLibrary(.{ - .name = "gumstalker", - .linkage = .static, - .root_module = c_mod, - }); - - stalker_lib.installHeadersDirectory(capstone_dep.path("include/capstone"), "capstone", .{}); - stalker_lib.installHeader(capstone_dep.path("include/platform.h"), "capstone/platform.h"); - - return stalker_lib; -} diff --git a/src/gloves.zig b/src/gloves.zig deleted file mode 100644 index 0ef2481..0000000 --- a/src/gloves.zig +++ /dev/null @@ -1,74 +0,0 @@ -const std = @import("std"); - -// https://github.com/ghostty-org/ghostty/blob/9fb03ba55c9e53901193187d5c43341f5b1b430d/src/pty.zig#L11 -pub const winsize = extern struct { - ws_row: u16 = 100, - ws_col: u16 = 80, - ws_xpixel: u16 = 800, - ws_ypixel: u16 = 600, -}; - -var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init; -const alloc = gpa.allocator(); -const ArrayList = std.ArrayList; - -pub fn main() !void { - // // var child = std.process.Child.init(&.{ "cat", "-" }, alloc); - // var child = std.process.Child.init(&.{"./study-samples/split"}, alloc); - // child.stdin_behavior = .Pipe; - // child.stdout_behavior = .Pipe; - // child.stderr_behavior = .Pipe; - - // var stdin_buf: [0x100]u8 = undefined; - // var stdin = std.fs.File.stdin().readerStreaming(&stdin_buf); - - // var stdout: ArrayList(u8) = .empty; - // defer stdout.deinit(alloc); - // var stderr: ArrayList(u8) = .empty; - // defer stderr.deinit(alloc); - - // try child.spawn(); - // errdefer { - // _ = child.kill() catch {}; - // } - - // var child_writer_buf: [0x100]u8 = undefined; - // var child_stdin_writer = child.stdin.?.writer(&child_writer_buf); - - // while (true) { - // if (stdin.interface.streamDelimiter(&child_stdin_writer.interface, '\n')) |_| {} else |e| { - // switch (e) { - // error.EndOfStream => { - // std.debug.print("end of stream\n", .{}); - // break; - // }, - // else => {}, - // } - // break; - // } - // _ = try child_stdin_writer.interface.writeByte('\n'); - // if (child_stdin_writer.interface.flush()) |_| {} else |_| { - // break; - // } - // } - - // child.collectOutput(alloc, &stdout, &stderr, 0x1000) catch {}; - // std.debug.print("{s}\n {s}\n", .{ stdout.items, stderr.items }); - - // const term = try child.wait(); - // switch (term) { - // .Signal => |s| { - // inline for (@typeInfo(std.os.linux.SIG).@"struct".decls) |f| { - // const field = @field(std.os.linux.SIG, f.name); - // const t = @TypeOf(field); - // if (t == comptime_int) { - // if (field == s) - // std.debug.print("Returned with Signal: {s} ({d})\n", .{ f.name, s }); - // } - // } - // }, - // else => std.debug.print("{any}\n", .{ .term = term }), - // } - - // // std.debug.print("*** If you this message alone... Something probably went wrong\nIs this leaking? {any}\n", .{gpa.detectLeaks()}); -} diff --git a/src/shock.zig b/src/shock.zig index 90e6edf..b2abba8 100644 --- a/src/shock.zig +++ b/src/shock.zig @@ -18,17 +18,6 @@ pub fn main(init: std.process.Init.Minimal) !void { defer threaded.deinit(); const io = threaded.io(); - // var evented: std.Io.Evented = undefined; - // try evented.init(alloc, .{ - // .argv0 = .init(init.args), - // .environ = init.environ, - // .backing_allocator_needs_mutex = false, - // }); - // defer evented.deinit(); - // const io = evented.io(); - - // const f = try std.Io.Dir.cwd().openFile(io, subject, .{ .mode = .read_only }); - // std.debug.print("file: {any}\n", .{f}); var child = try std.process.spawn(io, .{ .argv = &.{subject}, .stdout = .pipe, @@ -41,10 +30,8 @@ pub fn main(init: std.process.Init.Minimal) !void { std.debug.print("spawned child: {any}\n", .{child}); - // io.async(function: anytype, args: (unknown type)) var child_fut = io.async(std.process.Child.wait, .{ &child, io }); const child_out = try child_fut.await(io); - // const child_out = try child.wait(io); std.debug.print("stdout: {s}\n", .{buf}); { Binary files differ |
