Skip to content

Instantly share code, notes, and snippets.

@ioncodes
Last active February 24, 2018 14:06
Show Gist options
  • Save ioncodes/2840775c7d161b595c2ae9387881a342 to your computer and use it in GitHub Desktop.
Save ioncodes/2840775c7d161b595c2ae9387881a342 to your computer and use it in GitHub Desktop.
Calculates the bytes used for a negative relative jump over 126 bytes in x64 asm (e.g: je $-300)
loc = 200
asm = [0xfa, 0xff, 0xff, 0xff]
for i in range(0, loc):
if asm[0] == 0x00:
if asm[1] == 0x00:
if asm[2] == 0x00:
asm[3] -= 1
asm[2] = 0xff
asm[1] = 0xff
asm[0] = 0xff
else:
asm[2] -= 1
asm[1] = 0xff
asm[0] = 0xff
else:
asm[1] -= 1
asm[0] = 0xff
else:
asm[0] -= 1
print(''.join('{:02x} '.format(x) for x in asm))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment