Skip to content

Commit 1140fc4

Browse files
committed
[FEAT]: bisc 코드파일 추가
1 parent 58a54ea commit 1140fc4

File tree

5 files changed

+178
-25
lines changed

5 files changed

+178
-25
lines changed

client/public/img/c.png

26.9 KB
Loading

client/src/App.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import ConditionalBanner from "./components/ConditionalBanner";
1313

1414
function App() {
1515
const [section, setSection] = useState("1");
16-
const [file, setFile] = useState("hello.py");
16+
const [file, setFile] = useState(() => {
17+
const params = new URLSearchParams(window.location.search);
18+
return params.get("event") === "bisc" ? "ex.py" : "hello.py";
19+
});
1720
const [fileLength, setFileLength] = useState(928);
1821
const [position, setPosition] = useState({ x: 0, y: 0 });
1922
const [daynight, setdaynight] = useState(1);

client/src/components/AutoCompletion.jsx

+108-13
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,64 @@ export default function AutoCompletion({
1414
}) {
1515
const [comp, setComp] = useState([]);
1616
const [autoIndex, setAutoIndex] = useState(0);
17+
const cKeyword = [
18+
"auto",
19+
"break",
20+
"case",
21+
"char",
22+
"const",
23+
"continue",
24+
"default",
25+
"do",
26+
"double",
27+
"else",
28+
"enum",
29+
"extern",
30+
"float",
31+
"for",
32+
"goto",
33+
"if",
34+
"inline",
35+
"int",
36+
"long",
37+
"register",
38+
"return",
39+
"short",
40+
"signed",
41+
"sizeof",
42+
"static",
43+
"struct",
44+
"switch",
45+
"typedef",
46+
"union",
47+
"unsigned",
48+
"void",
49+
"volatile",
50+
"while",
51+
"#include",
52+
"#define",
53+
"#ifndef",
54+
"#endif",
55+
"NULL",
56+
"malloc",
57+
"free",
58+
"printf",
59+
"scanf",
60+
"main",
61+
"stdio.h",
62+
"stdlib.h",
63+
"string.h",
64+
];
65+
1766
const pyKeyword = [
1867
"False",
1968
"None",
2069
"True",
2170
"and",
2271
"as",
2372
"assert",
73+
"async",
74+
"await",
2475
"break",
2576
"class",
2677
"continue",
@@ -48,6 +99,24 @@ export default function AutoCompletion({
4899
"while",
49100
"with",
50101
"yield",
102+
"self",
103+
"__init__",
104+
"print",
105+
"len",
106+
"range",
107+
"list",
108+
"dict",
109+
"set",
110+
"tuple",
111+
"str",
112+
"int",
113+
"float",
114+
"bool",
115+
"input",
116+
"open",
117+
"append",
118+
"extend",
119+
"remove",
51120
];
52121

53122
const javaKeyword = [
@@ -91,37 +160,49 @@ export default function AutoCompletion({
91160
"static",
92161
"super",
93162
"switch",
163+
"synchronized",
94164
"this",
95165
"throw",
96166
"throws",
167+
"transient",
97168
"try",
98169
"void",
170+
"volatile",
99171
"while",
100172
"true",
101173
"false",
174+
"null",
175+
"String",
176+
"System",
177+
"println",
178+
"ArrayList",
179+
"HashMap",
180+
"Override",
102181
];
103182

104183
const jsKeyword = [
105184
"abstract",
106185
"arguments",
107-
"await*",
186+
"await",
108187
"boolean",
109188
"break",
110189
"byte",
111190
"case",
112191
"catch",
113192
"char",
114-
"class*",
193+
"class",
115194
"const",
116195
"continue",
117196
"debugger",
118197
"default",
119198
"delete",
120-
"dodouble",
199+
"do",
200+
"double",
121201
"else",
122-
"enum*",
123-
"evalexport*",
124-
"extends*",
202+
"enum",
203+
"eval",
204+
"export",
205+
"extends",
125206
"false",
126207
"final",
127208
"finally",
@@ -131,12 +212,12 @@ export default function AutoCompletion({
131212
"goto",
132213
"if",
133214
"implements",
134-
"import*",
215+
"import",
135216
"in",
136217
"instanceof",
137218
"int",
138219
"interface",
139-
"let*",
220+
"let",
140221
"long",
141222
"native",
142223
"new",
@@ -148,7 +229,7 @@ export default function AutoCompletion({
148229
"return",
149230
"short",
150231
"static",
151-
"super*",
232+
"super",
152233
"switch",
153234
"synchronized",
154235
"this",
@@ -159,10 +240,22 @@ export default function AutoCompletion({
159240
"try",
160241
"typeof",
161242
"var",
162-
"voidvolatile",
243+
"void",
244+
"volatile",
163245
"while",
164246
"with",
165247
"yield",
248+
"async",
249+
"document",
250+
"window",
251+
"console",
252+
"map",
253+
"filter",
254+
"reduce",
255+
"Promise",
256+
"async",
257+
"fetch",
258+
"addEventListener",
166259
];
167260

168261
const supportLangList = {
@@ -195,12 +288,14 @@ export default function AutoCompletion({
195288
}, [keyEvent]);
196289

197290
useEffect(() => {
198-
if (autoWord.length !== 0) {
291+
if (autoWord.length !== 0 && file) {
292+
// file 존재 여부 체크 추가
199293
const extension = file.split(".");
200294
setComp(
201-
supportLangList[extension[extension.length - 1]].filter((keyword) => {
295+
supportLangList[extension[extension.length - 1]]?.filter((keyword) => {
296+
// optional chaining 추가
202297
return autoWord.join("") == keyword.substring(0, autoWord.length);
203-
})
298+
}) || [] // fallback 배열 추가
204299
);
205300
} else {
206301
setComp([]);

client/src/components/Sidebar.jsx

+33-11
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,40 @@ import Debug from "./Debug";
33
import LeaderBoard from "./LeaderBoard";
44
import IconGenerator from "./IconGenerator";
55
export default function Sidebar(props) {
6-
const [filestate, setFilestate] = useState("hello.py");
7-
const filename = [
8-
"hello.py",
9-
"test.java",
10-
"server.js",
11-
"RectangleArea.java",
12-
"say_hello.py",
13-
"Example.java",
14-
"Fibonacci.java",
15-
];
6+
const [filestate, setFilestate] = useState(() => {
7+
const params = new URLSearchParams(window.location.search);
8+
return params.get("event") === "bisc" ? "ex.py" : "hello.py";
9+
});
10+
11+
const [isEventMode, setIsEventMode] = useState(false);
12+
1613
useEffect(() => {
17-
if (props.section === "1") {
14+
const params = new URLSearchParams(window.location.search);
15+
const event = params.get("event");
16+
setIsEventMode(event?.toLowerCase() === "bisc");
17+
}, []);
18+
19+
const filename = isEventMode
20+
? ["ex.py", "print.c", "sha256.java"]
21+
: [
22+
"hello.py",
23+
"test.java",
24+
"server.js",
25+
"RectangleArea.java",
26+
"say_hello.py",
27+
"Example.java",
28+
"Fibonacci.java",
29+
];
30+
31+
useEffect(() => {
32+
if (props.section === "1" && isEventMode) {
33+
setFilestate(filestate);
34+
props.setFile(filestate);
35+
}
36+
}, [props.section]);
37+
38+
useEffect(() => {
39+
if (props.section === "1" && !isEventMode) {
1840
setFilestate(filestate);
1941
props.setFile(filestate);
2042
} else if (props.section === "2") {

client/src/utils/filecontents.js

+33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
const getFilecontents = (filename) => {
22
switch (filename) {
3+
case "ex.py":
4+
return {
5+
content: `from pwn import *
6+
p = remote("bisc", 4444)
7+
payload = b"A" * 0x40
8+
payload += p32(0xdeadbeef)
9+
p.sendline(payload)
10+
p.interactive()`.split(""),
11+
colormap: "",
12+
};
13+
case "print.c":
14+
return {
15+
content: `#include <stdio.h>
16+
int main() {
17+
printf("welcome to bisc\\n")
18+
puts("WELCOME TO BISC\\n");
19+
write(1, "wELcOmE tO BisC\\n", 17);
20+
return 0;
21+
}`.split(""),
22+
colormap: "",
23+
};
24+
case "sha256.java":
25+
return {
26+
content: `public class HashPassword {
27+
public static void main(String[] args) throws Exception {
28+
String password = "bisc";
29+
MessageDigest md = MessageDigest.getInstance("SHA-256");
30+
byte[] hash = md.digest(password.getBytes());
31+
System.out.printf("%064x%n", new java.math.BigInteger(1, hash));
32+
}
33+
}`.split(""),
34+
colormap: "",
35+
};
336
case "RectangleArea.java":
437
return {
538
content: [

0 commit comments

Comments
 (0)