I discovered following strange Java code that print
Just another Java hacker
on your terminal.
Obviously, that piece of code looks like a mess. Even if you copy this code into your favorite IDE, IDE could not figure out the syntax of this code. Trust me, this piece of code works, and this is how it works.
Obviously, it has a class name with the main method. Let’s clear out the code and format it. Now it looks like this.
class Sig{
public static void main(String...args){
\u0066or(int\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));
}
}
Now you can see that there are some Unicode characters in this code. Next, we’ll extract all Unicode characters. Also, I’m removing
/*goto/*$/%\u0126//^\u002A\u002F
and \u002Array.const(~1)\*\u002F
section since those code sections is just commented on line written in Unicode characters.class Sig{
public static void main(String...args){
for(int $:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".toCharArray())
System.out.print((char)(($>>+(~'"'&'#'))+('<'>>('\\'/'.'))));
}
}
If you replace
(char)(($>>+(~'"'&'#'))+('<'>>('\\'/'.')))
the expression with relevant ASCII values then it would be something like (char)(($>>+(~42&35))+(60>>(92/46)))
. This is equivalent to (char)(c / 2 + 15)
. The final output of the simplified code would be something like below.class Sig{
public static void main(String...args){
for(int $:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".toCharArray())
System.out.print((char)($ / 2 + 15));
}
}
Now the mystery has been resolved. For loop take each of the characters from the string change its values according to the equation and prints it.
Why don’t you give it a try to write such a code with your favorite language and comment it down?
Warning: Don’t ever write this type of code in production repositories.
Comments
Post a Comment