Advertisement
pr4gasm

Untitled

Aug 27th, 2021
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.31 KB | None | 0 0
  1.  
  2. def Emit(opcodes):
  3.     if type(opcodes) != list and type(opcodes) != tuple:
  4.         return None
  5.  
  6.     raw = ""
  7.     for op in opcodes:
  8.         raw+=hex(op)[2:]+" "
  9.  
  10.     return raw
  11.  
  12. def encode_MISc2():
  13.  
  14.     # VEX.128.66.0F.WIG F7 /r VMASKMOVDQU xmm1, xmm2
  15.     # ModRM:reg (r) ModRM:r/m (r)
  16.  
  17.     # EVEX.512.F3.0F.W0 7F /r VMOVDQU32 zmm2/m512 {k1}{z}, zmm1
  18.     # ModRM:r/m (w) ModRM:reg (r)
  19.  
  20.     # EVEX.128.F3.0F.W1 6F /r VMOVDQU64 xmm1 {k1}{z}, xmm2/m128
  21.     # ModRM:reg (w) ModRM:r/m (r)
  22.  
  23.     # EVEX.256.66.0F.W0 78 /r VCVTTPS2UQQ ymm1 {k1}{z}, xmm2/m128/m32bcst
  24.     # ModRM:reg (w) ModRM:r/m (r)
  25.  
  26.     # EVEX.512.66.0F3A.W0 56 /r ib VREDUCEPS zmm1 {k1}{z}, zmm2/m512/m32bcst{sae}, imm8
  27.     # ModRM:reg (w) ModRM:r/m (r) Imm8
  28.  
  29.     insn1 = "VMASKMOVDQU xmm0, xmm12"
  30.     insn2 = "VMOVDQU32 ZMMWORD PTR fs:[r8d+edi*4+0x3604] {k3}, zmm24"
  31.     insn3 = "VMOVDQU64 xmm29 {k7}{z},XMMWORD PTR gs:[rdx*2]"
  32.     insn4 = "VCVTTPS2UQQ ymm1 {k1}{z},dword ptr [ebx+0x36] {1to4}"
  33.     insn5 = "VREDUCEPS zmm0,{k4}{z},zmm20,{sae},0x0c"
  34.  
  35.     pfRzAddr = 0x67
  36.     pfOvFs = 0x64
  37.     pfOvGs = 0x65
  38.  
  39.     vex2 = 0b11000100_110_00001_0_1111_0_01
  40.     evex1 = 0b01100010_010_0_00_01_0_1111_1_10_0_10_0_1_011
  41.     evex2 = 0b01100010_011_0_00_01_1_1111_1_10_1_00_0_1_111
  42.     evex3 = 0b01100010_111_1_00_01_0_1111_1_01_1_01_1_1_001
  43.     evex4 = 0b01100010_101_1_00_11_0_1111_1_01_1_10_1_1_100
  44.     opcode1 = 0xF7
  45.     opcode2 = 0x7F
  46.     opcode3 = 0x6F
  47.     opcode4 = 0x78
  48.     opcode5 = 0x56
  49.  
  50.     modrm1 = 0b11_000_100
  51.  
  52.     modrm2 = 0b10_000_100
  53.     sib2 = 0b10_111_000
  54.     disp32_2 = 0x04360000
  55.  
  56.     modrm3 = 0b00_101_100
  57.     sib3 = 0b01_010_101
  58.     disp32_3 = "00 00 00 00"
  59.  
  60.     modrm4 = 0b10_001_011
  61.     disp32_4 = 0x36000000
  62.  
  63.     modrm5 = 0b11_000_100
  64.     imm8_5 = 0x0c
  65.  
  66.     opcodes1 = [vex2,opcode1,modrm1]
  67.     opcodes2 = [pfRzAddr,pfOvFs,evex1,opcode2,modrm2,sib2,disp32_2]
  68.     opcodes3 = [pfOvGs,evex2,opcode3,modrm3,sib3]
  69.     opcodes4 = [pfRzAddr,evex3,opcode4,modrm4,disp32_4]
  70.     opcodes5 = [evex4,opcode5,modrm5,imm8_5]
  71.  
  72.     x86insn1 = Emit(opcodes1)
  73.     x86insn2 = Emit(opcodes2)
  74.     x86insn3 = Emit(opcodes3) + disp32_3
  75.     x86insn4 = Emit(opcodes4)
  76.     x86insn5 = Emit(opcodes5)
  77.  
  78.     print(x86insn1,insn1)
  79.     print(x86insn2,insn2)
  80.     print(x86insn3,insn3)
  81.     print(x86insn4,insn4)
  82.     print(x86insn5,insn5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement