你试试这个命令
tracert www.163.com
tracert www.163.com
解决方案 »
- 一个关于截取字符串的问题,请大家帮帮忙!
- 请问下如何在已有swing class的基础上 建一个新的页面,但是多一个button 而不需要重复写code!! 谢谢
- 跪求大侠告知,jta20.jar的使用方法,我就想用它的telnet服务嵌到界面中去!多谢多谢!
- 怎样在键盘按下-----松开间实现计时
- 请教:使用ServerSocketChannel的TCP服务器问题
- 菜鸟请教:cmp的find方法和select方法有什么区别?使用场合的区别是怎样?
- 想找工作的朋友过来看看
- 本人菜鸟,无JAVA基础,自学一个月,请教一个问题
- 怎样把String转换成int?怎样获得系统时间并转换成java.sql.date类型?
- 报表打印
- 100分相送!! 为什么我的jb提示说找不到 java.io.* ?
- 请问各位平时说的JDK DOCUMENT指的是什么?
ip,包,端口。。是这个问题的结果吗?
其他的工具有好多
you can install protocol: Network Monitor Dirver
and install 网络监视工具 on w2k install if you want to program it by yourself,
you must write a spi dll and register it to winsock2 spi level
可是java真的不能实现吗??-------------
期待中……
我曾问了一个做sniffer的人
他是在linux下用c写的
而且核心部分用的还是老外的东西
------------------------
还在期待。
----------------------------------------
==================================================================
注意:此人因发表爱国言论,被斑竹hexiaofen*扣除6分信誉分,问你死未?!*****************************************************************
直接获得,或者通过其他的方法间接获得这些信息,比如snmp ldap 等等,
后者其实也是通过底层的程序获得信息,然后把相关的信息存储在本地的某种类型的数据库中,比如snmp Agent和ldap维护的数据库中,然后在提取。
这几种方法都是通过其他途径来获得信息的。
我不知道
网卡物理地址在全球是唯一不重复的,所以有时我们需要得到一个计算机的网卡物理地址来确认用户身份,下面我编写了一个GetPhysicalAddress类来获得当前计算机的网卡物理地址,此方法只能获取win2k系统的网卡物理地址
,不能用于其他操作系统。 众所周知,在win2k下的shell环境里,我们可以使用ipconfig/all命令查看当前网卡配置情况,其中有一项是网卡的物理地址。例如在DOS环境中输入 ipconfig/all命令,结果如下: Host Name . . . . . . . . . . . . : mars
Primary DNS Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : worksoft.com.cnPPP adapter 263: Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : WAN (PPP/SLIP) I
Physical Address. . . . . . . . . : 00-53-45-00-00-0
DHCP Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 61.135.2.27
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 61.135.2.27
DNS Servers . . . . . . . . . . . : 202.106.196.152
202.106.196.115
加粗部分是网卡的物理地址我们只要在java中执行这个外部命令,然后把需要的字符串解析出来就可以得到当前机器的物理网卡地址了。
首先编写一个Util_syscmd类,方法execute()使我们能够执行外部命令,并返回一个Vector类型的结果集。
import java.lang.*;
import java.io.*;
import java.util.*;/**
* @author Jackliu
*
*/
public class Util_syscmd{ /**
* @param shellCommand
*
*/
public Vector execute(String shellCommand){
try{
Start(shellCommand);
Vector vResult=new Vector();
DataInputStream in=new DataInputStream(p.getInputStream());
BufferedReader reader=new BufferedReader(new InputStreamReader(in)); String line;
do{
line=reader.readLine();
if (line==null){
break;
}
else{
vResult.addElement(line);
}
}while(true);
reader.close();
return vResult; }catch(Exception e){
//error
return null;
}
}
/**
* @param shellCommand
*
*/
public void Start(String shellCommand){
try{
if(p!=null){
kill();
}
Runtime sys= Runtime.getRuntime();
p=sys.exec(shellCommand);
}catch(Exception e){
System.out.println(e.toString());
}
}
/**
kill this process
*/
public void kill(){
if(p!=null){
p.destroy();
p=null;
}
}
Process p;
}
然后设计一个GetPhysicalAddress类,这个类用来调用Util_syscmd类的execute()方法,执行cmd.exe/c ipconfig/all命令,并解析出网卡物理ip地址。getPhysicalAddress()方法返回网卡的物理地址,如果机器中没有安装网卡或操作系统不支持ipconfig命令,返回not find字符串
import java.io.*;
import java.util.*;class GetPhysicalAddress{
//网卡物理地址长度
static private final int _physicalLength =16;
public static void main(String[] args){
//output you computer phycail ip address
System.out.println(getPhysicalAddress());
}
static public String getPhysicalAddress(){
Util_syscmd shell =new Util_syscmd();
String cmd = "cmd.exe /c ipconfig/all";
Vector result ;
result=shell.execute(cmd);
return parseCmd(result.toString());
}
//从字符串中解析出所需要获得的字符串
static private String parseCmd(String s){
String find="Physical Address. . . . . . . . . :";
int findIndex=s.indexOf(find);
if (findIndex==-1)
return "not find";
else
return s.substring(findIndex+find.length()+1,findIndex+find.length()+1+_physicalLength);
}
}
http://www.csdn.net/expert/topic/1029/1029550.xml?temp=.168606
to: luoxxhh(雨夜孤狼)
谢谢你。
不过这段代码我以前看过,
只是原先没什么感触,现在我突发奇想,
可以用类似的方法,
调用cmd下的netstat命令。
不过还是不能抓包。。