/*
**********************************************************************
*NETBUIT协议??????????????????
*原因与MIB结构有关
*现象:通过//IP不能访问计算机的默认共享
* 但是通过//主机名能够访问计算机的默认共享
* 天网防火墙的网络安全级别高和禁止也不能
* 禁止这种方法的访问
* 可以通过这个方法和ICMP的REPLY包绕过防火墙进行攻击
**********************************************************************
*/
/**/
#include "stdafx.h"
#include <windows.h>
#include <IpHlpApi.h>
#include <iostream.h>
typedef DWORD(CALLBACK * PGNOINTERFACE)(PDWORD); //GetNumberOfInterfaces
typedef DWORD(CALLBACK * PGIINFO)(PIP_INTERFACE_INFO,PULONG ); //GetInterfaceInfo()
typedef DWORD(CALLBACK * PSETADA)(PMIB_IFROW); //SetIfEntry
typedef DWORD(CALLBACK * PGETADA)(PMIB_IFROW); //GetIfEntry
typedef DWORD(CALLBACK * PDELROUT)(PMIB_IPFORWARDROW); //DeleteIpForwardEntry
int main(int argc, char* argv[])
{
DWORD index = 0;
HINSTANCE hInst; //加载IPHELPAPI 的实例句柄
hInst = LoadLibrary("IpHlpApi.dll");
if(!hInst)
cout<<"Can't Load IpHlpApi.DLL. /n";
ULONG ulSize = 0;
//--------------------------------->>显示网络接口个数
DWORD ulNumOfInterfaces = 0;
PGNOINTERFACE pGNOInterface; //函数指针
PGIINFO pGIInfo;
pGNOInterface = (PGNOINTERFACE)GetProcAddress(hInst, "GetNumberOfInterfaces");
pGNOInterface(&ulNumOfInterfaces);
cout<<"U have "<<ulNumOfInterfaces<<" network interfaces/n";
//获取网络接口信息
pGIInfo = (PGIINFO)GetProcAddress(hInst,"GetInterfaceInfo");
PIP_INTERFACE_INFO pIInfo = NULL;
ulSize = 0;
pGIInfo(pIInfo, &ulSize); //第一次调用获得缓冲的大小
pIInfo = (PIP_INTERFACE_INFO)new(char[ulSize]);
pGIInfo(pIInfo, &ulSize);
PSETADA pSetAda; //函数指针
pSetAda = (PSETADA)GetProcAddress(hInst, "SetIfEntry");
MIB_IFROW *pMIBIf = NULL;
PGETADA pGetAda; //函数指针
pGetAda = (PGETADA)GetProcAddress(hInst, "GetIfEntry");
pMIBIf = new(MIB_IFROW);
//显示网络接口信息
/*思路的错误,不能删除路由表*/
//////////////////////////////////////////////////////////////
PDELROUT pDELRout;
pDELRout = (PDELROUT)GetProcAddress(hInst, "DeleteIpForwardEntry");
PMIB_IPFORWARDROW pMIBIPRow = NULL;
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
char key;
for(int i = 0; i < pIInfo->NumAdapters; i++)
{
cout<<"Adapter Index :"<<pIInfo->Adapter.Index<<endl;
cout<<"And Name :"<<pIInfo->Adapter.Name<<endl;
//------------------------------------------>>禁用网卡
pGetAda(pMIBIf);
cout<<"-----------------------------------------"<<endl;
cout<<"Chose Operation:"<<endl;
cout<<"(1) 1: Close Adapter!!!"<<endl;
cout<<"(2) 2: Open Adapter!!!"<<endl;
cout<<"-----------------------------------------"<<endl;
cin >> key;
if(key == '1')
{
pMIBIf->dwIndex = pIInfo->Adapter.Index;
pMIBIf->dwAdminStatus = MIB_IF_ADMIN_STATUS_DOWN;
// pMIBIf->dwOperStatus = MIB_IF_OPER_STATUS_NON_OPERATIONAL;
pSetAda(pMIBIf);
cout<<"Adapter Closed!!"<<endl;
}
else if(key == '2')
{
pMIBIf->dwIndex = pIInfo->Adapter.Index;
pMIBIf->dwAdminStatus = MIB_IF_ADMIN_STATUS_UP;
// pMIBIf->dwOperStatus = MIB_IF_OPER_STATUS_OPERATIONAL;
pSetAda(pMIBIf);
cout<<"Adapter Opened!!"<<endl;
}
}
cout<<endl<<endl;
//------------------------------------------>>接口信息显示完毕
delete pMIBIf;
return 0;
}
物理上禁用网卡的问题我也没有解决,希望我们共同讨论