이경수

dynamic.html 추가

...@@ -137,3 +137,7 @@ STATIC_URL = '/static/' ...@@ -137,3 +137,7 @@ STATIC_URL = '/static/'
137 STATICFILES_DIRS = [ 137 STATICFILES_DIRS = [
138 os.path.join(BASE_DIR, 'static') 138 os.path.join(BASE_DIR, 'static')
139 ] 139 ]
140 +
141 +MEDIA_URL = '/media/'
142 +
143 +MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
......
1 from django.contrib import admin 1 from django.contrib import admin
2 -from myapp.models import Question, Choice 2 +from myapp.models import *
3 # Register your models here. 3 # Register your models here.
4 4
5 +class UploadFileAdmin(admin.ModelAdmin):
6 + list_display = ('title', 'file')
5 7
6 -admin.site.register(Question) 8 +admin.site.register(UploadFileModel, UploadFileAdmin)
7 -admin.site.register(Choice)
......
1 from django import forms 1 from django import forms
2 +from .models import UploadFileModel
2 3
3 -class testform(forms.Form): 4 +class UploadFileForm(forms.ModelForm):
4 - text = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'size':80})) 5 + class Meta:
6 + model = UploadFileModel
7 + fields = ('title', 'file')
......
1 +# -*- coding: utf-8 -*-
2 +# Generated by Django 1.11.5 on 2018-05-22 10:19
3 +from __future__ import unicode_literals
4 +
5 +from django.db import migrations, models
6 +
7 +
8 +class Migration(migrations.Migration):
9 +
10 + dependencies = [
11 + ('myapp', '0001_initial'),
12 + ]
13 +
14 + operations = [
15 + migrations.CreateModel(
16 + name='DynamicCheckList',
17 + fields=[
18 + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 + ('classification', models.CharField(max_length=200)),
20 + ('checklist', models.CharField(max_length=200)),
21 + ('importance', models.CharField(max_length=200)),
22 + ],
23 + ),
24 + migrations.RemoveField(
25 + model_name='choice',
26 + name='question',
27 + ),
28 + migrations.DeleteModel(
29 + name='Choice',
30 + ),
31 + migrations.DeleteModel(
32 + name='Question',
33 + ),
34 + ]
1 +# -*- coding: utf-8 -*-
2 +# Generated by Django 1.11.5 on 2018-05-23 05:48
3 +from __future__ import unicode_literals
4 +
5 +from django.db import migrations, models
6 +
7 +
8 +class Migration(migrations.Migration):
9 +
10 + dependencies = [
11 + ('myapp', '0002_auto_20180522_1919'),
12 + ]
13 +
14 + operations = [
15 + migrations.CreateModel(
16 + name='UploadFileModel',
17 + fields=[
18 + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19 + ('title', models.TextField(default='')),
20 + ('file', models.FileField(null=True, upload_to='')),
21 + ],
22 + ),
23 + ]
1 +# -*- coding: utf-8 -*-
2 +# Generated by Django 1.11.5 on 2018-05-23 06:27
3 +from __future__ import unicode_literals
4 +
5 +from django.db import migrations
6 +
7 +
8 +class Migration(migrations.Migration):
9 +
10 + dependencies = [
11 + ('myapp', '0003_uploadfilemodel'),
12 + ]
13 +
14 + operations = [
15 + migrations.DeleteModel(
16 + name='DynamicCheckList',
17 + ),
18 + ]
...@@ -2,17 +2,6 @@ from django.db import models ...@@ -2,17 +2,6 @@ from django.db import models
2 2
3 # Create your models here. 3 # Create your models here.
4 4
5 -class Question(models.Model): 5 +class UploadFileModel(models.Model):
6 - question_text = models.CharField(max_length=200) 6 + title = models.TextField(default='')
7 - pub_date = models.DateTimeField('date published') 7 + file = models.FileField(null=True)
8 -
9 - def __str__(self):
10 - return self.question_text
11 -
12 -class Choice(models.Model):
13 - question = models.ForeignKey(Question)
14 - choice_text = models.CharField(max_length=200)
15 - votes = models.IntegerField(default=0)
16 -
17 - def __str__(self):
18 - return self.choice_text
......
1 +{% load staticfiles %}
2 +<!DOCTYPE html>
3 +<html lang="en">
4 + <head>
5 + <meta charset="utf-8">
6 + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7 + <meta name="description" content="">
8 + <meta name="author" content="">
9 + <title>VulnNotti</title>
10 + <!-- Bootstrap core CSS -->
11 + <link rel="stylesheet" href="{% static 'vendor/freelancer_bootstrap/css/bootstrap.min.css' %}">
12 + <!-- Custom fonts for this template -->
13 + <link rel="stylesheet" href="{% static 'vendor/freelancer_font-awesome/css/font-awesome.min.css' %}">
14 + <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css">
15 + <link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet" type="text/css">
16 + <!-- Plugin CSS -->
17 + <link rel="stylesheet" href="{% static 'vendor/magnific-popup/magnific-popup.css' %}">
18 + <!-- Custom styles for this template -->
19 + <link rel="stylesheet" href="{% static 'css/freelancer.min.css' %}">
20 + <!-- highlight.js -->
21 + <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/styles/default.min.css">
22 + <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
23 + <script>hljs.initHighlightingOnLoad();</script>
24 + <link rel="stylesheet" href="//cdn.jsdelivr.net/highlight.js/9.5.0/styles/vs2015.min.css">
25 + <script src="//cdn.jsdelivr.net/highlight.js/9.5.0/highlight.min.js"></script>
26 + <script>hljs.initHighlightingOnLoad();</script>
27 + </head>
28 +
29 +
30 + <body id="page-top">
31 + <!-- Navigation -->
32 + <nav class="navbar navbar-expand-lg bg-secondary fixed-top text-uppercase" id="mainNav">
33 + <div class="container">
34 + <a class="navbar-brand js-scroll-trigger" href="/">Home</a>
35 + <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">
36 + Menu
37 + <i class="fa fa-bars"></i>
38 + </button>
39 +
40 + </div>
41 + </nav>
42 +
43 + <!-- Header -->
44 + <header class="masthead bg-primary text-white text-center">
45 + <div class="container">
46 + <!-- <img class="img-fluid mb-5 d-block mx-auto" src="{% static 'img/profile.png' %}" alt=""> -->
47 + <h1 class="text-uppercase mb-0">동적 분석 페이지입니다.</h1>
48 + <hr class="star-light">
49 + <h2 class="font-weight-light mb-0">툴을 다운로드 받은 후 결과 파일을 업로드 해주세요.</h2>
50 +
51 +
52 + <a href="{% static 'img/profile.png' %}" download>
53 + <button class="btn btn-success">Download!</button>
54 + </a>
55 + <button class="btn btn-warning">Upload!</button>
56 + <form method="post" enctype="multipart/form-data">{% csrf_token %}
57 + <input type="file" name="sentFile" />
58 + <input type="submit" name="submit" value="Upload" />
59 + </form>
60 + </div>
61 + </header>
62 + <!-- <form method="post" action=".">
63 + <fieldset>{% csrf_token %}
64 + <div>
65 + {{ form.text.label_tag }} {{ form.text }}
66 + </div>
67 + <input type="submit" value="submit"/>
68 + </fieldset>
69 + </form> -->
70 +
71 + <!-- Portfolio Grid Section -->
72 +
73 +
74 + <div class="col-md-12 col-lg-12">
75 + <div style="width: 100%; margin-left: 0px; margin-right: 0px;">
76 + <!-- <form method="post" action=".">
77 + <fieldset>{% csrf_token %}
78 + <div>
79 + {{ form.text.label_tag }} {{ form.text }}
80 + </div>
81 + <input type="submit" value="submit"/>
82 + </fieldset>
83 + </form> -->
84 +
85 + <table class="table table-hover">
86 + <thead>
87 + <tr>
88 + <th>ID</th>
89 + <th>분류</th>
90 + <th>점검항목</th>
91 + <th>항목 중요도</th>
92 + <th>결과</th>
93 + </tr>
94 + <tbody>
95 + {% for object in object_list %}
96 + <tr>
97 + <td>{{ object.id }}</td>
98 + <td>{{ object.classification }}</td>
99 + <td>{{ object.checklist }}</td>
100 + <td>{{ object.importance }}</td>
101 + <td>{{ object.result }}</td>
102 + <!-- <td id="modal_{{ forloop.counter }}">
103 + <a class="portfolio-item d-block mx-auto" href="#portfolio-modal-{{ forloop.counter }}">
104 + <button class="btn btn-primary">자세히보기</button></td>
105 + </a>
106 + </td> -->
107 + </tr>
108 + {% endfor %}
109 + </tbody>
110 + </table>
111 + </div>
112 +
113 + {% for object in object_list %}
114 + <div class="portfolio-modal mfp-hide" id="portfolio-modal-{{ forloop.counter }}">
115 + <div class="portfolio-modal-dialog bg-white">
116 + <!-- header -->
117 + <div class="modal-header">
118 +
119 + </div>
120 + <!-- left side -->
121 + <div class="col-lg-12">
122 + {{ object.result }}
123 + </div>
124 + <!-- footer -->
125 + <div class="modal-footer" style="float: clear;">
126 + <a class="btn btn-primary btn-lg rounded-pill portfolio-modal-dismiss" href="#">
127 + <i class="fa fa-close"></i>
128 + Close
129 + </a>
130 + </div>
131 +
132 + </div>
133 + </div>
134 + {% endfor %}
135 +
136 + </body>
137 +
138 + <script src="{% static 'js/Chart.min.js' %}"></script>
139 + <script src="{% static 'vendor/freelancer_jquery/jquery.min.js' %}"></script>
140 + <script src="{% static 'vendor/freelancer_bootstrap/js/bootstrap.bundle.min.js' %}"></script>
141 + <script src="{% static 'vendor/jquery-easing/jquery.easing.min.js' %}"></script>
142 + <script src="{% static 'vendor/magnific-popup/jquery.magnific-popup.min.js' %}"></script>
143 + <script src="{% static 'js/jqBootstrapValidation.js' %}"></script>
144 + <script src="{% static 'js/contact_me.js' %}"></script>
145 + <script src="{% static 'js/freelancer.min.js' %}"></script>
146 +
147 + <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
148 + <script type="text/javascript" src="{% static 'js/Chart.min.js' %}"></script>
149 + <script type="text/javascript">
150 +
151 +
152 +</html>
...@@ -3,7 +3,7 @@ from myapp.views import * ...@@ -3,7 +3,7 @@ from myapp.views import *
3 3
4 4
5 urlpatterns = [ 5 urlpatterns = [
6 - url(r'^$', MypageView.as_view(), name='mypage'), 6 + url(r'^static/', StaticView.as_view(), name='static'),
7 - url(r'^table', TableView.as_view(), name='table'), 7 + url(r'^dynamic/', DynamicView.as_view(), name='dynamic'),
8 8
9 ] 9 ]
......
1 from django.views.generic.base import TemplateView 1 from django.views.generic.base import TemplateView
2 from django.views.generic import FormView 2 from django.views.generic import FormView
3 from django.views.generic import View 3 from django.views.generic import View
4 -from myapp.forms import testform
5 from django.db import connection 4 from django.db import connection
6 from django.shortcuts import render 5 from django.shortcuts import render
6 +from django.http import HttpResponseRedirect
7 +from .forms import UploadFileForm
8 +import re
7 9
10 +class DynamicView(TemplateView):
11 + template_name = 'dynamic.html'
8 12
9 -class MypageView(TemplateView): 13 + def get(self, request, *args, **kwargs):
10 - template_name = 'mypage.html' 14 +
11 - form_class = testform 15 + query = 'SELECT * FROM vuln.dynamic'
16 +
17 + param_list = []
18 +
19 + with connection.cursor() as cursor:
20 + cursor.execute(query, param_list)
21 +
22 + columns = [column[0] for column in cursor.description]
23 +
24 + object_list = []
25 +
26 + for row in cursor.fetchall():
27 + object_list.append(dict(zip(columns, row)))
28 +
29 + context = {}
30 +
31 + context['object_list'] = object_list
32 +
33 +
34 + # f = open("C:/Users/dlrud/Desktop/shell.txt", 'r')
35 + # while True:
36 + # line = f.readline()
37 + # if not line: break
38 + # print(line)
39 + # f.close()
40 +
41 + return render(self.request, self.template_name, context)
42 +
43 + def post(self, request, *args, **kwargs):
44 + file = request.FILES['sentFile'] # here you get the files needed
45 +
46 + temp = ""
47 +
48 + while True:
49 + line = file.readline()
50 +
51 + temp += str(line, 'UTF-8')
52 + if not line: break
53 + # print(str(line, 'UTF-8'))
54 +
55 + # r = re.compile('\@.+\@', )
56 + r = re.compile(r'\@(.+)\@', re.MULTILINE)
57 + results = r.findall(temp)
58 +
59 + result_list = dict(enumerate(results, 0))
60 +
61 + query = 'SELECT * FROM vuln.dynamic'
62 +
63 + param_list = []
64 +
65 + with connection.cursor() as cursor:
66 + cursor.execute(query, param_list)
67 +
68 + columns = [column[0] for column in cursor.description]
69 +
70 + object_list = []
71 +
72 + for row in cursor.fetchall():
73 + object_list.append(dict(zip(columns, row)))
74 +
75 +
76 + for i in range(0, len(result_list)):
77 + object_list[i]['result'] = result_list[i]
78 +
79 + context = {}
80 + context['object_list'] = object_list
81 +
82 +
83 + return render(self.request, self.template_name, context)
84 +
85 +
86 +class StaticView(TemplateView):
87 + template_name = 'static.html'
12 88
13 def get(self, request, *args, **kwargs): 89 def get(self, request, *args, **kwargs):
14 context = {} 90 context = {}
...@@ -36,7 +112,7 @@ class MypageView(TemplateView): ...@@ -36,7 +112,7 @@ class MypageView(TemplateView):
36 112
37 context['red'] = red 113 context['red'] = red
38 context['blue'] = blue 114 context['blue'] = blue
39 - context['green'] = green 115 + context['green'] = green
40 context['object_list'] = object_list 116 context['object_list'] = object_list
41 117
42 return render(self.request, self.template_name, context) 118 return render(self.request, self.template_name, context)
......
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
32 <div class="collapse navbar-collapse" id="navbarResponsive"> 32 <div class="collapse navbar-collapse" id="navbarResponsive">
33 <ul class="navbar-nav ml-auto"> 33 <ul class="navbar-nav ml-auto">
34 <li class="nav-item mx-0 mx-lg-1"> 34 <li class="nav-item mx-0 mx-lg-1">
35 - <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/">Static</a> 35 + <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/static">Static</a>
36 </li> 36 </li>
37 <li class="nav-item mx-0 mx-lg-1"> 37 <li class="nav-item mx-0 mx-lg-1">
38 - <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="#about">Dynamic</a> 38 + <a class="nav-link py-3 px-0 px-lg-3 rounded js-scroll-trigger" href="/myapp/dynamic">Dynamic</a>
39 </li> 39 </li>
40 {% if user.is_active %} 40 {% if user.is_active %}
41 <!-- <li class="nav-item mx-0 mx-lg-1"> 41 <!-- <li class="nav-item mx-0 mx-lg-1">
......