-
Notifications
You must be signed in to change notification settings - Fork 0
/
23.go
59 lines (47 loc) · 1.38 KB
/
23.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
51
52
53
54
55
56
57
package main
import (
"reflect"
"fmt"
"net/http"
"io/ioutil"
"regexp"
"os/exec"
)
const URL string = "http://www.pythonchallenge.com/pc/hex/"
const Yell, Cyan, Rest string = "\033[33m", "\033[36m", "\033[0m"
func main(){
res, err := exec.Command("python3", "-c", "import this").Output()
fmt.Println("err/exec", err)
fmt.Println("typ/", reflect.TypeOf(res))
fmt.Println("\n" + Yell + string(res) + Rest)
source := string(res)
re := regexp.MustCompile(`(?is)in the face of (.*?)[, ]`)
word := re.FindAllStringSubmatch( source, -1)[0][1]
fmt.Println("word/", Cyan + word, Rest)
}
func init(){
// GET
conn := & http.Client{}
req, _ := http.NewRequest("GET", URL + "bonus.html", nil)
req.SetBasicAuth( "butter", "fly" )
resp, _ := conn.Do(req)
defer resp.Body.Close()
temp, _ := ioutil.ReadAll(resp.Body)
body := string(temp)
fmt.Println(Cyan + body + Rest + "body ends/\n")
re := regexp.MustCompile(`(?s)<!--\n'(.*?)'\n-->`)
msg := re.FindAllStringSubmatch(body, -1)[0][1]
fmt.Println("cmt/", Yell + msg, Rest)
fmt.Println("r13/", Cyan + r13 (msg), Rest)
}
func r13(s string)string{
res := ""
for _, char := range s {
if char < 'a' || char > 'z' {
res += string(char)
} else {
res += string((char - 'a' + 13) % 26 + 'a')
}
}
return res
}