├── .gitignore ├── LICENSE ├── README.md ├── asmshell.rb ├── irasm.rb └── tests.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /spec/examples.txt 9 | /test/tmp/ 10 | /test/version_tmp/ 11 | /tmp/ 12 | 13 | # Used by dotenv library to load environment variables. 14 | # .env 15 | 16 | ## Specific to RubyMotion: 17 | .dat* 18 | .repl_history 19 | build/ 20 | *.bridgesupport 21 | build-iPhoneOS/ 22 | build-iPhoneSimulator/ 23 | 24 | ## Specific to RubyMotion (use of CocoaPods): 25 | # 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 29 | # 30 | # vendor/Pods/ 31 | 32 | ## Documentation cache and generated files: 33 | /.yardoc/ 34 | /_yardoc/ 35 | /doc/ 36 | /rdoc/ 37 | 38 | ## Environment normalization: 39 | /.bundle/ 40 | /vendor/bundle 41 | /lib/bundler/man/ 42 | 43 | # for a library or gem, you might want to ignore these files since the code is 44 | # intended to run in multiple environments; otherwise, check them in: 45 | # Gemfile.lock 46 | # .ruby-version 47 | # .ruby-gemset 48 | 49 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 50 | .rvmrc 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 XlogicX 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 | # irasm 2 | Interactive Redundant Assembler (shell) 3 | 4 | # Description 5 | The irasm shell takes an x86 (32-bit) assembly instruction as input, and gives the corresponding machine code as output.
6 | The main distinction between this tool and something like nasm_shell, is that the output not only gives an official machine code output, but it also gives alternative machine-code, including some machine-code that no assembler would output (valid machine code)
7 | Not every instruction format is supported. For those that aren't, this script gracefully falls back on using nasm to assemble some machine code
8 | Some instruction formats that may never get support are ones with xmm registers and VEX prefixes 9 | 10 | # Supported Instruction Formats 11 | Atomic (nop, ret, pause, etc...)
12 | OP al, imm8 (xor al, 0x13)
13 | OP ax, imm16 (xor ax, 0x1337)
14 | OP eax, imm32 (xor eax, 0x13371337)
15 | OP r/m8, imm8 (adc byte [eax + ebx + 0x1337], 66)
16 | OP r/m16, imm8 (adc word [eax + ebx + 0x1337], 0x22)
17 | OP r/m32, imm8 (adc dword [eax + ebx + 0x1337], 0x22)
18 | OP r/m16, imm16 (adc word [eax + ebx + 0x1337], 0x4444)
19 | OP r/m32, imm32 (adc dword [eax + ebx + 0x1337], 0x88888888)
20 | OP r/m8, r8 (xor al, ah)
21 | OP r/m16, r16 (xor ax, ax)
22 | OP r/m32, r32 (xor eax, eax)
23 | OP r8, r/m8 (xor al, ah)
24 | OP r16, r/m16 (xor ax, ax)
25 | OP r32, r/m32 (xor eax, eax)
26 | OP rel8
27 | OP rel16
28 | OP rel32
29 | 30 | # Fully Supported Instructions 31 | adc, aad, aam, aas, add, and, cbw, cmp cwde, clac, clc, cld, cli, clts, cmc, cmpsb, cmpsw, cmpsd, cpuid, cwd, cdq, daa, das, emms, f2xm1, fabs, faddp, fchs, fclex, fnclex, fcompp, fcos, fdecstp, fincstp, finit, fninit, fld1, fldl2t, fldl2e, fldpi, fldlg2, fldln2, fldz, fnop, fpatan, fprem, fprem1, fptan, frndint, fscale, fsin, fsincos, fsqrt, ftst, fucompp, fxam, fxtract, fyl2x, fyl2xp1, hlt, insb, insw, insd, into, invd, iretw, iretd, iret, lahf, leave, leavew, lfence, lock, lodsb, lodsw, lodsd, mfence, monitor, movsb, movsw, movsd, mwait, nop, or, outsb, outsw, outsd, pause, popaw, popad, popa, popfw, popfd, popf, pushaw, pushad, pusha, pushfw, pushfd, pushf, rdmsr, rdpmc, rdtsc, rdtscp, rsm, sbb, scasb, scasw, scasd, sfence, stac, stc, std, sti, stosb, stosw, stosd, sub, swapgs, syscall, sysenter, sysexit, sysret, test, ud2, fwait, wait, wbinvd, wrmsr, xgetbv, xlat, xor, xsetbv, and xtest 32 | 33 | # Partially Supported Instructions (only with the above instruction formats) 34 | fcom, fcomp, fdivp, fdivrp, fmulp, fstsw ax, fnstsw ax, fsubp, fsubrp, fucom, fucomp, fxch, in, ret, retf, and sahf 35 | 36 | # Test Instructions 37 | The below instructions are examples that can be used to test out the functionality of irasm:
38 | aad
39 | add eax, 0x00000022
40 | adc byte [ebp + eax + 0x13371337], 88
41 | mfence
42 | cmp ax, 0x5555
43 | and al, 0x66
44 | -------------------------------------------------------------------------------- /asmshell.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | def main(bits) 4 | while 1 do 5 | print 'asmshell > ' 6 | asm = gets.chomp 7 | if /(quit|(?