views.py
4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from django.views.generic.base import TemplateView
from django.views.generic import FormView
from django.views.generic import View
from django.db import connection
from django.shortcuts import render
from django.http import JsonResponse
from django.http import HttpResponseRedirect
from .forms import UploadFileForm
import re
class DynamicView(TemplateView):
template_name = 'dynamic.html'
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.DOTALL)
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):
if request.is_ajax():
data = 1
idx = request.GET.get('idx')
method = request.GET.get('method')
print(idx)
print(method)
return JsonResponse(data, safe=False)
context = {}
query = 'SELECT * FROM vuln.vulnInfo LIMIT 50'
param_list = []
with connection.cursor() as cursor:
cursor.execute(query, param_list)
columns = [column[0] for column in cursor.description]
print(columns)
object_list = []
for row in cursor.fetchall():
object_list.append(dict(zip(columns, row)))
context = {}
red = 3
blue = 4
green = 5
context['red'] = red
context['blue'] = blue
context['green'] = green
context['object_list'] = object_list
return render(self.request, self.template_name, context)
def post(self, request, *args, **kwargs):
text = self.request.POST['text']
context = {}
context['form'] = testform
print(text)
return render(self.request, self.template_name, context)
# class ServerList(View):
# template_name = 'test.html'
#
# def get(self, request, *args, **kwargs):
#
# query = 'SELECT * FROM vuln.vulnInfo'
# param_list = []
#
# with connection.cursor() as cursor:
# cursor.execute(query, param_list)
#
# columns = [column[0] for column in cursor.description]
#
# for row in cursor.fetchall():
# object_list.append(dict(zip(columns, row)))
#
# context = {}
# object_list = []
# context['object_list'] = object_list
#
# return render(self.request, self.template_name, context)
#
# class TableView(TemplateView):
# template_name = 'myapp_table.html'