kd7979148 commited on
Commit
afd9f5c
·
verified ·
1 Parent(s): 66a3b1b

Upload 14 files

Browse files
#readme.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *requirements:
2
+
3
+ install python first and
4
+ pip install torch
5
+ pip install transformers
6
+ pip install flask
7
+
8
+ *how to use:
9
+
10
+ python test_server.py
11
+ python moniter.py
12
+ open browser and enter:
13
+ http://127.0.0.1:8080/?q=abcde : OK
14
+ http://127.0.0.1:8080/?q=<img src='x' onerror='alert("xss")'> :this will be detected and logged.
15
+
16
+ *inference_bert_url.py
17
+ It's just a simple cli tool that judge your input contains xss payloads.
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ static/banner.jpg filter=lfs diff=lfs merge=lfs -text
inference_bert_url.py ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+
3
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
+ import torch
5
+
6
+ from urllib.parse import (
7
+ urlparse,
8
+ parse_qs,
9
+ unquote
10
+ )
11
+
12
+ #################################################
13
+ # 모델 경로
14
+ #################################################
15
+
16
+ model_path = "xss_detect_trained"
17
+
18
+ #################################################
19
+ # URL 여부 확인
20
+ #################################################
21
+
22
+ def is_url(text):
23
+ return text.startswith("http://") or text.startswith("https://")
24
+
25
+ #################################################
26
+ # URL에서 parameter value 추출
27
+ #################################################
28
+
29
+ def extract_url_payload(url):
30
+
31
+ try:
32
+ parsed = urlparse(url)
33
+
34
+ # query parameter 파싱
35
+ params = parse_qs(parsed.query)
36
+
37
+ extracted = []
38
+
39
+ for key, values in params.items():
40
+
41
+ for value in values:
42
+
43
+ # URL decode
44
+ decoded = unquote(value)
45
+
46
+ extracted.append(decoded)
47
+
48
+ # parameter 없으면 path 사용
49
+ if not extracted:
50
+ return parsed.path
51
+
52
+ # 여러 parameter면 합침
53
+ return " ".join(extracted)
54
+
55
+ except:
56
+ return url
57
+
58
+ #################################################
59
+ # 의심 코드 존재 여부 검사
60
+ #################################################
61
+
62
+ def contains_suspicious_code(text):
63
+
64
+ suspicious_patterns = [
65
+
66
+ # HTML / JS
67
+ "<",
68
+ ">",
69
+ "script",
70
+ "javascript:",
71
+ "onerror",
72
+ "onclick",
73
+ "onload",
74
+ "iframe",
75
+ "svg",
76
+
77
+ # JS 실행
78
+ "eval(",
79
+ "alert(",
80
+ "prompt(",
81
+ "confirm(",
82
+ "document.cookie",
83
+ "document.domain",
84
+ "window.location",
85
+
86
+ # 난독화 / 우회
87
+ "constructor",
88
+ "fromcharcode",
89
+ "\\x",
90
+ "%3c",
91
+ "%3e",
92
+ "&#",
93
+ "base64",
94
+ "atob(",
95
+
96
+ # 특수 실행 패턴
97
+ "srcdoc",
98
+ "data:text/html",
99
+ "vbscript:",
100
+ "expression("
101
+ ]
102
+
103
+ text_lower = text.lower()
104
+
105
+ for pattern in suspicious_patterns:
106
+
107
+ if pattern in text_lower:
108
+ return True
109
+
110
+ return False
111
+
112
+ #################################################
113
+ # 모델 로드
114
+ #################################################
115
+
116
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
117
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
118
+
119
+ device = torch.device("cpu")
120
+
121
+ model.to(device)
122
+ model.eval()
123
+
124
+ #################################################
125
+ # 라벨
126
+ #################################################
127
+
128
+ labels = {
129
+ 0: "NORMAL",
130
+ 1: "XSS"
131
+ }
132
+
133
+ #################################################
134
+ # 테스트
135
+ #################################################
136
+
137
+ print("\n테스트 시작 (exit 입력 시 종료)\n")
138
+
139
+ while True:
140
+
141
+ text = input("입력: ")
142
+
143
+ if text.lower() == "exit":
144
+ break
145
+
146
+ #################################################
147
+ # 기본값
148
+ #################################################
149
+
150
+ target_text = text
151
+
152
+ #################################################
153
+ # URL 처리
154
+ #################################################
155
+
156
+ if is_url(text):
157
+
158
+ target_text = extract_url_payload(text)
159
+
160
+ print(f"[추출된 parameter]: {target_text}")
161
+
162
+ #################################################
163
+ # 의심 코드 없으면 바로 NORMAL
164
+ #################################################
165
+
166
+ if not contains_suspicious_code(target_text):
167
+
168
+ print("결과: NORMAL")
169
+ print("신뢰도: heuristic\n")
170
+
171
+ continue
172
+
173
+ #################################################
174
+ # 토크나이즈
175
+ #################################################
176
+ MAX_INPUT_LENGTH = 2000
177
+
178
+ if len(target_text) > MAX_INPUT_LENGTH:
179
+
180
+ print("입력 길이 초과\n")
181
+
182
+ continue
183
+ inputs = tokenizer(
184
+ target_text,
185
+ return_tensors="pt",
186
+ truncation=True,
187
+ padding=True,
188
+ max_length=128
189
+ ).to(device)
190
+
191
+ #################################################
192
+ # 추론
193
+ #################################################
194
+
195
+ with torch.no_grad():
196
+
197
+ outputs = model(**inputs)
198
+
199
+ logits = outputs.logits
200
+
201
+ probs = torch.softmax(logits, dim=1)
202
+
203
+ confidence, pred = torch.max(probs, dim=1)
204
+
205
+ pred = pred.item()
206
+ confidence = confidence.item()
207
+
208
+ label = labels[pred]
209
+
210
+ #################################################
211
+ # 출력
212
+ #################################################
213
+
214
+ print(f"결과: {label}")
215
+ print(f"신뢰도: {confidence:.4f}\n")
moniter.py ADDED
@@ -0,0 +1,410 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+
3
+ #################################################
4
+ # XSS Log Monitor + BERT Detector
5
+ #################################################
6
+
7
+ import re
8
+ import time
9
+ import sqlite3
10
+ import unicodedata
11
+
12
+ from urllib.parse import (
13
+ urlparse,
14
+ parse_qs,
15
+ unquote
16
+ )
17
+
18
+ import torch
19
+
20
+ from transformers import (
21
+ AutoTokenizer,
22
+ AutoModelForSequenceClassification
23
+ )
24
+
25
+ #################################################
26
+ # 설정
27
+ #################################################
28
+
29
+ LOG_FILE = "access.log"
30
+
31
+ MODEL_PATH = "xss_detect_trained"
32
+
33
+ MAX_INPUT_LENGTH = 2000
34
+
35
+ CHECK_INTERVAL = 0.2
36
+
37
+ #################################################
38
+ # SQLite 초기화
39
+ #################################################
40
+
41
+ conn = sqlite3.connect("xss_detection.db")
42
+
43
+ cursor = conn.cursor()
44
+
45
+ cursor.execute("""
46
+ CREATE TABLE IF NOT EXISTS detections (
47
+
48
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
49
+
50
+ timestamp TEXT,
51
+
52
+ ip TEXT,
53
+
54
+ url TEXT,
55
+
56
+ payload TEXT,
57
+
58
+ prediction TEXT,
59
+
60
+ confidence REAL
61
+ )
62
+ """)
63
+
64
+ conn.commit()
65
+
66
+ #################################################
67
+ # 모델 로드
68
+ #################################################
69
+
70
+ print("[+] 모델 로드 중...")
71
+
72
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
73
+
74
+ model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH)
75
+
76
+ device = torch.device("cpu")
77
+
78
+ model.to(device)
79
+
80
+ model.eval()
81
+
82
+ print("[+] 모델 로드 완료")
83
+
84
+ #################################################
85
+ # 라벨
86
+ #################################################
87
+
88
+ labels = {
89
+ 0: "NORMAL",
90
+ 1: "XSS"
91
+ }
92
+
93
+ #################################################
94
+ # URL 여부
95
+ #################################################
96
+
97
+ def is_url(text):
98
+
99
+ return (
100
+ text.startswith("http://")
101
+ or text.startswith("https://")
102
+ or text.startswith("/")
103
+ )
104
+
105
+ #################################################
106
+ # Unicode 정규화
107
+ #################################################
108
+
109
+ def normalize_unicode(text):
110
+
111
+ return unicodedata.normalize("NFKC", text)
112
+
113
+ #################################################
114
+ # URL payload 추출
115
+ #################################################
116
+
117
+ def extract_url_payload(url):
118
+
119
+ try:
120
+
121
+ parsed = urlparse(url)
122
+
123
+ raw_query = unquote(parsed.query)
124
+
125
+ params = parse_qs(parsed.query)
126
+
127
+ extracted = []
128
+
129
+ #################################################
130
+ # parameter value 추출
131
+ #################################################
132
+
133
+ for key, values in params.items():
134
+
135
+ for value in values:
136
+
137
+ decoded = unquote(value)
138
+
139
+ extracted.append(decoded)
140
+
141
+ #################################################
142
+ # query 자체에 suspicious code 존재 시 추가
143
+ #################################################
144
+
145
+ if contains_suspicious_code(raw_query):
146
+
147
+ extracted.append(raw_query)
148
+
149
+ #################################################
150
+ # parameter 없으면 path 사용
151
+ #################################################
152
+
153
+ if not extracted:
154
+
155
+ return parsed.path
156
+
157
+ return " ".join(extracted)
158
+
159
+ except:
160
+
161
+ return url
162
+
163
+ #################################################
164
+ # suspicious code 존재 여부
165
+ #################################################
166
+
167
+ def contains_suspicious_code(text):
168
+
169
+ suspicious_patterns = [
170
+
171
+ # HTML / JS
172
+ "<",
173
+ ">",
174
+ "script",
175
+ "javascript:",
176
+ "onerror",
177
+ "onclick",
178
+ "onload",
179
+ "iframe",
180
+ "svg",
181
+
182
+ # JS 실행
183
+ "eval(",
184
+ "alert(",
185
+ "prompt(",
186
+ "confirm(",
187
+ "document.cookie",
188
+ "document.domain",
189
+ "window.location",
190
+
191
+ # 난독화 / 우회
192
+ "constructor",
193
+ "fromcharcode",
194
+ "\\x",
195
+ "%3c",
196
+ "%3e",
197
+ "&#",
198
+ "base64",
199
+ "atob(",
200
+
201
+ # 특수 실행
202
+ "srcdoc",
203
+ "data:text/html",
204
+ "vbscript:",
205
+ "expression("
206
+ ]
207
+
208
+ text_lower = text.lower()
209
+
210
+ for pattern in suspicious_patterns:
211
+
212
+ if pattern in text_lower:
213
+
214
+ return True
215
+
216
+ return False
217
+
218
+ #################################################
219
+ # 로그 한 줄 파싱
220
+ #################################################
221
+
222
+ def parse_log_line(line):
223
+
224
+ """
225
+ Apache/Nginx common log format 대응
226
+ """
227
+
228
+ try:
229
+
230
+ ip_match = re.search(r'^(\S+)', line)
231
+
232
+ request_match = re.search(
233
+ r'\"(GET|POST|PUT|DELETE|HEAD|OPTIONS)\s+(.+?)\s+HTTP',
234
+ line
235
+ )
236
+
237
+ if not ip_match or not request_match:
238
+
239
+ return None, None
240
+
241
+ ip = ip_match.group(1)
242
+
243
+ url = request_match.group(2)
244
+
245
+ return ip, url
246
+
247
+ except:
248
+
249
+ return None, None
250
+
251
+ #################################################
252
+ # BERT 추론
253
+ #################################################
254
+
255
+ def predict_xss(text):
256
+
257
+ inputs = tokenizer(
258
+ text,
259
+ return_tensors="pt",
260
+ truncation=True,
261
+ padding=True,
262
+ max_length=128
263
+ ).to(device)
264
+
265
+ with torch.no_grad():
266
+
267
+ outputs = model(**inputs)
268
+
269
+ logits = outputs.logits
270
+
271
+ probs = torch.softmax(logits, dim=1)
272
+
273
+ confidence, pred = torch.max(probs, dim=1)
274
+
275
+ pred = pred.item()
276
+
277
+ confidence = confidence.item()
278
+
279
+ label = labels[pred]
280
+
281
+ return label, confidence
282
+
283
+ #################################################
284
+ # 로그 감시
285
+ #################################################
286
+
287
+ def follow(thefile):
288
+
289
+ thefile.seek(0, 2)
290
+
291
+ while True:
292
+
293
+ line = thefile.readline()
294
+
295
+ if not line:
296
+
297
+ time.sleep(CHECK_INTERVAL)
298
+
299
+ continue
300
+
301
+ yield line
302
+
303
+ #################################################
304
+ # 메인
305
+ #################################################
306
+
307
+ print(f"[+] 로그 감시 시작: {LOG_FILE}")
308
+
309
+ with open(LOG_FILE, "r", encoding="utf-8", errors="ignore") as logfile:
310
+
311
+ loglines = follow(logfile)
312
+
313
+ for line in loglines:
314
+
315
+ try:
316
+
317
+ ip, url = parse_log_line(line)
318
+
319
+ if not url:
320
+
321
+ continue
322
+
323
+ #################################################
324
+ # unicode normalization
325
+ #################################################
326
+
327
+ url = normalize_unicode(url)
328
+
329
+ #################################################
330
+ # URL payload 추출
331
+ #################################################
332
+
333
+ if is_url(url):
334
+
335
+ target_text = extract_url_payload(url)
336
+
337
+ else:
338
+
339
+ target_text = url
340
+
341
+ #################################################
342
+ # 길이 제한
343
+ #################################################
344
+
345
+ if len(target_text) > MAX_INPUT_LENGTH:
346
+
347
+ continue
348
+
349
+ #################################################
350
+ # suspicious fragment 없으면 skip
351
+ #################################################
352
+
353
+ if not contains_suspicious_code(target_text):
354
+
355
+ continue
356
+
357
+ #################################################
358
+ # ML 추론
359
+ #################################################
360
+
361
+ label, confidence = predict_xss(target_text)
362
+
363
+ #################################################
364
+ # XSS 탐지 시 출력
365
+ #################################################
366
+
367
+ if label == "XSS":
368
+
369
+ print("\n==============================")
370
+ print("[XSS DETECTED]")
371
+ print(f"IP : {ip}")
372
+ print(f"URL : {url}")
373
+ print(f"Payload : {target_text}")
374
+ print(f"Confidence : {confidence:.4f}")
375
+ print("==============================\n")
376
+
377
+ #################################################
378
+ # DB 저장
379
+ #################################################
380
+
381
+ cursor.execute("""
382
+ INSERT INTO detections (
383
+ timestamp,
384
+ ip,
385
+ url,
386
+ payload,
387
+ prediction,
388
+ confidence
389
+ )
390
+ VALUES (
391
+ datetime('now'),
392
+ ?,
393
+ ?,
394
+ ?,
395
+ ?,
396
+ ?
397
+ )
398
+ """, (
399
+ ip,
400
+ url,
401
+ target_text,
402
+ label,
403
+ confidence
404
+ ))
405
+
406
+ conn.commit()
407
+
408
+ except Exception as e:
409
+
410
+ print(f"[ERROR] {e}")
static/banner.jpg ADDED

