-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtools.go
More file actions
132 lines (109 loc) · 3.49 KB
/
Copy pathtools.go
File metadata and controls
132 lines (109 loc) · 3.49 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package main
import (
"crypto/rand"
"fmt"
"html/template"
"net/http"
"strings"
)
type Page struct {
Title string
R string
Body []byte
}
//show ip
func ipHandler(w http.ResponseWriter, r *http.Request) {
templates.ExecuteTemplate(w, "ip.html", &Page{R: strings.Split(r.RemoteAddr,":")[0] })
}
func raw_ipHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, strings.Split(r.RemoteAddr,":")[0] )
}
//end show ip
//pass gen
func passgenHandler(w http.ResponseWriter, r *http.Request) {
body := r.FormValue("body")
if body == "" {
renderTemplate(w, "html", "PASS GENERATOR")
return
}
rand_bytes := make([]byte, len(body))
rand_bytes2 := make([]byte, len(body))
rand.Read(rand_bytes)
rand.Read(rand_bytes2)
reduced_ascii := make([]byte, 94)
for i := 0; i < 94; i++ {
var tmp byte
tmp = byte('!' + i)
reduced_ascii[i] = tmp
}
pass := make([]byte, len(body))
for i := 0; i < len(body); i++ {
tmp := rand_bytes[i] % 94
if tmp == 0 {
tmp = 94
}
pass[i] = reduced_ascii[(body[i]+rand_bytes2[i])%tmp]
}
templates.Execute(w, &Page{Title: "PASS GENERATOR", R: string(pass) })
}
func raw_passgenHandler(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "raw", "raw")
body := r.FormValue("body")
if body == "" {return}
rand_bytes := make([]byte, len(body))
rand.Read(rand_bytes)
rand_bytes2 := make([]byte, len(body))
rand.Read(rand_bytes2)
reduced_ascii := make([]byte, 94)
for i := 0; i < 94; i++ {
var tmp byte
tmp = byte('!' + i)
reduced_ascii[i] = tmp
}
pass := make([]byte, len(body))
for i := 0; i < len(body); i++ {
tmp := rand_bytes[i] % 94
if tmp == 0 {
tmp = 94
}
pass[i] = reduced_ascii[(body[i]+rand_bytes2[i])%tmp]
}
fmt.Fprint(w, string(pass))
}
//end passgen
var templates = template.Must(template.ParseFiles("html.html", "index.html", "ip.html"))
func renderTemplate(w http.ResponseWriter, tmpl string, title string) {
err := templates.ExecuteTemplate(w, tmpl+".html", &Page{Title: title})
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
func makeHandler(fn func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fn(w, r)
return
}
}
func main() {
Hello := func(w http.ResponseWriter, r *http.Request) { templates.ExecuteTemplate(w, "index.html", nil) }
http.HandleFunc("/", Hello)
http.HandleFunc("/md5", makeHandler(md5Handler))
http.HandleFunc("/raw_md5", makeHandler(raw_md5Handler))
http.HandleFunc("/sha3256", makeHandler(sha3Handler))
http.HandleFunc("/raw_sha3256", makeHandler(raw_sha3Handler))
http.HandleFunc("/sha3512", makeHandler(sha3512Handler))
http.HandleFunc("/raw_sha3512", makeHandler(raw_sha3512Handler))
http.HandleFunc("/encodeBase64", makeHandler(encodeBase64Handler))
http.HandleFunc("/raw_encodeBase64", makeHandler(raw_encodeBase64Handler))
http.HandleFunc("/decodeBase64", makeHandler(decodeBase64Handler))
http.HandleFunc("/raw_decodeBase64", makeHandler(raw_decodeBase64Handler))
http.HandleFunc("/passgen", makeHandler(passgenHandler))
http.HandleFunc("/raw_passgen", makeHandler(raw_passgenHandler))
http.HandleFunc("/encodeHex", makeHandler(encodeHexHandler))
http.HandleFunc("/raw_encodeHex", makeHandler(raw_encodeHexHandler))
http.HandleFunc("/decodeHex", makeHandler(decodeHexHandler))
http.HandleFunc("/raw_decodeHex", makeHandler(raw_decodeHexHandler))
http.HandleFunc("/ip", makeHandler(ipHandler))
http.HandleFunc("/raw_ip", makeHandler(raw_ipHandler))
http.ListenAndServe(":1337", nil)
}