이경수

dynamic.html 추가

......@@ -137,3 +137,7 @@ STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
......
from django.contrib import admin
from myapp.models import Question, Choice
from myapp.models import *
# Register your models here.
class UploadFileAdmin(admin.ModelAdmin):
list_display = ('title', 'file')
admin.site.register(Question)
admin.site.register(Choice)
admin.site.register(UploadFileModel, UploadFileAdmin)
......
from django import forms
from .models import UploadFileModel
class testform(forms.Form):
text = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'size':80}))
class UploadFileForm(forms.ModelForm):
class Meta:
model = UploadFileModel
fields = ('title', 'file')
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-05-22 10:19
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('myapp', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='DynamicCheckList',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('classification', models.CharField(max_length=200)),
('checklist', models.CharField(max_length=200)),
('importance', models.CharField(max_length=200)),
],
),
migrations.RemoveField(
model_name='choice',
name='question',
),
migrations.DeleteModel(
name='Choice',
),
migrations.DeleteModel(
name='Question',
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-05-23 05:48
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('myapp', '0002_auto_20180522_1919'),
]
operations = [
migrations.CreateModel(
name='UploadFileModel',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.TextField(default='')),
('file', models.FileField(null=True, upload_to='')),
],
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-05-23 06:27
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('myapp', '0003_uploadfilemodel'),
]
operations = [
migrations.DeleteModel(
name='DynamicCheckList',
),
]
......@@ -2,17 +2,6 @@ from django.db import models
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question_text
class Choice(models.Model):
question = models.ForeignKey(Question)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text
class UploadFileModel(models.Model):
title = models.TextField(default='')
file = models.FileField(null=True)
......
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>VulnNotti</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="{% static 'vendor/freelancer_bootstrap/css/bootstrap.min.css' %}">
<!-- Custom fonts for this template -->
<link rel="stylesheet" href="{% static 'vendor/freelancer_font-awesome/css/font-awesome.min.css' %}">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
<!-- Plugin CSS -->
<link rel="stylesheet" href="{% static 'vendor/magnific-popup/magnific-popup.css' %}">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="{% static 'css/freelancer.min.css' %}">
<!-- highlight.js -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/highlight.js/9.5.0/styles/vs2015.min.css">
<script src="//cdn.jsdelivr.net/highlight.js/9.5.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body id="page-top">
<!-- Navigation -->
<nav class="navbar navbar-expand-lg bg-secondary fixed-top text-uppercase" id="mainNav">
<div class="container">
<a class="navbar-brand js-scroll-trigger" href="/">Home</a>
<button class="navbar-toggler navbar-toggler-right text-uppercase bg-primary text-white rounded" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fa fa-bars"></i>
</button>
</div>
</nav>
<!-- Header -->
<header class="masthead bg-primary text-white text-center">
<div class="container">
<!-- <img class="img-fluid mb-5 d-block mx-auto" src="{% static 'img/profile.png' %}" alt=""> -->
<h1 class="text-uppercase mb-0">동적 분석 페이지입니다.</h1>
<hr class="star-light">
<h2 class="font-weight-light mb-0">툴을 다운로드 받은 후 결과 파일을 업로드 해주세요.</h2>
<a href="{% static 'img/profile.png' %}" download>
<button class="btn btn-success">Download!</button>
</a>
<button class="btn btn-warning">Upload!</button>
<form method="post" enctype="multipart/form-data">{% csrf_token %}
<input type="file" name="sentFile" />
<input type="submit" name="submit" value="Upload" />
</form>
</div>
</header>
<!-- <form method="post" action=".">
<fieldset>{% csrf_token %}
<div>
{{ form.text.label_tag }} {{ form.text }}
</div>
<input type="submit" value="submit"/>
</fieldset>
</form> -->
<!-- Portfolio Grid Section -->
<div class="col-md-12 col-lg-12">
<div style="width: 100%; margin-left: 0px; margin-right: 0px;">
<!-- <form method="post" action=".">
<fieldset>{% csrf_token %}
<div>
{{ form.text.label_tag }} {{ form.text }}
</div>
<input type="submit" value="submit"/>
</fieldset>
</form> -->
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>분류</th>
<th>점검항목</th>
<th>항목 중요도</th>
<th>결과</th>
</tr>
<tbody>
{% for object in object_list %}
<tr>
<td>{{ object.id }}</td>
<td>{{ object.classification }}</td>
<td>{{ object.checklist }}</td>
<td>{{ object.importance }}</td>
<td>{{ object.result }}</td>
<!-- <td id="modal_{{ forloop.counter }}">
<a class="portfolio-item d-block mx-auto" href="#portfolio-modal-{{ forloop.counter }}">
<button class="btn btn-primary">자세히보기</button></td>
</a>
</td> -->
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% for object in object_list %}
<div class="portfolio-modal mfp-hide" id="portfolio-modal-{{ forloop.counter }}">
<div class="portfolio-modal-dialog bg-white">
<!-- header -->
<div class="modal-header">
</div>
<!-- left side -->
<div class="col-lg-12">
{{ object.result }}
</div>
<!-- footer -->
<div class="modal-footer" style="float: clear;">
<a class="btn btn-primary btn-lg rounded-pill portfolio-modal-dismiss" href="#">
<i class="fa fa-close"></i>
Close
</a>
</div>
</div>
</div>
{% endfor %}
</body>
<script src="{% static 'js/Chart.min.js' %}"></script>
<script src="{% static 'vendor/freelancer_jquery/jquery.min.js' %}"></script>
<script src="{% static 'vendor/freelancer_bootstrap/js/bootstrap.bundle.min.js' %}"></script>
<script src="{% static 'vendor/jquery-easing/jquery.easing.min.js' %}"></script>
<script src="{% static 'vendor/magnific-popup/jquery.magnific-popup.min.js' %}"></script>
<script src="{% static 'js/jqBootstrapValidation.js' %}"></script>
<script src="{% static 'js/contact_me.js' %}"></script>
<script src="{% static 'js/freelancer.min.js' %}"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script type="text/javascript" src="{% static 'js/Chart.min.js' %}"></script>
<script type="text/javascript">
</html>
......@@ -3,7 +3,7 @@ from myapp.views import *
urlpatterns = [
url(r'^$', MypageView.as_view(), name='mypage'),
url(r'^table', TableView.as_view(), name='table'),
url(r'^static/', StaticView.as_view(), name='static'),
url(r'^dynamic/', DynamicView.as_view(), name='dynamic'),
]
......
from django.views.generic.base import TemplateView
from django.views.generic import FormView
from django.views.generic import View
from myapp.forms import testform
from django.db import connection
from django.shortcuts import render
from django.http import HttpResponseRedirect
from .forms import UploadFileForm
import re
class DynamicView(TemplateView):
template_name = 'dynamic.html'
class MypageView(TemplateView):
template_name = 'mypage.html'
form_class = testform
def get(self, request, *args, **kwargs):
query = 'SELECT * FROM vuln.dynamic'
param_list = []
with connection.cursor() as cursor:
cursor.execute(query, param_list)
columns = [column[0] for column in cursor.description]
object_list = []
for row in cursor.fetchall():
object_list.append(dict(zip(columns, row)))
context = {}
context['object_list'] = object_list
# f = open("C:/Users/dlrud/Desktop/shell.txt", 'r')
# while True:
# line = f.readline()
# if not line: break
# print(line)
# f.close()
return render(self.request, self.template_name, context)
def post(self, request, *args, **kwargs):
file = request.FILES['sentFile'] # here you get the files needed
temp = ""
while True:
line = file.readline()
temp += str(line, 'UTF-8')
if not line: break
# print(str(line, 'UTF-8'))
# r = re.compile('\@.+\@', )
r = re.compile(r'\@(.+)\@', re.MULTILINE)
results = r.findall(temp)
result_list = dict(enumerate(results, 0))
query = 'SELECT * FROM vuln.dynamic'
param_list = []
with connection.cursor() as cursor:
cursor.execute(query, param_list)
columns = [column[0] for column in cursor.description]
object_list = []
for row in cursor.fetchall():
object_list.append(dict(zip(columns, row)))
for i in range(0, len(result_list)):
object_list[i]['result'] = result_list[i]
context = {}
context['object_list'] = object_list
return render(self.request, self.template_name, context)
class StaticView(TemplateView):
template_name = 'static.html'
def get(self, request, *args, **kwargs):
context = {}
......@@ -36,7 +112,7 @@ class MypageView(TemplateView):
context['red'] = red
context['blue'] = blue
context['green'] = green
context['green'] = green
context['object_list'] = object_list
return render(self.request, self.template_name, context)
......
......@@ -32,10 +32,10 @@
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/">Static</a>
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/static">Static</a>
</li>
<li class="nav-item mx-0 mx-lg-1">
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#about">Dynamic</a>
<a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/dynamic">Dynamic</a>
</li>
{% if user.is_active %}
<!-- <li class="nav-item mx-0 mx-lg-1">
......