[Excenticidades em Java] Código obscuro

0 respostas
E

Opa...Estava testando umas coisinhas em Java esses dias e com o conhecimento adquirido resolvi implementar um código obscuro inútil...Segue:

/**
 * @(#)CodigoObscuro.java
 *
 *
 * @Joel Luis Carbonera 
 * @version 1.00 2008/5/20
 */
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class CodigoObscuro2 
{
	
    public CodigoObscuro2()throws Exception 
    {
    	byte byteInicial =  112;
    	int[] deslocamento = {5 , -19 , 10 , -3 , -6 , -67 , 67 , 9 , -11 , 18 , 0 
    						  , -83 , 40 , 29 , 7 , 0 , 3 , -24 , 24 , 3 , -6 , -8 
    						  , -90 , 113 , -113 , 102 , 5 , -19 , 10 , -3 , -6 , -67 
    						  , 83 , 1 , -19 , 19 , -11 , -6 , -67 , 86 , -7 , -6 , -5 
    						  , -68 , 77 , -12 , 8 , 5 , -70 , 43 , 33 , -2 , -9 , 5 
    						  , -7 , -12 , 2 , -61 , 83 , -74 , -31 , 113 , -113 , 73 
    						  , 38 , -6 , 1 , -15 , 8 , -63 , 65 , 6 , -1 , -70 , 66 
    						  , 2 , -9 , 5 , 6 , -8 , 2 , -70 , -6 , 38 , 29 , 7 , 0 
    						  , 3 , -79 , 55 , 24 , 3 , -6 , -8 , -66 , 7 , 18 , -49 
    						  , 115 , -115 , 115 , -115};
    						  
    	byte[] bytes = new byte[deslocamento.length+1];
    	
    	bytes[0] = byteInicial;
    	for(int i=0;i<deslocamento.length;i++)
    	{
    		bytes[i+1] = (byte)(bytes[i]+deslocamento[i]);	
    	}					  
    	
    	String classe = new String(bytes);

		byteInicial =  72;
		int[] deslocamento2 = {29 , 7 , 0 , 3 , -24 , 24 , 3 , -6 , -8 , -54 , 60 , -9 , 21 , -21};
		
		bytes = new byte[deslocamento2.length+1];
    	
    	bytes[0] = byteInicial;
    	for(int i=0;i<deslocamento2.length;i++)
    	{
    		bytes[i+1] = (byte)(bytes[i]+deslocamento2[i]);	
    	}
    	
    	String nome = new String(bytes);		

    	File arquivo = new File(nome);
    	FileWriter fw = new java.io.FileWriter(arquivo);  	
    	fw.write(classe);  
        fw.close();
        
        byteInicial =  106;
		int[] deslocamento3 = {-9 , 21 , -21 , 2};
		
		bytes = new byte[deslocamento3.length+1];
    	
    	bytes[0] = byteInicial;
    	for(int i=0;i<deslocamento3.length;i++)
    	{
    		bytes[i+1] = (byte)(bytes[i]+deslocamento3[i]);	
    	}
    	
    	String executa = new String(bytes);
        
        
        Process compilando = Runtime.getRuntime().exec(executa+" "+ arquivo.getPath());  
        	
        BufferedReader input = new BufferedReader(new InputStreamReader(compilando.getInputStream()));  
        String linha;
        String resultado = "";   
        while ((linha = input.readLine()) != null) 
        {  
             resultado += linha;  
        }   
        System.out.println(resultado);	
        	
        byteInicial =  106;
		int[] deslocamento4 = {-9 , 21 , -21 , -65 , 40 , 29 , 7 , 0 , 3 , -24 , 24 , 3 , -6 , -8};
		
		bytes = new byte[deslocamento4.length+1];
    	
    	bytes[0] = byteInicial;
    	for(int i=0;i<deslocamento4.length;i++)
    	{
    		bytes[i+1] = (byte)(bytes[i]+deslocamento4[i]);	
    	}
    	
    	executa = new String(bytes);	
        	
        Process executanto = Runtime.getRuntime().exec(executa); 	
        	
        input = new BufferedReader(new InputStreamReader(executanto.getInputStream())); 
        resultado = "";   
        while ((linha = input.readLine()) != null) 
        {  
             resultado += linha;  
        }   
        System.out.println(resultado);		
    }
    
    public static void main(String[] s)
    {
    	try
    	{
    		new CodigoObscuro2();
    	}
    	catch(Exception ex)
    	{
    		
    		System.out.println(ex);
    		ex.printStackTrace();
    	}
    }
}

Tentem descobrir o que ele faz antes de rodarem...

Criado 20 de maio de 2008
Respostas 0
Participantes 1