-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from andrisecops/IT-Infrastructure-Webserver
build(devsecops)insfratuctur
- Loading branch information
Showing
12 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from flask import Flask | ||
from config import Config | ||
|
||
app = Flask(__name__) | ||
app.config.from_object(Config) | ||
|
||
from app import routes, dashboard, monitoring, analysis | ||
|
||
# Inisialisasi logging | ||
import logging | ||
from logging.handlers import RotatingFileHandler | ||
import os | ||
|
||
if not os.path.exists(app.config['LOG_PATH']): | ||
os.makedirs(app.config['LOG_PATH']) | ||
|
||
file_handler = RotatingFileHandler(os.path.join(app.config['LOG_PATH'], 'system.log'), maxBytes=10240, backupCount=10) | ||
file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s')) | ||
file_handler.setLevel(logging.INFO) | ||
app.logger.addHandler(file_handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def analyze_file(file_path): | ||
# Contoh analisis sederhana | ||
with open(file_path, 'rb') as file: | ||
content = file.read() | ||
if b'backdoor' in content: | ||
return 'Malware Detected' | ||
return 'File is Safe' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import random | ||
|
||
def get_dashboard_data(): | ||
# Contoh data, ganti dengan data yang diambil dari sistem | ||
data = { | ||
'traffic_in': random.randint(100, 1000), | ||
'traffic_out': random.randint(100, 1000), | ||
'threats_detected': random.randint(0, 5), | ||
'alerts': random.randint(0, 3), | ||
} | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
import logging | ||
|
||
def monitor_incoming_files(directory): | ||
files = os.listdir(directory) | ||
for file in files: | ||
if file.endswith(('.php', '.exe', '.js', '.bat')): | ||
logging.warning(f'Threat detected in file: {file}') | ||
alert_admin(f'Threat detected in file: {file}') | ||
|
||
def alert_admin(message): | ||
# Fungsi untuk mengirim notifikasi email | ||
logging.info(f'Sending alert to admin: {message}') | ||
# Implementasi pengiriman email di sini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from flask import render_template | ||
from app import app | ||
from app.dashboard import get_dashboard_data | ||
|
||
@app.route('/') | ||
def index(): | ||
data = get_dashboard_data() | ||
return render_template('dashboard.html', data=data) | ||
|
||
# Tambahkan rute lainnya yang diperlukan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from flask_mail import Mail, Message | ||
from app import app | ||
|
||
mail = Mail(app) | ||
|
||
def send_email(subject, recipient, body): | ||
msg = Message(subject, sender=app.config['ALERT_EMAIL'], recipients=[recipient]) | ||
msg.body = body | ||
mail.send(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import os | ||
|
||
class Config: | ||
SECRET_KEY = os.environ.get('SECRET_KEY') or 'kunci_rahasia' | ||
DEBUG = True | ||
LOG_PATH = os.path.join(os.getcwd(), 'logs') | ||
ALERT_EMAIL = '[email protected]' | ||
REPORT_INTERVAL = 7 # days | ||
|
||
# Tambahkan konfigurasi lainnya yang diperlukan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Flask==2.0.1 | ||
Flask-Mail==0.9.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from app import app | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
padding: 20px; | ||
background-color: #333; | ||
color: #fff; | ||
} | ||
|
||
#data-visualization { | ||
margin: 20px auto; | ||
padding: 10px; | ||
max-width: 600px; | ||
background-color: #fff; | ||
border-radius: 5px; | ||
box-shadow: 0 0 10px rgba(0,0,0,0.1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Anda bisa menambahkan interaktivitas di sini jika diperlukan. | ||
console.log('Dashboard loaded'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>IT Infrastruktur Dashboard</title> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"> | ||
</head> | ||
<body> | ||
<h1>Dashboard</h1> | ||
<div id="data-visualization"> | ||
<p>Traffic In: {{ data.traffic_in }}</p> | ||
<p>Traffic Out: {{ data.traffic_out }}</p> | ||
<p>Threats Detected: {{ data.threats_detected }}</p> | ||
<p>Alerts: {{ data.alerts }}</p> | ||
</div> | ||
</body> | ||
</html> |