nickboucher / trojan-source

Trojan Source: Invisible Vulnerabilities
https://trojansource.codes
MIT License
1.24k stars 266 forks source link

invisible-function.c and homoglyph-function.c cant be build with gcc <= 9.1, but successful with gcc 11.2 #19

Open neutronstz opened 2 years ago

neutronstz commented 2 years ago

gcc-9.1:

$ gcc-9.1 -v
Using built-in specs.
COLLECT_GCC=gcc-9.1
COLLECT_LTO_WRAPPER=/usr/local/gcc-9.1/libexec/gcc/x86_64-linux-gnu/9.1.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc-9.1.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/usr/local/gcc-9.1 --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-9.1
Thread model: posix
gcc version 9.1.0 (GCC)
$ gcc-9.1 invisible-function.c -o invisible-function
invisible-function.c:8:8: error: stray ‘\342’ in program
    8 | bool is��Admin() {
      |        ^
invisible-function.c:8:9: error: stray ‘\200’ in program
    8 | bool is��Admin() {
      |         ^
invisible-function.c:8:10: error: stray ‘\213’ in program
    8 | bool is�Admin() {
      |          ^
invisible-function.c:8:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Admin’
    8 | bool is​Admin() {
      |           ^~~~~
invisible-function.c: In function ‘main’:
invisible-function.c:13:11: error: stray ‘\342’ in program
   13 |     if (is��Admin()) {
      |           ^
invisible-function.c:13:12: error: stray ‘\200’ in program
   13 |     if (is��Admin()) {
      |            ^
invisible-function.c:13:13: error: stray ‘\213’ in program
   13 |     if (is�Admin()) {
      |             ^
invisible-function.c:13:9: error: ‘is’ undeclared (first use in this function)
   13 |     if (is​Admin()) {
      |         ^~
invisible-function.c:13:9: note: each undeclared identifier is reported only once for each function it appears in
invisible-function.c:13:11: error: expected ‘)’ before ‘Admin’
   13 |     if (is��Admin()) {
      |        ~  ^  ~~~~~
      |           )
$ gcc-9.1 homoglyph-function.c -o homoglyph-function
homoglyph-function.c:7:9: error: stray ‘\320’ in program
    7 | void say�ello() {
      |         ^
homoglyph-function.c:7:10: error: stray ‘\235’ in program
    7 | void say�ello() {
      |          ^
homoglyph-function.c:7:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ello’
    7 | void sayНello() {
      |           ^~~~
homoglyph-function.c: In function ‘main’:
homoglyph-function.c:12:8: error: stray ‘\320’ in program
   12 |     say�ello();
      |        ^
homoglyph-function.c:12:9: error: stray ‘\235’ in program
   12 |     say�ello();
      |         ^
homoglyph-function.c:12:5: error: unknown type name ‘say’
   12 |     sayНello();
      |     ^~~

gcc-6.3:

$ gcc-6 -v
Using built-in specs.
COLLECT_GCC=gcc-6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
$ gcc-6 invisible-function.c -o invisible-function
invisible-function.c:8:8: error: stray ‘\342’ in program
 bool is��Admin() {
        ^
invisible-function.c:8:9: error: stray ‘\200’ in program
 bool is��Admin() {
         ^
invisible-function.c:8:10: error: stray ‘\213’ in program
 bool is�Admin() {
          ^
invisible-function.c:8:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Admin’
 bool is​Admin() {
           ^~~~~
invisible-function.c: In function ‘main’:
invisible-function.c:13:11: error: stray ‘\342’ in program
     if (is��Admin()) {
           ^
invisible-function.c:13:12: error: stray ‘\200’ in program
     if (is��Admin()) {
            ^
invisible-function.c:13:13: error: stray ‘\213’ in program
     if (is�Admin()) {
             ^
invisible-function.c:13:9: error: ‘is’ undeclared (first use in this function)
     if (is​Admin()) {
         ^~
invisible-function.c:13:9: note: each undeclared identifier is reported only once for each function it appears in
invisible-function.c:13:14: error: expected ‘)’ before ‘Admin’
     if (is​Admin()) {
              ^~~~~
$ gcc-6 homoglyph-function.c -o homoglyph-function
homoglyph-function.c:7:9: error: stray ‘\320’ in program
 void say�ello() {
         ^
homoglyph-function.c:7:10: error: stray ‘\235’ in program
 void say�ello() {
          ^
homoglyph-function.c:7:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ello’
 void sayНello() {
           ^~~~
homoglyph-function.c: In function ‘main’:
homoglyph-function.c:12:8: error: stray ‘\320’ in program
     say�ello();
        ^
homoglyph-function.c:12:9: error: stray ‘\235’ in program
     say�ello();
         ^
homoglyph-function.c:12:5: error: unknown type name ‘say’
     sayНello();
     ^~~

gcc-5.3.1:

$ gcc-5 -v
Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.3.1-14ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2)
$ gcc-5 invisible-function.c -o invisible-function
invisible-function.c:8:1: error: stray ‘\342’ in program
 bool is​Admin() {
 ^
invisible-function.c:8:1: error: stray ‘\200’ in program
invisible-function.c:8:1: error: stray ‘\213’ in program
invisible-function.c:8:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Admin’
 bool is​Admin() {
           ^
invisible-function.c: In function ‘main’:
invisible-function.c:13:5: error: stray ‘\342’ in program
     if (is​Admin()) {
     ^
invisible-function.c:13:5: error: stray ‘\200’ in program
invisible-function.c:13:5: error: stray ‘\213’ in program
invisible-function.c:13:9: error: ‘is’ undeclared (first use in this function)
     if (is​Admin()) {
         ^
invisible-function.c:13:9: note: each undeclared identifier is reported only once for each function it appears in
invisible-function.c:13:14: error: expected ‘)’ before ‘Admin’
     if (is​Admin()) {
              ^
$ gcc-5 homoglyph-function.c -o homoglyph-function
homoglyph-function.c:7:1: error: stray ‘\320’ in program
 void sayНello() {
 ^
homoglyph-function.c:7:1: error: stray ‘\235’ in program
homoglyph-function.c:7:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ello’
 void sayНello() {
           ^
homoglyph-function.c: In function ‘main’:
homoglyph-function.c:12:5: error: stray ‘\320’ in program
     sayНello();
     ^
homoglyph-function.c:12:5: error: stray ‘\235’ in program
homoglyph-function.c:12:5: error: unknown type name ‘say’

gcc-4.9.2:

$ gcc-4.9 -v
Using built-in specs.
COLLECT_GCC=gcc-4.9
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10+deb8u2' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Debian 4.9.2-10+deb8u2) 
$ gcc-4.9 invisible-function.c -o invisible-function
invisible-function.c:8:1: error: stray ‘\342’ in program
 bool is​Admin() {
 ^
invisible-function.c:8:1: error: stray ‘\200’ in program
invisible-function.c:8:1: error: stray ‘\213’ in program
invisible-function.c:8:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘Admin’
 bool is​Admin() {
           ^
invisible-function.c: In function ‘main’:
invisible-function.c:13:5: error: stray ‘\342’ in program
     if (is​Admin()) {
     ^
invisible-function.c:13:5: error: stray ‘\200’ in program
invisible-function.c:13:5: error: stray ‘\213’ in program
invisible-function.c:13:9: error: ‘is’ undeclared (first use in this function)
     if (is​Admin()) {
         ^
invisible-function.c:13:9: note: each undeclared identifier is reported only once for each function it appears in
invisible-function.c:13:14: error: expected ‘)’ before ‘Admin’
     if (is​Admin()) {
              ^
$ gcc-4.9 homoglyph-function.c -o homoglyph-function
homoglyph-function.c:7:1: error: stray ‘\320’ in program
 void sayНello() {
 ^
homoglyph-function.c:7:1: error: stray ‘\235’ in program
homoglyph-function.c:7:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ello’
 void sayНello() {
           ^
homoglyph-function.c: In function ‘main’:
homoglyph-function.c:12:5: error: stray ‘\320’ in program
     sayНello();
     ^
homoglyph-function.c:12:5: error: stray ‘\235’ in program
homoglyph-function.c:12:5: error: unknown type name ‘say’

gcc-11.2: successful

$ gcc-11.2 -v
Using built-in specs.
COLLECT_GCC=gcc-11.2
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-linux-gnu/11.2.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --enable-checking=release --enable-languages=c,c++ --disable-multilib --program-suffix=-11.2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (GCC)
$ gcc-11.2 invisible-function.c -o invisible-function
$ gcc-11.2 homoglyph-function.c -o homoglyph-function
$ ./invisible-function 
You are an admin
$ ./homoglyph-function 
Goodbye, World!