Skip to content

Commit ccffe52

Browse files
committed
First Commit
1 parent 7f0a499 commit ccffe52

28 files changed

+941
-790
lines changed

.vscode/c_cpp_properties.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "windows-gcc-x64",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"compilerPath": "gcc",
9+
"cStandard": "${default}",
10+
"cppStandard": "${default}",
11+
"intelliSenseMode": "windows-gcc-x64",
12+
"compilerArgs": [
13+
""
14+
]
15+
}
16+
],
17+
"version": 4
18+
}

.vscode/launch.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "C/C++ Runner: Debug Session",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
"args": [],
9+
"stopAtEntry": false,
10+
"externalConsole": true,
11+
"cwd": "c:/Users/mihai/Desktop/SO/so_2_1_dobra_mihai",
12+
"program": "c:/Users/mihai/Desktop/SO/so_2_1_dobra_mihai/build/Debug/outDebug",
13+
"MIMode": "gdb",
14+
"miDebuggerPath": "gdb",
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing for gdb",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
}
21+
]
22+
}
23+
]
24+
}

.vscode/settings.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"C_Cpp_Runner.cCompilerPath": "gcc",
3+
"C_Cpp_Runner.cppCompilerPath": "g++",
4+
"C_Cpp_Runner.debuggerPath": "gdb",
5+
"C_Cpp_Runner.cStandard": "",
6+
"C_Cpp_Runner.cppStandard": "",
7+
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat",
8+
"C_Cpp_Runner.useMsvc": false,
9+
"C_Cpp_Runner.warnings": [
10+
"-Wall",
11+
"-Wextra",
12+
"-Wpedantic",
13+
"-Wshadow",
14+
"-Wformat=2",
15+
"-Wcast-align",
16+
"-Wconversion",
17+
"-Wsign-conversion",
18+
"-Wnull-dereference"
19+
],
20+
"C_Cpp_Runner.msvcWarnings": [
21+
"/W4",
22+
"/permissive-",
23+
"/w14242",
24+
"/w14287",
25+
"/w14296",
26+
"/w14311",
27+
"/w14826",
28+
"/w44062",
29+
"/w44242",
30+
"/w14905",
31+
"/w14906",
32+
"/w14263",
33+
"/w44265",
34+
"/w14928"
35+
],
36+
"C_Cpp_Runner.enableWarnings": true,
37+
"C_Cpp_Runner.warningsAsError": false,
38+
"C_Cpp_Runner.compilerArgs": [],
39+
"C_Cpp_Runner.linkerArgs": [],
40+
"C_Cpp_Runner.includePaths": [],
41+
"C_Cpp_Runner.includeSearch": [
42+
"*",
43+
"**/*"
44+
],
45+
"C_Cpp_Runner.excludeSearch": [
46+
"**/build",
47+
"**/build/**",
48+
"**/.*",
49+
"**/.*/**",
50+
"**/.vscode",
51+
"**/.vscode/**"
52+
],
53+
"C_Cpp_Runner.useAddressSanitizer": false,
54+
"C_Cpp_Runner.useUndefinedSanitizer": false,
55+
"C_Cpp_Runner.useLeakSanitizer": false,
56+
"C_Cpp_Runner.showCompilationTime": false,
57+
"C_Cpp_Runner.useLinkTimeOptimization": false,
58+
"C_Cpp_Runner.msvcSecureNoWarnings": false
59+
}

README.md

