⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 网络攻击view.cpp

📁 这是局域网扫描空密码主机和ftp共享资源的一个软件的源代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	ilist.Add(icon);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_share1);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_user);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_password);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_ftp);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_ports);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_ports2);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_text);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_folder);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_app);
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_rar);//13
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_avi);//14
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_help);//15
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_htm);//16
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_mp3);//17
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_pdf);//18
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_ppt);//19
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_rm);//20
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_valid);//21
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_word);//22
	ilist.Add(icon);
	icon=AfxGetApp()->LoadIcon(IDI_get);//23
	ilist.Add(icon);
	m_show.SetImageList(&ilist,TVSIL_NORMAL);
	m_course.AddString("      网络攻击");
	m_course.AddString("--------------------------");
	m_course.AddString("   超强功能:");
	m_course.AddString("   自动监测共享资源");
	m_course.AddString("   自动扫描主机用户");
	m_course.AddString("   通过双击共享资源进入");
	m_course.AddString("   进行简单密码破解");
	m_course.AddString("--------------------------");
	m_course.AddString("                          ");
	m_course.AddString("      使用说明");
	m_course.AddString("--------------------------");
	m_course.AddString("   最好是IP范围小于等于254");
	m_course.AddString("   可能会出现错误,软件关闭");
	m_course.AddString("   可以免费使用本软件");
	m_course.AddString("--------------------------");
	m_course.AddString("                          ");
	m_course.AddString("      作者信息");
	m_course.AddString("--------------------------");
	m_course.AddString("   name:王国庆");
	m_course.AddString("   qq:52440582");
	m_course.AddString("   Email:wangsir789456123@163.com");
	m_course.AddString("--------------------------");
	m_course.AddString("      < 欢迎使用本软件 >");
	m_course.AddString("--------------------------");
	m_course.AddString("                         2003-11-20");
	m_course.AddString("             **********************");
	pplist.AddTail("");
	pplist.AddTail("@");
	passwordfile=new CStdioFile;
	passwordfile->Open("password.txt",
      CFile::modeRead );
	bool fileend=false;
	CString linestr="";
	//fileend=!passwordfile->ReadString(linestr);
	while(fileend==false)
	{
	fileend=!passwordfile->ReadString(linestr);
	if(fileend==true)
	break;
	if(linestr!="")
	{
	POSITION pos=pplist.GetHeadPosition();
	bool gg=false;
	CString tem="";
	while(pos)
	{
	tem=pplist.GetAt(pos);
	if(tem==linestr)
	{
	gg=true;
	break;
	}
	pplist.GetNext(pos);
	}
	if(gg==false)
	pplist.AddTail(linestr);
	}
	}
	passwordfile->Close();
	delete passwordfile;
	m_stop.ShowWindow(false);
}

/////////////////////////////////////////////////////////////////////////////
// CMyView printing

BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CMyView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CMyView diagnostics

#ifdef _DEBUG
void CMyView::AssertValid() const
{
	CFormView::AssertValid();
}

