Replace main.pas for final Release
This commit is contained in:
parent
d66f2c952e
commit
d457674862
171
main.pas
171
main.pas
|
@ -7,12 +7,13 @@ unit Main;
|
|||
// Created at 23th of January 2020, by Linuxer (https://gitlab.com/psposito), from scratch with Free Pascal
|
||||
// Redesigned and further Developed at 28th of January 2020, by Linuxer (https://gitlab.com/psposito)
|
||||
// to provide Camera and Mic status alone with On/Off and Mute/Unmute fuctions
|
||||
// Developed further for intrusion feeling and logging at 2nd of February 2020 by Linuxer (https://gitlab.com/psposito)
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
|
||||
Menus, UTF8Process, VpClock, Unix, process, About;
|
||||
Menus, PopupNotifier, UTF8Process, VpClock, Unix, process, About, Logs;
|
||||
|
||||
type
|
||||
|
||||
|
@ -22,11 +23,14 @@ type
|
|||
Button1 : TButton;
|
||||
Button2 : TButton;
|
||||
ImageListCam : TImageList;
|
||||
ImageListStatus: TImageList;
|
||||
ImageListMic : TImageList;
|
||||
AProcess : TProcessUTF8;
|
||||
MenuItem1 : TMenuItem;
|
||||
MenuItem10 : TMenuItem;
|
||||
MenuItem11 : TMenuItem;
|
||||
MenuItem12: TMenuItem;
|
||||
MenuItem13: TMenuItem;
|
||||
MenuItem2 : TMenuItem;
|
||||
MenuItem3 : TMenuItem;
|
||||
MenuItem4 : TMenuItem;
|
||||
|
@ -36,14 +40,18 @@ type
|
|||
MenuItem8 : TMenuItem;
|
||||
MenuItem9 : TMenuItem;
|
||||
PopupMenu1 : TPopupMenu;
|
||||
PopupMenu2: TPopupMenu;
|
||||
ProcessUTF8_1 : TProcessUTF8;
|
||||
TrayIcon1 : TTrayIcon;
|
||||
TrayIcon2 : TTrayIcon;
|
||||
TrayIcon3: TTrayIcon;
|
||||
VpClock1 : TVpClock;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure MenuItem10Click(Sender: TObject);
|
||||
procedure MenuItem12Click(Sender: TObject);
|
||||
procedure MenuItem13Click(Sender: TObject);
|
||||
procedure MenuItem2Click(Sender: TObject);
|
||||
procedure MenuItem3Click(Sender: TObject);
|
||||
procedure MenuItem4Click(Sender: TObject);
|
||||
|
@ -52,6 +60,7 @@ type
|
|||
procedure MenuItem9Click(Sender: TObject);
|
||||
procedure TrayIcon1Click(Sender: TObject);
|
||||
procedure TrayIcon2Click(Sender: TObject);
|
||||
procedure TrayIcon3Click(Sender: TObject);
|
||||
procedure VpClock1SecondChange(Sender: TObject);
|
||||
private
|
||||
CamImageIndex : integer;
|
||||
|
@ -67,7 +76,14 @@ var
|
|||
MicSwitchStr : String;
|
||||
Password : String;
|
||||
isMicOn : boolean;
|
||||
MicStatus : boolean;
|
||||
CamStatus : boolean;
|
||||
HasPassword : boolean;
|
||||
MicClicked : boolean;
|
||||
CamClicked : boolean;
|
||||
MicClicksCounter : byte;
|
||||
CamClicksCounter : byte;
|
||||
GridLine : Integer;
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -93,10 +109,14 @@ begin
|
|||
//showmessage(AStringList.Strings[AstringList.Count-1]);
|
||||
//showmessage(MicSwitchStr);
|
||||
if CompareText(MicSwitchStr,'[On]') = 0 then
|
||||
isMicOn := true
|
||||
begin
|
||||
isMicOn := true;
|
||||
end
|
||||
//if CompareText(MicSwitchStr,'[Off]') = 0 then
|
||||
else
|
||||
isMicOn := false;
|
||||
begin
|
||||
isMicOn := false;
|
||||
end;
|
||||
//if isMicOn = true then
|
||||
// showmessage('Mic is on');
|
||||
//if isMicOn = false then
|
||||
|
@ -133,31 +153,42 @@ begin
|
|||
HasPassword := false;
|
||||
CamImageIndex := 0;
|
||||
MicImageIndex := 0;
|
||||
MicClicked := false;
|
||||
CamClicked := false;
|
||||
CamClicksCounter := 0;
|
||||
MicClicksCounter := 0;
|
||||
GridLine := 1;
|
||||
|
||||
VpClock1.Active := true;
|
||||
|
||||
GetMicCaptureStatus;
|
||||
|
||||
if DirectoryExists('/dev/v4l/') then
|
||||
if (DirectoryExists('/dev/v4l/') or DirectoryExists('/dev/video0')) then
|
||||
begin
|
||||
ImageListCam.GetIcon(0, TrayIcon1.Icon);
|
||||
CamStatus := true;
|
||||
//ShowMessage('Camera is On');
|
||||
end
|
||||
else
|
||||
begin
|
||||
ImageListCam.GetIcon(1, TrayIcon1.Icon);
|
||||
CamStatus := false;
|
||||
//ShowMessage('Camera is Off');
|
||||
end;
|
||||
|
||||
if isMicOn = true then
|
||||
begin
|
||||
ImageListMic.GetIcon(0, TrayIcon2.Icon);
|
||||
MicStatus := true;
|
||||
end;
|
||||
|
||||
if isMicOn = false then
|
||||
begin
|
||||
ImageListMic.GetIcon(1, TrayIcon2.Icon);
|
||||
MicStatus := false;
|
||||
end;
|
||||
|
||||
ImageListStatus.GetIcon(0, TrayIcon3.Icon);
|
||||
//ImageListCam.GetIcon(0, TrayIcon1.Icon);
|
||||
//ImageListMic.GetIcon(0, TrayIcon2.Icon);
|
||||
//ShowMessage('Press Ok');
|
||||
|
@ -171,12 +202,28 @@ begin
|
|||
ImageListCam.Free;
|
||||
ImageListMic.Free;
|
||||
PopupMenu1.Free;
|
||||
PopupMenu2.Free;
|
||||
TrayIcon1.Free;
|
||||
TrayIcon2.Free;
|
||||
TrayIcon3.Free;
|
||||
Halt (0);
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem2Click(Sender: TObject);
|
||||
procedure TForm1.MenuItem12Click(Sender: TObject); //ShowLogs;
|
||||
begin
|
||||
Logs.Form3.Show;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem13Click(Sender: TObject); //ClearLogs;
|
||||
begin
|
||||
ImageListStatus.GetIcon(0, TrayIcon3.Icon);
|
||||
Logs.Form3.StringGrid1.Clean;
|
||||
GridLine := 1;
|
||||
Logs.Form3.StringGrid1.InsertRowWithValues(0,['DateTime Stamp', 'Event Description']);
|
||||
ImageListStatus.GetIcon(0, TrayIcon3.Icon);
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem2Click(Sender: TObject); // Password Reset
|
||||
begin
|
||||
HasPassword := false;
|
||||
ShowMessage('Passsword, has been reset');
|
||||
|
@ -214,30 +261,40 @@ begin
|
|||
begin
|
||||
CameraOn;
|
||||
ImageListCam.GetIcon(0, TrayIcon1.Icon);
|
||||
CamClicksCounter := 1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
AskPassword;
|
||||
CameraOn;
|
||||
if HasPassword then
|
||||
ImageListCam.GetIcon(0, TrayIcon1.Icon);
|
||||
AskPassword;
|
||||
CameraOn;
|
||||
if HasPassword then
|
||||
begin
|
||||
ImageListCam.GetIcon(0, TrayIcon1.Icon);
|
||||
CamClicksCounter := 1;
|
||||
end
|
||||
end;
|
||||
CamClicked := true;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem4Click(Sender: TObject); // Camera Off
|
||||
begin
|
||||
if HasPassword then
|
||||
begin
|
||||
CameraOff;
|
||||
ImageListCam.GetIcon(1, TrayIcon1.Icon);
|
||||
end
|
||||
begin
|
||||
CameraOff;
|
||||
ImageListCam.GetIcon(1, TrayIcon1.Icon);
|
||||
CamClicksCounter := 1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
AskPassword;
|
||||
CameraOff;
|
||||
if HasPassword then
|
||||
ImageListCam.GetIcon(1, TrayIcon1.Icon);
|
||||
AskPassword;
|
||||
CameraOff;
|
||||
if HasPassword then
|
||||
begin
|
||||
ImageListCam.GetIcon(1, TrayIcon1.Icon);
|
||||
CamClicksCounter := 1;
|
||||
end
|
||||
end;
|
||||
CamClicked := true;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem6Click(Sender: TObject); // Microphone Mute
|
||||
|
@ -245,6 +302,8 @@ begin
|
|||
S := fpsystem('amixer set Capture nocap');
|
||||
//ShowMessage('Microphone has been mutted');
|
||||
ImageListMic.GetIcon(1, TrayIcon2.Icon);
|
||||
MicClicked := true;
|
||||
MicClicksCounter := 1;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem7Click(Sender: TObject); // Microphone Unmute
|
||||
|
@ -252,9 +311,11 @@ begin
|
|||
S := fpsystem('amixer set Capture cap');
|
||||
//ShowMessage('Microphone has been mutted');
|
||||
ImageListMic.GetIcon(0, TrayIcon2.Icon);
|
||||
MicClicked := true;
|
||||
MicClicksCounter := 1;
|
||||
end;
|
||||
|
||||
procedure TForm1.MenuItem9Click(Sender: TObject);
|
||||
procedure TForm1.MenuItem9Click(Sender: TObject); // About
|
||||
begin
|
||||
About.Form2.Label1.Caption:='Developer';
|
||||
About.Form2.Label2.Caption:='Licence';
|
||||
|
@ -281,29 +342,99 @@ begin
|
|||
PopUpMenu1.PopUp;
|
||||
end;
|
||||
|
||||
procedure TForm1.TrayIcon3Click(Sender: TObject);
|
||||
begin
|
||||
PopUpMenu2.PopUp;
|
||||
end;
|
||||
|
||||
procedure TForm1.VpClock1SecondChange(Sender: TObject);
|
||||
var
|
||||
HackedTime : TDateTime;
|
||||
|
||||
begin
|
||||
GetMicCaptureStatus;
|
||||
|
||||
if DirectoryExists('/dev/v4l/') then
|
||||
if (DirectoryExists('/dev/v4l/') or DirectoryExists('/dev/video0')) then
|
||||
begin
|
||||
ImageListCam.GetIcon(0, TrayIcon1.Icon);
|
||||
//ShowMessage('Camera is On');
|
||||
If ((CamStatus = false) and (CamClicked = true) and (CamClicksCounter = 1)) then
|
||||
begin
|
||||
CamClicked := false;
|
||||
CamClicksCounter := 0;
|
||||
CamStatus := true;
|
||||
end;
|
||||
If ((CamStatus = false) and (CamClicked = false) and (CamClicksCounter = 0)) then
|
||||
begin
|
||||
HackedTime := now;
|
||||
ShowMessage('Camera hacked !!! Please Check Log');
|
||||
Logs.Form3.StringGrid1.InsertRowWithValues(GridLine,[FormatDateTime('dd/mm/yyyy, ', HackedTime) + RightStr(DateTimeToStr(VPClock1.Time), 8), 'Camera Hacked to On']);
|
||||
GridLine := GridLine + 1;
|
||||
CamStatus := true;
|
||||
ImageListStatus.GetIcon(1, TrayIcon3.Icon);
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
ImageListCam.GetIcon(1, TrayIcon1.Icon);
|
||||
If ((CamStatus = true) and (CamClicked = true) and (CamClicksCounter = 1)) then
|
||||
begin
|
||||
CamClicked := false;
|
||||
CamClicksCounter := 0;
|
||||
CamStatus := false;
|
||||
end;
|
||||
If ((CamStatus = true) and (CamClicked = false) and (CamClicksCounter = 0)) then
|
||||
begin
|
||||
HackedTime := now;
|
||||
ShowMessage('Camera hacked !!! Please Check Log');
|
||||
Logs.Form3.StringGrid1.InsertRowWithValues(GridLine,[FormatDateTime('dd/mm/yyyy, ', HackedTime) + RightStr(DateTimeToStr(VPClock1.Time), 8), 'Camera Hacked to Off']);
|
||||
CamStatus := false;
|
||||
GridLine := GridLine + 1;
|
||||
ImageListStatus.GetIcon(1, TrayIcon3.Icon);
|
||||
end;
|
||||
//ShowMessage('Camera is Off');
|
||||
end;
|
||||
|
||||
if isMicOn = true then
|
||||
begin
|
||||
ImageListMic.GetIcon(0, TrayIcon2.Icon);
|
||||
If ((MicStatus = false) and (MicClicked = true) and (MicClicksCounter = 1)) then
|
||||
begin
|
||||
MicClicked := false;
|
||||
MicClicksCounter := 0;
|
||||
MicStatus := true;
|
||||
end;
|
||||
If ((MicStatus = false) and (MicClicked = false) and (MicClicksCounter = 0)) then
|
||||
begin
|
||||
ImageListStatus.GetIcon(1, TrayIcon3.Icon);
|
||||
HackedTime := now;
|
||||
ShowMessage('Microphone hacked !!! Please Check Log');
|
||||
Logs.Form3.StringGrid1.InsertRowWithValues(GridLine,[FormatDateTime('dd/mm/yyyy, ', HackedTime) + RightStr(DateTimeToStr(VPClock1.Time), 8), 'Microphone Hacked to Muted']);
|
||||
MicStatus := true;
|
||||
GridLine := GridLine + 1;
|
||||
ImageListStatus.GetIcon(1, TrayIcon3.Icon);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
if isMicOn = false then
|
||||
begin
|
||||
ImageListMic.GetIcon(1, TrayIcon2.Icon);
|
||||
If ((MicStatus = true) and (MicClicked = true) and (MicClicksCounter = 1)) then
|
||||
begin
|
||||
MicClicked := false;
|
||||
MicClicksCounter := 0;
|
||||
MicStatus := false;
|
||||
end;
|
||||
If ((MicStatus = true) and (MicClicked = false) and (MicClicksCounter = 0)) then
|
||||
begin
|
||||
ImageListStatus.GetIcon(1, TrayIcon3.Icon);
|
||||
HackedTime := now;
|
||||
ShowMessage('Microphone hacked !!! Please Check Log');
|
||||
Logs.Form3.StringGrid1.InsertRowWithValues(GridLine,[FormatDateTime('dd/mm/yyyy, ', HackedTime) + RightStr(DateTimeToStr(VPClock1.Time), 8), 'Microphone Hacked to Unmuted']);
|
||||
MicStatus := false;
|
||||
GridLine := GridLine + 1;
|
||||
ImageListStatus.GetIcon(1, TrayIcon3.Icon);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
|
Loading…
Reference in New Issue