-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.java
52 lines (42 loc) · 1.38 KB
/
Main.java
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
package ctf.xorqr;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
public class Main {
public static void main(String[] args) throws IOException {
String flag = null;
Socket s = new Socket();
s.connect(new InetSocketAddress("asis-ctf.ir", 12431));
s.setSoTimeout(3000);
BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
PrintWriter out = new PrintWriter(s.getOutputStream(), true);
boolean started = false;
while (s.isConnected()) {
String line = in.readLine();
if(line == null)
break;
if(line.contains("ASIS_")) {
flag = line.substring(line.indexOf("ASIS_"), line.length());
break;
}
if (line.startsWith("send ")) {
started = true;
out.println("START");
}
if(started) {
Cracker cracker = new Cracker();
for(int i = 0; i < 14; i++) {
cracker.read(in);
String code = cracker.crack();
out.println(code);
in.readLine();
}
started = false;
}
}
if(!s.isClosed()){
s.close();
}
System.out.println(flag);
}
}