Git LFS Details

  • SHA256: e5167e5860110c51cd6388d7451904cfac3ce2d85b64e69b00841b9053bcfbbb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.97 MB
static/style.css ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+
3
+ margin: 0;
4
+
5
+ background: #f5f5f5;
6
+
7
+ color: #222;
8
+
9
+ font-family: "Segoe UI", sans-serif;
10
+ }
11
+
12
+ .hero {
13
+
14
+ height: 320px;
15
+
16
+ background-image: url("/static/banner.jpg");
17
+
18
+ background-size: cover;
19
+
20
+ background-position: center;
21
+
22
+ position: relative;
23
+ }
24
+
25
+ .overlay {
26
+
27
+ width: 100%;
28
+ height: 100%;
29
+
30
+ background: rgba(0,0,0,0.45);
31
+
32
+ display: flex;
33
+
34
+ flex-direction: column;
35
+
36
+ justify-content: center;
37
+
38
+ align-items: center;
39
+
40
+ color: white;
41
+ }
42
+
43
+ .overlay h1 {
44
+
45
+ font-size: 52px;
46
+
47
+ margin-bottom: 10px;
48
+ }
49
+
50
+ .overlay p {
51
+
52
+ font-size: 18px;
53
+
54
+ opacity: 0.9;
55
+ }
56
+
57
+ .container {
58
+
59
+ max-width: 900px;
60
+
61
+ margin: auto;
62
+
63
+ margin-top: 40px;
64
+
65
+ background: white;
66
+
67
+ padding: 40px;
68
+
69
+ border-radius: 12px;
70
+
71
+ box-shadow: 0 4px 20px rgba(0,0,0,0.08);
72
+ }
73
+
74
+ h2 {
75
+
76
+ margin-top: 0;
77
+ }
78
+
79
+ input {
80
+
81
+ width: 100%;
82
+
83
+ padding: 14px;
84
+
85
+ font-size: 16px;
86
+
87
+ border-radius: 8px;
88
+
89
+ border: 1px solid #ccc;
90
+
91
+ margin-top: 10px;
92
+ }
93
+
94
+ button {
95
+
96
+ margin-top: 15px;
97
+
98
+ padding: 12px 24px;
99
+
100
+ border: none;
101
+
102
+ border-radius: 8px;
103
+
104
+ background: #222;
105
+
106
+ color: white;
107
+
108
+ font-size: 15px;
109
+
110
+ cursor: pointer;
111
+ }
112
+
113
+ button:hover {
114
+
115
+ background: #444;
116
+ }
117
+
118
+ .result {
119
+
120
+ margin-top: 40px;
121
+ }
122
+
123
+ .output {
124
+
125
+ margin-top: 15px;
126
+
127
+ padding: 20px;
128
+
129
+ background: #fafafa;
130
+
131
+ border-radius: 8px;
132
+
133
+ border: 1px solid #ddd;
134
+
135
+ word-break: break-word;
136
+ }
137
+
138
+ footer {
139
+
140
+ text-align: center;
141
+
142
+ padding: 30px;
143
+
144
+ color: #777;
145
+ }
templates/index.html ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ko">
3
+
4
+ <head>
5
+
6
+ <meta charset="utf-8">
7
+
8
+ <title>MINSUNG's XSS TEST PAGE</title>
9
+
10
+ <link
11
+ rel="stylesheet"
12
+ href="{{ url_for('static', filename='style.css') }}"
13
+ >
14
+
15
+ </head>
16
+
17
+ <body>
18
+
19
+ <div class="hero">
20
+
21
+ <div class="overlay">
22
+
23
+ <h1>Great Memories~~</h1>
24
+
25
+ <p>
26
+ MINSUNG's xss test environment
27
+ </p>
28
+
29
+ </div>
30
+
31
+ </div>
32
+
33
+ <div class="container">
34
+
35
+ <h2>Input</h2>
36
+
37
+ <form method="GET" action="/">
38
+
39
+ <input
40
+ type="text"
41
+ name="q"
42
+ placeholder="Enter payload..."
43
+ value="{{ q }}"
44
+ >
45
+
46
+ <button type="submit">
47
+ Submit
48
+ </button>
49
+
50
+ </form>
51
+
52
+ <div class="result">
53
+
54
+ <h3>Reflected Output</h3>
55
+
56
+ <div class="output">
57
+ {{ q|safe }}
58
+ </div>
59
+
60
+ </div>
61
+
62
+ </div>
63
+
64
+ <footer>
65
+
66
+
67
+
68
+ </footer>
69
+
70
+ </body>
71
+
72
+ </html>
test_server.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ from flask import (
3
+ Flask,
4
+ request,
5
+ render_template
6
+ )
7
+ app = Flask(__name__)
8
+
9
+ @app.route("/", methods=["GET", "POST"])
10
+ def home():
11
+
12
+ #################################################
13
+ # 로그 저장
14
+ #################################################
15
+
16
+ with open("access.log", "a", encoding="utf-8") as f:
17
+
18
+ log = (
19
+ f'{request.remote_addr} - '
20
+ f'"{request.method} {request.full_path} HTTP/1.1"\n'
21
+ )
22
+
23
+ f.write(log)
24
+
25
+ f.flush()
26
+
27
+ #################################################
28
+ # q 파라미터 출력
29
+ #################################################
30
+
31
+ q = request.args.get("q", "")
32
+
33
+ #################################################
34
+ # html render
35
+ #################################################
36
+
37
+ return render_template(
38
+ "index.html",
39
+ q=q
40
+ )
41
+
42
+ if __name__ == "__main__":
43
+
44
+ app.run(
45
+ host="0.0.0.0",
46
+ port=8080,
47
+ debug=False
48
+ )
xss_detect_trained/config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation": "gelu",
3
+ "architectures": [
4
+ "DistilBertForSequenceClassification"
5
+ ],
6
+ "attention_dropout": 0.1,
7
+ "dim": 768,
8
+ "dropout": 0.1,
9
+ "dtype": "float32",
10
+ "hidden_dim": 3072,
11
+ "initializer_range": 0.02,
12
+ "max_position_embeddings": 512,
13
+ "model_type": "distilbert",
14
+ "n_heads": 12,
15
+ "n_layers": 6,
16
+ "pad_token_id": 0,
17
+ "problem_type": "single_label_classification",
18
+ "qa_dropout": 0.1,
19
+ "seq_classif_dropout": 0.2,
20
+ "sinusoidal_pos_embds": false,
21
+ "tie_weights_": true,
22
+ "transformers_version": "4.57.3",
23
+ "vocab_size": 30522
24
+ }
xss_detect_trained/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f67b36e0aa339dc914d178da974f6507e6cf79cddf3c643f7a2a80d2cab7bbea
3
+ size 267832560
xss_detect_trained/special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
xss_detect_trained/tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
xss_detect_trained/tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
46
+ "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "DistilBertTokenizer",
55
+ "unk_token": "[UNK]"
56
+ }
xss_detect_trained/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:248f94b765fe79a616bfe9dad2106bf7c617d3f5011ce8a209c8997268e9b6ad
3
+ size 5841
xss_detect_trained/vocab.txt ADDED
The diff for this file is too large to render. See raw diff