website stats » “Hola Mundo” ofuscado en C | Informática Práctica |

“Hola Mundo” ofuscado en C

Escrito por J.F. el Miércoles, 27 de Febrero del 2008 a las 17:56

Todo aquel que haya estudiado informática, o haya tenido algún contacto con el mundo de la programación quizás le suene el lenguaje de programación C. Es antiguo, y en multitud de ocasiones es el primer lenguaje de programación que aprendes, y luego usas sus bases para aprender otros nuevos más modernos y avanzados.

Por ello, me ha resultado gracioso toparme en ésta página con diferentes formas ofuscadas de programar el "Hola Mundo". Aquí las teneis, hay que ser muy geek para hacer ésto:

hello1.c

C:
  1. #define _________ }
  2. #define ________ putchar
  3. #define _______ main
  4. #define _(a) ________(a);
  5. #define ______ _______(){
  6. #define __ ______ _(0x48)_(0x65)_(0x6C)_(0x6C)
  7. #define ___ _(0x6F)_(0x2C)_(0x20)_(0x77)_(0x6F)
  8. #define ____ _(0x72)_(0x6C)_(0x64)_(0x21)
  9. #define _____ __ ___ ____ _________
  10. #include<stdio.h>
  11. _____

hello2.c

C:
  1. #include<stdio.h>
  2. main(){
  3. int x=0,y[14],*z=&amp;y;*(z++)=0x48;*(z++)=y[x++]+0x1D;
  4. *(z++)=y[x++]+0x07;*(z++)=y[x++]+0x00;*(z++)=y[x++]+0x03;
  5. *(z++)=y[x++]-0x43;*(z++)=y[x++]-0x0C;*(z++)=y[x++]+0x57;
  6. *(z++)=y[x++]-0x08;*(z++)=y[x++]+0x03;*(z++)=y[x++]-0x06;
  7. *(z++)=y[x++]-0x08;*(z++)=y[x++]-0x43;*(z++)=y[x]-0x21;
  8. x=*(--z);while(y[x]!=NULL)putchar(y[x++]);
  9. }

hello3.c

C:
  1. #include<stdio.h>
  2. #define __(a) goto a;
  3. #define ___(a) putchar(a);
  4. #define _(a,b) ___(a) __(b);
  5. main()
  6. { _:__(t)a:_('r',g)b:_('$',p)
  7. c:_('l',f)d:_(' ',s)e:_('a',s)
  8. f:_('o',q)g:_('l',h)h:_('d',n)
  9. i:_('e',w)j:_('e',x)k:_('\n',z)
  10. l:_('H',l)m:_('X',i)n:_('!',k)
  11. o:_('z',q)p:_('q',b)q:_(',',d)
  12. r:_('i',l)s:_('w',v)t:_('H',j)
  13. u:_('a',a)v:_('o',a)w:_(')',k)
  14. x:_('l',c)y:_('\t',g)z:___(0x0)}

hello4.c

C:
  1. int n[]={0x48,
  2. 0x65,0x6C,0x6C,
  3. 0x6F,0x2C,0x20,
  4. 0x77,0x6F,0x72,
  5. 0x6C,0x64,0x21,
  6. 0x0A,0x00},*m=n;
  7. main(n){putchar
  8. (*m)!='\0'?main
  9. (m++):exit(n++);}

hello5.c

C:
  1. main(){int i,n[]={(((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;
  2. 1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1)))+((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1))), (((1
  3. &lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1))-((1&lt;&lt;1)&lt;&lt;(
  4. 1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1))+((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1)))+ (1
  5. &lt;&lt;(1&gt;&gt;1))),(((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1
  6. &lt;&lt;1))-((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1)))- ((1
  7. &lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1)))),(((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1
  8. &lt;&lt;1)&lt;&lt;(1&lt;&lt;1))-((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1
  9. )))-((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1)))),(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&lt;(1&lt;&lt;(1&gt;&gt;1)))),
  22. (((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1))- ((1
  23. &lt;&lt;1)&lt;&lt;(1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1))+((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;
  24. 1)))), (((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1) &lt;&lt;(1&lt;&lt;1))+(1&lt;&lt;(1
  25. &gt;&gt;1))),(((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;1))+((1&lt;&lt;1)&lt;&lt;(1&lt;&lt;(
  26. 1&gt;&gt;1))) + (1&lt;&lt;(1&gt;&gt;1)))}; for(i=(1&gt;&gt;1);i
  27. &lt;(((1&lt;&lt;1) &lt;&lt;(1&lt;&lt;1))+((1 &lt;&lt;1)&lt;&lt;(1&lt;&lt;(1&gt;&gt;1
  28. ))) + (1&lt;&lt;1)); i++) printf("%c",n[i]); }

hello6.cpp

C:
  1. Cheating a bit here. This only works with a cpp compiler (tried it with g++).</stdio.h></stdio.h></stdio.h>
  2.  
  3. #include <stdio.h>
  4. #define _(_) putchar(_);
  5. int main(void){int i = 0;_(
  6. ++++++++++++++++++++++++++++
  7. ++++++++++++++++++++++++++++
  8. ++++++++++++++++++++++++++++
  9. ++++++++++++++++++++++++++++
  10. ++++++++++++++++++++++++++++
  11. ++++i)_(++++++++++++++++++++
  12. ++++++++++++++++++++++++++++
  13. ++++++++++i)_(++++++++++++++
  14. i)_(--++i)_(++++++i)_(------
  15. ----------------------------
  16. ----------------------------
  17. ----------------------------
  18. ----------------------------
  19. ----------------i)_(--------
  20. ----------------i)_(++++++++
  21. ++++++++++++++++++++++++++++
  22. ++++++++++++++++++++++++++++
  23. ++++++++++++++++++++++++++++
  24. ++++++++++++++++++++++++++++
  25. ++++++++++++++++++++++++++++
  26. ++++++++++++++++++++++++++i)
  27. _(----------------i)_(++++++
  28. i)_(------------i)_(--------
  29. --------i)_(----------------
  30. ----------------------------
  31. ----------------------------
  32. ----------------------------
  33. ----------------------------
  34. ------i)_(------------------
  35. ----------------------------
  36. i)return i;}

Finalmente el clásico:

C:
  1. #include <stdio.h>
  2. int main(void)
  3. {
  4. printf("¡Hola, mundo!\n");
  5. return 0;
  6. }

Enlace: | Manuales de C
Vía: | MundoGeek

Categoría: Curiosidades, Programación |

Entradas relacionadas


Deja un comentario

XHTML: Etiquetas permitidas: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Tenga en cuenta: La moderación de comentarios se encuentra activada, por lo que su comentario podría tardar en aparecer. No hay razón para enviar varias veces su comentario.