而更換IP的方式,當(dāng)然也要做成自動(dòng)的,不可能讓用戶再手動(dòng)更新,那就達(dá)不到"自動(dòng)化"了.
在win中,動(dòng)態(tài)更改IP有不少方法,有的直接調(diào)用winapi(類Win32_NetworkAdapterConfiguration官方文檔:http://msdn.microsoft.com/zh-cn/library/aa394217(v=vs.85).aspx),不管是C++或是C#甚至是vbs腳本.也可以通過(guò)在cmd下執(zhí)行netsh命令來(lái)修改(可以寫成bat,供程序從外部調(diào)用).
通過(guò)在程序中調(diào)用WINAPI,可以方便獲得返回的狀態(tài),編制更健壯的程序.
對(duì)于躲避監(jiān)控,最好的辦法是執(zhí)行分布式批量下載.當(dāng)然,最安全的做法是,在幾十個(gè)學(xué)校中執(zhí)行.數(shù)據(jù)庫(kù)商家及學(xué)校,都無(wú)法防得了.大多知名的迅速"暴富"的商業(yè)公司就是利用這種方法來(lái)積累資源的.只是可惜,學(xué)校里頭的防控只防學(xué)生,卻不防大蟲.真所謂"竊鉤者誅,竊國(guó)者為諸侯".有人指責(zé)我非法采集超星的視頻,可這些道貌岸然的人物,為何不指責(zé)超星掏掉CNKI?不才只是為了方便窮書生找資源的苦楚,面對(duì)商業(yè)公司,而對(duì)國(guó)家科研機(jī)構(gòu)的重重壁壘,讓些小蟲有點(diǎn)活路不壞壟斷大局.知識(shí)越來(lái)越容易共享,也越來(lái)越不會(huì)分享.不管是商還是官,還是官商勾結(jié),窮書生從不是他們的服務(wù)對(duì)象.我沒有用上百臺(tái)機(jī)器分布采集,也沒有直接掛機(jī)到鏡像下載,我只是想從那個(gè)高墻處挖個(gè)小水溝,供窮書生們啜食.我只提供了省掉個(gè)人點(diǎn)擊之苦的CNKI批量下載器,而且也做了數(shù)量的限制,別的下載器都限內(nèi)部使用,沒有在互聯(lián)網(wǎng)上散播,希望那些高尚的大人物,莫太指責(zé)我惡意踐踏知識(shí)產(chǎn)權(quán),不尊重作者的研究成果.我只是一只小蟲,挖個(gè)小洞,給窮書生們解解渴,因?yàn)楦F書生們不能公款吃喝,大魚大肉.
附:
C#
using System;
using System.Collections.Generic;
usingSystem.Text;
using System.Text.RegularExpressions;
usingSystem.Management;
namespaceIPProvider
{
classWMIForIPSet
{
publicWMIForIPSet()
{
}
///
/// 設(shè)置IP地址信息
///
///
///
///
///
public static void SetIPAddress(string[]ip, string[] submask, string[]gatway, string[]dns)
{
ManagementClass wmi =new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = wmi.GetInstances();
ManagementBaseObject inPar = null;
ManagementBaseObject outPar = null;
foreach (ManagementObject mo in moc)
{

//如果沒有啟用IP設(shè)置的網(wǎng)絡(luò)設(shè)備則跳過(guò)
if (!(bool)mo["IPEnabled"])
{
continue;
}
//設(shè)置IP地址和掩碼
if (ip != null &&submask != null)
{
inPar = mo.GetMethodParameters("EnableStatic");
inPar["IPAddress"]= ip;
inPar["SubnetMask"]= submask;
outPar = mo.InvokeMethod("EnableStatic",inPar, null);
}
//設(shè)置網(wǎng)關(guān)地址
if (gatway != null)
{
inPar = mo.GetMethodParameters("SetGateways");
inPar["DefaultIPGateway"]= gatway;
outPar = mo.InvokeMethod("SetGateways",inPar, null);
}
//設(shè)置DNS地址
if (dns != null)
{
inPar = mo.GetMethodParameters("SetDNSServerSearchOrder");
inPar["DNSServerSearchOrder"]= dns;
outPar = mo.InvokeMethod("SetDNSServerSearchOrder",inPar, null);
}
}
}
///
/// 開啟DHCP
///
public static void EnableDHCP()
{
ManagementClass wmi =new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection moc = wmi.GetInstances();
foreach (ManagementObject mo in moc)
{
//如果沒有啟用IP設(shè)置的網(wǎng)絡(luò)設(shè)備則跳過(guò)
if (!(bool)mo["IPEnabled"])
continue;
//重置DNS為空
mo.InvokeMethod("SetDNSServerSearchOrder",null);
//開啟DHCP
mo.InvokeMethod("EnableDHCP",null);
}
}
///
/// 判斷IP地址的合法性
///
///
///
public static bool IsIPAddress(string ip)
{
string[]arr = ip.Split('.');
if (arr.Length != 4)
return false;
stringpattern = @"d{1,3}";
for (inti = 0; i<</span>arr.Length; i++)
{
stringd = arr[i];
if (i== 0 &&d == "0")
return false;
if (!Regex.IsMatch(d, pattern))
return false;
if (d !="0")
{
d = d.TrimStart('0');
if (d== "")
return false;
if (int.Parse(d) > 255)
return false;
}
}
returntrue;
}
///
/// 設(shè)置DNS
///
///
public static void SetDNS(string[]dns)
{
SetIPAddress(null,null, null,dns);
}
///
/// 設(shè)置網(wǎng)關(guān)
///
///
public static void SetGetWay(string getway)
{
SetIPAddress(null,null, newstring[] { getway }, null);
}
///
/// 設(shè)置網(wǎng)關(guān)
///
///
public static void SetGetWay(string[]getway)
{
SetIPAddress(null,null, getway, null);
}
///
/// 設(shè)置IP地址和掩碼
///
///
///
public static void SetIPAddress(string ip, string submask)
{
SetIPAddress(newstring[] { ip }, new string[] {submask }, null,null);
}
///
/// 設(shè)置IP地址,掩碼和網(wǎng)關(guān)
///
///
///
///
public static void SetIPAddress(string ip, string submask, string getway)
{
SetIPAddress(newstring[] { ip }, new string[] {submask }, newstring[] { getway }, null);
}
}
}
vbs
strComputer = "."
Set objWMIService = GetObject("winmgmts://" &strComputer & "/root/cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select *from Win32_NetworkAdapterConfiguration whereMACAddress='00:24:8c:xx:xx:xx'")
strIPAddress = Array("192.168.17.14")
strSubnetMask = Array("255.255.255.192")
strGateway = Array("192.168.17.254")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable =objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways= objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable= 0 Then
IPChan=1
Else
IPChan=0
End If
Exit For
Next
If IPChan = 1 Then
WScript.Echo"The IP address has been changed to 192網(wǎng)段"
Else
WScript.Echo"The IP address could not be changed."
End If
cmd下用netsh:
C:>netsh
netsh>interface
netsh interface>ip
netsh interface ip>set address name="本地連接"source=dhcp
netsh interface ip>set address "本地連接" static192.168.0.2 255.255.255.0 192.168.0.11
愛華網(wǎng)



