Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

c++ program, which generates ARP packets.

  1. I downloaded and installed crafter library on my debian machine. The installation is as easy as described in libcrafter. The first example, which I tried, detects the computer's IP and MAC address.

  2. In this case, I used a written example, which creates ARP packets.

    /* Simple ARP Ping on local network
    *
    * The program assembles a set of ARP requests on a container of packets ...
    */

    But instead of sending them through my home network. I print each packet content using crafter print method. The Print function gives a lot of information while the RawString function has an annoying display. So I modified the latter:

    /* Print Payload */
    void Packet::RawString(ostream& str) {
      Craft();
      /* Print raw data in hexadecimal format */
      for(size_t i = 0 ; i < bytes_size ; i++) {
        //str << "\\x";
        if(i > 0 && (i%16) == 0) cout << endl;
        else if(i > 0) cout << " ";
        str << std::hex << setfill('0') << setw(2) << (unsigned int)(raw_data)[i];
      }
      str << endl; }

    A print example of one packet is shown below:

    < Ethernet (14 bytes) :: DestinationMAC = ff:ff:ff:ff:ff:ff , SourceMAC = 00:0c:29:b4:41:b0 , Type = 0x800 , >
    < ARP (28 bytes) :: HardwareType = 0x1 , ProtocolType = 0x800 , HardwareLength = 6 , ProtocolLength = 4 , Operation = 1 , SenderMAC = 00:0c:29:b4:41:b0 , SenderIP = 192.168.0.180 , TargetMAC = 00:00:00:00:00:00 , TargetIP = 192.168.0.255 , >
    ff ff ff ff ff ff 00 0c 29 b4 41 b0 08 06 00 01
    08 00 06 04 00 01 00 0c 29 b4 41 b0 c0 a8 00 b4
    00 00 00 00 00 00 c0 a8 00 ff

  3. The code is based on the example ARPping.cpp. The send packets code has been removed. Instead the print functions are used.

        /* Finally, push the packet into the container */
        request_packets.push_back(packet);
        (*packet).Print();
        (*packet).RawString();

  ...


Search This Site


Feedback This Site




new pages on this site