Lines changed: 80 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,93 @@
1-
# SO_2_1_Dobra_Mihai
1+
# Folder Integrity and Malicious File Scanner
2+
3+
4+
[![Assembly](https://img.shields.io/badge/language-C-green.svg)](https://en.wikipedia.org/wiki/C_(programming_language))
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
[![University: UPT](https://img.shields.io/badge/University-Politehnica%20Timisoara-red.svg)](https://www.upt.ro/)
7+
[![Status: Academic](https://img.shields.io/badge/Status-Academic%20Project-success.svg)](https://github.com/mijay6/Operating-System-File-Monitoring-Tool)
28

3-
## Name
4-
Proiect S0.
59

610
## Description
7-
Acest program va analiza o serie de foldere si in functie de cum se apeleaza programul,
8-
va realiza diferite functionalitati in aceste foldere.
11+
This utility scans one or more directories (and their subdirectories), computes and stores SHA-256 checksums and metadata for every file, then compares snapshots across runs to detect:
12+
13+
- **Additions**: new files or folders
14+
- **Deletions**: removed files or folders
15+
- **Modifications**: changes in content (checksum), name, type or permissions
16+
17+
Additionally, an optional mode will analyze each file for malicious characteristics (based on size, content, keywords, or non-ASCII characters) and move any flagged files to an isolation folder.
18+
19+
## Features
920

10-
## Installation
11-
Va fi compilat asa: gcc -Wall -o prog prog.c -lssl -lcrypto
21+
- Recursively traverse directories and record metadata in a snapshot file (`<dirname>_snapshot.dat`).
22+
- Compare current and previous snapshots to list added, removed, or modified entries.
23+
- Compute SHA-256 checksum using OpenSSL.
24+
- `-o` option: specify an output directory for generated snapshots.
25+
- `-s` option: specify an isolation directory for malicious files.
26+
- Concurrent processing: each directory is scanned in parallel to improve performance.
27+
- Malicious file detection via a helper Bash script (`verify_for_malicious.sh`).
28+
29+
## Prerequisites & Build
30+
31+
- **GCC** (with C99 support)
32+
- **OpenSSL** development libraries (for SHA-256)
33+
34+
Compile with:
35+
36+
```bash
37+
gcc -Wall -o prog prog.c -lssl -lcrypto
38+
```
1239

1340
## Usage
1441

15-
./prog folder1 folder2 folder3...etc (maxim 10 directoare)
42+
```bash
43+
# Basic snapshot and comparison
44+
./prog folder1 folder2 ...
45+
46+
# Save snapshots to a dedicated output directory
47+
./prog -o snapshots_out folder1 folder2 ...
48+
49+
# Additionally isolate malicious files to a quarantine directory
50+
./prog -o snapshots_out -s quarantine_dir folder1 folder2 ...
51+
```
52+
53+
## Behavior
54+
55+
First run: generates `<dirname>_snapshot.dat` and reports
56+
> "First run: no previous snapshot found."
57+
58+
Subsequent runs: compares to previous snapshot and prints:
59+
60+
- **Added**: new files or folders
61+
- **Removed**: deleted files or folders
62+
- **Modified**: name change, content change, permission change, size change, or type change
63+
64+
**With `-s`**: files deemed malicious are moved to the specified quarantine directory.
65+
66+
## Malicious File Detection
67+
68+
The script `verify_for_malicious.sh` applies the following heuristics:
69+
70+
1. Flags files exceeding **100 lines**, **5 000 words**, or **10 000 characters** as dangerous.
71+
2. Flags files with fewer than **3 lines** but more than **1 000 words** or **2 000 characters** as suspicious, then:
72+
- Searches for keywords: `corrupted`, `dangerous`, `risk`, `attack`, `malware`, `malicious`.
73+
- Detects non-ASCII characters.
74+
3. Any flagged file has its permissions revoked and is either printed (`SAFE` or file path) or moved to quarantine.
1675

17-
Se da ca parametru unul sau mai multe foldere si programul va calcula suma de control SHA-256
18-
a tuturor fisierelor din folder si subfoldere si va pastra metadatele fiecarei fisiere din folder
19-
intrun fisier snapshot. Va compara snapshotul anterior cu cel actual si va printa modificarile.
20-
----------------------------------------------------------------------
21-
./prog -o outputdir folder1 folder2 folder3...etc (maxim 10 directoare)
76+
## Test Folders
2277

23-
Functionalitatea este extinsa cu un parametru -o urmat de un folder unde
24-
se vor pune fisierele snapshot ale folderelor date ca parametru
25-
----------------------------------------------------------------------
26-
./prog -o outputdir -s izolated_space_dir folder1 folder2 folder3...etc (maxim 10 directoare)
78+
This repository includes three sample test folders:
2779

28-
Functionalitatea este extinsa cu un parametru -s urmat de un folder unde se vor muta fisierele malitioase
29-
----------------------------------------------------------------------
80+
- `test_folder1/`
81+
- `test_folder2/`
82+
- `test_folder3/`
3083

31-
## Authors and acknowledgment
32-
Dobra Mihai
84+
Each contains various files and nested directories (including deliberately malicious files) to validate snapshot integrity and malicious detection.
3385

34-
## License
35-
Open Source
86+
## Author
87+
Politehnica University of Timișoara
88+
Faculty of Automation and Computer Science
89+
Operating systems
90+
Academic Year 2023-2024
3691

37-
## Project status
38-
Finish
92+
## Contributing
93+
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

corrupted_file.txt~

Lines changed: 0 additions & 2 deletions
This file was deleted.

folder1/sub2/subfisier.txt~

Whitespace-only changes.

prog

-35.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)