Skip to content

Instantly share code, notes, and snippets.

@WellingtonEspindula
Created November 9, 2023 21:08
Show Gist options
  • Select an option

  • Save WellingtonEspindula/f2a2ca9f9a30fbe6ba9a82428b94bfb1 to your computer and use it in GitHub Desktop.

Select an option

Save WellingtonEspindula/f2a2ca9f9a30fbe6ba9a82428b94bfb1 to your computer and use it in GitHub Desktop.
Rotate x times chars (using unsigned char) in a byte string (useful to desobfuscate secrets in C code)
def rotate(byte_string, x_times):
return "".join( [ chr( (byte + x_times) % 256) for byte in memoryview(byte_string).tolist()])
# exemple
rotate(b'\x74\x66\x75\x66\x64\x62\x74\x75\x73\x70\x6f\x70\x6e\x7a\x00', 0xff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment