Results 1 to 11 of 11
  1. #1
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default [ask] help me, please

    Hi all
    Greetings from me, dadu
    Can we create a socket port scanning with methods like this?
    :confused:


    because so far, I make it just like this :

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    
    
    public class MySocket{
        private JFrame frame = new JFrame();
        private JLabel LabelIp,LabelFirs,LabelLast;
        private JTextField txtIp,txtFirsPort,txtLastPort;
        private JButton btnPort,btnExit;
        private JTextArea Scanning;
        static int ulang;
        public void buatTampilan(){
            LabelIp = new JLabel("IP : ");
            LabelIp.setSize(LabelIp.getPreferredSize());
            LabelIp.setLocation(20,20);
    
            txtIp = new JTextField(20);
            txtIp.setSize(txtIp.getPreferredSize());
            txtIp.setLocation(100,20);
    
            LabelFirs = new JLabel("firs port : ");
            LabelFirs.setSize(LabelFirs.getPreferredSize());
            LabelFirs.setLocation(20,60);
    
            txtFirsPort = new JTextField(20);
            txtFirsPort.setSize(txtFirsPort.getPreferredSize());
            txtFirsPort.setLocation(100,60);
    
            LabelLast = new JLabel("Last Port : ");
            LabelLast.setSize(LabelLast.getPreferredSize());
            LabelLast.setLocation(20,100);
    
            txtLastPort = new JTextField(20);
            txtLastPort.setSize(txtLastPort.getPreferredSize());
            txtLastPort.setLocation(100,100);
    
            btnPort = new JButton("Scan");
            btnPort.setSize(btnPort.getPreferredSize());
            btnPort.setLocation(20,140);
            btnPort.setMnemonic('S');
    
            btnExit = new JButton("Exit");
            btnExit.setSize(btnExit.getPreferredSize());
            btnExit.setLocation(100,140);
            btnExit.setMnemonic('K');
    
            Scanning = new JTextArea(20,25);
            Scanning.setLocation(20,180);
    
        }
    
        public void CreateGui(){
    
            frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
            frame.setLayout(new FlowLayout());
            frame.setTitle("Port Scanning");
            frame.getContentPane().add(LabelIp);
            frame.getContentPane().add(txtIp);
            frame.getContentPane().add(LabelFirs);
            frame.getContentPane().add(txtFirsPort);
            frame.getContentPane().add(LabelLast);
            frame.getContentPane().add(txtLastPort);
            frame.getContentPane().add(btnPort);
            frame.getContentPane().add(btnExit);
            frame.getContentPane().add(Scanning);
            frame.setSize(320,500);
            frame.setVisible(true);
    
            btnPort.addActionListener(new ActionListener(){
            private String varIp,varPortAwal,varPortAkhir,textlamabener;
            private int jumlahIp,jumlahPortAwal,jumlahPortAkhir;
            int po_a,po_b;
                public void actionPerformed(ActionEvent a){
    
                    varIp = txtIp.getText();
                    varPortAwal = txtFirsPort.getText();
                    varPortAkhir = txtLastPort.getText();
    
                    po_a = Integer.parseInt(varPortAwal);
                    po_b = Integer.parseInt(varPortAkhir);
    
                    jumlahIp = varIp.length();
                    jumlahPortAwal = varPortAwal.length();
                    jumlahPortAkhir = varPortAkhir.length();
    
                        if(jumlahIp > 0){
                            if(jumlahPortAwal > 0){
                                if(jumlahPortAkhir > 0){
    
                                    for(ulang=po_a;ulang<=po_b;ulang++){
                                        mulai(varIp,ulang);
                                    }
                                    textlamabener = Scanning.getText();
                                    Scanning.setText(textlamabener + "\n Scanning");
    
                                }else{
                                    JOptionPane.showMessageDialog(null,"Last Port is empty");
                                }
                            }else{
                                JOptionPane.showMessageDialog(null,"Firs Port is empty");
                            }
                        }else{
                            JOptionPane.showMessageDialog(null,"Ip is empty");
                        }
    
    
                }
    
            });
    
            btnExit.addActionListener(new ActionListener(){
    
                public void actionPerformed(ActionEvent e){
                    System.exit(1);
                }
    
            });
        }
        public void mulai(String IP,int ulang){
        String textLama,textLm;
        String strPort;
            try{
    
                    textLama = Scanning.getText();
                    strPort = Integer.toString(ulang);
                    Scanning.setText(textLama + "Port . . .");
    
                    Socket gw = new Socket(IP,ulang);
                    textLm = Scanning.getText();
                    Scanning.setText(textLm + strPort + " Connected \n");
    
            }catch(Exception aku){
    
                textLama = Scanning.getText();
                strPort = Integer.toString(ulang);
                Scanning.setText(textLama + strPort +" Not Connected \n");
    
            }
    
        }
    
        public static void main(String[] args){
            MySocket j = new MySocket();
            j.buatTampilan();
            j.CreateGui();
    
        }
    }
    if it can, I really hope anyone can teach me to make it. because I have already tried and find references but it's not success.

    thank you
    Last edited by dadu; 04-06-2011 at 08:37 PM.

  2. #2
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    anyone can help me

  3. #3
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    Please help.... :(

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  5. #5
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    What you really want to do?
    of course, please help me..:(
    and I am very thankful if anyone help me..

  6. #6
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    had done this many times I tried it, but not success
    is there anything that can and want to help me?

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  8. #8
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    ooh sorry... :)
    I want to make port scanning as my picture above

  9. #9
    dadu is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    anyone can help me?

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by dadu View Post
    anyone can help me?
    For god's sake, please stop begging and tell us specifically what isn't working. Until you do, it is unlikely anyone will help you since they have no idea how to help you.

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Tags for this Thread

Posting Permissions

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