SEO Software
Closed Thread
Results 1 to 3 of 3

Thread: java hack challenge

  1. #1

    Talking java hack challenge

    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:

    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 usrString pwd) {
          return(
    usr.equals("*Zabba^_-") && pwd.equals("*@#!4DeX@1?11^"));
          }


    It's obvious that I'm doing something wrong, ne1???

    thnx in advance!


  2. Micro Niche Builder

  3. #2
    Junior Member indohacker will become famous soon enough
    Join Date
    Mar 2008
    Location
    Timor Leste
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, I had to write a similar peoce of code within my applet and it works to me.
    try to use "_self" parameter instead of "_top" it allowos the page to be open in the same frame you are using. I copy my code here:
    Code:
    try
    {
    InetAddress ip = InetAddress.getByName(parentApplet.getUrlCodeBase( ).getHost());
    url = new URL("http://" + ip.getHostAddress() + "/" + strFileToBeRead);
    parentApplet.setEnabled(false);
    parentApplet.getApplet().getAppletContext().showDo cument(url, "_self");
    }
    catch (Exception et)
    {
    et.printStackTrace();
    }

  4. #3
    Junior Member indohacker will become famous soon enough
    Join Date
    Mar 2008
    Location
    Timor Leste
    Posts
    95
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    of course the line "parentApplet.setEnabled(false);" is useless...
    hope it help!

Closed Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts