Created
April 12, 2022 09:49
-
-
Save packmad/8bb74c1d67d53fb75f1f1fbe5d903391 to your computer and use it in GitHub Desktop.
Printable ASCII characters which are also valid x86 instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
from capstone import * | |
modes = [CS_MODE_32, CS_MODE_64] | |
for mode in modes: | |
md = Cs(CS_ARCH_X86, mode) | |
printables = string.printable[:-5] | |
valid = 0 | |
for c in printables: | |
dis = list(md.disasm(bytes([ord(c)]), 0x1000)) | |
if len(dis) == 1: | |
for i in dis: | |
print("|%s| ->\t%s\t%s" %(c, i.mnemonic, i.op_str)) | |
valid += 1 | |
elif len(dis) == 0: | |
print(f"|{c}|") | |
else: | |
assert False | |
print(f'{valid}/{len(printables)}') | |
''' x86_32 | |
|0| | |
|1| | |
|2| | |
|3| | |
|4| | |
|5| | |
|6| | |
|7| -> aaa | |
|8| | |
|9| | |
|a| -> popal | |
|b| | |
|c| | |
|d| | |
|e| | |
|f| | |
|g| | |
|h| | |
|i| | |
|j| | |
|k| | |
|l| -> insb byte ptr es:[edi], dx | |
|m| -> insd dword ptr es:[edi], dx | |
|n| -> outsb dx, byte ptr [esi] | |
|o| -> outsd dx, dword ptr [esi] | |
|p| | |
|q| | |
|r| | |
|s| | |
|t| | |
|u| | |
|v| | |
|w| | |
|x| | |
|y| | |
|z| | |
|A| -> inc ecx | |
|B| -> inc edx | |
|C| -> inc ebx | |
|D| -> inc esp | |
|E| -> inc ebp | |
|F| -> inc esi | |
|G| -> inc edi | |
|H| -> dec eax | |
|I| -> dec ecx | |
|J| -> dec edx | |
|K| -> dec ebx | |
|L| -> dec esp | |
|M| -> dec ebp | |
|N| -> dec esi | |
|O| -> dec edi | |
|P| -> push eax | |
|Q| -> push ecx | |
|R| -> push edx | |
|S| -> push ebx | |
|T| -> push esp | |
|U| -> push ebp | |
|V| -> push esi | |
|W| -> push edi | |
|X| -> pop eax | |
|Y| -> pop ecx | |
|Z| -> pop edx | |
|!| | |
|"| | |
|#| | |
|$| | |
|%| | |
|&| | |
|'| -> daa | |
|(| | |
|)| | |
|*| | |
|+| | |
|,| | |
|-| | |
|.| | |
|/| -> das | |
|:| | |
|;| | |
|<| | |
|=| | |
|>| | |
|?| -> aas | |
|@| -> inc eax | |
|[| -> pop ebx | |
|\| -> pop esp | |
|]| -> pop ebp | |
|^| -> pop esi | |
|_| -> pop edi | |
|`| -> pushal | |
|{| | |
||| | |
|}| | |
|~| | |
| | | |
42/95 | |
''' | |
''' x86_64 | |
|0| | |
|1| | |
|2| | |
|3| | |
|4| | |
|5| | |
|6| | |
|7| | |
|8| | |
|9| | |
|a| | |
|b| | |
|c| | |
|d| | |
|e| | |
|f| | |
|g| | |
|h| | |
|i| | |
|j| | |
|k| | |
|l| -> insb byte ptr [rdi], dx | |
|m| -> insd dword ptr [rdi], dx | |
|n| -> outsb dx, byte ptr [rsi] | |
|o| -> outsd dx, dword ptr [rsi] | |
|p| | |
|q| | |
|r| | |
|s| | |
|t| | |
|u| | |
|v| | |
|w| | |
|x| | |
|y| | |
|z| | |
|A| | |
|B| | |
|C| | |
|D| | |
|E| | |
|F| | |
|G| | |
|H| | |
|I| | |
|J| | |
|K| | |
|L| | |
|M| | |
|N| | |
|O| | |
|P| -> push rax | |
|Q| -> push rcx | |
|R| -> push rdx | |
|S| -> push rbx | |
|T| -> push rsp | |
|U| -> push rbp | |
|V| -> push rsi | |
|W| -> push rdi | |
|X| -> pop rax | |
|Y| -> pop rcx | |
|Z| -> pop rdx | |
|!| | |
|"| | |
|#| | |
|$| | |
|%| | |
|&| | |
|'| | |
|(| | |
|)| | |
|*| | |
|+| | |
|,| | |
|-| | |
|.| | |
|/| | |
|:| | |
|;| | |
|<| | |
|=| | |
|>| | |
|?| | |
|@| | |
|[| -> pop rbx | |
|\| -> pop rsp | |
|]| -> pop rbp | |
|^| -> pop rsi | |
|_| -> pop rdi | |
|`| | |
|{| | |
||| | |
|}| | |
|~| | |
| | | |
20/95 | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment