Skip to content

Commit 0fe451c

Browse files
committed
Auth review
1 parent 6a26f10 commit 0fe451c

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

Identity/VLAIdentity.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public static async Task<object> VulnerableQuery(string User, string Passwd)
3030
{
3131
/*
3232
Authentifie les utilisateurs par login et mot de passe, et renvoie un token JWT si l'authentification a réussi
33-
*/
34-
35-
bool IsAdmin = false;
33+
*/
3634
SHA256 Sha256Hash = SHA256.Create();
3735
byte[] Bytes = Sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(Passwd));
3836
StringBuilder stringbuilder = new StringBuilder();
@@ -41,10 +39,10 @@ public static async Task<object> VulnerableQuery(string User, string Passwd)
4139

4240
VLAController.VLAController.VulnerableLogs("login attempt for:\n" + User + "\n" + Passwd + "\n", LogFile);
4341
var DataSet = VLAModel.Data.GetDataSet();
44-
var Result = DataSet.Tables[0].Select("Passwd = '" + Hash + "' and User = '" + User + "'");
45-
if( DataSet.Tables[0].Select("User = '" + User.Replace("'", "''") + "' and IsAdmin = 1" ).Length > 0) IsAdmin = true;
42+
var Result = DataSet.Tables[0].Select("Passwd = '" + Hash + "' and User = '" + User + "'");
43+
var userRow = DataSet.Tables[0].AsEnumerable().FirstOrDefault(row => row.Field<string>("User") == User && row.Field<int>("IsAdmin") == 1);
4644

47-
return Result.Length > 0 ? Results.Ok(VulnerableGenerateToken(User, IsAdmin)) : Results.Unauthorized();
45+
return Result.Length > 0 ? Results.Ok(VulnerableGenerateToken(User, userRow != null)) : Results.Unauthorized();
4846
}
4947

5048
public static string VulnerableGenerateToken(string User, bool IsAdmin)

Model/Model.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Contenu de la BDD relationnelle (Utilisateurs)
4343
table.Columns.Add("User", typeof(string));
4444
table.Columns.Add("Passwd", typeof(string));
4545
table.Columns.Add("IsAdmin", typeof(int));
46-
table.Rows.Add("User", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 0);
46+
table.Rows.Add("user", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", 0);
4747
table.Rows.Add("root", "ce5ca673d13b36118d54a7cf13aeb0ca012383bf771e713421b4d1fd841f539a", 1);
4848
table.Rows.Add("admin", "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a444", 1);
4949
table.Rows.Add("Alice", "9b510b4af0d9b121f68d5a3400975047cbf38f963963b4c7510842d9d6310e7f", 0);

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Run it at your own risk.
55

66
## Tracability
77

8-
A simple way to keep some logs is to redirect console output in a file :
8+
A simple way to keep some logs is to redirect console output into a file :
99

1010
```powershell
1111
.\VulnerableWebApplication.exe >> C:\Users\<UserName>\log.txt

0 commit comments

Comments
 (0)