Skip to content

Instantly share code, notes, and snippets.

@911992
Created March 5, 2020 20:26
Show Gist options
  • Save 911992/bbcd709416b6c7ce82fd10772a6ad18f to your computer and use it in GitHub Desktop.
Save 911992/bbcd709416b6c7ce82fd10772a6ad18f to your computer and use it in GitHub Desktop.
C trigraphs, and some little tip for obfuscating
%:include <stdio.h>
main(void) ??<
char _vls<:4:>=<%1,3,5,7%>;
printf("val:%d ??/n", 1??(_vls??) );
??>
/*
Above code equals to following code.
Prints 3.
*/
/*
#include <stdio.h>
int main(void) {
char _vls[4]={1,3,5,7};
printf("val:%d \n", _vals[1] );
return 0;
}/*
/*
More reading:
Trigraphs:
http://www.open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf § 5.1.1.2 and § 5.2.1.1
main(startup) function related:
http://www.open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf § 5.1.2.2.3
Array indexing:
http://www.open-std.org/JTC1/sc22/wg14/www/docs/n1256.pdf § 6.5.2.1
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment