Skip to content

Commit 1a1a8bf

Browse files
committed
Merge pull request #11 from WebGoat/WEB-139
Web 139
2 parents 9708292 + 8f2fc26 commit 1a1a8bf

File tree

8 files changed

+81
-90
lines changed

8 files changed

+81
-90
lines changed

src/main/java/org/owasp/webgoat/lessons/PasswordStrength.java

Lines changed: 63 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11

22
package org.owasp.webgoat.lessons;
33

4-
import java.util.ArrayList;
4+
import java.util.ArrayList;
5+
import java.util.HashMap;
56
import java.util.List;
7+
import java.util.Map;
8+
import java.util.TreeMap;
9+
import java.util.Map.Entry;
10+
11+
import org.apache.commons.collections.CollectionUtils;
612
import org.apache.ecs.Element;
713
import org.apache.ecs.ElementContainer;
814
import org.apache.ecs.StringElement;
@@ -15,6 +21,7 @@
1521
import org.apache.ecs.html.TR;
1622
import org.apache.ecs.html.Table;
1723
import org.owasp.webgoat.session.ECSFactory;
24+
import org.owasp.webgoat.session.ParameterNotFoundException;
1825
import org.owasp.webgoat.session.WebSession;
1926

2027

@@ -52,6 +59,38 @@
5259

