Skip to content

Instantly share code, notes, and snippets.

@ilyakurdyukov
Created October 8, 2020 11:31
Show Gist options
  • Save ilyakurdyukov/58a597392b608e781a2f2400539eda03 to your computer and use it in GitHub Desktop.
Save ilyakurdyukov/58a597392b608e781a2f2400539eda03 to your computer and use it in GitHub Desktop.
An example of splitting a C program into separate characters.
#include <stdio.h>
#define X(a,b) a##b
#define x(a,b) X(a,b)
#define s(a) #a
x ( i , x ( n , t
) ) x ( m , x ( a
, x ( i , n ) ) )
( ) { x ( p , x (
r , x ( i , x ( n
, x ( t , f ) ) )
) ) ( s ( H ) s (
e ) s ( l ) s ( l
) s ( o ) s ( % )
s ( c ) s ( W ) s
( o ) s ( r ) s (
l ) s ( d ) s ( !
) s ( % ) s ( c )
, x ( 3 , 2 ) , x
( 1 , 0 ) ) ; ; }
@ilyakurdyukov
Copy link
Author

ilyakurdyukov commented Oct 8, 2020

Unobfuscated code is:

int main() { printf("Hello%cWorld!%c", 32, 10); }

The space has a numeric value of 32 and the newline character is 10, both of them cannot be encoded in the same way as other characters.
The same problem should be expected with parentheses and commas when used in a string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment