Class: Dvash::Honeyport

Inherits:
Core
  • Object
show all
Defined in:
lib/dvash/honeyports/ipv4/rdp.rb,
lib/dvash/honeyports/ipv4/ssh.rb,
lib/dvash/honeyports/ipv6/rdp.rb,
lib/dvash/honeyports/ipv6/ssh.rb,
lib/dvash/honeyports/ipv4/http.rb,
lib/dvash/honeyports/ipv6/http.rb,
lib/dvash/honeyports/ipv4/telnet.rb

Overview

Main Honeyport class to simulate daemons

Instance Method Summary collapse

Methods inherited from Core

#client_ip, #load_conf, #load_honeyport, #random_data, #valid_ip?, #valid_user?, #validate_os

Instance Method Details

#ipv4_httpObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv4/http.rb', line 17

def ipv4_http
  # IPv4 TCPServer object
  # @return [TCPServer] tcp/80 HTTPd
  server = TCPServer.new(80)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Validate client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then 
            # Send the connected client junk data
            client.puts(random_data)
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end

#ipv4_rdpObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv4/rdp.rb', line 17

def ipv4_rdp
  # IPv4 TCPServer object
  # @return [TCPServer] tcp/3389 RDPd
  server = TCPServer.new(3389)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Make sure the client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then 
        # Send the connected client junk data
        client.puts(random_data)
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end

#ipv4_sshObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv4/ssh.rb', line 17

def ipv4_ssh
  # IPv4 TCPServer object
  # @return [TCPServer] tcp/22 SSHd
  server = TCPServer.new(22)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Make sure the client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then
            # Send the connected client junk data
            client.puts(random_data) 
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end

#ipv4_telnetObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv4/telnet.rb', line 17

def ipv4_telnet
  # IPv4 TCPServer object
  # @return [TCPServer] tcp/23 Telnetd
  server = TCPServer.new(23)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Make sure the client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then 
            # Send the connected client junk data
            client.puts(random_data)
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end

#ipv6_httpObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv6/http.rb', line 17

def ipv6_http
  # IPv6 TCPServer object
  # @return [TCPServer] tcp/80 HTTPd
  server = TCPServer.new('::', 80)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Make sure the client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then 
            # Send the connected client junk data
            client.puts(random_data)
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end

#ipv6_rdpObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv6/rdp.rb', line 17

def ipv6_rdp
  # IPv6 TCPServer object
  # @return [TCPServer] tcp/3389 RDPd
  server = TCPServer.new('::', 3389)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Make sure the client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then 
            # Send the connected client junk data
            client.puts(random_data)
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end

#ipv6_sshObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dvash/honeyports/ipv6/ssh.rb', line 17

def ipv6_ssh
  # IPv6 TCPServer object
  # @return [TCPServer] tcp/22 SSHd
  server = TCPServer.new('::', 22)
  # Infinite listening loop
  loop do
    # Fork a new instance of [TCPServer] when a client connects
      Thread.fork(server.accept) do |client| 
          # Make sure the client has a valid IP address
          # @return [Boolean] true|false
          if valid_ip?(client_ip(client)) then 
            # Send the connected client junk data
            client.puts(random_data)
            # Block the IP address
            @@os.block_ip(client_ip(client))
          end
          # Close the connection to the client and kill the forked process
          client.close
      end
  end
end