void CMyView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CMyDoc* CMyView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
	return (CMyDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyView message handlers
UINT scanshares(LPVOID lParam)
{
	info *tem=(info*)lParam;
    CString strlist;
	CString str="";
	CStringList shares; 
	CStringList users;
	CStringList ports;
	if(!shares.IsEmpty())
	shares.RemoveAll();	
    if(!users.IsEmpty())
		users.RemoveAll();	
    if(!ports.IsEmpty())
		ports.RemoveAll();
    BOOL m_winb1=TRUE, m_winb2=TRUE,m_winb3=FALSE;
	BOOL bWorking=FALSE;
	BOOL ipgood=TRUE;
	if(tem->myview->m_bping==TRUE)
	ipgood=pingip(tem->ip1,tem->ip2,tem->ip3,tem->ip4,tem->backstr,50);
	if(ipgood==TRUE)
	{
	if(tem->myview->m_bshare==TRUE)
	{
	m_winb1=SharesScan(tem->ip,strlist,shares);
	m_winb2=UsersScan(tem->ip,strlist,users);
	}
	if(tem->myview->m_bports==TRUE)
	{
	int port[5]={21,80,25,135,139};
	int counter=5;
	SOCKADDR_IN dest;
	memset(&dest,0,sizeof(dest));
	dest.sin_addr.S_un.S_addr=inet_addr(tem->ip);
	dest.sin_port=0;
	dest.sin_family=AF_INET;
	SOCKET hsock;
	CString temp,temp1;
	int error;
	for(int i=0;i<counter;i++)
	{
		hsock=socket(AF_INET,SOCK_STREAM,0);
		dest.sin_port=htons(port[i]);
		error=connect(hsock,(sockaddr*)(&dest),sizeof(SOCKADDR_IN));
		tem->myview->m_ports.Format("%d",port[i]);
		tem->myview->UpdateData(false);
		if(error!=-1)
		{
		m_winb3=TRUE;
		break;
		}
		closesocket(hsock);
	}
	}
	if(tem->myview->m_bftp==TRUE)
	{
	try
	{	
		CInternetSession sess(_T("MyProgram/1.0"));
		CFtpConnection* pConnect = sess.GetFtpConnection(tem->ip);
		CFtpFileFind finder(pConnect);
		CString findname="";
		bWorking = finder.FindFile(findname);
		bWorking = finder.FindNextFile();
		if (pConnect != NULL)
		pConnect->Close();
		delete pConnect;

	}
	catch (CInternetException* pEx)
	{
      TCHAR sz[1024];
      pEx->GetErrorMessage(sz, 1024);
      pEx->Delete();
	}
	}
	if(users.GetCount()!=0&&shares.GetCount()!=0||m_winb3==TRUE||bWorking==TRUE)
	{
	if(users.GetCount()!=0&&shares.GetCount()!=0||tem->myview->m_bftp==TRUE||tem->myview->m_bports==TRUE)
	tem->counter=tem->myview->m_show.InsertItem(tem->ip,0,0,0,0);
	if(users.GetCount()!=0&&shares.GetCount()!=0)
	{
	tem->myview->iboth++;
	tem->myview->m_both.Format("2者均有主机数:%d",tem->myview->iboth);
	HTREEITEM item3=tem->myview->m_show.InsertItem("共享资源($)",1,1,tem->counter,0);
	HTREEITEM item2=tem->myview->m_show.InsertItem("用户名",2,2,tem->counter,0);
	tem->myview->AddString(strlist,shares,item3,0,tem->ip);
    tem->myview->AddString(strlist,users,item2,1,tem->ip);
	}
	if(bWorking==TRUE)
	{
	if(tem->myview->m_bftp==TRUE)
	{
	HTREEITEM item5=tem->myview->m_show.InsertItem("FTP资源",8,8,tem->counter,0);
	tem->myview->getftpfile(tem->ip,item5);
	}
	}
	if(m_winb3==TRUE)
	{
	if(tem->myview->m_bports==TRUE)
	{
	HTREEITEM item4=tem->myview->m_show.InsertItem("打开端口",8,8,tem->counter,0);
	tem->myview->ScanPorts(tem->ip,strlist,ports,item4);
	}
	}
	}
	else
	{
	str.Format(" ( %d )",tem->myview->m_progress.GetPos()+1);
	tem->myview->updatestring(tem->ip+str);
	}
	}
	else
	{
	/*str.Format(" <%d> ",	tem->myview->m_progress.GetPos()+1);
	CString string="";
	string+=str;
	tem->myview->m_curip =tem->ip+string;
	tem->myview->UpdateData(false);*/
	}
	tem->myview->userprogress--;
	tem->myview->m_progress.SetPos(tem->myview->m_progress.GetPos()+1);
	if(tem->myview->userprogress<=0)
	{
	int maxnum=0,minnum=0;
	tem->myview->m_progress.GetRange(minnum,maxnum);
	tem->myview->m_progress.SetPos(maxnum);
	//AfxMessageBox("扫描结束");
	tem->myview->m_bstart=FALSE;
	tem->myview->m_scan.EnableWindow(true);
	tem->myview->m_progress.SetPos(0);
	}
	tem->myview->UpdateData(false);

	delete lParam;
	return 0;
}
void CMyView::Onscan() //扫描
{
	m_scan.EnableWindow(false);
	m_bstart=TRUE;
	m_course.ResetContent();
	m_course.AddString("        当前主要功能设置");
	m_course.AddString("--------------------------");
	if(m_bget==TRUE)
	{
	m_course.AddString("破解简单密码");
	}
	if(m_bftp==TRUE)
	{
	m_course.AddString("FTP扫描");
	}
	if(m_bshare==TRUE)
	{
	m_course.AddString("共享扫描");
	}
	if(m_bports==TRUE)
	{
	m_course.AddString("端口扫描");
	}
	m_course.AddString("--------------------------");
	m_show.DeleteAllItems();
	m_getp = _T("破解密码主机数:0");
	m_both = _T("2者均有主机数:0");
	m_curip = _T("127.0.0.1");
	m_sum = _T("总扫描数:0");
	m_share = _T("找到共享主机数:0");
	m_user = _T("找到用户主机数:0");
	m_ftp="0";
	iuser=0;
	igetp=0;
	ishare=0;
	iboth=0;
	iftp=0;
	name="Administrator";
	password="";
	threadnum=0;
    if(!m_stringshares.IsEmpty())
		m_stringshares.RemoveAll();	
    if(!m_stringusers.IsEmpty())
		m_stringusers.RemoveAll();	
    if(!m_stringlist.IsEmpty())
		m_stringlist.RemoveAll();
	byte ip11,ip12,ip13,ip14;
	byte ip21,ip22,ip23,ip24;
	m_ip1.GetAddress(ip11,ip12,ip13,ip14);
	m_ip2.GetAddress(ip21,ip22,ip23,ip24);
	CString strip;
	int k3=0;
	int k4=0;
	if(ip14>254)
		ip14=254;
	if(ip24>254)
		ip24=254;
	int i=0;
	m_sum.Format("总扫描数: %d",(ip23-ip13)*254+(ip24-ip14)+1);
	shareprogress=(ip23-ip13)*254+(ip24-ip14)+1;
	userprogress=(ip23-ip13)*254+(ip24-ip14)+1;
	m_progress.SetRange(0,((ip23-ip13)*254+(ip24-ip14)+1));
	m_progress.SetPos(0);
	curthread=0;
	do{
	info*infotem=new info();
	infotem->myview=this;
	strip.Format("%d.%d.%d.%d",ip11,ip12,ip13+k3,ip14+k4);
	infotem->ip1=ip11;
	infotem->ip2=ip12;
	infotem->ip3=ip13+k3;
	infotem->ip4=ip14+k4;
	if(k4<=254)
	{
	k4++;
	}
	else
	{
	k4=0;
	k3++;
	}
	curip=strip;
	m_curip=strip;
	infotem->ip=strip;
	AfxBeginThread(scanshares,infotem,0);
	curthread++;
	threadnum++;
	UpdateData(false);
	}while(curthread<=(ip23-ip13)*254+(ip24-ip14));
	UpdateData(false);
}

void CMyView::Onface() 
{
	MessageBox("face");
	
}

void CMyView::OnUpdateFileNew(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMyView::OnUpdateface(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CMyView::Onfoldclose() 
{
HTREEITEM root=m_show.GetRootItem();
HTREEITEM c1=m_show.GetChildItem(root);
c1=m_show.GetChildItem(c1);
while(root!=NULL)
{
m_show.Expand(root,TVE_COLLAPSE);
root=m_show.GetNextItem(root,TVGN_NEXT);
}
}

void CMyView::Onfoldopen() 
{
HTREEITEM root=m_show.GetRootItem();
HTREEITEM c1=m_show.GetChildItem(root);
c1=m_show.GetChildItem(c1);
while(root!=NULL)
{
m_show.Expand(root,TVE_EXPAND);
root=m_show.GetNextItem(root,TVGN_NEXT);
}
while(c1!=NULL)
{
m_show.Expand(c1,TVE_EXPAND);
c1=m_show.GetNextItem(c1,TVGN_NEXT);
}
}

void CMyView::Onstop() 
{
	// TODO: Add your control no tification handler code here
	
}

void CMyView::OnDblclkTree1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	HTREEITEM item=m_show.GetSelectedItem();
	CString text1=m_show.GetItemText(item);
	HTREEITEM p1=m_show.GetParentItem(item);
	CString text2=m_show.GetItemText(p1);
	LPNETRESOURCE netres=new NETRESOURCE;
	if(text2=="共享资源($)")
	{
	CString sever="\\\\";
	p1=m_show.GetParentItem(p1);
	text2=m_show.GetItemText(p1);
	sever+=text2;
	sever+="\\";
	sever+=text1;

	////////////////////

	TCHAR username[32] = "Administrator",
    p[32] = "",
    szLocalName[32] ="";
	netres->dwType=RESOURCETYPE_DISK;
	netres->lpLocalName="";
	netres->dwScope=RESOURCE_GLOBALNET;
	netres->dwUsage=RESOURCEUSAGE_CONTAINER;
	netres->lpProvider=NULL;
	wchar_t Temp[MAX_PATH]=L"";
    swprintf(Temp,L"%s",(sever));
	TCHAR szRemoteName[MAX_PATH]="\\\\202.196.38.177\\d$" ;
	for(int i=0;i<sever.GetLength();i++)
	szRemoteName[i]=sever[i];
	szRemoteName[sever.GetLength()]=0;
	netres->lpRemoteName=LPTSTR(Temp);
	netres->lpRemoteName=szRemoteName;
	do
	{
	if(NO_ERROR==WNetAddConnection3(this->m_hWnd,netres,password,name,CONNECT_UPDATE_PROFILE))
	{
	ShellExecute(NULL, _T("open"), sever, NULL, NULL, SW_SHOWMAXIMIZED);
	break;
	}
	else
	{
	Cuserdlg dlg;
	dlg.m_name=name;
	dlg.m_password=password;
	if(IDOK==dlg.DoModal())
	{
	name=dlg.m_name;
	password=dlg.m_password;
	}
	else
	{
	break;
	}
	}
    }while(1);
	}
	delete netres;
	*pResult = 0;
}

void CMyView::AddString(CString strshow, CStringList & shares, HTREEITEM num, int type,CString ip)
{


CString str;
str.Format(" ( %d )",m_progress.GetPos()+1);
m_curip =ip+str;
UpdateData(false);
if(type==0&&shares.GetCount()!=0)
{
	ishare++;
	m_share.Format("找到共享主机数: %d",ishare);
	CString name="";
	POSITION pos=shares.GetHeadPosition();
	for(int i=0;i<shares.GetCount();i++)
	{
	str=shares.GetAt(pos);
	if(str!=""&&str!=" ")
	HTREEITEM pitem=m_show.InsertItem(str,4,4,num,0);
	shares.GetNext(pos);
	}
}
else
{
	if(type==1&&shares.GetCount()!=0)
	{
	iuser++;
	m_user.Format("找到用户主机数: %d",iuser);
	char*str2=new char[50];
	POSITION pos=shares.GetHeadPosition();
	for(int i=0;i<shares.GetCount();i++)
	{
	str=shares.GetAt(pos);
	for(int j=1;j<str.GetLength();j++)
		str2[j-1]=str[j];
	str2[str.GetLength()-1]=0;
	name=str2;
	////////////////////测试简单密码
	if(str!=""&&str!=" ")
	{
	HTREEITEM pitem=m_show.InsertItem(name,5,5,num,0);
	if(m_bget==TRUE)
	getpassword(name,ip,pitem);
	}
	shares.GetNext(pos);
	}
	delete str2;
	}
if(type==2&&shares.GetCount()!=0)
{
	CString name="";
	POSITION pos=shares.GetHeadPosition();
	for(int i=0;i<shares.GetCount();i++)
	{
	str=shares.GetAt(pos);
	if(str!=""&&str!=" ")
	HTREEITEM pitem=m_show.InsertItem(str,9,9,num,0);
	shares.GetNext(pos);
	}
}
}
UpdateData(false);
}
void CMyView::OnFieldchangedIpaddress1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	byte ip11=0,ip12=0,ip13=0,ip14=0;
	byte ip21=0,ip22=0,ip23=0,ip24=0;
	m_ip1.GetAddress(ip11,ip12,ip13,ip14);
	m_ip2.GetAddress(ip21,ip22,ip23,ip24);
	m_ip2.SetAddress(ip11,ip12,ip13,ip24);
	*pResult = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -