Introduction
There are too many security programs that lock, encrypt,... files in different forms, but sometimes working with them is not easy and takes a long time.
Also, some of them are heavy and slow.
This always made me think about developing a quick, easy, and powerful program on my own. Therefore I decided to design a program that protects and locks every window in
Windows and encrypts any files, even large ones, without any problem. I think my program is quite useful.
Features
- Takes little space from RAM and hard memory.
- Does the job quickly, with just a few clicks.
- Doesn't change the file's data.
- Has good and suitable security.
- Locks file in every format.
- Locks every window that appears.
- Included with Explorer with a nice environment.
- It's like a gadget.
- Encrypts files with non-returnable algorithm.
- Can run in XP, Vista, and 7.
- Doesn't need external program or library such as .NET Framework.
- Runs for all users, even if you add a user later or for a limited user account.
- Has a very quick installer.
First Main Part - Locking files
This works quickly because when you lock a file, the program keeps the file in open mode and doesn't change the file's data.
It's easy and clear and doesn't allow the user to open, delete, move, rename, copy, or cut the file. Nothing can be done unless you unlock the file.
It works when the program is opened (system loaded). It's not a system driver.
Second Main Part - Encrypting files
This program includes two encryption algorithms. First one is a common algorithm, and the second a non-returnable algorithm.
Even if you're encrypting a large file and cancel it when the program is working, you can decrypt the incomplete file.
Third Main Part - Locking windows
This part is very useful and a new subject in security. Have you ever thought of how you can lock a window if we don't have its executable file, such as "Start menu", "Action Center",
"System Properties", "Volume mixer", and other important windows.
Source code
There are three programs in this unit: Installer program, Main program, Guard program.
Installer program
To run the application, first we need to install the essential files or put these files next to our program (the same directory). We do this in the installer. The files are:
- "mfc100ud.dll" and "msvcr100d.dll" to the "windows\system32" directory
- "calibri.ttf" to the "windows\fonts" directory
Because the installer must be executable, we put these files beside Installer.exe. Then for intalling the files, we need to detect "Windows' drive". For this, we use the below code,
and since we need it the first time, we put this code in the OnInitDialog
function. "OnInitDialog
" executes every code written in it.
We define the below variables as global.
CString address,pathi,pathw,os,osd;
bool bos=1;
CFile f;
TCHAR tc[260];
BOOL CWindowssPermission1InstalerDlg::OnInitDialog(){
CDialogEx::OnInitDialog();
SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE);
SetBackgroundColor(RGB(101,158,224)); TCHAR tc[260];GetWindowsDirectory(tc,260);osd=tc; GetCurrentDirectory(260,tc);pathw=tc;
return TRUE; }
The next step is determining the Operating System: XP or Vista or 7, and push it in "os
" and finally in "wu
" (Windows user folder) file.
The main program works with it.
For getting a text, we define a class by name "CinputBox
" and use it. After that, the program needs a security password to run, to uninstall, and to manage the program.
We save it to "MicM.dll". And in "MicN.dll", we save "Windows user directory" as the main program uses it. We use these to determine if the program is installed or not.
It's a connection. To have more security, we need to load the program at startup therefore we create a ".reg" file with the settings.
Main program
The cryptography, locking, and base application are in this part. There are multiple sections, "Explorer" ,"Icon Tray", "Lock", ... We have these global variables:
const int filecount=10000,windowcount=10000;
CRect rc[29],r1,r2;
CPoint p1,pc;
CString pathw,pathe
,tic,til
,nic,nir
,nil,tir
,plf[filecount],pplf[filecount]
,wl[windowcount][2]
,pfc,os;
int cc=0,c,b=-1,w=112
,h=211,ow=150
,dx1=-8,dy1=-93,xw=0,yw=0,ifc=0,tf[filecount][2]
,tw[windowcount],lcfu=0,ccf=0
,locktime=0;
bool s1=1,s2=0,active=1;
CImage i1,il,ic,ir;
COLORREF cl=RGB(0,162,232);
CFile lf[filecount],fq,fz;
HWND hd=0;
Some tasks done in the OnInitDialog function include:
- Is the program loaded? Then exit.
- Is the program uninstalled or damaged? Then exit.
- Load the program's directory.
- Load the program's coordinates from
xw
and yw
, included X and Y of application in screen. - Load Windows passwords and their names from the
qw
file. - Load file passwords and their names from the
zw
file. - Automatically lock time from the
tw
file. - Load the Windows user directory from the
wu
file. - Start the Guard program.
- Load the icon tray.
And in OnTrayNotify
, we manage the icon tray and menu.
We design and load the background and Explorer appearance in OnPaint
. The Operating System calls this function when the application needs to redraw.
OnTimer
is the most important function. It includes the locking and cryptography and window moving. The Operating System calls "OnTimer
" automatically with
a specific interval. By the way, I didn't use any buttons in the dialog. I think this method is better because it has more quality and
uses less space in RAM. Of course, it doesn't matter nowadys. And also we can design every thing in our mind. I defined rectangles for every button.
IsNear
is a function that checks if a point is in a rectangle or not. In OnMouseMove
, if is cursor is in one of the rectangles, we put a
relation number in a global variable, then in OnLButtonDown
, run the relation code.
GetCursorPos(&pc);if(IsNear(pc.x,pc.y,r1,50)){
int x=0,y=0;x=pc.x-r1.left-dx1;y=pc.y-r1.top-dy1;
if(ow<255&&s1){SetTimer(3,10,0);s1=0;} if(IsNearX(x,y,rc[0],1))b=0; else if(IsNearX(x,y,rc[1],1))b=1; else if(IsNearX(x,y,rc[2],1))b=2; else if(IsNearX(x,y,rc[3],1))b=3; else if(IsNearX(x,y,rc[4],1))b=4; else if(IsNearX(x,y,rc[5],1))b=5; else if(IsNearX(x,y,rc[6],1))b=6; else if(IsNearX(x,y,rc[7],1))b=7; else if(IsNearX(x,y,rc[8],1))b=8; else if(IsNearX(x,y,rc[9],1))b=9; else if(IsNearX(x,y,rc[10],1))b=10; else if(IsNearX(x,y,rc[11],1))b=11; else if(IsNearX(x,y,rc[12],1))b=12; else if(IsNearX(x,y,rc[16],1))b=16; else if(IsNearX(x,y,rc[17],1))b=17; else if(IsNearX(x,y,rc[18],1))b=18; else if(IsNearX(x,y,rc[19],1))b=19; else if(IsNearX(x,y,rc[20],1))b=20; else if(IsNearX(x,y,rc[21],1))b=21; else if(IsNearX(x,y,rc[22],1))b=22; else if(IsNearX(x,y,rc[23],1))b=23; else if(IsNearX(x,y,rc[25],1))b=25; else if(IsNearX(x,y,rc[26],1)&&!s2)b=26; else if(IsNearX(x,y,rc[27],1)&&!s2)b=27; else if(IsNearX(x,y,rc[28],1))b=28; else {b=-1;}
The LoadToTray
function sets the icon on the taskbar to use the menu. The encryption and decryption codes are shown here:
inline CString encrypt(CString str){
CString s1(_T(""));USES_CONVERSION;unsigned char c1=0;char *c=0;
for(register int i=str.GetLength()-1;i>=0;i--){
c1=0;c=0;c=T2A(str.Mid(i,1).GetBuffer());c1=*c;
unsigned char i1=((int)c1),i2,i3,i4;int i5;i2=i3=i4=i5=i1;
i2*=2;i2/=128;i2=!i2;i2*=64;i3/=128;
i3*=128;i4*=4;i4/=4;
i5=255-(i2+i3+i4)+1;s1+=((char)i5);
}
return s1;
}
Cryptography
The encryption logic I applied is:
inline CString encrypt(CString str){
CString s1(_T(""));USES_CONVERSION;unsigned char c1=0;char *c=0;
for(register int i=str.GetLength()-1;i>=0;i--){
c1=0;c=0;c=T2A(str.Mid(i,1).GetBuffer());c1=*c;
unsigned char i1=((int)c1),i2,i3,i4;int i5;i2=i3=i4=i5=i1;
i2*=2;i2/=128;i2=!i2;i2*=64;i3/=128;
i3*=128;i4*=4;i4/=4;
i5=255-(i2+i3+i4)+1;s1+=((char)i5);
}
return s1;
}
And the decryption logic:
CString dec(CString str){
CString s1(_T(""));USES_CONVERSION;unsigned char c1=0;char *c=0;
for(register int i=str.GetLength()-1;i>=0;i--){
c1=0;c=0;c=T2A(str.Mid(i,1).GetBuffer());c1=*c;
unsigned char i1=255-((int)c1)+1,i2,i3,i4,i5;i2=i3=i4=i5=i1;
i2*=2;i2/=128;i2=!i2;i2*=64;i3/=128;i3*=128;i4*=4;i4/=4;
i5=i2+i3+i4;s1+=i5;
}
return s1;
}
Guard program
This part just has one duty. If the main program closes, it opens it. The Find
function finds the main program handle and with IsWindow
, we check
of it is open or not. See code below:
if(!Find()){
ShellExecute(0,0,pathw+_T("\\Windows's Permission 1.exe"),0,0,1);
}
Techniques
About the security implementation, I used a technique called Nod32. The program is made of two programs. The main program and the guard program. It keep files in read mode
and doesn't close them to lock them. If you unlock a file or window and forget to lock it, locking will be activated automatically.
if(fd.Open(pathw+_T("\\Data\\tw"),CFile::modeRead)){
fd.Read(&gf[0],fd.GetLength());
locktime=atoi(gf); for(ie=0;ie<1000000;ie++)
gf[ie]=0;
fd.Close();
}
if(fd.Open(pathw+_T("\\Data\\wu"),CFile::modeRead)){
fd.Read(&gf[0],fd.GetLength());
os=gf;
for(ie=0;ie<1000000;ie++)
gf[ie]=0;
fd.Close();
}
Limitation
Unfortunately, this program and algorithm has defects.
- It's not a system driver. This means if you turn off the system or remove the hard disk, the files and windows will be opened and released. It's only suitable
for a computer that is always on such as telecommunication computers, and even coffee nets.
- The cryptography algorithm isn't powerful.