Ejemplo n.º 1
0
    def AddServerDetail(self, driver, UIDs, Port):
        # edit button
        ByIdClicking(driver, 'deviceDetailButtonEdit')

        # manufacturer
        # ret = fuzzer_method.fuzz()
        # ByIdSendKey(driver, 'deviceDetail_manufacturer', ret)
        # # Device type
        # ret = fuzzer_method.fuzz()
        # ByIdSendKey(driver, 'deviceDetail_device_type', ret)
        # Comment
        ret = fuzzer_method.fuzz(100)
        ByIdSendKey(driver, 'deviceDetail_comment', ret)
        # Done
        ByIdClicking(driver, 'deviceDetailButtonDone')

        # Server detail input
        ByIdClicking(driver, 'deviceServiceButtonEdit')
        ByIdClicking(driver, 'deviceServiceSelect__BV_toggle_')
        ByIdClicking(driver, 'deviceServiceSelect_modbus_tcp_slave')
        ByIdClicking(driver, 'deviceServiceButtonDone')

        ByIdClicking(driver, 'deviceConnectionButtonEdit')

        ByIdSendKey(driver, 'deviceConnectionInput_port', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_port', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_port', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_port', Port)

        ByIdSendKey(driver, 'deviceConnectionInput_uids', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_uids', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_uids', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_uids', UIDs)

        ByIdClicking(driver, 'deviceConnectionButtonDone')
Ejemplo n.º 2
0
    def AddDeviceDetail_MELSEC_ETHERNET(self, driver, gret, ret):
        # print(name)
        ByXpathClicking(
            driver, f'//*[@id="lineDevice_device_{str(gret)}_{str(ret)}"]')

        # Edit
        ByIdClicking(driver, 'deviceDetailButtonEdit')

        # # manufacturer
        # ret = fuzzer_method.fuzz()
        # ByIdSendKey(driver, 'deviceDetail_manufacturer', ret)
        # # Device type
        # ret = fuzzer_method.fuzz()
        # ByIdSendKey(driver, 'deviceDetail_device_type', ret)
        # Comment
        ret = fuzzer_method.fuzz(100)
        ByIdSendKey(driver, 'deviceDetail_comment', ret)

        # Done
        ByIdClicking(driver, 'deviceDetailButtonDone')

        # Device service
        ByIdClicking(driver, 'deviceServiceButtonEdit')
        ByIdClicking(driver, 'deviceServiceSelect__BV_toggle_')
        ByIdClicking(driver, 'deviceServiceSelect_melsec_ethernet')
        ByIdClicking(driver, 'deviceServiceButtonDone')
Ejemplo n.º 3
0
def ModbusTCP_test(dv, dt, count):
    # croll a excel data which involving a server tags
    df = pd.read_excel('ServerTags.xlsx', index=False)
    del df['Unnamed: 0']
    # print(len(df))
    # print(df)

    ret = fuzzer_method.fuzz(max_length=20)

    # """ Init Chrome Driver and Selenium """
    chrome, driver = init()
    
    localhost = f'http://localhost:1290'
    check_name = f'/device?category=device&name={ret}&{ret}&line={ret}&index=0'
    
    driver.get(f'{localhost}')

    # Create object that selenium running module
    start = selenium_method.AddToContents()

    Device_UID = 55
    Device_interval = dv
    Device_addr = '127.0.0.1'
    Device_port = 502
    Device_count = 1
    Device_TImeOut = dt

    # start, driver, ret, df, iter
    modTCP(start, driver, ret, df, count, Device_interval, Device_UID, Device_addr, Device_port, Device_count, Device_TImeOut)

    start.Commit(driver)
    time.sleep(5)

    # get page index of Device tags
    driver.get(f'{localhost}' + f'{check_name}')
    count = 0
    Results = pd.DataFrame({"ModbusTCP_result":checkData(start, driver, localhost, check_name)})
    # print(Results['result'])
    for i in range(len(Results)):
        if Results['ModbusTCP_result'][i] == 'NoData':
            pass
        else:
            count += 1
    print(f'[*] ModbusTCP success data results: {count}')
    print(f'[!] driver quit')
    # driver.quit()

    # print(f'[!] measuring CPU/MEM usage of the erl process for 5 seconds. Please wait.')
    # for proc in psutil.process_iter(['name']):
    #     if proc['name'] == 'erl':
    #         print(proc.info)
    

    return Results
Ejemplo n.º 4
0
    def AddDeviceOfDevice(self, driver, dv):
        ByClassClicking(driver, 'nav-left-search-add')

        ByIdClicking(driver, 'newEntityModal_Type_dropdown__BV_toggle_')
        ByIdClicking(driver, 'newEntityModal_Type_dropdown_option_Device')
        ByIdClicking(driver, 'newEntityModal_Group_dropdown__BV_toggle_')

        # print(id_name)
        ByIdClicking(driver, f'newEntityModal_Group_dropdown_option_{str(dv)}')

        ret2 = fuzzer_method.fuzz(5)
        ByIdSendKey(driver, 'newEntityModal_deviceName_input', ret2)

        # print("ret2 ",ret2)

        return ret2
Ejemplo n.º 5
0
def DeviceTesting(start):
    for xnum in range(100):
        dv = fuzzer_method.fuzz(max_length=19)
        start.AddDevice(driver)
        time.sleep(0.1)
        start.TypeString(driver, str(dv))
        start.Confirm(driver)
        start.AddDeviceDetail(driver, str(dv), str(dv), 1)
    # for num in range(11):
    #     start.AddDeviceTag(driver, str(num))

    # for j in range(2,7):
    #     ret2 = start.AddDeviceOfDevice(driver, str(dv))
    #     start.Confirm(driver)
    #     start.AddDeviceDetail(driver, str(dv), str(ret2), j)
    #     time.sleep(0.1)
    #     for i in range(5):
    #         start.AddDeviceTag(driver, str(i))
    
    return dv
Ejemplo n.º 6
0
def MELSEC_ETH_test():
    # croll a excel data which involving a server tags
    df = pd.read_excel('ServerTags.xlsx', index=False)
    del df['Unnamed: 0']
    # print(len(df))
    # print(df)

    ret = fuzzer_method.fuzz(max_length=20)

    # """ Init Chrome Driver and Selenium """
    chrome, driver = init()
    
    localhost = f'http://localhost:1290'
    check_name = f'/device?category=device&name={ret}&{ret}&line={ret}&index=0'
    
    driver.get(f'{localhost}')

    # Create object that selenium running module
    start = selenium_method.AddToContents()

    MELSEC_ETH(start, driver, ret, df, 10)

    start.Commit(driver)
    time.sleep(5)

    # get page index of Device tags
    driver.get(f'{localhost}' + f'{check_name}')
    count = 0
    Results = pd.DataFrame({"MELSEC_ETH_result":checkData(start, driver, localhost, check_name)})
    # print(Results['result'])
    for i in range(len(Results)):
        if Results['MELSEC_ETH_result'][i] == 'NoData':
            pass
        else:
            count += 1
    print(f'[*] MELSEC_ETHERNET success data results: {count}')
    print(f'[!] driver quit')
    driver.quit()

    return Results
Ejemplo n.º 7
0
    def AddDeviceDetail_TCP(self, driver, gret, ret, UID, address, port, CC,
                            TimeOut):
        # print(name)
        ByXpathClicking(
            driver, f'//*[@id="lineDevice_device_{str(gret)}_{str(ret)}"]')

        # Edit
        ByIdClicking(driver, 'deviceDetailButtonEdit')

        # # manufacturer
        # ret = fuzzer_method.fuzz()
        # ByIdSendKey(driver, 'deviceDetail_manufacturer', ret)
        # # Device type
        # ret = fuzzer_method.fuzz()
        # ByIdSendKey(driver, 'deviceDetail_device_type', ret)
        # Comment
        ret = fuzzer_method.fuzz(100)
        ByIdSendKey(driver, 'deviceDetail_comment', ret)

        # Done
        ByIdClicking(driver, 'deviceDetailButtonDone')

        # Device service
        ByIdClicking(driver, 'deviceServiceButtonEdit')
        ByIdClicking(driver, 'deviceServiceSelect__BV_toggle_')
        ByIdClicking(driver, 'deviceServiceSelect_modbus_tcp_master')
        ByIdClicking(driver, 'deviceServiceButtonDone')
        ByIdClicking(driver, 'deviceConnectionButtonEdit')

        # Addr
        for i in range(15):
            ByIdSendKey(driver, 'deviceConnectionInput_address',
                        Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_address', address)

        # port
        ByIdSendKey(driver, 'deviceConnectionInput_port', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_port', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_port', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_port', port)

        # Connection Count
        ByIdSendKey(driver, 'deviceConnectionInput_connections',
                    Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_connections',
                    Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_connections',
                    Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_connections', CC)

        # UID
        ByIdSendKey(driver, 'deviceConnectionInput_uid', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_uid', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_uid', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_uid', UID)

        # Timeout
        ByIdSendKey(driver, 'deviceConnectionInput_timeout', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_timeout', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_timeout', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_timeout', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_timeout', Keys.BACKSPACE)
        ByIdSendKey(driver, 'deviceConnectionInput_timeout', TimeOut)

        # Done
        ByIdClicking(driver, 'deviceConnectionButtonDone')