Work-In-Progress | Comprehensive A/V Client, IDS, & Blue Team C&C.
The scanner that tells you what it did not check.
No cookies · No databases · No third party connections · No analytics · No exceptions
HRProtect is a self hosted scanner for the files on a server. Point it at a folder. One or more scanners judge every file in it, what is not clean is quarantined or reported, & you are told what it did.
You are also told what it did not do. A file that could not be read is never called clean. A scanner that stops working is never trusted. A part that is not watching is named.
It sends nothing anywhere.
Important
This is v0.0.8, an early build, on the HRProprietary Engine v4.2.5. It is a command line program that root runs. It has no web interface & does not watch a server while it runs. From v0.0.7 systemd can run a scan on a schedule, & from v0.0.8 a check of which parts are watching. Its tests run where systemd is not running, so the units of both have been written & read by them & never started. Read Documentation/ABOUT_SCANNING.txt before you rely on it.
A folder with three ordinary files & one copy of the harmless test file every scanner knows:
$ sudo php protectCore.php --app-scan /tmp/uploads
Scanning /tmp/uploads with scancore.
Infected /tmp/uploads/2026/invoice.pdf.exe -> quarantined as 20261120-065430-f3403278e73e
Findings
Infected /tmp/uploads/2026/invoice.pdf.exe
scancore: Infected: invoice.pdf.exe (Trojan.Eicar.4, SHA256 Hash Match: 275a021bbfb6489e54d471899f7db9d1663fc695ec2fe2a2c4538aabf651fd0f)
Quarantined as 20261120-065430-f3403278e73e.
Summary
Files read 4
Clean 3
Judged by fewer scanners 0
Infected 1
Suspicious 0
Quarantined 1
Not read in full 0
Folders read 2
Links passed over 0
Other things passed over 0
Filesystems not entered 0
Scanner runs 5
The report is at /DATA/HRProtect/Reports/Scan-20261120-065430-64f452f355ed.json
Three things in that output are the whole idea.
- The file was moved, & not deleted.
--app-restoreputs it back exactly, with the owner & the mode it had. - Five scanner runs for four files. A batch that is not clean is halved until each file in it has been judged alone. Nothing a scanner prints is trusted to say which file it meant.
- Every count that could hide something has a line of its own. What was not read in full, what was passed over & what fewer scanners judged are each said, even when the answer is 0.
Then ask it what is watching:
$ sudo php protectCore.php --app-coverage
What is watching, as HRProtect 0.0.8 stands on this server.
This machine
ScanCore scanner ready 0.0.2 It is the default scanner.
ClamAV scanner off 0.0.2 It is not the default scanner, so a scan runs it only where it is named, or with all.
Quarantine file ready 0.0.3 A file a scan finds infected is quarantined.
Scheduled scan timer off - No path is set in --Scheduled Scan Paths--, so no scan is scheduled.
The blue team
Event Core core ready 0.0.3 What is done & found is recorded.
Scheduled check timer off - Its timer is not installed, so a part that stops watching is found when somebody asks. sudo php protectCore.php --setup --install-service writes it.
Every part that is switched on is ready.
php protectCore.php --app-coverage --probe Also hands each scanner a file to judge, & loads every other pipeline.
A scanner's whole job is to open hostile files, so HRProtect treats every scanner as something that can be taken over. Everything else follows from that.
- No scanner is shown a file where it lives. Root reads each file & hands the scanner a copy, in a sandbox that holds that batch of copies & nothing else. A scanner parses hostile files, so it is assumed to be exploitable.
- A scanner is handed nothing of root's. It reads from nothing, prints to a pipe, & is handed no file root holds open, so it cannot write to a log or a lock.
- A file is judged alone before anything is done to it. A batch that is not clean is halved until each file in it has been handed to a scanner by itself. Nothing a scanner prints is read to find out which file it meant.
- Root is never led by a link. A folder another account owns is entered one name at a time, & a link is refused rather than followed.
- What you type is sanitized, & never changed. A path is accepted whole or refused whole, so a scan never reads a file you did not name. A path holding a control character, or one PHP would open as a stream such as
phar://, is refused. - What could not be read is never called clean. It is reported as not read, & the exit status says so.
- A scan that is stopped stops itself. Asked to stop, or sent
TERMor Ctrl+C, it finishes the file it is on, removes what it had read, writes its report & calls nothing clean that no scanner judged.
| Command | What it does |
|---|---|
--app-scan PATH [SCANNER] |
Scans a file or a folder. SCANNER is scancore, clamav, or all. |
--app-scan PATH [SCANNER] --detach |
Runs the same scan in the background, with a log of its own, & returns. |
--app-scan-status |
Says whether a scan is running & how far it is, or how the last one ended. |
--app-scan-stop [ID] |
Asks the scan that is running to stop. It writes its report first. |
--app-scan-scheduled |
Scans every path --Scheduled Scan Paths-- names, one after another. A timer runs it, & root types it to see what the timer will do. |
--app-quarantine [ID] |
Lists what is quarantined, or shows everything known about one file. |
--app-restore ID [FOLDER] |
Puts a quarantined file back, where it was or in FOLDER. |
--app-purge ID |
Removes a quarantined file for good. It asks first. |
--app-events [DAYS] [SEVERITY] |
Lists what the event record holds for the last day, or the last DAYS, oldest first. |
--app-event ID |
Shows everything one event holds, as JSON. |
--app-coverage [--probe] |
Says which parts of HRProtect are watching & which are not. --probe also tries each one. |
--app-coverage-scheduled |
Looks at every part, & says which stopped watching since the last check. A timer runs it, & root types it to see what the timer will do. |
Every one of them is root's alone. -h lists the rest, which are the Engine's.
A file a scanner calls infected is moved into a folder only root can open, with a record of where it came from, who owned it & what its mode was, so it can be put back exactly.
A file that is copied back out of the quarantine is held to the length of the file kept. A copy that comes out shorter is removed again, & the file stays in the quarantine. That is from v0.0.6. Until then a read that failed partway was taken for the end of the file, so a short copy was called put back & what the quarantine kept was removed. The Quarantine pipeline is v0.0.3.
From v0.0.3 what HRProtect does & finds is kept in an event record, one line of JSON for each event, in a folder only root can open. A scan that began or ended, each file found infected or suspicious, & a quarantined file put back or removed is each an event. No event is changed or removed. --Record Events-- in config.php switches the record off, & a scan runs the same without it.
From v0.0.4 a scanner that is not working is set aside by a scan. A scanner that leaves three files in a row unfinished is handed a file of HRProtect's own, & one that cannot judge that file is not run again in that scan. What the other scanners call clean after that is counted as judged by fewer scanners & never as clean, & a scan that found nothing then exits 3. A scan whose only scanner is set aside stops, with error 50006.
From v0.0.5 --app-coverage lists each scanner, the quarantine & the Event Core, says where each stands & why, & exits 0 only where every part that is switched on is ready. A part is ready, off, detached, refused or unable. --probe hands each scanner a file of HRProtect's own & loads the code of the quarantine, so a scanner that is installed & judges nothing is found before a scan depends on it. Every scan keeps the same answer in its report, & says in a note where a part that was expected was not watching.
From v0.0.8 it asks itself, on a schedule. --app-coverage-scheduled looks at every part, compares what it sees with what the last check saw, & keeps an event for each part that was ready & is not, coverage.lost, & for each that was not ready & is now, coverage.gained. The Engine writes hrprotect-coverage.service & hrprotect-coverage.timer for it, & enables neither. Coverage that is not whole leaves the unit failed, so systemctl --failed says so without anybody asking. It only looks. It hands no scanner a file, so it never holds the lock a scan needs. The first check has nothing to compare with, & says that as well, because a record somebody took away looks the same.
From v0.0.7 a scan runs on a schedule. --Scheduled Scan Paths-- names what to scan & --Scheduled Scan Calendar-- says when. The Engine writes a systemd service & a timer for it, hrprotect-scan.service & hrprotect-scan.timer, & enables neither. An administrator enables the timer. Each path is scanned as --app-scan scans it, & a run that scanned nothing, or left a path out, says so with its exit status, a warning & an event. --app-coverage gains a row for the schedule, which is ready only where systemd says the timer is installed, enabled & running.
A script can act on these. No status but 0 ever means clean.
| Status | Meaning |
|---|---|
0 |
Everything was read & nothing was found. |
1 |
Something infected or suspicious was found. |
2 |
The command could not run as it was given. |
3 |
Nothing was found, & not everything was read in full & judged by every scanner asked for. A scan that was stopped, or that set a scanner aside, ends this way. |
With --detach the status is that of starting the scan: 0 where it began, 2 where it did not. --app-scan-status shows what the scan itself ended with.
--app-scan-scheduled exits with the same four, said of the whole run. 2 means no path was scanned, & 3 that a path was not scanned or was not read in full. Its unit calls 0 & 1 a success, so systemctl --failed shows a run that ended with 2 or 3.
--app-coverage & --app-coverage-scheduled have statuses of their own. 0 means every part that is switched on is ready, 1 that a part is not watching, & 2 that the parts could not be listed. --app-coverage --probe exits 3 where it could hand no scanner a file. The unit of the check calls only 0 a success.
HRProtect needs PHP 8 on the command line & Bubblewrap. ScanCore is bundled. ClamAV is optional. A scan in the background needs setsid, & a scan answers a signal to end where PHP has pcntl.
sudo php protectCore.php -fp # Installs it into /DATA/HRProtect/Application & makes its folders.
php protectCore.php -v # Says what this installation has & what it lacks.
sudo php protectCore.php --app-scan /srv/uploads
sudo php protectCore.php --app-scan / --detach # A long scan, in the background.
sudo php protectCore.php --app-scan-status
sudo php protectCore.php --app-events 7 high # What the last seven days hold that is high or critical.
sudo php protectCore.php --app-coverage --probe # Which parts are watching, with each one tried.
A scan on a schedule is three more steps, & each is yours to take. Nothing HRProtect does enables the timer.
sudo php protectCore.php --config # Set --Scheduled Scan Paths--, as '/home, /var/www' is written.
sudo php protectCore.php --app-scan-scheduled # Run it by hand first, & read what it says.
sudo php protectCore.php --setup --install-service # Writes hrprotect-scan.service & hrprotect-scan.timer.
sudo systemctl enable --now hrprotect-scan.timer # Enables the timer.
sudo php protectCore.php --app-coverage # Says whether the schedule is watching, & when it last ran.
A check of which parts are watching is two steps, & it runs every hour unless --Scheduled Coverage Calendar-- says otherwise.
sudo php protectCore.php --app-coverage-scheduled # Run it by hand first. The first check says it has nothing to compare with.
sudo php protectCore.php --setup --install-service # Writes hrprotect-coverage.service & hrprotect-coverage.timer as well.
sudo systemctl enable --now hrprotect-coverage.timer # Enables the timer.
sudo php protectCore.php --app-events 7 high # A part that stopped watching is here, as coverage.lost.
The unit of the check is confined, so it cannot see /home or /root. An installation whose data location is beneath either cannot use it as it is. The unit then fails each time it is started, systemctl --failed lists it, & its row in --app-coverage says that no check on a schedule has written down what it saw.
v0.0.3 adds one setting, --Record Events--. An installation that keeps its own config.php runs sudo php protectCore.php --config --repair & then -fp. Until it is repaired HRProtect stops with error 28000, which says so. -fp run from a whole new tree installs the config.php that tree carries, which is the one HRProtect ships with.
v0.0.7 adds two more, --Scheduled Scan Paths-- & --Scheduled Scan Calendar--, & the same holds for them. A release installed over this one brings its own config.php, so --Scheduled Scan Paths-- is empty again afterwards & is set again. The installation that was replaced is kept in Last-Installed-Version in the data location, with its config.php. Until the paths are set again --app-coverage says the schedule is unable, & each run of an enabled timer scans nothing & exits 2.
v0.0.8 adds one more, --Scheduled Coverage Calendar--. What a check on a schedule wrote down is kept through an upgrade, because it is in the data location. So where the timer of the check is enabled, the first check after an upgrade that emptied --Scheduled Scan Paths-- says that the schedule stopped watching.
HRProtect is built on the HRProprietary Engine, which it carries a copy of. The Engine brings the kernel, the sandbox, the installer & the command line. HRProtect brings the scanning, the quarantine, the event record & the coverage.
-fp is the Engine's installer. It also publishes a loader under the web server's document root & writes an Apache & a PHP configuration, as it does for every application built on the Engine. HRProtect answers a browser with one sentence. Documentation/ENGINE_RECONCILIATION_HRPROTECT.txt says more about that, & about everything this application changed in the Engine & why.
| Document | What it covers |
|---|---|
ABOUT_SCANNING.txt |
How a scan reads & judges files, runs in the background, on a schedule & is stopped, & what it does not do. |
ABOUT_QUARANTINE.txt |
How a file is quarantined & put back. |
ABOUT_EVENTS.txt |
The record of what HRProtect did & found, the Event Core that keeps it, & how to read it. |
ABOUT_COVERAGE.txt |
Which parts are watching, how that is learned, what --probe adds & what a check on a schedule records. |
ABOUT_COMMAND_LINE_ARGUMENTS.txt |
Every command, the Engine's & HRProtect's own. |
ERROR_DESCRIPTIONS.txt |
Every numbered error & every warning, its cause & its fix. |
CHANGELOG.txt |
What changed & when. |
DEVELOPMENT_NOTES.txt |
Why each part is shaped the way it is, & what came before. |
ENGINE_RECONCILIATION_HRPROTECT.txt |
What this application changed in the Engine & why. |
CODING_CONVENTIONS.txt |
The conventions this codebase follows. |
Every document lives in Documentation.
GNU GPLv3. Copyright Justin Grimes, www.github.com/zelon88.

