Coder Social home page Coder Social logo

pjbgf-archives / gosystract Goto Github PK

View Code? Open in Web Editor NEW
30.0 2.0 3.0 4.62 MB

A lightweight CLI tool that finds system calls being called inside golang applications.

License: MIT License

Makefile 1.96% Go 43.28% Dockerfile 0.65% Shell 54.11%
syscalls tool linux security-tool golang cli

gosystract's Introduction

gosystract

gosystract extracts all system calls that may be called within the execution path of a go application.

codecov Dependabot Status GoReport GoDoc build MIT License

Installation:

using container image

docker run --rm -it paulinhu/gosystract gosystract

using go environment

go install github.com/pjbgf/gosystract

If you don't have $GOPATH/bin in your $PATH, prefix the command with:

PATH=$PATH:$GOPATH/bin gosystract

Note that gosystract has a dependency to the go tools when working against executable files. In that case, ensure that go is in your $PATH.

Command-line Usage:

Syntax

Usage:

	gosystrac [flags] filePath

Flags:
    --dumpfile, -d    Handles a dump file instead of a go executable.
    --template        Defines a go template for the results.
                      Example: --template='{{- range . }}{{printf "%d - %s\n" .ID .Name}}{{- end}}'

Running against gosystract itself:

$ gosystract $(which gosystract)

18 system calls found:
    sched_yield (24)
    futex (202)
    write (1)
    rt_sigprocmask (14)
    getpid (39)
    epoll_ctl (233)
    gettid (186)
    mmap (9)
    tgkill (234)
    rt_sigaction (13)
    exit_group (231)
    madvise (28)
    read (0)
    getpgrp (111)
    arch_prctl (158)
    readlinkat (267)
    close (3)
    fcntl (72)

Running the sample dump file:

$ gosystract --dumpfile test/keyring.dump

20 system calls found:
    sched_yield (24)
    futex (202)
    read (0)
    write (1)
    rt_sigprocmask (14)
    getpid (39)
    gettid (186)
    tgkill (234)
    rt_sigaction (13)
    exit_group (231)
    mmap (9)
    madvise (28)
    getpgrp (111)
    arch_prctl (158)
    epoll_ctl (233)
    readlinkat (267)
    close (3)
    fcntl (72)
    add_key (248)
    keyctl (250)

To generate a dump file from a go application use the go tool objdump:

$ go tool objdump goapp > goapp.dump

Using it programmatically

package main

import "github.com/pjbgf/gosystract/cmd/systract"

func main() {
	source := systract.NewExeReader("goapp")
	syscalls, err := systract.Extract(source)
	if err != nil {
		panic(err)
	}

    for _, syscall := range syscalls {
        fmt.Printf("%s (%d)\n", syscall.Name, syscall.ID)
    }
}

License

This application is licensed under the MIT License, you may obtain a copy of it here.

gosystract's People

Contributors

pjbgf avatar dependabot-preview[bot] avatar

Stargazers

Roman Dmytrenko avatar  avatar  avatar Burden Haze  avatar rok avatar  avatar Daniel Iziourov avatar Mauro Risonho de Paula Assumpção avatar Emanuel Bennici avatar Ilmari Vacklin avatar Eddie Zaneski avatar Kohei Morita avatar Chaddy H. avatar  avatar Alexandr Tcherniakhovski avatar Juanjo Guerrero Cerezuela avatar qiye avatar Rustam Zagirov avatar Onur Yartaşı avatar Jintao Zhang avatar Iglou.eu avatar Max Mazurov avatar Alexey Vilenski avatar Acumenix avatar Rohit Jain avatar Milos Gajdos avatar Serge Simard avatar Eddy L O Jansson avatar Farhan avatar Alexandre Leveille avatar

Watchers

James Cloos avatar  avatar

gosystract's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.