惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - 哈哈

cas服务器搭建后的调整 使用python直接连接http服务器获取数据 request的url地址 numpy的多项式函数与求导 pandas相关 tcp与ip的包结构 江苏铁路 易经-64卦 使用python实现rpc服务 图书分类-中图法,值得一看的图书 linux时区,curl的使用,nginx日志,watch python与java的交互 计算斐波那契数列 Python线程 selenium的使用 pip使用 python读取postgresql 18位身份证的验证码 python读取docx文件属性-最后一次保存的时间等
使用selenium模仿登录,执行js
哈哈 · 2021-03-13 · via 博客园 - 哈哈
import os
import requests
import tkinter.messagebox
import execjs
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

def login666():
    # check wifi
    cmd = 'netsh wlan show interfaces'
    out=os.popen(cmd)
    cmd_ret = out.read()
    wifi = ''
    if cmd_ret:
        data = cmd_ret.split('\n')
        if data:
            for x in data:
                if x.strip().startswith('SSID'):
                    wifi = x[x.index(':')+1:].strip()
    print('----------'+wifi+'----------')

    if wifi or True:
    # if True:
        url='http://6.6.6.6/login.jsp'
        option = webdriver.ChromeOptions()
        # option.add_argument('disable-infobars')
        # option.add_argument('user-data-dir=C:\\python37\\profile')

        driver = webdriver.Chrome()
        driver.get(url)
        #try:
        button = WebDriverWait(driver,10,1).until(EC.visibility_of_element_located((By.ID,'password_submitBtn')))
        user = WebDriverWait(driver,10,1).until(EC.visibility_of_element_located((By.ID,'password_name')))
        pwd = WebDriverWait(driver,10,1).until(EC.visibility_of_element_located((By.ID,'password_pwd')))
        user.send_keys('abc')
        pwd.send_keys('bbb')
        # button.submit()
        button.click()
            
        #except:
        #    print('get element error')
        #finally:
        driver.close()
    else:
        tkinter.messagebox.showinfo('info ','on find WIFI')


if __name__ == '__main__':
    login666()

执行js

import execjs

jsfile = ''' function do_encrypt_rc4(src, passwd) { passwd = passwd + ''; var i, j = 0, a = 0, b = 0, c = 0, temp; var plen = passwd.length, size = src.length; var key = Array(256); //int var sbox = Array(256); //int var output = Array(size); //code of data for (i = 0; i < 256; i++) { key[i] = passwd.charCodeAt(i % plen); sbox[i] = i; } for (i = 0; i < 256; i++) { j = (j + sbox[i] + key[i]) % 256; temp = sbox[i]; sbox[i] = sbox[j]; sbox[j] = temp; } for (i = 0; i < size; i++) { a = (a + 1) % 256; b = (b + sbox[a]) % 256; temp = sbox[a]; sbox[a] = sbox[b]; sbox[b] = temp; c = (sbox[a] + sbox[b]) % 256; temp = src.charCodeAt(i) ^ sbox[c];//String.fromCharCode(src.charCodeAt(i) ^ sbox[c]); temp = temp.toString(16); if (temp.length === 1) { temp = '0' + temp; } else if (temp.length === 0) { temp = '00'; } output[i] = temp; } return output.join(''); } ''' TIMESTAMP=''' +(new Date()) + '' ''' USERNAME = 'abc' PASSWORD = 'def' def get_pass(pwd): ts = execjs.eval(TIMESTAMP) npwd = execjs.compile(jsfile).call('do_encrypt_rc4',pwd,ts) return ts,npwd

按钮提交

# 方法1:直接调用click()
a.click()
# 方法2:调用execute_script()
driver.execute_script("arguments[0].click();", a)
# 方法3:调用webdriver控制
webdriver.ActionChains(driver).move_to_element(a).click(a).perform()

配置selenium

http://npm.taobao.org/mirrors/chromedriver/

存放位置,和chrome.exe放置一起

C:\Program Files (x86)\Google\Chrome\Application

from selenium import webdriver

d=webdriver.Chrome()

d.close()

安装execjs

pip install PyExecJS