diff --git a/.gitignore b/.gitignore index bfb842bbb..f08dbb7f1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.pyc env pygoat/db.sqlite3 +venv *.sqlite3 *db.sqlite3 */app.log diff --git a/pygoat/db.sqlite3 b/pygoat/db.sqlite3 index 5104abc20..61d823227 100644 Binary files a/pygoat/db.sqlite3 and b/pygoat/db.sqlite3 differ diff --git a/pygoat/introduction/__pycache__/views.cpython-38.pyc b/pygoat/introduction/__pycache__/views.cpython-38.pyc index 044825e69..af70d8933 100644 Binary files a/pygoat/introduction/__pycache__/views.cpython-38.pyc and b/pygoat/introduction/__pycache__/views.cpython-38.pyc differ diff --git a/pygoat/introduction/mitre.py b/pygoat/introduction/mitre.py index dfc0d4821..419bfb8c9 100644 --- a/pygoat/introduction/mitre.py +++ b/pygoat/introduction/mitre.py @@ -4,6 +4,8 @@ from hashlib import md5 import jwt import datetime +import re +import subprocess from .models import CSRF_user_tbl from django.views.decorators.csrf import csrf_exempt # import os @@ -218,4 +220,25 @@ def mitre_lab_25_api(request): @authentication_decorator def mitre_lab_25(request): - return render(request, 'mitre/mitre_lab_25.html') \ No newline at end of file + return render(request, 'mitre/mitre_lab_25.html') + +@authentication_decorator +def mitre_lab_17(request): + return render(request, 'mitre/mitre_lab_17.html') + +def command_out(command): + process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + return process.communicate() + + +@csrf_exempt +def mitre_lab_17_api(request): + if request.method == "POST": + ip = request.POST.get('ip') + command = "nmap " + ip + res, err = command_out(command) + res = res.decode() + err = err.decode() + pattern = "STATE SERVICE.*\\n\\n" + ports = re.findall(pattern, res,re.DOTALL)[0][14:-2].split('\n') + return JsonResponse({'raw_res': str(res), 'raw_err': str(err), 'ports': ports}) \ No newline at end of file diff --git a/pygoat/introduction/templates/mitre/mitre_lab_17.html b/pygoat/introduction/templates/mitre/mitre_lab_17.html new file mode 100644 index 000000000..733d6c34e --- /dev/null +++ b/pygoat/introduction/templates/mitre/mitre_lab_17.html @@ -0,0 +1,51 @@ +{% extends "introduction/base.html" %} +{% load static %} +{% block content %} +{% block title %} +
+ This is a web utility for scanning IP address for open ports.
+ Can you use this utility for something other than scanning ports?
+
+
+ This lab helps you to get an idea of how SSRF can result in major Security flaw.
+
+ The next pages shows some blog, but can you figure out how the blogs are presented?
+
+
+
+ This website sends a request to the given url and displays the page withing the page.
+ now there is a page at /ssrf_target which only allowes request from localhost ( ie 127.0.0.1 )
+
+ now start the server using python manage.py runserver 0:8000
+ get your network ip using ifconfig
or ipcofig
(in windows)
+ now go to http://[your ip]/ssrf_target
+
+ Now you can't access the page because it is not from localhost.
+ Try to get access to this page content now using the utility.
+