当前位置:首页 > 代码 > 正文

ip伪装java代码(IP地址伪装)

admin 发布:2022-12-19 18:57 222


今天给各位分享ip伪装java代码的知识,其中也会对IP地址伪装进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

局域网在线扫描 IP,MAC Java源代码

1.得到局域网网段,可由自己机器的IP来确定 (也可以手动获取主机IP-CMD-ipconfig /all)

2.根据IP类型,一次遍历局域网内IP地址

JAVA类,编译之后直接运行便可以得到局域网内所有IP,具体怎样使用你自己编写相应代码调用便可

代码如下::

package bean;

import java.io.*;

import java.util.*;

public class Ip{

static public HashMap ping; //ping 后的结果集

public HashMap getPing(){ //用来得到ping后的结果集

return ping;

}

//当前线程的数量, 防止过多线程摧毁电脑

static int threadCount = 0;

public Ip() {

ping = new HashMap();

}

public void Ping(String ip) throws Exception{

//最多30个线程

while(threadCount30)

Thread.sleep(50);

threadCount +=1;

PingIp p = new PingIp(ip);

p.start();

}

public void PingAll() throws Exception{

//首先得到本机的IP,得到网段

InetAddress host = InetAddress.getLocalHost();

String hostAddress = host.getHostAddress();

int k=0;

k=hostAddress.lastIndexOf(“.”);

String ss = hostAddress.substring(0,k+1);

for(int i=1;i =255;i++){ //对所有局域网Ip

String iip=ss+i;

Ping(iip);

}

//等着所有Ping结束

while(threadCount0)

Thread.sleep(50);

}

public static void main(String[] args) throws Exception{

Ip ip= new Ip();

ip.PingAll();

java.util.Set entries = ping.entrySet();

Iterator iter=entries.iterator();

String k;

while(iter.hasNext()){

Map.Entry entry=(Map.Entry)iter.next();

String key=(String)entry.getKey();

String value=(String)entry.getValue();

if(value.equals(“true”))

System.out.println(key+“--”+value);

}

}

class PingIp extends Thread{

public String ip; // IP

public PingIp(String ip){

this.ip=ip;

}

public void run(){

try{

Process p= Runtime.getRuntime()。exec (“ping ”+ip+ “ -w 300 -n 1”);

InputStreamReader ir = new InputStreamReader(p.getInputStream());

LineNumberReader input = new LineNumberReader (ir);

//读取结果行

for (int i=1 ; i 7; i++)

input.readLine();

String line= input.readLine();

if (line.length() 17 || line.substring(8,17)。equals(“timed out”))

ping.put(ip,“false”);

else

ping.put(ip,“true”);

//线程结束

threadCount -= 1;

}catch (IOException e){}

}

}

}

IP切换 java语言

///改这玩意 害我断网断了好几次...-_-!~

import java.io.IOException;

import javax.swing.JOptionPane;

public class IP {

/**

* @param args

*/

public static void main(String[] args)

{

String [] options={"宿舍","A102","C201","A410","B103"};

String n = (String)JOptionPane.showInputDialog(null, "地址选择", "IP切换", JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);

if("宿舍".equals(n))

try {

Runtime.getRuntime().exec( "Netsh interface ip set address \"本地连接\" static 10.1.43.154 255.255.255.0 10.1.43.254 1");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if("A102".equals(n))

try {

Runtime.getRuntime().exec( "Netsh interface ip set address \"本地连接\"172.26.104.154 255.255.255.0 172.26.104.254 1");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if("C201".equals(n))

try {

Runtime.getRuntime().exec( "Netsh interface ip set address \"本地连接\" static 172.26.41.154 255.255.255.0 172.26.104.254 1");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if("A410".equals(n))

try {

Runtime.getRuntime().exec( "Netsh interface ip set address \"本地连接\" static 172.26.22.154 255.255.255.0 172.26.22.254 1");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if("B103".equals(n))

try {

Runtime.getRuntime().exec( "Netsh interface ip set address \"本地连接\" static 172.26.63.154 255.255.255.0 172.26.63.254 1");

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

IP动态变化功能java如何实现

ava代码

语法:rasdial 连接名称 /disconnect

实例: rasdial 宽带 /disconnect

java程序调用rasdial命令:

Java代码

package com.sesame.network;

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class ConnectNetWork {

/**

* 执行CMD命令,并返回String字符串

*/

public static String executeCmd(String strCmd) throws Exception {

Process p = Runtime.getRuntime().exec(“cmd /c ” + strCmd);

StringBuilder sbCmd = new StringBuilder();

BufferedReader br = new BufferedReader(new InputStreamReader(p

.getInputStream()));

String line;

while ((line = br.readLine()) != null) {

sbCmd.append(line + ”\n”);

}

return sbCmd.toString();

}

/**

* 连接ADSL

*/

public static boolean connAdsl(String adslTitle, String adslName, String adslPass) throws Exception {

System.out.println(“正在建立连接.”);

String adslCmd = ”rasdial ” + adslTitle + ” ” + adslName + ” ”

+ adslPass;

String tempCmd = executeCmd(adslCmd);

// 判断是否连接成功

if (tempCmd.indexOf(“已连接”) 0) {

System.out.println(“已成功建立连接.”);

return true;

} else {

System.err.println(tempCmd);

System.err.println(“建立连接失败”);

return false;

}

}

请用java如何编程实现修改pc互联网IP

通过 Java 修改注册表可以达到更改 IP地址的目的。

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

java 修改注册表的资料,

注册表与 TCP/IP的资料

用 .net 的话可以直接通过 ManagementClass 在修改

ip伪装java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于IP地址伪装、ip伪装java代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/18920.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载