端口扫描程序java实现
来源:互联网 发布:游戏程序员工资待遇 编辑:程序博客网 时间:2024/06/05 21:09
怎么样扫描计算机系统本地和远程的端口,监测其是打开还是关闭的在很多应用程序中都要用到,下面是用java实现的简单的端口扫描程序。
Source Code:
/*
* Created on 2005-3-22
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author whandey connect to me: whandey@163.com
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.io.*;
import java.net.*;
import java.util.*;
public class SocketPort {
public static void main(String[] args) {
String ip = "159.162.39.27";
String hostname = new String();
try{ //get the target ip address and hostname
InetAddress address = InetAddress.getByName(ip);
System.out.println(address);
hostname = address.getHostName();
System.out.println(hostname);
}
catch(UnknownHostException e)
{
System.out.println("Could not find "+ ip);
}
try
{ // creat the output file
PrintWriter fout = new PrintWriter( new FileWriter("PortInf.txt"));
fout.println("Information Of The Port On the " + hostname +"computer ");
fout.println();
// do ports scan
for(int nport = 25;nport < 30;++nport)
{
try
{
Socket s = new Socket(hostname,nport);
fout.println("The port " + nport + " is open!");
fout.println("Connected to "+ s.getInetAddress() + " on port " + s.getPort() + " from port "+ s.getLocalPort() + " of " + s.getLocalAddress());
//print the connected socket information
}
catch(IOException e)
{
fout.println("The port " + nport + " is closed!");
}
}
fout.close();
}
catch(IOException e){}
}
}
- 端口扫描程序java实现
- 端口扫描程序实现原理
- 端口扫描程序(java)
- 端口扫描程序(java)
- 端口扫描程序(java)
- 端口扫描程序(java)
- 端口扫描程序(java)
- 端口扫描程序[JAVA]
- java实现端口扫描
- c语言实现端口扫描程序
- 端口扫描程序
- JAVA端口扫描
- Java端口扫描
- 端口扫描原理,(java)UDP端口扫描
- 端口扫描程序nmap使用手册
- 端口扫描程序nmap使用手册
- 端口扫描程序nmap使用手册
- 易速端口扫描程序
- 第6章 .P89C669的端口,电源控制和外围设备[1-5]
- Oracle8i中使用Java语言来开发存储过程
- 第6章 .P89C669的端口,电源控制和外围设备[6-9]
- 用Soap Toolkit调用WebService的一个问题
- 用Wing IDE 看wxPython DEMO的源码,
- 端口扫描程序java实现
- 关于JAVA加密的例子
- 取得光标在多行textbox中的行和列
- 知道了一个几年前就碰到没有解决的问题
- [原创]MASM32新手指南
- 用户控件--控制一个文本框只允许输入固定多个字符(按照字节计算)
- .net中Socket的使用不再用Winsock,而是.......请看详细内容
- 在VB.NET环境下如何判断INsert,NumLock等键盘的状态。
- 在richtextbox中每行输入字符数量的限制。(不完全!)