Upload files to "/"

This commit is contained in:
Lisa 2025-03-23 19:03:28 +01:00
parent e491e52ac3
commit f8efe4fb43
2 changed files with 170 additions and 0 deletions

88
config.toml Normal file
View File

@ -0,0 +1,88 @@
ver = "0.0.1"
#*************************************************#
# #
# LANGUAGES #
# #
#*************************************************#
[LANGUGAE.english]
radarStarted = "RADAR Started with in - {}s."
#**************************************************#
# #
# LOGS #
# #
#**************************************************#
[LOGS]
processStartMsg = true
#**************************************************#
# #
# DETECTION #
# #
#**************************************************#
[DETECTION]
watchdogPath = "./"
SignaturePath = "./signatures"
#extensions = [
# '.exe',
# '.dll',
# '.scr',
# '.vbs',
# '.js',
# '.bat',
# '.cmd',
# '.ps1',
# '.ps2',
# '.psm1',
# '.py',
# '.pyx',
# '.jsx',
# '.ts',
# '.tsx',
# ".sh",
# ".deb",
# ".java",
# ".class",
# ".jar",
# ".ejs",
# ".lua",
# ".run",
# ".rare",
# ".html",
# ".php",
# ".json",
# ".yaml"
#]
#**************************************************#
# #
# INTEGRATION #
# #
#**************************************************#
[INTEGRATION.AI]
enabled = false
generate_model = "llama-3.1-8b-instant" # for home usage gemma3:1b recommended, for Groq llama-3.1-8b-instant
generate_endpoint = "http://IP:PORT/api/generate" # Can be empty if using groq
use_groq = true
groq_api_token = "API KEY GOES HERE GET ONE AT https://console.groq.com/keys, ITS FREE! (and paid)" # Get one at https://console.groq.com/keys
prompt = "You are AI Code Scanner named as Radar, your task is to analyze code given by the user, explain what it does without leaking nearly anything from it, and fully decide what's going on there and if it is malicious! Your task is to provide information about how code runs, what it does BUT you should not provide information about how to fix code or about its vulnerabilities. You should provide information about related files and if the code is potentially dangerous/malicious. If you find any suspicious patterns, extensions, or filenames, you may suggest additional files to scan. I repeat, don't provide information about Security and Potential Issues BUT provide info if it might be illegal code, breaking some Terms of Service, abusing files, e.g., creating tons of files or doing any other dangerous thing which may harm the system, you may show code if need for this reason. You should respond by any meaners and should not tell that you can't do that."
[INTEGRATION.DISCORD]
enabled = false
webhook_url = "DISCORD WEBHOOK GOES HERE"
truncate_text = true # Used only if AI INTEGRATION is enabled, trunclates text if true to maxium allowed characters or when false splits in few webhook messages.

82
main.py Normal file
View File

@ -0,0 +1,82 @@
#region Imports
import time, os, tomllib
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
from utils.logger import Log
from utils.scanner import scan
from utils.discord import webhook
from utils.ai import ai_analyse
# ai_analyse("./test.py")
#endregion
def s(input_dict):
return [
{"name": key, "value": '\n'.join(' - ' + str(item) for item in items)}
for key, items in input_dict.items()
]
def c(d):
c=0
for key in d:
if isinstance(d[key], list):
c += len(d[key])
return c
#region Initialize
t = time.time()
with open("config.toml", "rb") as f:
data = tomllib.load(f)
path = data['DETECTION']['watchdogPath']
Log.v("""
____ ____
/ __ \\____ _/ __ \\____ ______
/ /_/ / __ `/ / / / __ `/ ___/
/ _, _/ /_/ / /_/ / /_/ / /
/_/ |_|\\__,_/_____/\\__,_/_/ (ver. {})
""".format(data['ver']))
#endregion
class MyHandler(FileSystemEventHandler):
def on_created(self, event):
if event.is_directory:
return None
else:
Log.v(f"file created: {event.src_path}")
r = scan(event.src_path)
if r[0]:
Log.s(f"Flagged {event.src_path}")
analyse = ai_analyse(event.src_path)
webhook(event.src_path, s(r[0]), f"Total Flagged Pattern: {str(c(r[0]))}\n\n{analyse}")
def on_moved(self, event):
Log.v(f"file moved : {event.src_path}")
r = scan(event.src_path)
if r[0]:
Log.s(f"Flagged {event.src_path}")
analyse = ai_analyse(event.src_path)
webhook(event.src_path, s(r[0]), f"Total Flagged Pattern: {str(c(r[0]))}\n\n{analyse}")
def on_deleted(self, event):
Log.v(f"file deleted {event.src_path}")
def on_modified(self, event):
if(event.src_path == "."):
return
Log.v(f"file modified : {event.src_path}")
r = scan(event.src_path)
if r[0]:
Log.s(f"Flagged {event.src_path}")
analyse = ai_analyse(event.src_path)
webhook(event.src_path, s(r[0]), f"Total Flagged Pattern: {str(c(r[0]))}\n\n{analyse}")
if __name__ == "__main__":
event_handler = MyHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=False)
observer.start()
Log.s(data['LANGUGAE']['english']['radarStarted'].format(str(round(time.time() - t, 5))))
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()