├── LICENSE ├── README.md ├── requirements.txt └── shellcodetoasm.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Dayanç 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShellcodeToAssembly 2 | 3 | ## Replace in shellcodetoasm.py with your shellcode. { Endian type is little endian. } 4 | ```c 5 | shellcode = '' 6 | ``` 7 | --------- 8 | 9 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)]() 10 | 11 | ## Installation 12 | `git clone https://github.com/blacknbunny/ShellcodeToAssembly.git && cd ShellcodeToAssembly/ && pip2 install -r requirements.txt && python2 shellcodetoasm.py` 13 | 14 | 15 | ## Modules manual installation 16 | #### `pip install -r requirements.txt` it can be `pip2 install -r requirements.txt` 17 | 18 | ## Usage 19 | `python2 shellcodetoasm.py [returnbit] [architecture] [assembly-flavor]` 20 | 21 | ## For example 22 | `python2 shellcodetoasm.py 32 x86 att` 23 | 24 | `python2 shellcodetoasm.py 64 x86` 25 | 26 | `Second one is auto intel` 27 | 28 | ## Architectures 29 | ### `ARM` 30 | ### `ARM64` 31 | ### `MIPS` 32 | ### `ppc` 33 | ### `X86` 34 | 35 | ## Return Bit 36 | ### `64` 37 | ### `32` 38 | 39 | ## Assembly Flavor 40 | ### `AT&T` 41 | ### `INTEL` 42 | 43 | ------ 44 | 45 | [![demo](https://asciinema.org/a/xjWrXfftZS7BvSzVRd44LuzkP.png)](https://asciinema.org/a/xjWrXfftZS7BvSzVRd44LuzkP?autoplay=1) 46 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | capstone==3.0.4 2 | -------------------------------------------------------------------------------- /shellcodetoasm.py: -------------------------------------------------------------------------------- 1 | from capstone import * 2 | import time, sys, os 3 | 4 | # Change here 5 | shellcode = '\x31\xf6' 6 | 7 | def loading(): 8 | print "Loading..." 9 | for i in range(0, 100): 10 | time.sleep(0.1) 11 | width = (i + 1) / 4 12 | bar = "[" + "#" * width + " " * (25 - width) + "]" 13 | sys.stdout.write(u"\u001b[1000D" + bar) 14 | sys.stdout.flush() 15 | print 16 | def cls(): 17 | os.system('cls' if os.name == 'nt' else 'clear') 18 | 19 | def holefunc(architecture, mode): 20 | options = Cs(architecture, mode) 21 | try: 22 | if sys.argv[3] == 'att': 23 | options.syntax = CS_OPT_SYNTAX_ATT 24 | except: 25 | options.syntax = CS_OPT_SYNTAX_INTEL 26 | listofinstructions = options.disasm(shellcode, 0x2000) 27 | print("\n") 28 | for shtoasm in listofinstructions: 29 | print("%x\t%s\t%s" %(shtoasm.address, shtoasm.mnemonic, shtoasm.op_str)) 30 | s = raw_input("\nDo you want to write shellcode bytes to an file ? Y/n : ") 31 | if s == 'Y' or s == 'y' or s == '': 32 | with open("shellcode", "w") as f: 33 | f.write(shtoasm.bytes) 34 | f.close() 35 | else: 36 | return False 37 | def error(error): 38 | cls() 39 | print("Select the bit %s" % (error)) 40 | sys.exit(1) 41 | 42 | if len(sys.argv) < 3: 43 | cls() 44 | print("Author : https://www.github.com/blacknbunny") 45 | print("Usage:\t./shellcodetoasm.py [returnbit] [architecture] [assembly-flavor]") 46 | sys.exit(1) 47 | else: 48 | cls() 49 | loading() 50 | returnbit = sys.argv[1] 51 | arch = sys.argv[2] 52 | if returnbit == '64': 53 | if arch == 'arm': 54 | holefunc(CS_ARCH_ARM, CS_MODE_ARM) 55 | elif arch == 'arm64': 56 | holefunc(CS_ARCH_ARM64, CS_MODE_ARM) 57 | elif arch == 'mips': 58 | holefunc(CS_ARCH_MIPS, CS_MODE_MIPS64) 59 | elif arch == 'ppc': 60 | holefunc(CS_ARCH_PPC, CS_MODE_64) 61 | elif arch == 'x86': 62 | holefunc(CS_ARCH_X86, CS_MODE_64) 63 | else: 64 | error("architecture") 65 | elif returnbit == '32': 66 | if arch == 'arm': 67 | holefunc(CS_ARCH_ARM, CS_MODE_ARM) 68 | elif arch == 'arm64': 69 | holefunc(CS_ARCH_ARM64, CS_MODE_ARM) 70 | elif arch == 'mips': 71 | holefunc(CS_ARCH_MIPS, CS_MODE_MIPS32) 72 | elif arch == 'ppc': 73 | holefunc(CS_ARCH_PPC, CS_MODE_32) 74 | elif arch == 'x86': 75 | holefunc(CS_ARCH_X86, CS_MODE_32) 76 | else: 77 | error("architecture") 78 | --------------------------------------------------------------------------------