📜 ⬆️ ⬇️

ScreenLogger - smile, you are hidden camera

So, welcome. This article will analyze the process of writing a program that allows you to track in real time all actions that occur on a remote computer, without the knowledge of the end user. The author warns that he is not responsible for the misuse of the following technologies and does not recommend using it for illegal purposes. Go!

When writing any sufficiently large software product, it is required to break the global task into several simpler ones. So in this case, I have identified several practically unrelated processes, which, working together, allow us to achieve the desired result. In particular, for the implementation of the task you need to implement:

0) Adding service files when you first start the system folders
1) Screenshot removal
2) Send a screenshot to a remote server

Accordingly, the .NET platform, with all the necessary functionality, was chosen for implementation. The application is written on Windows Forms for clarity and debugging purposes, by and large it could be a console.
')
Description of functions:

SetConfig - provides read configuration settings from the attached settings file
Send - is responsible for sending a screenshot by email.
MakeScreen - is responsible for taking screenshots.
Circle - is responsible for repeating taking and sending a screenshot in the background with a specified frequency
CasualStart - defines actions at the next program launch
FirstStart - ensures the correct installation of the program

Now - a little more detail on each of the functions. Configuration setting:

Since the software must be flexible, it must be possible to change the internal parameters of the program from outside its code. Each time this software is launched, it tries to find the SaveScreen.ini file, update its settings and only then start working in the normal mode. In the case when the parameters cannot be updated, the default values ​​are used.

(about which parameter is responsible for what - will be at the end of the article)

For technical reasons, instead of a space, it was necessary to use an underscore, and instead of @ - #, but a reverse replacement is performed inside the program.

Program execution begins in the Form1_load block, and can be developed in two modes - normal start (if the computer has an installation directory) and installation (if there is no installation directory). Consider each one of them.

First start:
When you first start, you need to create a directory in which program files will be placed, transfer the executable file and configuration file there, and also add the necessary entries to the registry to add software to autorun.

Accordingly, this is implemented by the FirstStart () function.

image

After installation, the application closes - the next time you restart the computer, it will work as normal.

Regular launch:
A regular launch launches a background thread that removes and sends a screenshot, as well as clears the folder with screenshots taken during the last session. After that, it waits for a considerable period of time before forcing the application to close. Before starting the background thread, a pause is possible, which should be set up on relatively slow computers to speed up the system boot and no conflicts at startup.
asualStart ()

image

Circulation:
Everything is prosaic to a disgrace - in the eternal cycle we take and send screenshots, after which we wait for the specified time. Much more interesting is the process of removing and sending the screen.

image

Take a screenshot:
In C #, it is possible to save an image to a bitmap by copying from the screen. Therefore, all that needs to be done is to create an object to store the screenshot, with a resolution equal to the current screen resolution, attach an object to it that can get the bitmap from the screen and save it to a previously created directory.

image

Sending by mail:
In C #, it is possible to work with mail using the predefined classes, which allow you to fill in the letter fields, specify the addressee and the addressee, and actually send by calling one method. This method is wrapped in a try-catch block in case there is no connection to the network - even in this case, the program will not give an error message, but will wait for it submissively until it has the opportunity to contact the server. The mail server was chosen for reasons of simplicity, in principle - you can transfer images anywhere.

image

General interaction:
The launch of the program, I repeat, is carried out in the Form1_Load method. The program tries to update the config, then it determines whether it was started for the first time, if yes, it is added to the desired folder and automatically loaded and disconnected, and if not, it starts the background process, which stably over the specified interval sends the screen image to the mail server. Nothing complicated or unusual, just the interaction of several built-in classes.
image

And finally, the explanation of the autoconfiguration file - all the variable names coincide with the names in the program, therefore, explaining the fields in the init file, I also describe the variables themselves.

image

wayToDir - the name of the subfolder into which screenshots are thrown
finalDir = -name of the directory to which the program is transferred
nameOfApp = executable file name
subKeyAdress = path to registry entries to add to avtoran
reserved - reserved field
name - the name of the entry in the registry
startPause - pause before recording screenshots
exitPause - pause before forcibly exiting the program
adressFrom - the sender's address
nameFrom - the sender's signature
nameTo - recipient's email address
mailSubject - Email Subject
mailBody - letter text
smtpAdress - the SMTP address of the sender's mail server
smtpPort - mail sending port
mailPassword - password from the sender's mail
exp - file extension
timeBetweenScreens - the time between taking two screenshots.

Summarizing:

We have just described the process of writing an application to track actions on a remote computer. By connecting here the receipt of a file with a list of commands from the server and splitting it, we get a simplified samopisny TeamViewer. But this is not in this article.

Sources

Source: https://habr.com/ru/post/457172/


All Articles