Skip to content

Commit

Permalink
rewrite in go
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterion committed Oct 9, 2024
1 parent d595e39 commit 3f3d653
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 215 deletions.
10 changes: 0 additions & 10 deletions README.md

This file was deleted.

43 changes: 0 additions & 43 deletions app.py

This file was deleted.

1 change: 0 additions & 1 deletion conf.cfg

This file was deleted.

124 changes: 0 additions & 124 deletions deploy.sh

This file was deleted.

12 changes: 6 additions & 6 deletions templates/index.html → files/exploit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
color: #2F3335;
}
</style>
<script src="/static/logging.js"></script>
<script src="logging.js"></script>
<script>
function allset() {
document.getElementById("loader").style.display = "none";
Expand All @@ -65,10 +65,10 @@
logMessage("done");
}
</script>
<script src="/static/int64.js"></script>
<script src="/static/rop.js"></script>
<script src="/static/kexploit.js"></script>
<script src="/static/webkit.js"></script>
<script src="int64.js"></script>
<script src="rop.js"></script>
<script src="kexploit.js"></script>
<script src="webkit.js"></script>
</head>

</html>
Expand All @@ -89,4 +89,4 @@
</body>
<script>

</script>
</script>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
105 changes: 105 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package main

import (
"embed"
"fmt"
"io/fs"
"log"
"net"
"net/http"
"strings"
"time"
)

//go:embed files
var files embed.FS

func getIps() []string {
ips := make([]string, 0)
ifaces, err := net.Interfaces()
if err != nil {
panic(err)
}
for _, i := range ifaces {
addrs, err := i.Addrs()
if err != nil {
panic(err)
}
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
case *net.IPAddr:
ip = v.IP
}
if ip.To4() != nil && (ip.IsPrivate() || ip.IsLoopback()) {
ips = append(ips, ip.String())
}
}
}
return ips
}

func main() {
exploit, err := fs.Sub(files, "files/exploit")
if err != nil {
log.Println("Couldn't find exploit folder")
panic(err)
}
payloadFilePath := ""

func() {
fs.WalkDir(files, "files/payload", func(path string, d fs.DirEntry, err error) error {
if !d.IsDir() && strings.HasSuffix(d.Name(), ".bin") {
payloadFilePath = path
}
return nil
})
}()

if payloadFilePath == "" {
panic("Couldn't find payload 😱")
}

send := func(ip string) {
log.Printf("Payload: %s\n", payloadFilePath)
log.Printf("Sending payload to : tcp://%s:%s\n", ip, "9020")

address := net.JoinHostPort(ip, "9020")
conn, err := net.DialTimeout("tcp", address, 3*time.Second)
if err != nil {
log.Printf("failed to connect: %s\n", err)
}
defer conn.Close()

conn.SetWriteDeadline(time.Now().Add(time.Second * 10))
fileB, err := fs.ReadFile(files, payloadFilePath)
if err != nil {
log.Printf("failed to open payload: %s, %s\n", payloadFilePath, err)
}

_, err = conn.Write(fileB)
if err != nil {
log.Printf("failed to send file: %s\n", err)
}
}

http.Handle("/", http.FileServerFS(exploit))
http.HandleFunc("/log/", func(w http.ResponseWriter, r *http.Request) {
ip := strings.Split(r.RemoteAddr, ":")[0]
go send(ip)
w.Write([]byte("OK"))
})

port := 1337

for _, u := range getIps() {
log.Printf("Serving at http://%s:%v/\n", u, port)
}

err = http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
if err != nil {
panic(err)
}
}
Binary file removed payload/goldhen_2.0b2_900.bin
Binary file not shown.
8 changes: 0 additions & 8 deletions ps4.service

This file was deleted.

2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

13 changes: 0 additions & 13 deletions sender.py

This file was deleted.

4 changes: 0 additions & 4 deletions start.sh

This file was deleted.

4 changes: 0 additions & 4 deletions wsgi.py

This file was deleted.

0 comments on commit 3f3d653

Please sign in to comment.