Skip to content

Commit 739d2c6

Browse files
committed
Add remaining fixes
1 parent b12e287 commit 739d2c6

File tree

3 files changed

+38
-46
lines changed

3 files changed

+38
-46
lines changed

run_csas.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@
33
dir=`pwd`
44

55
cd csas && vagrant up
6-
cd ${dir}
76

8-
# while true; do
9-
# echo "Running demonstration with csas enabled"
7+
while true; do
8+
vagrant ssh -c 'mysql -uroot -pcsas -e "USE csas; TRUNCATE TABLE post;"'
9+
echo "Running demonstration with csas enabled"
1010
# Run the Python script to do the XSS injections
11-
# python xss_demo.py --url http://localhost:8081
12-
# Reboot the Vagrant machine when the demo is done
13-
# cd csas && vagrant reload
14-
# done
15-
16-
echo "Running demonstration with csas enabled"
17-
# Run the Python script to do the XSS injections
18-
python xss_demo.py --url http://localhost:8081
19-
# Reboot the Vagrant machine when the demo is done
20-
# cd csas && vagrant reload
21-
11+
python ${dir}/xss_demo.py --url http://localhost:8081
12+
done
2213

run_no_csas.sh

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,11 @@
33
dir=`pwd`
44

55
cd no_csas && vagrant up
6-
cd ${dir}
76

8-
# while true; do
9-
# echo "Running demonstration with csas NOT enabled"
7+
while true; do
8+
vagrant ssh -c 'mysql -uroot -pcsas -e "USE csas; TRUNCATE TABLE post;"'
9+
echo "Running demonstration with csas NOT enabled"
1010
# Run the Python script to do the XSS injections
11-
# python xss_demo.py --url http://localhost:8082
12-
# Reboot the Vagrant machine when the demo is done
13-
# cd csas && vagrant reload
14-
# done
15-
16-
echo "Running demonstration with csas NOT enabled"
17-
# Run the Python script to do the XSS injections
18-
python xss_demo.py --url http://localhost:8082
19-
# Reboot the Vagrant machine when the demo is done
20-
# cd csas && vagrant reload
11+
python ${dir}/xss_demo.py --url http://localhost:8082
12+
done
2113

xss_demo.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import anyconfig
1111
from selenium import webdriver
12-
from selenium.webdriver.common.keys import Keys
1312
from selenium.webdriver.common.alert import Alert
1413
from selenium.common.exceptions import NoAlertPresentException
1514

@@ -98,14 +97,13 @@ def get_config(config_file):
9897
def generate_payload(context):
9998
if context == 'HTML_PCDATA':
10099
options = [
101-
"<b> bolded all day every day</b>",
102-
"<i> italics rule</i>",
103-
" \\\ & \\\" a\\ra\\na\\va\\fa\\t",
104-
"<h1>HACKED</h1>",
100+
# "<b> bolded all day every day</b>",
101+
# "<i> italics rule</i>",
102+
# "<h1>HACKED</h1>",
105103
'<input type="file" accept="video/*;capture=camcorder">',
106-
'<input type="file" accept="audio/*;capture=microphone">',
107-
'<img src="http://forklog.net/wp-content/uploads/2015/05/12035-hacked_article.jpg" />',
108-
'<iframe width="420" height="315" src="https://www.youtube.com/embed/7t96m2ynKw0&autoplay=1" frameborder="0" allowfullscreen></iframe>'
104+
# '<input type="file" accept="audio/*;capture=microphone">',
105+
# '<img src="http://forklog.net/wp-content/uploads/2015/05/12035-hacked_article.jpg" />',
106+
# '<iframe width="420" height="315" src="https://www.youtube.com/embed/7t96m2ynKw0&autoplay=1" frameborder="0" allowfullscreen></iframe>'
109107
]
110108
return random.choice(options)
111109
elif context == 'HTML_QUOTED':
@@ -120,9 +118,8 @@ def generate_payload(context):
120118
return 'https://bank.com/transfer?id=hacker&amount=1000000000'
121119
elif context == 'JS_STRING':
122120
options = [
123-
'<script>alert(document.cookie + " YOU\'VE BEEN HACKED")</script>',
124-
'</script>alert("XSSSSSSSSSSSED AGAIN")</script>',
125-
"javascript:(function(){var s=document.createElement('style');s.innerHTML='%40-moz-keyframes roll { 100%25 { -moz-transform: rotate(360deg); } } %40-o-keyframes roll { 100%25 { -o-transform: rotate(360deg); } } %40-webkit-keyframes roll { 100%25 { -webkit-transform: rotate(360deg); } } body{ -moz-animation-name: roll; -moz-animation-duration: 4s; -moz-animation-iteration-count: 1; -o-animation-name: roll; -o-animation-duration: 4s; -o-animation-iteration-count: 1; -webkit-animation-name: roll; -webkit-animation-duration: 4s; -webkit-animation-iteration-count: 1; }';document.getElementsByTagName('head')[0].appendChild(s);}());",
121+
# '<script>alert(document.cookie + " YOU\'VE BEEN HACKED")</script>',
122+
'<script>alert("HACKED AGAIN")</script>'
126123
]
127124
return random.choice(options)
128125

@@ -150,18 +147,30 @@ def main():
150147

151148
cli = Cli()
152149
driver = make_driver(cli.args.browser)
150+
driver.maximize_window()
153151
driver.get(cli.args.url)
154-
comment_form = driver.find_element_by_id('commentForm')
155-
comment_message = driver.find_element_by_name('message')
156-
comment_link = driver.find_element_by_name('link')
157-
for payload in generate_all_payloads(CONTEXTS):
158-
send_key_sequence(comment_message, payload)
159-
# Try this later
160-
# send_key_sequence(comment_link, payload)
152+
handle_alert(driver)
153+
for i, payload in enumerate(generate_all_payloads(CONTEXTS)):
154+
handle_alert(driver)
155+
comment_form = driver.find_element_by_id('commentForm')
156+
if i in [0, 1, 2, 6]:
157+
comment_message = driver.find_element_by_name('message')
158+
send_key_sequence(comment_message, payload)
159+
elif i in [3, 4, 5]:
160+
comment_message = driver.find_element_by_name('message')
161+
comment_link = driver.find_element_by_name('link')
162+
send_key_sequence(comment_message, 'Check out this link!')
163+
send_key_sequence(comment_link, payload)
164+
else:
165+
comment_message = driver.find_element_by_name('message')
166+
comment_link = driver.find_element_by_name('link')
167+
send_key_sequence(comment_message, payload)
168+
send_key_sequence(comment_link, payload)
169+
161170
comment_form.submit()
162-
# Maybe make this shorter or longer in order to see the effect of XSS
163171
time.sleep(2)
164172
handle_alert(driver)
173+
165174
driver.close()
166175

167176

0 commit comments

Comments
 (0)