{"id":16032897,"url":"https://github.com/dimkr/go-papaw","last_synced_at":"2025-03-17T04:49:35.993Z","repository":{"id":57522457,"uuid":"253714143","full_name":"dimkr/go-papaw","owner":"dimkr","description":"Go module for papaw","archived":false,"fork":false,"pushed_at":"2020-06-19T10:00:56.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T14:29:34.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimkr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-07T07:05:50.000Z","updated_at":"2020-06-19T10:00:59.000Z","dependencies_parsed_at":"2022-08-30T04:22:06.667Z","dependency_job_id":null,"html_url":"https://github.com/dimkr/go-papaw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimkr%2Fgo-papaw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimkr%2Fgo-papaw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimkr%2Fgo-papaw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimkr%2Fgo-papaw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimkr","download_url":"https://codeload.github.com/dimkr/go-papaw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243976502,"owners_count":20377692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-08T21:41:07.299Z","updated_at":"2025-03-17T04:49:35.974Z","avatar_url":"https://github.com/dimkr.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n  __ _  ___        _ __   __ _ _ __   __ ___      __\n / _` |/ _ \\ _____| '_ \\ / _` | '_ \\ / _` \\ \\ /\\ / /\n| (_| | (_) |_____| |_) | (_| | |_) | (_| |\\ V  V /\n \\__, |\\___/      | .__/ \\__,_| .__/ \\__,_| \\_/\\_/\n |___/            |_|         |_|\n```\n\n## Overview\n\ngo-papaw is a [Go](https://golang.org) module for [papaw](http://github.com/dimkr/papaw).\n\ngo-papaw does two things:\n\n1. It makes executables smaller and harder to reverse-engineer\n2. It allows executables to run from RAM and delete themselves\n\n## Implementation\n\ngo-papaw is implemented using [cgo](https://golang.org/cmd/cgo).\n\n## Packing\n\nTo pack (compress and obfuscate) an executable:\n\n```\n$ go get -u github.com/dimkr/go-papaw\n$ go run github.com/dimkr/go-papaw/cmd/pack -input /tmp/example -output /tmp/example-compressed\n```\n\nBefore:\n\n```\n$ /tmp/example\nHello world!\n$ du -h /tmp/example\n2.0M    /tmp/example\n```\n\nAfter:\n```\n$ /tmp/example-compressed\nHello world!\n$ du -h /tmp/example-compressed\n992K    /tmp/example-compressed\n```\n\nThe `pack` tool offers two compression algorithms: `-algo deflate` (the default) and `-algo lzma`.\n\nThe compression ratio will vary based on the chosen algorithm (LZMA has a better compression ratio), the input executable content (the length and number of identical sequences) and the target CPU architecture (RISC or CISC, fixed- or variable-sized instructions).\n\nHowever, the compression ratio tends to be __at least 50%__:\n\n```\n$ CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags \"-s -w\" -o /tmp/example\n$ go run github.com/dimkr/go-papaw/cmd/pack -input /tmp/example -output /tmp/example-packed\n2020/04/07 16:07:10 Done: output is 62.62% smaller.\n$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \"-s -w\" -o /tmp/example\n$ go run github.com/dimkr/go-papaw/cmd/pack -input /tmp/example -output /tmp/example-packed\n2020/04/07 16:07:11 Done: output is 58.45% smaller.\n$ go run github.com/dimkr/go-papaw/cmd/pack -input /tmp/example -output /tmp/example-packed -algo lzma\n2020/04/07 16:07:12 Done: output is 66.89% smaller.\n$ CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags \"-s -w\" -o /tmp/example\n$ go run github.com/dimkr/go-papaw/cmd/pack -input /tmp/example -output /tmp/example-packed\n2020/04/07 16:07:13 Done: output is 56.11% smaller.\n$ CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags \"-s -w\" -o /tmp/example\n$ go run github.com/dimkr/go-papaw/cmd/pack -input /tmp/example -output /tmp/example-packed\n2020/04/07 16:07:14 Done: output is 62.78% smaller.\n```\n\n## Fileless Execution\n\nJust import the module!\n\n```go\nimport (\n        _ \"github.com/dimkr/go-papaw\"\n)\n```\n\nThe module's init function locks the executable to RAM, then deletes the executable.\n\nBefore:\n\n```\n$ cat \u003c\u003c EOF \u003e main.go\npackage main\nimport \"time\"\nfunc main() {\n    time.Sleep(time.Hour)\n}\nEOF\n$ go build -o /tmp/example\n$ /tmp/example \u0026\n$ pid=$!\n[1] 28165\n$ grep example /proc/$pid/maps\n00010000-00065000 r-xp 00000000 00:26 179920                             /tmp/example \u003c--\n00070000-000e6000 r--p 00060000 00:26 179920                             /tmp/example \u003c--\n000f0000-000f4000 rw-p 000e0000 00:26 179920                             /tmp/example \u003c--\n$ ls -la /proc/$pid/exe\nlrwxrwxrwx. 1 user user 0 Apr  7 12:10 /proc/28165/exe -\u003e /tmp/example                \u003c--\n$ head -c 4 /proc/$pid/exe\nELF                                                                                   \u003c--\n$ ls example\nexample                                                                               \u003c--\n```\n\nAfter:\n\n```\n$ cat \u003c\u003c EOF \u003e main.go\npackage main\nimport (\n    _ \"github.com/dimkr/go-papaw\"                                                     \u003c--\n    \"time\"\n)\nfunc main() {\n    time.Sleep(time.Hour)\n}\nEOF\n$ go build -o /tmp/example\n$ /tmp/example \u0026\n$ pid=$!\n[2] 27812\n$ grep example /proc/$pid/maps\n$ ls -la /proc/$pid/exe\nlrwxrwxrwx. 1 user user 0 Apr  7 12:11 /proc/27812/exe -\u003e '/tmp/example (deleted)'\n$ head -c 4 /proc/$pid/exe\n$ ls example\nls: cannot access 'example': No such file or directory\n```\n\n## Legal Information\n\ngo-papaw is free and unencumbered software released under the terms of the MIT license; see COPYING for the license text.\n\nThe ASCII art logo at the top was made using [FIGlet](http://www.figlet.org/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimkr%2Fgo-papaw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimkr%2Fgo-papaw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimkr%2Fgo-papaw/lists"}