Skip to main content

Weird Encoded Java Code and How It Works

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)\*\u002Fsection 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

Popular posts from this blog

Database Internel Architecture: SQLite

Introduction A database is an essential part of building a software system which used to store and read data efficiently. Here, We are going to discuss some architectural details of database implementation by using an early version of SQLite. SQLite is a small database application which used in millions of software and devices. SQLite invented by D.Richard Hipp in August 2000. SQLite is a high performance, lightweight relational database. If you are willing to learn internal of a database in coding level, then SQLite is the best open source database available out there with highly readable source code with lots of documentation. Reading later versions of SQLite become a little harder since it contains lots of new features. In order to understand the basic implementation of database internals, You should have good knowledge about data structures, some knowledge about Theory of Computing and how an operating system works. Here we are looking into the SQLite 2.5.0 version. Here

Weird Programming Languages

There are thousands of programming languages are invented and only about hundred of programming languages are commonly used to build software. Among this thousands of programming languages, there are some weird type of programming languages can be also found. These programming languages are seems to be called weird, since their programming syntax and the way it represent its code. In this blog we will look into some of these language syntax. Legit Have you ever wonder, when you come to a Github project that print hello world program, but you cannot see any codes or any content. Check this link  https://github.com/blinry/legit-hello  and you will see nothing in this repository. But trust me, there is hidden code in this project. If you see the  commit  section, you can reveal the magic. Yeah, you are right. Its storing hello world code in inside the git commit history. If you clone this project and run the following command, then you can see the hidden code in this project. g

Basic Concepts of the Kubernetes

Handling large software which has multiple services is a tedious, time-consuming task for DevOps engineer. Microservices comes into the rescue DevOps engineers from all these complicated deployment processes. Simply, each microservice in the system has it own responsibility to handle one specific task. The container can be used to deploy each of these micro-tasks as a unit of service. If you are not that familiar with Containers, read this article to get to know about Docker, Which is the most popular and widely used container technology to deploy microservices. As I described early, we can use single container to deploy a single service and container contain all required configurations and dependencies. Single service always faces a common problem of a single point of failure. In order to avoid single point failure, we need to set up another service such that if one service is getting down, next available service takes that load and continue to provide the service. Another requi