{"id":13540309,"url":"https://github.com/unixpickle/gobfuscate","last_synced_at":"2025-04-08T09:08:03.105Z","repository":{"id":39352068,"uuid":"69762597","full_name":"unixpickle/gobfuscate","owner":"unixpickle","description":"Obfuscate Go binaries and packages","archived":false,"fork":false,"pushed_at":"2021-12-07T22:27:26.000Z","size":46,"stargazers_count":1408,"open_issues_count":22,"forks_count":160,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-04-14T18:18:26.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unixpickle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-01T20:40:37.000Z","updated_at":"2024-04-13T08:14:55.000Z","dependencies_parsed_at":"2022-07-04T07:17:26.704Z","dependency_job_id":null,"html_url":"https://github.com/unixpickle/gobfuscate","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/unixpickle%2Fgobfuscate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unixpickle%2Fgobfuscate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unixpickle%2Fgobfuscate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unixpickle%2Fgobfuscate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unixpickle","download_url":"https://codeload.github.com/unixpickle/gobfuscate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809962,"owners_count":20999816,"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-08-01T09:01:46.224Z","updated_at":"2025-04-08T09:08:03.084Z","avatar_url":"https://github.com/unixpickle.png","language":"Go","funding_links":[],"categories":["开源类库","Go","\u003ca id=\"783f861b9f822127dba99acb55687cbb\"\u003e\u003c/a\u003e工具","Packers / Obfuscators"],"sub_categories":["构建编译","\u003ca id=\"85bb0c28850ffa2b4fd44f70816db306\"\u003e\u003c/a\u003e混淆器\u0026\u0026Obfuscate"],"readme":"# gobfuscate\n\nWhen you compile a Go binary, it contains a lot of information about your source code: field names, strings, package paths, etc. If you want to ship a binary without leaking this kind of information, what are you to do?\n\nWith gobfuscate, you can compile a Go binary from obfuscated source code. This makes a lot of information difficult or impossible to decipher from the binary.\n\n# How to use\n```\ngo get -u github.com/unixpickle/gobfuscate\ngobfuscate [flags] pkg_name out_path\n```\n`pkg_name` is the path relative from your $GOPATH/src to the package to obfuscate (typically something like domain.tld/user/repo)\n\n`out_path` is the path where the binary will be written to\n\n### Flags\n```\nUsage: gobfuscate [flags] pkg_name out_path\n  -keeptests\n    \tkeep _test.go files\n  -noencrypt\n    \tno encrypted package name for go build command (works when main package has CGO code)\n  -nostatic\n    \tdo not statically link\n  -outdir\n    \toutput a full GOPATH\n  -padding string\n    \tuse a custom padding for hashing sensitive information (otherwise a random padding will be used)\n  -tags string\n    \ttags are passed to the go compiler\n  -verbose\n    \tverbose mode\n  -winhide\n    \thide windows GUI\n```\n\n\n# What it does\n\nCurrently, gobfuscate manipulates package names, global variable and function names, type names, method names, and strings.\n\n### Package name obfuscation\n\nWhen gobfuscate builds your program, it constructs a copy of a subset of your GOPATH. It then refactors this GOPATH by hashing package names and paths. As a result, a package like \"github.com/unixpickle/deleteme\" becomes something like \"jiikegpkifenppiphdhi/igijfdokiaecdkihheha/jhiofoppieegdaif\". This helps get rid of things like Github usernames from the executable.\n\n**Limitation:** currently, packages which use CGO cannot be renamed. I suspect this is due to a bug in Go's refactoring API.\n\n### Global names\n\nGobfuscate hashes the names of global vars, consts, and funcs. It also hashes the names of any newly-defined types.\n\nDue to restrictions in the refactoring API, this does not work for packages which contain assembly files or use CGO. It also does not work for names which appear multiple times because of build constraints.\n\n### Struct methods\n\nGobfuscate hashes the names of most struct methods. However, it does not rename methods whose names match methods of any imported interfaces. This is mostly due to internal constraints from the refactoring engine. Theoretically, most interfaces could be obfuscated as well (except for those in the standard library).\n\nDue to restrictions in the refactoring API, this does not work for packages which contain assembly files or use CGO. It also does not work for names which appear multiple times because of build constraints.\n\n### Strings\n\nStrings are obfuscated by replacing them with functions. A string will be turned into an expression like the following:\n\n```go\n(func() string {\n\tmask := []byte{33, 15, 199}\n\tmaskedStr := []byte{73, 106, 190}\n\tres := make([]byte, 3)\n\tfor i, m := range mask {\n\t\tres[i] = m ^ maskedStr[i]\n\t}\n\treturn string(res)\n}())\n```\n\nSince `const` declarations cannot include function calls, gobfuscate tries to change any `const` strings into `var`s. It works for declarations like any of the following:\n\n```\nconst MyStr = \"hello\"\nconst MyStr1 = MyStr + \"yoyo\"\nconst MyStr2 = MyStr + (MyStr1 + \"hello1\")\n\nconst (\n  MyStr3 = \"hey there\"\n  MyStr4 = MyStr1 + \"yo\"\n)\n```\n\nHowever, it does not work for mixed const/int blocks:\n\n```\nconst (\n  MyStr = \"hey there\"\n  MyNum = 3\n)\n```\n\n# License\n\nThis is under a BSD 2-clause license. See [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funixpickle%2Fgobfuscate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funixpickle%2Fgobfuscate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funixpickle%2Fgobfuscate/lists"}