This repo contains solution for one internal cybersecurity hackathon, where we must solve 5 tasks:
- Password policy
- Problem: find UNIX and non-UNIX accounts with weak passwords and reset 'em
- Solution: search for UNIX and SMB accounts, supply their hashes to John The Ripper and change passwords if we can bruteforce them
- Network policy
- Problem: find vulnerable services and close their external opened ports
- Solution: search for Dockerfile, docker-compose.yaml and .sh files, search for vulnerability in them using LLM and block it's ports
- SAST
- Problem: find a project in python and fix vulnerabilities found in code
- Solution: search for a project was implemented as algorythm, search and fix problems implemented using semgrep
- CVE-management
- Problem: find CVE in project dependencies from previous task and fix by updating vulnerable dependencies
- Solution: just supply requirements.txt to LLM and ask to fix vulnerable dependencies :)
- Q/A-agent
- Problem: given multiple documents, answer multiple questions using document data.
- Solution: pass documents to chromadb to build and index. If LLM chooses to search in index, then pass question to index and repeatedly ask LLM for an answer using given data from index.
For each problem solution was written using langchain_openai and langgraph libraries.
Some data sets, e.g. for track 5 RAG was deleted to avoid issues with NDA.
- Upgrade pip
pip install --upgrade pip- Install dependencies:
# Install dependencies
pip install -r requirements.txt-
Define a GIGACHAT_TOKEN env variable.
- If using Gemini define GEMINI_API_KEY
-
(Optional) Install RU government certificates for GigaChat
# 1. Скачиваем сертификат
Invoke-WebRequest -Uri "https://gu-st.ru/content/lending/russian_trusted_root_ca_pem.crt" -OutFile "russian_trusted_root_ca_pem.crt"
# 2. Находим путь к cacert.pem из пакета certifi
$certifiPath = python -c "import certifi; print(certifi.where())"
# 3. Добавляем сертификат к списку доверенных
Get-Content "russian_trusted_root_ca_pem.crt" | Add-Content $certifiPath- Run
python -m src.track1-password-policy.main- Together.ai https://docs.together.ai/docs/rate-limits (60 RPM)
LangGraph basically like langchain, but:
- Simplifies to run AI-agents asynchronously
- Allows merge results from step before
- Supports conditional node
All this can be obtained using langchain, but with more code complexity n requires higher threshold for new developers to entry into project.
- Update requirements.txt
pipreqs . --force --encoding=UTF8 --ignore ".venv"Contributors:
- https://github.com/ratedRRu (track 3)
- https://github.com/fresh-fx59 (track 2 & 5)