當前位置:首頁 » 編程語言 » java埠掃描

java埠掃描

發布時間: 2024-01-12 06:21:21

㈠ 有沒有用java代碼操作nmap進行過埠掃描的

nmap埠狀態解析

open , 應用程序在該埠接收 TCP 連接或者 UDP 報文。

closed 關閉的埠對於nmap也是可訪問的, 它接收nmap探測報文並作出響應。但沒有應用程序在其上監聽。

filtered 由於包過濾阻止探測報文到達埠,nmap無法確定該埠是否開放。過濾可能來自專業的防火牆設備,路由規則 或者主機上的軟體防火牆。

unfiltered 未被過濾狀態意味著埠可訪問,但是nmap無法確定它是開放還是關閉。 只有用於映射防火牆規則集的 ACK 掃描才會把埠分類到這個狀態。

㈡ 請教大神,怎麼使用java實現UDP埠掃描

給你個UDP服務端與客戶端的示例:

服務端代碼:


importjava.net.DatagramPacket;
importjava.net.InetAddress;
importjava.net.MulticastSocket;

publicclassUDPMulticastServer{
finalstaticintRECEIVE_LENGTH=1024;

staticStringmulticastHost="224.0.0.1";

staticintlocalPort=9998;

publicstaticvoidmain(String[]args)throwsException{

InetAddressreceiveAddress=InetAddress.getByName(multicastHost);

if(!receiveAddress.isMulticastAddress()){//測試是否為多播地址

thrownewException("請使用多播地址");

}

intport=localPort;

=newMulticastSocket(port);

receiveMulticast.joinGroup(receiveAddress);


booleanisStop=false;
while(!isStop){
DatagramPacketdp=newDatagramPacket(newbyte[RECEIVE_LENGTH],RECEIVE_LENGTH);
receiveMulticast.receive(dp);
Stringdata=newString(dp.getData()).trim();
System.out.println(data);
if("exit".equals(data)){
System.out.println("程序退出");
isStop=true;
}
}

receiveMulticast.close();
}
}

客戶端代碼:


importjava.net.DatagramPacket;
importjava.net.InetAddress;
importjava.net.MulticastSocket;

publicclassUDPMulticastClient{
staticStringdestAddressStr="224.0.0.1";

staticintdestPortInt=9998;

staticintTTLTime=4;

publicstaticvoidmain(String[]args)throwsException{ InetAddressdestAddress=InetAddress.getByName(destAddressStr);

if(!destAddress.isMulticastAddress()){//檢測該地址是否是多播地址

thrownewException("地址不是多播地址");

}

intdestPort=destPortInt;


MulticastSocketmultiSocket=newMulticastSocket();

// intTTL=TTLTime;
// multiSocket.setTimeToLive(TTL);

byte[]sendMSG="exit".getBytes();

DatagramPacketdp=newDatagramPacket(sendMSG,sendMSG.length,destAddress,destPort);

multiSocket.send(dp);

multiSocket.close();

}

}
熱點內容
伺服器是物理機域名怎麼備案 發布:2025-08-27 15:20:50 瀏覽:533
購買電腦伺服器 發布:2025-08-27 15:18:42 瀏覽:304
四川金星壓縮機 發布:2025-08-27 15:18:27 瀏覽:257
ftp命令解壓 發布:2025-08-27 15:15:15 瀏覽:417
ps3游戲怎麼解壓 發布:2025-08-27 15:10:12 瀏覽:456
bxp伺服器怎麼換ip 發布:2025-08-27 14:55:16 瀏覽:766
安卓反編譯apk工具中文版 發布:2025-08-27 14:44:17 瀏覽:464
我的世界純伺服器生存 發布:2025-08-27 14:44:15 瀏覽:437
sqlin的效率 發布:2025-08-27 14:26:21 瀏覽:255
如何把我的世界網易伺服器卡炸 發布:2025-08-27 14:10:54 瀏覽:456