Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent a process from being killed in C#?

Tags:

c#

process

Ok, the title is my question.

No, this ain't for malware. It is for a parental control program for my own netbook.
Yes, I am tired of my brother's friends visiting porn sites on my laptop when I am away.

Oh, yes, I have red other questions and don't do the "You can't!" thing. It must be possible.

like image 919
Vercas Avatar asked Apr 19 '11 09:04

Vercas


People also ask

How do you protect a process from killing?

You can't kill the system process without crashing windows. So an approach is to inject code into the system process that starts a pair of threads and have the threads protect each and do whatever you would've had your unkillable process do (or have a third thread to do whatever work you want).

How do you protect a process in Linux?

All you have to do is remount the /proc filesystem with the Linux kernel hardening hidepid option. This hides process from all other commands such as ps, top, htop, pgrep and more.

Can a process ignore SIGKILL?

The SIGKILL signal is used to cause immediate program termination. It cannot be handled or ignored, and is therefore always fatal.

Does kill terminate the process?

Terminate the process. When no signal is included in the kill command-line syntax, the default signal that is used is –15 (SIGKILL). Using the –9 signal (SIGTERM) with the kill command ensures that the process terminates promptly.


2 Answers

Well, you could run several processes, and when one of them is killed, one of the others would launch a replacement. You can also run a service that would monitor the process and launch another process when the process is killed.

like image 162
Ilya Kogan Avatar answered Oct 09 '22 10:10

Ilya Kogan


Sorry, I can't comment so I've posted this as a 'answer'.

A few things to consider:

  • Is a 13 year old or his friends going to notice a process in taskmanager that shouldn't be there? (for example a second explorer.exe, svchost.exe etc.)

  • What are you trying to actually achieve as there may be other ways to do what it is you want. Are you trying to block them from going on certain sites? Are you trying to monitor what they do? Are you trying to prove to your mum what they are doing? Something else?

  • Unless you are trying to block them, will they care about anything you may have running? Would they bother to look for 'logging' software running on the PC? I would guess that they wouldn't bother to even open task manager unless the sites weren't working.

If you are trying to give proof or monitor your pc, running a VNC service in the background allows you to connect a viewer from another computer so that you/your mum can watch a live view of what they are up to.

If you want to monitor the sites then you have a wide range of options: keylogging software, browser logging software, proxy software or logging software on your router

If you want to block the sites then you also have a wide range of solutions: hosts file, dns based blocking (e.g. openDNS), blocking software on the pc (e.g. netnanny), blocking software on the router, etc.

Remember: If you are trying to block sites remember that nothing will block 100% of websites. You will only achieve 1 of 2 things: (Ideally) it becomes too much effort trying to find sites not blocked and they use another computer for their porn -or- they persist and find a way around it/to disable it/sites that it doesn't catch

like image 36
syserr0r Avatar answered Oct 09 '22 11:10

syserr0r