moectf2020 write up for Frank,永远滴神

这道题要我们统计所有文本文件中字符串FrankNB!的出现次数~

直接用Java写轻松些,以及偷懒没写高级的字符串匹配算法(毕竟不会像OI那样TLEwwwwww)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import java.util.*;
import java.lang.*;
import java.io.*;

public class Test
{

public static int searchString(String path)
{
File file = new File(path);
int num = 0;

if(file.isDirectory())//if the variable "file" is a directory, files in it will be searched in recursion
{
boolean exist = false;
File[] files = file.listFiles();

for(File f:files)
{
num += searchString(path+"\\"+f.getName());
}
return num;
}
else
{
try (FileInputStream fileInputStream = new FileInputStream(file))
{
FileOutputStream fileOutputStream = new FileOutputStream(new File("test.txt"));
int c, index = 0;
String str = "";
char[] frk = {'F','r','a','n','k','N','B','!'};
while((c = fileInputStream.read()) != -1)//EOF
{
str += String.valueOf((char)c);
}
int len = str.length();
for(int i=0;i<len;i++)
{
c = str.charAt(i);
if(c == frk[index])
{
index++;
if(c == '!')
{
index = 0;
num++;
}
}
else
{
i-=index;

index = 0;
}
}
}
catch (Exception e)
{
System.out.print("\n"+file.getAbsolutePath());
e.printStackTrace();
}
return num;
}
}

public static void main(String[] args)
{
System.out.println(searchString(args[0]));
}
}

得到205232次

image.png

base64编码即得flag> <

1
moectf{MjA1MjMy}
Posted on

2020-11-13

Updated on

2020-11-18

Licensed under

Comments

:D 一言句子获取中...

Loading...Wait a Minute!