-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.go
50 lines (44 loc) · 1.25 KB
/
main.go
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
package main
import (
"fmt"
"log"
)
func main() {
// Initial Flag
flag := "PCTF{"
// Get user input
fmt.Println("++++++++++++++++++++")
fmt.Println("Secret Please: ")
fmt.Println("++++++++++++++++++++")
var userInput string
fmt.Scanln(&userInput)
// Sekret Generation
var sekret []string
for i := 33; i < 123; i+=5 {
data := fmt.Sprintf("%c", i)
sekret = append(sekret, data)
}
// Comparing length of userinput with sekret
if len(userInput) == len(sekret) {
fmt.Println("++++++++++++++++++++")
fmt.Println("Correct Flag Length -> Proceeding")
fmt.Println("++++++++++++++++++++")
} else {
fmt.Println("-----------------------")
log.Fatal("Wrong Flag Length")
}
// Compare userInput and sekret
for i, _ := range sekret {
if sekret[i] == string(userInput[i]) {
flag += string(userInput[i]+7)
} else {
fmt.Println("-----------------------")
log.Fatal("Wrong Flag")
fmt.Println("-----------------------")
}
}
fmt.Println("Congratulations")
fmt.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
fmt.Println(flag)
fmt.Println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
}