⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jmapfe.java

📁 优秀的内网子机及端口嗅探器(附java代码).JMap is a Java network port scanner, a security tool to identify open ports o
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			scanButton.setToolTipText("Start Scanning");		}		else{			scanButton.setText("Stop");			scanButton.setToolTipText("Stop Scanning");		}	}	class Scanning extends Thread implements Observer{		JDialog progressDialog; //dialog to show progress bar		JProgressBar progress;		JPanel dialogPanel;		JLabel portDescription;		Scanning(){			enableInputs(false);			resultsText.setText("");			//get subnet			String subnet;			if (subnetOption.isSelected()){				subnet = subnetInput.getText();			}			else{				subnet = null;			}			if (hostnameInput.getText().length() == 0){				resultsText.setText("You have not entered a hostname\n"									+ "YOU FOOL!!!\n");				enableInputs(true); //reactivate the inputs				return; //they havent entered a hostname			}			try{				if (portsSelected.isSelected()){					scan = new Scan(hostnameInput.getText(), 								  subnet,								  Integer.parseInt(lowestPortInput.getText()), 								  Integer.parseInt(highestPortInput.getText()));				}				else if (scanSubnetForOption.isSelected()){					//work out what part number has been selected					String selectedPortName = 								 (String)scanSubnetForCombo.getSelectedItem();					int selectedPortNumber = Integer.parseInt(											selectedPortName.substring(0, 											   selectedPortName.indexOf(' ')));					scan = new Scan(hostnameInput.getText(), 								  subnet,								  selectedPortNumber,								  selectedPortNumber);				}				else{					scan = new Scan(hostnameInput.getText(), subnet);				}			}			catch(Exception e){				resultsText.setText(e.getMessage());				enableInputs(true);				scan = null;				return;			}			//add this as one of the observers of scan			scan.addObserver(this);			//setup progress dialog - set non-model			progressDialog = new JDialog(frame, "Scanning....", false);			progressDialog.addWindowListener(new DialogWindowListener());			dialogPanel = new JPanel(new BorderLayout());			progress = new JProgressBar(0, scan.getNumberPorts());			portDescription = new JLabel(					"_____________________PLEASE WAIT_______________________");					//forces a wider progress window			//add swing components			progressDialog.getContentPane().add(dialogPanel);			progressDialog.setBounds(FRAME_WIDTH/10, FRAME_HEIGHT/4, 									 FRAME_WIDTH/2, FRAME_HEIGHT/4);			dialogPanel.add(portDescription, BorderLayout.NORTH);			dialogPanel.add(stopProcessButton, BorderLayout.SOUTH);			dialogPanel.add(progress, BorderLayout.CENTER);			progressDialog.pack();		}		public void update(Observable o, Object arg){			if (arg instanceof Integer){				//we should update our progress by this number				progress.setValue( progress.getValue() +								 ((Integer)arg).intValue() );				return;			}			else{				//increment the progress bar's value				progress.setValue(progress.getValue()+1);				portDescription.setText((String)arg);			}		}		public void run(){			if (scan == null){				return;			}			progressDialog.setVisible(true);			progress.setStringPainted(true);			progress.setValue(0);			// if UDP scanning, warn of length of time			if (scanUDPOption.isSelected()){				resultsText.setText(					"UDP Scanning takes some time\n" +					"go have a coffee :)\n");			}			resultsText.setText( "\n" + scan.scan(											 scanTCPOption.isSelected(), 											 scanUDPOption.isSelected()));			enableInputs(true);			progressDialog.setVisible(false);		}		public void destroy(){			scan.stop();		}		//handles this dialog window closing		class DialogWindowListener extends WindowAdapter{			public void windowClosing(WindowEvent e){				scanButton.setText("Halting");				stopProcessButton.setText("Halting");				sh.destroy();			}		}	}	class JMapFEWindowAdapter extends WindowAdapter{		public void windowClosing(WindowEvent e){			System.exit(0); //kill everything		}	}	class JMapFEActionListener implements ActionListener{		public void actionPerformed(ActionEvent e){			String action = e.getActionCommand();			if (action.equals(scanButton.getText())){				if (action.equals("Stop")){					scanButton.setText("Halting");					stopProcessButton.setText("Halting");					sh.destroy();				}				else{					sh = new Scanning();					sh.start();				}			}			else if (action.equals(quitButton.getText())){				System.exit(0); //quit			}			else if (action.equals(portsSelected.getText())){				lowestPortInput.setEditable(portsSelected.isSelected());				highestPortInput.setEditable(portsSelected.isSelected());				if (portsSelected.isSelected()){					//disable scanSubnetForOption					scanSubnetForOption.setSelected(false);					scanSubnetForCombo.setEnabled(false);				}			}			else if (action.equals(scanSubnetForOption.getText())){			  scanSubnetForCombo.setEnabled(scanSubnetForOption.isSelected());				if (scanSubnetForOption.isSelected()){					portsSelected.setSelected(false);					//disable port range, if necessary					lowestPortInput.setEditable(false);					highestPortInput.setEditable(false);				}			}			else if (action.equals(subnetOption.getText())){				subnetInput.setEditable(subnetOption.isSelected());				scanSubnetForOption.setEnabled(subnetOption.isSelected());				if (!subnetOption.isSelected()){					//if deselecting subnet scanning, disable scan subnet					//for server					scanSubnetForOption.setSelected(false);					scanSubnetForCombo.setEnabled(false); //disable combo				}			}			else if (action.equals(stopProcessButton.getText())){				scanButton.setText("Halting");				stopProcessButton.setText("Halting");				sh.destroy();			}			else{				//System.err.println("Unknown action: " + action);			}		}	}	class JMapFEKeyAdapter extends KeyAdapter{		public void keyPressed(KeyEvent e){			if (e.getKeyCode() == KeyEvent.VK_ENTER){				sh = new Scanning();				sh.start();			}		}	}	class JMapFEMenuListener implements ActionListener {		public void actionPerformed(ActionEvent e){			String event = e.getActionCommand();			if (event.equals(scanMenuItem.getText())){				sh = new Scanning();				sh.start();			}			else if (event.equals(exitMenuItem.getText())){				System.exit(0);			}			else if (event.equals(usageMenuItem.getText())){				resultsText.setText(getUsage());			}			else if (event.equals(aboutMenuItem.getText())){				resultsText.setText("JMap - GNU Java Port Scanner\n"						   + "written by Tom Salmon tom@slashtom.org\n"						   + "http://slashtom.org\n\n"+ "This program is free software; you can redistribute it and/or\n"+ "modify it under the terms of the GNU General Public License\n"+ "as published by the Free Software Foundation; version 2.\n"+ "\n"+ "This program is distributed in the hope that it will be useful,\n"+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"+ "GNU General Public License for more details.\n"+ "\n"+ "You should have received a copy of the GNU General Public License\n"+ "along with this program; if not, write to the Free Software\n"+ "Foundation, Inc., 59 Temple Place - \n"+ "Suite 330, Boston, MA  02111-1307, USA.");			}			else if (event.equals(versionMenuItem.getText())){				resultsText.setText("JMap - " + version + "\n");			}			else if (event.equals(bugsMenuItem.getText())){				resultsText.setText("JMap\n\n" +									" Report bugs to: jmap@slashtom.org" +									"\n");			}			else {				//System.err.println("Unknown event: " + event);			}		}	}	public static void main(String [] args){		JMapFE jmap = new JMapFE();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -