Beispiel #1
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
Beispiel #2
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
Beispiel #3
0
def ServerTesting(start, dv):
    for i in range(3):
        start.AddServer(driver)
        start.AddServerDetail(driver)
        # for j in range(1,3):
        #     start.AddServerTag(driver, j, "MLCC#1", "ingress",tag, valType)

if __name__ == "__main__":

    # """ Init Chrome Driver and Selenium """
    chrome = selenium_method.InitDriver()
    driver = chrome.SetChrome()
    driver.get('localhost:1290')

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

    # running time measure
    start_time = time.time()
    print("Start time: ", start_time)

    # start.ConfigureClear(driver)
    
    for i in range(200):
        data = crolling.DataScarp()
        try:
            start.AddServerTag(driver, j, "MLCC#1", "ingress",data[tag][i], data[valueType][i])
        except:
            exit()
    # dv = DeviceTesting(start)
    # ServerTesting(start, dv)