5360
public class PasswordStrength extends LessonAdapter
5461
{
62+
private Map<String, Password> passwords = new TreeMap<String, Password>() {{
63+
put("pass1", new Password("123456", "seconds", "0", "dictionary based, in top 10 most used passwords"));
64+
put("pass2", new Password("abzfezd", "seconds", "2", "26 chars on 7 positions, 8 billion possible combinations"));
65+
put("pass3", new Password("a9z1ezd", "seconds", "19", "26 + 10 chars on 7 positions = 78 billion possible combinations"));
66+
put("pass4", new Password("aB8fEzDq", "hours", "15", "26 + 26 + 10 chars on 8 positions = 218 trillion possible combinations"));
67+
put("pass5", new Password("z8!E?7D$", "days", "20", "96 chars on 8 positions = 66 quintillion possible combinations"));
68+
put("pass6", new Password("My1stPassword!:Redd", "quintillion years", "364", "96 chars on 19 positions = 46 undecillion possible combinations"));
69+
}};
70+
71+
private class Password {
72+
73+
String password;
74+
String timeUnit;
75+
String answer;
76+
private String explanation;
77+
78+
public Password(String password, String timeUnit, String answer, String explanation) {
79+
this.password = password;
80+
this.timeUnit = timeUnit;
81+
this.answer = answer;
82+
this.explanation = explanation;
83+
}
84+
}
85+
86+
private boolean checkSolution(WebSession s) throws ParameterNotFoundException {
87+
boolean allCorrect = true;
88+
for ( int i = 1; i <= passwords.size(); i++ ) {
89+
String key = "pass" + i;
90+
allCorrect = allCorrect && s.getParser().getStringParameter(key, "").equals(passwords.get(key).answer);
91+
}
92+
return allCorrect;
93+
}
5594

5695
/**
5796
* Description of the Method
@@ -66,87 +105,39 @@ protected Element createContent(WebSession s)
66105

67106
try
68107
{
69-
if (s.getParser().getStringParameter("pass1", "").equals("0")
70-
&& s.getParser().getStringParameter("pass2", "").equals("1394")
71-
&& s.getParser().getStringParameter("pass3", "").equals("5")
72-
&& s.getParser().getStringParameter("pass4", "").equals("2")
73-
&& s.getParser().getStringParameter("pass5", "").equals("41"))
108+
if (checkSolution(s))
74109
{
75110
makeSuccess(s);
111+
ec.addElement(new BR());
76112
ec.addElement(new StringElement("As a guideline not bound to a single solution."));
77113
ec.addElement(new BR());
78-
ec.addElement(new StringElement("Assuming the brute-force power of 1,000,000 hash/second: "));
114+
ec.addElement(new StringElement("Assuming the calculations per second 4 billion: "));
79115
ec.addElement(new BR());
80116
OL ol = new OL();
81-
ol.addElement(new LI("123456 - 0 seconds (dictionary based, one of top 100)"));
82-
ol.addElement(new LI("abzfez - up to 5 minutes ( 26 chars on 6 positions = 26^6 seconds)"));
83-
ol.addElement(new LI("a9z1ez - up to 40 minutes ( 26+10 chars on 6 positions = 36^6 seconds)"));
84-
ol.addElement(new LI("aB8fEz - up to 16 hours ( 26+26+10 chars on 6 positions = 62^6 seconds)"));
85-
ol.addElement(new LI("z8!E?7 - up to 50 days ( 127 chars on 6 positions = 127^6 seconds)"));
117+
for ( Password password : passwords.values()) {
118+
ol.addElement(new LI(String.format("%s - %s %s (%s)", password.password, password.answer, password.timeUnit, password.explanation)));
119+
}
86120
ec.addElement(ol);
87121
} else
88122
{
89-
90-
ec.addElement(new StringElement("How much time you need for these passwords? "));
91123
ec.addElement(new BR());
124+
ec.addElement(new StringElement("How much time would a desktop PC take to crack these passwords?"));
92125
ec.addElement(new BR());
93126
ec.addElement(new BR());
94127
Table table = new Table();
95-
table.addAttribute("align='center'", 0);
96-
TR tr1 = new TR();
97-
TD td1 = new TD();
98-
TD td2 = new TD();
99-
Input input1 = new Input(Input.TEXT, "pass1", "");
100-
td1.addElement(new StringElement("Password = 123456"));
101-
td2.addElement(input1);
102-
td2.addElement(new StringElement("seconds"));
103-
tr1.addElement(td1);
104-
tr1.addElement(td2);
105-
106-
TR tr2 = new TR();
107-
TD td3 = new TD();
108-
TD td4 = new TD();
109-
Input input2 = new Input(Input.TEXT, "pass2", "");
110-
td3.addElement(new StringElement("Password = abzfez"));
111-
td4.addElement(input2);
112-
td4.addElement(new StringElement("seconds"));
113-
tr2.addElement(td3);
114-
tr2.addElement(td4);
115-
116-
TR tr3 = new TR();
117-
TD td5 = new TD();
118-
TD td6 = new TD();
119-
Input input3 = new Input(Input.TEXT, "pass3", "");
120-
td5.addElement(new StringElement("Password = a9z1ez"));
121-
td6.addElement(input3);
122-
td6.addElement(new StringElement("hours"));
123-
tr3.addElement(td5);
124-
tr3.addElement(td6);
125-
126-
TR tr4 = new TR();
127-
TD td7 = new TD();
128-
TD td8 = new TD();
129-
Input input4 = new Input(Input.TEXT, "pass4", "");
130-
td7.addElement(new StringElement("Password = aB8fEz"));
131-
td8.addElement(input4);
132-
td8.addElement(new StringElement("days"));
133-
tr4.addElement(td7);
134-
tr4.addElement(td8);
135-
136-
TR tr5 = new TR();
137-
TD td9 = new TD();
138-
TD td10 = new TD();
139-
Input input5 = new Input(Input.TEXT, "pass5", "");
140-
td9.addElement(new StringElement("Password = z8!E?7"));
141-
td10.addElement(input5);
142-
td10.addElement(new StringElement("days"));
143-
tr5.addElement(td9);
144-
tr5.addElement(td10);
145-
table.addElement(tr1);
146-
table.addElement(tr2);
147-
table.addElement(tr3);
148-
table.addElement(tr4);
149-
table.addElement(tr5);
128+
for ( Entry<String, Password> entry : passwords.entrySet()) {
129+
TR tr = new TR();
130+
TD td1 = new TD();
131+
TD td2 = new TD();
132+
Input input1 = new Input(Input.TEXT, entry.getKey(), "");
133+
td1.addElement(new StringElement("Password = " + entry.getValue().password));
134+
td1.setWidth("50%");
135+
td2.addElement(input1);
136+
td2.addElement(new StringElement(" " + entry.getValue().timeUnit));
137+
tr.addElement(td1);
138+
tr.addElement(td2);
139+
table.addElement(tr);
140+
}
150141
ec.addElement(table);
151142
ec.addElement(new BR());
152143
ec.addElement(new BR());
@@ -197,9 +188,9 @@ protected Category getDefaultCategory()
197188

198189
public String getInstructions(WebSession s)
199190
{
200-
String instructions = "The Accounts of your Webapplication are only as save as the passwords. "
201-
+ "For this exercise, your job is to test several passwords on <a href=\"https://www.cnlab.ch/codecheck\" target=\"_blank\">https://www.cnlab.ch/codecheck</a>. "
202-
+ " You must test all 5 passwords at the same time...<br>"
191+
String instructions = "The accounts of your web application are only as save as the passwords. "
192+
+ "For this exercise, your job is to test several passwords on <a href=\"https://howsecureismypassword.net\" target=\"_blank\">https://howsecureismypassword.net</a>. "
193+
+ " You must test all 6 passwords at the same time...<br>"
203194
+ "<b> On your applications you should set good password requirements! </b>";
204195
return (instructions);
205196
}

src/main/webapp/lesson_plans/English/PasswordStrength.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
</div>
44
<p><b>Concept / Topic To Teach:</b> </p>
55
<!-- Start Instructions -->
6-
Accounts are only as secure as their passwords. Most users have the same weak password everywhere. If you want to protect them against brute-force-attacks your application should have good requirements for passwords. The password should contain lower case letters, capitals and numbers. The longer the password, the better.
6+
Accounts are only as secure as their passwords. Most users have the same weak password everywhere. If you want to protect them against brute-force-attacks your application should have good requirements for passwords. The password should contain lower case letters, capitals, numbers and special characters. The longer the password, the better, consider using a passphrase instead. For
7+
more information see: <a href="https://www.owasp.org/index.php/Authentication_Cheat_Sheet#Implement_Proper_Password_Strength_Controls" target="_blank">OWASP proper password strength</a>.
78
<!-- Stop Instructions -->
8-
<br>
9+
<br/><br/>
910
<p><b>General Goal(s):</b> </p>
10-
For this exercise, your job is to test several passwords on <a href="https://www.cnlab.ch/codecheck" target="_blank">https://www.cnlab.ch/codecheck</a>
11+
For this exercise, your job is to test several passwords on <a href="https://howsecureismypassword.net/" target="_blank">https://howsecureismypassword.net/</a>

src/main/webapp/lesson_plans/en/PasswordStrength.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
</div>
44
<p><b>Concept / Topic To Teach:</b> </p>
55
<!-- Start Instructions -->
6-
Accounts are only as secure as their passwords. Most users have the same weak password everywhere. If you want to protect them against brute-force-attacks your application should have good requirements for passwords. The password should contain lower case letters, capitals and numbers. The longer the password, the better.
6+
Accounts are only as secure as their passwords. Most users have the same weak password everywhere. If you want to protect them against brute-force-attacks your application should have good requirements for passwords. The password should contain lower case letters, capitals and numbers. The longer the password, the sbetter.
77
<!-- Stop Instructions -->
88
<br>
99
<p><b>General Goal(s):</b> </p>
10-
For this exercise, your job is to test several passwords on <a href="https://www.cnlab.ch/codecheck" target="_blank">https://www.cnlab.ch/codecheck</a>
10+
For this exercise, your job is to test several passwords on <a href="https://howsecureismypassword.net/" target="_blank">https://howsecureismypassword.net/</a>

src/main/webapp/lesson_plans/ru/PasswordStrength.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
<!-- Stop Instructions -->
1111
<br>
1212
<p><b>Основные цели и задачи:</b> </p>
13-
Попробуйте проверить несколько используемых вами паролей на стойкость вот на этом сервисе - <a href="https://www.cnlab.ch/codecheck" target="_blank">https://www.cnlab.ch/codecheck</a>
13+
Попробуйте проверить несколько используемых вами паролей на стойкость вот на этом сервисе - <a href="https://howsecureismypassword.net/" target="_blank">https://howsecureismypassword.net/</a>
5.27 KB
Loading
16.4 KB
Loading
-21.9 KB
Binary file not shown.

src/main/webapp/lesson_solutions_1/PasswordStrength.html

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,24 @@
1414
<!-- Stop Instructions -->
1515
<br>
1616
<p><b>General Goal(s):</b> </p>
17-
For this exercise, your job is to test several passwords on <a href="https://www.cnlab.ch/codecheck" target="_blank">https://www.cnlab.ch/codecheck</a>.
17+
For this exercise, your job is to test several passwords on <a href="https://howsecureismypassword.net/" target="_blank">https://howsecureismypassword.net/</a>.
1818
<br><br>
1919
<b>Solution:</b><br/>
20-
Open your browser on <a href="https://www.cnlab.ch/codecheck" target="_blank">https://www.cnlab.ch/codecheck</a>. Copy the first password in the field and click "Run the check".<br><br>
20+
Open your browser on <a href="https://howsecureismypassword.net/" target="_blank">https://howsecureismypassword.net/</a>. Copy the first password in the field and the page will automatically be updated.<br><br>
2121
<img src="lesson_solutions/PasswordStrength_files/image001.jpg"><br/>
22-
<font size="2"><b>Code checker</b></font><br/><br/><br/>
23-
You will get a little pop-up. Choose "Yes, I want this word to be tested".<br><br>
24-
<img src="lesson_solutions/PasswordStrength_files/image002.jpg"><br/>
25-
<font size="2"><b>Pop-up</b></font><br/><br/><br/>
22+
<font size="2"><b>Password checker</b></font><br/><br/><br/>
2623
You will get get the result of the check.<br><br>
27-
<img src="lesson_solutions/PasswordStrength_files/image003.jpg"><br/>
24+
<img src="lesson_solutions/PasswordStrength_files/image002.jpg"><br/>
2825
<font size="2"><b>The result</b></font><br/><br/><br/>
29-
Do this with all of the five given passwords.<br><br>
26+
Do this with all of the six given passwords.<br><br>
3027
Here are the results you get:<br><br>
28+
3129
Password = 123456: <font color="#ff0000">0</font> seconds<br>
32-
Password = abzfez: <font color="#ff0000">1394</font> seconds<br>
33-
Password = a9z1ez: <font color="#ff0000">5</font> hours<br>
34-
Password = aB8fEz: <font color="#ff0000">2</font> days<br>
35-
Password = z8!E?7: <font color="#ff0000">41</font> days<br>
30+
Password = abzfezd: <font color="#ff0000">2</font> seconds<br>
31+
Password = a9z1ezd: <font color="#ff0000">19</font> seconds<br>
32+
Password = aB8fEzDq: <font color="#ff0000">15</font> hours<br>
33+
Password = z8!E?7: <font color="#ff0000">20</font> days<br>
34+
Password = My1stPassword!:Redd: <font color="#ff0000">364</font> quintillion years<br>
3635
<br><br><br>
3736
</body>
3837
</html>

0 commit comments

Comments
 (0)