delphi 用内存流文件流资源生成客户端


本文整理自网络,侵删。

 正文:
很多木马生成器就是用的内存流和文件流生成客户端的,
废话不多说了,代码如下:
unitMain;

interface

uses
Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,
Dialogs,StdCtrls,Inifiles;

type
TForm1=class(TForm)
GroupBox1:TGroupBox;
msgtitle:TEdit;
GroupBox2:TGroupBox;
Memo1:TMemo;
Button1:TButton;
Button2:TButton;
procedureButton1Click(Sender:TObject);
procedureButton2Click(Sender:TObject);
private
{Privatedeclarations}
public
{Publicdeclarations}
end;

var
Form1:TForm1;
Inifile:TInifile;

implementation

{$R*.dfm}
{$RClient.RES}

procedureTForm1.Button1Click(Sender:TObject);
var
File1,File2:TFileStream;
Size:integer;
Files:string;
exe:tresourcestream;
begin
if(msgtitle.Text='')or(memo1.Text='')then
begin
Application.MessageBox('标题或内容不能为空!','错误');
exit;
end
else
begin
exe:=tresourcestream.Create(hinstance,pchar('myexe'),'exe');
exe.SaveToFile('Client.exe');
IniFile:=TIniFile.Create(ExtractFilePath(paramstr(0)) 'Config.ini');
IniFile.WriteString('msg','msgtitle',msgtitle.Text);
IniFile.WriteString('msg','msgtext',memo1.Text);
IniFile.Free;
Files:=ExtractFileDir(Application.ExeName) '\config.ini';
File1:=TFileStream.Create(ExtractFileDir(Application.ExeName) '\Client.exe',fmOpenWrite);
File2:=TFilestream.Create(Files,fmOpenRead);
try
File1.Seek(0,soFromEnd);
File1.CopyFrom(File2,0);
Size:=File2.Size SizeOf(Size);
File1.WriteBuffer(Size,SizeOf(Size));
Application.MessageBox('客户端已经生成!','提示');
Finally
File1.Free;
File2.Free;
exe.Free;
DeleteFile(Files);
end;
end;
end;

procedureTForm1.Button2Click(Sender:TObject);
begin
Close;
end;

end.

相关阅读 >>

Delphi richedit控件中插入gif动画表情

Delphi udp文件传输

Delphi让listbox实现即指即显功能

Delphi xe中 exit 的新用法

Delphi edit 让密码变成点

winapi 字符及字符串函数(10): lstrcpy - 复制字符串

Delphi ado 连接 excel (附excel各个版本的版本号)

Delphi unidac 连接mdb access 数据库

Delphi tms web core webmemo 横竖滚动条

Delphi 去掉mdi窗口的滚动条

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



打赏

取消

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

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

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

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

评论

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