Skip to content

Commit 57d396d

Browse files
committed
fix: flag leet
1 parent 7ca5205 commit 57d396d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

GZCTF/Controllers/TeamController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,6 @@ public async Task<IActionResult> KickUser([FromRoute] int id, [FromRoute] string
308308

309309
try
310310
{
311-
if (team is null)
312-
return BadRequest(new RequestResponse("队伍未找到"));
313-
314311
if (team.Locked && await teamRepository.AnyActiveGame(team, token))
315312
return BadRequest(new RequestResponse("队伍已锁定"));
316313

GZCTF/Utils/Codec.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@ public static class Leet
9090
public static double LeetEntropy(string flag)
9191
{
9292
double entropy = 0;
93+
bool doLeet = false;
9394
foreach (char c in flag)
9495
{
95-
if (CharMap.ContainsKey(c))
96-
entropy += Math.Log2(CharMap[c].Length);
96+
if (c == '{' || c == ']')
97+
doLeet = true;
98+
else if (doLeet && (c == '}' || c == '['))
99+
doLeet = false;
100+
else if (doLeet && CharMap.TryGetValue(char.ToUpper(c), out string? table) && table is not null)
101+
entropy += Math.Log(table.Length, 2);
97102
}
98103
return entropy;
99104
}
@@ -118,7 +123,7 @@ public static string LeetFlag(string original)
118123
continue;
119124
}
120125

121-
sb.Append(c);
126+
sb.Append(c == ' ' ? '_' : c); // replace blank to underline
122127
}
123128

124129
return sb.ToString();

0 commit comments

Comments
 (0)