Beispiel #1
0
def discovery_acknowledgement():
    operation_code = 2
    hardware_type = 1
    hardware_address_length = 6
    transaction_identifier = 1200
    client_IP_address = '0.0.0.0'
    your_IP_address = '192.168.20.20'
    server_IP_address = '192.168.20.1'
    gateway_IP_address = '0.0.0.0'
    client_hardware_address= 'fe:1d:20:1c:f6:8d'
    DHCACK = dhcp_message(operation_code,
                    hardware_type,
                    hardware_address_length,
                    transaction_identifier,
                    client_IP_address,
                    your_IP_address,
                    server_IP_address,
                    gateway_IP_address,
                    client_hardware_address
                    )

    test = socket.inet_ntoa(DHCACK[12:16])
    print('Sanity Check (1): ', test == '0.0.0.0')
    test = socket.inet_ntoa(DHCACK[16:20])
    print('Sanity Check (2): ', test == '192.168.20.20')
    test = socket.inet_ntoa(DHCACK[20:24])
    print('Sanity Check (3): ', test == '192.168.20.1')
def dhcp_test():
    dhcp_msg = dhcp_message(operation_code=1,
                            hardware_type=1,
                            hardware_address_length=6,
                            transaction_identifier=1206,
                            client_IP_address='0.0.0.0',
                            your_IP_address='0.0.0.0',
                            server_IP_address='0.0.0.0',
                            gateway_IP_address='0.0.0.0',
                            client_hardware_address='fe:1d:20:1c:f6:8d')
    client_hardware_address = 'fe:1d:20:1c:f6:8d'
    print('dhcp message length: {0} bytes'.format(len(dhcp_msg)))
    _mac = []
    for i in range(-16, -10):
        _mac.append(hex(struct.unpack('B', dhcp_msg[i:i + 1])[0]))
    _mac = ':'.join(_mac).replace('0x', '')
    print('HW MAC check (1): ', client_hardware_address == _mac)
def discovery_check():
    operation_code = 1
    hardware_type = 1
    hardware_address_length = 6
    transaction_identifier = 1200
    client_IP_address = '0.0.0.0'
    your_IP_address = '0.0.0.0'
    server_IP_address = '0.0.0.0'
    gateway_IP_address = '0.0.0.0'
    client_hardware_address = 'fe:1d:20:1c:f6:8d'
    DHCPDISCOVER = dhcp_message(operation_code, hardware_type,
                                hardware_address_length,
                                transaction_identifier, client_IP_address,
                                your_IP_address, server_IP_address,
                                gateway_IP_address, client_hardware_address)

    test_HLen = struct.unpack('B', DHCPDISCOVER[1:2])[0]
    print('Sanity Check: ', test_HLen == hardware_type == 1)