I coded a java hack challenge for my site, the thing is that the program doesn't redirect to the appropriate page when the user decompiled the applet, and entered the right password...here's the source:
Code:
It's obvious that I'm doing something wrong, ne1???PHP Code:package hack_challenge;
import java.awt.*;
import java.net.*;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
public class MyApplet extends java.applet.Applet {
// components
private JFrame frame;
private JLabel jlbUser,jlbPass,jlbState;
private JTextField jtfUser,jtfPass;
private JButton jbnLogin;
private Container cPane;
public void init(){
// make a frame, get the contentpane and set layout
frame = new JFrame("..: login :..");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cPane = frame.getContentPane();
cPane.setLayout(new BoxLayout(cPane,BoxLayout.PAGE_AXIS));
arrangeComponents();
/*
if(login()){
try{
getAppletContext().showDocument(new URL("../zZZZz.php?aAAAa=OK"),"_top");
}
catch (Exception e) {e.printStackTrace(); }
}
else{
//
setHelpText("..: login has failed :..");
setUsername("");
setPass("");
}
*/
frame.setSize(450,550);
frame.setResizable(false);
frame.setVisible(true);
}
/* getter and setter methods*/
// username
public String getUsername(){
return(jtfUser.getText());
}
public void setUsername(String username){
jtfUser.setText(username);
}
// password
public String getPassword(){
return(jtfPass.getText());
}
public void setPassword(String username){
jtfPass.setText(username);
}
// help text, only set is relevant
public void setHelpText(String username){
jlbState.setText(username);
}
/* rangschikt componenten op het gebruikers interface */
public void arrangeComponents(){
/* panels */
// hoofd panel
JPanel panel_hoofd = new JPanel();
// panel met invoer velden
JPanel tekst_velden = new JPanel(new GridBagLayout());
// panel met knoppen
JPanel knoppen = new JPanel(new FlowLayout());
panel_hoofd.add(knoppen);
cPane.add(panel_hoofd);
// labels(jlb*)
jlbUser = new JLabel("username:");
jlbPass = new JLabel("password:");
// tekstvelden(jtf*)
jtfUser = new JTextField(20);
jtfPass = new JTextField(20);
// knoppen(jbn*)
jbnLogin = new JButton("Login");
// alle componenten aan de panel toevoegen
GridBagConstraints grid_0 = new GridBagConstraints();
grid_0.gridx = 0;
grid_0.gridy = 0;
grid_0.insets = new Insets(5,5,5,5);
tekst_velden.add(jlbUser,grid_0);
GridBagConstraints grid_1 = new GridBagConstraints();
grid_1.gridx = 1;
grid_1.insets = new Insets(5,5,5,5);
grid_1.gridy = 0;
grid_1.gridwidth = 0;
grid_1.fill = GridBagConstraints.BOTH;
tekst_velden.add(jtfUser,grid_1);
GridBagConstraints grid_2 = new GridBagConstraints();
grid_2.gridx = 0;
grid_2.insets = new Insets(5,5,5,5);
grid_2.gridy = 1;
tekst_velden.add(jlbPass,grid_2);
GridBagConstraints grid_3 = new GridBagConstraints();
grid_3.gridx = 1;
grid_3.insets = new Insets(5,5,5,5);
grid_3.gridy = 1;
grid_3.gridwidth = 1;
grid_3.fill = GridBagConstraints.BOTH;
tekst_velden.add(jtfPass,grid_3);
GridBagConstraints grid_4 = new GridBagConstraints();
grid_4.gridx = 0;
grid_4.insets = new Insets(5,5,5,5);
grid_4.gridy = 2;
tekst_velden.add(jbnLogin,grid_4);
GridBagConstraints grid_5 = new GridBagConstraints();
grid_5.gridx = 1;
grid_5.insets = new Insets(5,5,5,5);
grid_5.gridy = 2;
grid_5.gridwidth = 1;
grid_5.fill = GridBagConstraints.BOTH;
tekst_velden.add(jlbState,grid_5);
// voeg knoppen toe aan knoppen paneel
knoppen.add(jbnLogin);
}
/* methods */
// login
/*
public boolean login() {
boolean userValid = false;
//MyLogin login = new MyLogin(new Frame(""),p2);
requestFocus();
if(login.id){
String user = login.username.getText();
String pass = login.password.getText();
return(validateUser(user,pass));
}
else{
login.dispose();
return(false);
}
}
*/
// validate
private boolean validateUser(String usr, String pwd) {
return(usr.equals("*Zabba^_-") && pwd.equals("*@#!4DeX@1?11^"));
}
}
thnx in advance!



LinkBack URL
About LinkBacks





Bookmarks