Last active
April 25, 2020 08:45
-
-
Save jwlin/c03ecc1fe90509fb1eafd814630ed422 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
from django.shortcuts import get_object_or_404, render | |
from .models import Account, Client | |
def show(request): | |
uname = request.POST["uname"] | |
if "injection" in request.POST: | |
# Use raw SQL and string concatenation, resulting in SQL injection | |
accounts = Account.objects.raw(f'SELECT * FROM atm_account as a, atm_client as c WHERE a.client_id=c.id and c.username="{uname}"') | |
else: | |
# Use built-in ORM in Django | |
accounts = Account.objects.filter(client__username=uname) | |
return render(request, "atm/show.html", {"accounts": accounts}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment