Rating:

[full writeup](https://ctf.harrisongreen.me/2019/x-mas-ctf/discount_vmprotect/)

Disassembled code:

program 1:


__start:
[00] :: push(res[128]) | r
[02] :: strcpy

__loop:
[03] :: dup | r r
[04] :: dup | r r r
[05] :: res[128] = pop() | r r
[07] :: push(flag[pop()]) | r f[r]
[08] :: jz 0x12
[0A] :: push 0x1 | r 1
[0D] :: dup | (r+1) (r+1)
[0E] :: dup | (r+1) (r+1) (r+1)
[0F] :: sub | (r+1) (r+1)
[10] :: jz 0x3 | (r+1)

__end_of_flag:
[12] :: push 0x23 | len 0x23
[14] :: sub | (len - 0x23)
[15] :: jz 0x1b

__incorrect_length:
[17] :: push 0x0
[19] :: res[0] = pop() | res[0] = 0

__correct_length:
[1B] :: push 0x0
[1D] :: res[128] = pop() | res[128] = 0
[1F] :: ret


program 2:

__start:
[00] :: push(res[128]) | r
[02] :: dup | r r
[03] :: dup | r r r
[04] :: res[128] = pop() | r r
[06] :: push(flag[pop()]) | r f[r]
[07] :: dup | r f[r] f[r]
[08] :: jz 0x28 | r f[r]

__flag_not_zero:
[0A] :: ror | r (f[r] >>> 1)
[0B] :: push 0x63 | r (f[r] >>> 1) 0x63
[0D] :: xor | r ((f[r] >>> 1)^0x63)
[0E] :: push 0x98 | r ((f[r] >>> 1)^0x63) 0x98
[10] :: add | r (((f[r] >>> 1)^0x63)+0x98)
[11] :: not | r ~(((f[r] >>> 1)^0x63)+0x98)
[12] :: dbg
[13] :: push(res[128]) | r ~(((f[r] >>> 1)^0x63)+0x98) r
[15] :: push 0xa | r ~((f[r] >>> 1)^0x63)+0x98) r 0xa
[17] :: add | r ~(((f[r] >>> 1)^0x63)+0x98) (r+0xa)
[18] :: get res[top] | r ~(((f[r] >>> 1)^0x63)+0x98) res[(r+0xa)]
[19] :: sub
[1A] :: jz 0x20

__incorrect_char
[1C] :: push 0x0
[1E] :: res[0] = pop()

__correct_char
[20] :: push 0x1