Skip to content

Commit ea2d715

Browse files
Merge pull request #316 from immortal71/fix/xss-lab3-regex-pattern
Fix XSS Lab 3: Change regex pattern to allow JSFuck-style payloads
2 parents beacf39 + b7ff109 commit ea2d715

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

introduction/templates/Lab/XSS/xss.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,14 @@ <h4>Exploiting the Reflection of the search query </h4>
104104
<button class="coll btn btn-info">Lab Details</button>
105105
<div class="lab">
106106
<p class="bp">
107-
This lab is a demonstration of a Reflected XSS
107+
This lab is a demonstration of a Reflected XSS with alphanumeric filter bypass.
108108
</p>
109-
<p class="bp">The goal of this challenge is to trigger an alert, User input is being Reflected on script Tag, but the real challenge lies in the fact that all alphanumeric characters are escaped. Can you find way to pop an alert ?
109+
<p class="bp">
110+
The goal of this challenge is to trigger an alert. User input is being reflected in a script tag, but all alphanumeric characters (letters A-Z, a-z, and digits 0-9) are removed from your input.
111+
Can you find a way to execute JavaScript using only special characters?
112+
</p>
113+
<p class="bp">
114+
<b>Hint:</b> Research "JSFuck" - a technique to write JavaScript using only 6 characters: <code>[]()!+</code> (though other special characters are also available)
110115
</p>
111116

112117

introduction/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ def xss_lab2(request):
122122
def xss_lab3(request):
123123
if request.user.is_authenticated:
124124
if request.method == 'POST':
125-
username = request.POST.get('username')
126-
print(type(username))
127-
pattern = r'\w'
125+
username = request.POST.get('username', '')
126+
# Remove only alphanumeric characters (letters and digits)
127+
# This allows special characters like []()!+ for JSFuck-style payloads
128+
pattern = r'[a-zA-Z0-9]'
128129
result = re.sub(pattern, '', username)
129130
context = {'code':result}
130131
return render(request, 'Lab/XSS/xss_lab_3.html',context)

0 commit comments

Comments
 (0)