[问题]一个JAVA程序

苦逼热狗

路边通讯社社长
VIP
注册
2002-10-12
消息
47,114
荣誉分数
2,376
声望点数
393
有这么一个程序,如何才能推算出来正确的未知值呢

public class Program{

private static String hash(String s)
{
String s1 = "";
int i = 0;
for(int j = 0; j < s.length(); j++)
{
i = (s.charAt(j) * (j + i + 3) + 17) % 676;
s1 = s1 + "" + (char)(i % 26 + 65);
s1 = s1 + "" + (char)(i / 26 + 65);
}

return s1;
}

public static void main(String args[]){
String s = "未知值";
s = hash(s);
if(s.compareTo("CMZQHWEOTJKMPX") == 0)
{
System.out.println("correct!");
} else
{
System.out.println("wrong");
}
}
}
 
if the hash function is correct, then according to the principle of cryptography, it is impossible to get the initial value.
 
the hash function is correct

CMZQHWEOTJKMPX

代码:
 C  Z  H  E  T  K  P
67 90 72 69 84 75 80
-------------------------
77 81 87 79 74 77 88
 M  Q  W  O  J  M  X
[-65]
12 16 22 14  9 12 23
[*26]
312 416 572 364 234 312 598
it will encrypt a 14 length string into 28 length string.
the problem is I have no idea how to solve the i = (s.charAt(j) * (j + i + 3) + 17) % 676;
i,j is there, but how to get the value of s.charAt(j)
312=(s.charAt(0)*3+17)%676

well, I dont' really think I am right on above personal thinking

here is the challenge page
http://www.icefortress.com/guests/challenges/java2/level8TbSd3.html

here is the decomplied source code:
代码:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URL;

public class level8TbSd3 extends Applet
    implements ActionListener
{

    private Button SubmitButton;
    private TextField PasswordField;

    public level8TbSd3()
    {
        SubmitButton = new Button();
        PasswordField = new TextField("", 8);
    }

    public void init()
    {
        SubmitButton.setLabel("submit");
        SubmitButton.addActionListener(this);
        PasswordField.setEchoChar('*');
        PasswordField.setForeground(new Color(192, 192, 192));
        add(PasswordField);
        add(SubmitButton);
        setBackground(new Color(0, 0, 0));
    }

    public void start()
    {
    }

    public void stop()
    {
    }

    public void destroy()
    {
    }

    public void actionPerformed(ActionEvent actionevent)
    {
        String s = PasswordField.getText();
        String s1 = "";
        String s2 = getDocumentBase().toString();
        s2 = s2.substring(0, s2.lastIndexOf('/') + 1);
        String s3 = decrypt("lewfn:P3JxnO/htmm", s);
        s = hash(s);
        if(s.compareTo("CMZQHWEOTJKMPX") == 0)
        {
            s1 = s2 + s3;
        } else
        {
            s1 = s2 + "doh.html";
        }
        try
        {
            getAppletContext().showDocument(new URL(s1));
        }
        catch(Exception exception)
        {
            exception.printStackTrace();
        }
    }

    private static String decrypt(String s, String s1)
    {
        String s2 = "";
        for(; s1.length() < s.length(); s1 = s1 + s1) { }
        for(int i = 0; i < s.length(); i++)
        {
            s2 = s2 + "" + (char)(s.charAt(i) - s1.charAt(i) % 3);
        }

        return s2;
    }

    private static String hash(String s)
    {
        String s1 = "";
        int i = 0;
        for(int j = 0; j < s.length(); j++)
        {
            i = (s.charAt(j) * (j + i + 3) + 17) % 676;
            s1 = s1 + "" + (char)(i % 26 + 65);
            s1 = s1 + "" + (char)(i / 26 + 65);
        }

        return s1;
    }
}
 
well, I just solved the problem
Thanks for the help
 
oh, men , u hacking, I will think about this code as i have time, i have 2 midterms this week.
 
lol, fine, whatever you wanna say. That's a really good challenge game.
ICE provided 3 kinds of challenges to public, easy for newbie, middle level in JAVA and one for reversing engineer.

and for the decomplie .class file part, you can also try google that's the best search engine in the world currently.
you might wanna use this one which is the one that I am using. It's a FREE software. http://www.bysoft.se/sureshot/cavaj/index.html

Tutorial:Wireless Attacks Explained
http://www.astalavista.com/library/wlan/wlansecurity.htm

Introduction to Reverse Engineering Software
http://www.acm.uiuc.edu/sigmil/RevEng/
 
后退
顶部