在 wordpress 中自动重置密码python 请求或其他方式

如何解决在 wordpress 中自动重置密码python 请求或其他方式

我正在尝试衡量使用默认 WordPress 方法重置用户密码的速度。 WordPress 首先要求提供电子邮件或用户名,然后发送指向该用户电子邮件的链接。如果您点击链接,它会将您重定向到一个页面(“localhost/wordpress_5_4_2_try3/wp-login.php?action=rp”),您必须在其中为该用户插入新密码。它看起来像这样: Provide new password image (default content on the password field)

我能够对 WordPress 代码进行一些小的更改(例如,我更改了 wp_mail 功能,因此不发送邮件并在特定文件中添加了一些激活链接的存储)。我需要对许多试图同时更改密码的用户进行实验。我已经使用 Selenium 编写了关于它的代码,但这不是我想要的,因为它很慢。我试图找出是否有更快的解决方案(通过 python 请求库或其他库/工具/语言)。我对不同的想法持开放态度。您可以在下面找到我已经尝试过的内容:

1)

    import requests
    
    s=requests.Session()
    info = {'pass1':'a_password#38'}
    url1 = "http://localhost/wordpress_5_4_2_try3/wp-login.php?action=rp&key=theKey&login=user_name"
    url2 = "http://localhost/wordpress_5_4_2_try3/wp-login.php?action=rp"
    
    r = s.get(url1)
    r2 = s.post(url1,data=info)
    r3 = requests.post(url2,data=info)
  1. 我尝试了 1 的许多版本。例如,在其中一些版本中,我没有使用 r,只使用了 r2,其他一些我没有使用 r3。我相信我的问题来自于它被重定向到给我表格的事实。您可以在此处找到我使用 print(r2.text) 时得到的回复,以防万一:

         <!--[if IE 8]>
                 <html xmlns="http://www.w3.org/1999/xhtml" class="ie8" lang="en-US">
         <![endif]-->
         <!--[if !(IE 8) ]><!-->
                 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
         <!--<![endif]-->
         <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
         <title>Reset Password &lsaquo; wordPrSite3 &#8212; WordPress</title>
         <link rel='dns-prefetch' href='//s.w.org' /> <script> var userSettings = {"url":"\/wordpress_5_4_2_try3\/","uid":"0","time":"1621286619","secure":""}; </script> <script src='http://localhost/wordpress_5_4_2_try3/wp-includes/js/utils.min.js?ver=5.4.6'></script> <script src='http://localhost/wordpress_5_4_2_try3/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp'></script> <script src='http://localhost/wordpress_5_4_2_try3/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script> <script> var _zxcvbnSettings = {"src":"http:\/\/localhost\/wordpress_5_4_2_try3\/wp-includes\/js\/zxcvbn.min.js"}; </script> <script src='http://localhost/wordpress_5_4_2_try3/wp-includes/js/zxcvbn-async.min.js?ver=1.0'></script> <link rel='stylesheet' id='dashicons-css'  href='http://localhost/wordpress_5_4_2_try3/wp-includes/css/dashicons.min.css?ver=5.4.6' media='all' /> <link rel='stylesheet' id='buttons-css'  href='http://localhost/wordpress_5_4_2_try3/wp-includes/css/buttons.min.css?ver=5.4.6' media='all' /> <link rel='stylesheet' id='forms-css'  href='http://localhost/wordpress_5_4_2_try3/wp-admin/css/forms.min.css?ver=5.4.6' media='all' /> <link rel='stylesheet' id='l10n-css'  href='http://localhost/wordpress_5_4_2_try3/wp-admin/css/l10n.min.css?ver=5.4.6' media='all' /> <link rel='stylesheet' id='login-css'  href='http://localhost/wordpress_5_4_2_try3/wp-admin/css/login.min.css?ver=5.4.6' media='all' />
         <meta name='robots' content='noindex,noarchive' />
         <meta name='referrer' content='strict-origin-when-cross-origin' />
                 <meta name="viewport" content="width=device-width" />
                 </head>
         <body class="login no-js login-action-rp wp-core-ui  locale-en-us">
         <script type="text/javascript">
                 document.body.className = document.body.className.replace('no-js','js');
         </script>
                 <div id="login">
                 <h1><a href="https://wordpress.org/">Powered by WordPress</a></h1>
         <p class="message reset-pass">Enter your new password below.</p>
                 <form name="resetpassform" id="resetpassform" action="http://localhost/wordpress_5_4_2_try3/wp-login.php?action=resetpass" method="post" autocomplete="off">
                         <input type="hidden" id="user_login" value="user_name " autocomplete="off" />
    
                         <div class="user-pass1-wrap">
                                 <p>
                                         <label for="pass1">New password</label>
                                 </p>
    
                                 <div class="wp-pwd">
                                         <input type="password" data-reveal="1" data-pw="t)&amp;NlDW$C7wgG^20" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="off" aria-describedby="pass-strength-result" />
    
                                         <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="Hide password">
                                                 <span class="dashicons dashicons-hidden" aria-hidden="true"></span>
                                         </button>
                                         <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite">Strength indicator</div>
                                 </div>
                                 <div class="pw-weak">
                                         <input type="checkbox" name="pw_weak" id="pw-weak" class="pw-checkbox" />
                                         <label for="pw-weak">Confirm use of weak password</label>
                                 </div>
                         </div>
    
                         <p class="user-pass2-wrap">
                                 <label for="pass2">Confirm new password</label>
                                 <input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" />
                         </p>
    
                         <p class="description indicator-hint">Hint: The password should be at least twelve characters long. To make it stronger,use upper and lower case letters,numbers,and symbols like ! " ? $ % ^ &amp; ).</p>
                         <br class="clear" />
    
                                                 <input type="hidden" name="rp_key" value="theKey" />
                         <p class="submit">
                                 <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="Reset Password" />
                         </p>
                 </form>
    
                 <p id="nav">
                         <a href="http://localhost/wordpress_5_4_2_try3/wp-login.php">Log in</a>
                          | <a href="http://localhost/wordpress_5_4_2_try3/wp-login.php?action=register">Register</a> </p>
                                 <p id="backtoblog"><a href="http://localhost/wordpress_5_4_2_try3/">
                 &larr; Back to wordPrSite3              </a></p>
                         </div>
                         <script type="text/javascript">
                 try{document.getElementById('user_pass').focus();}catch(e){}
                 if(typeof wpOnload=='function')wpOnload();
                 </script>
                 <script> var pwsL10n = {"unknown":"Password strength unknown","short":"Very weak","bad":"Weak","good":"Medium","strong":"Strong","mismatch":"Mismatch"}; </script> <script src='http://localhost/wordpress_5_4_2_try3/wp-admin/js/password-strength-meter.min.js?ver=5.4.6'></script> <script src='http://localhost/wordpress_5_4_2_try3/wp-includes/js/underscore.min.js?ver=1.8.3'></script> <script> var _wpUtilSettings = {"ajax":{"url":"\/wordpress_5_4_2_try3\/wp-admin\/admin-ajax.php"}}; </script> <script src='http://localhost/wordpress_5_4_2_try3/wp-includes/js/wp-util.min.js?ver=5.4.6'></script> <script> var userProfileL10n = {"warn":"Your new password has not been saved.","warnWeak":"Confirm use of weak password","show":"Show","hide":"Hide","cancel":"Cancel","ariaShow":"Show password","ariaHide":"Hide password"}; </script> <script src='http://localhost/wordpress_5_4_2_try3/wp-admin/js/user-profile.min.js?ver=5.4.6'></script>
         <script>
         /(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
         </script>
                 <div class="clear"></div>
         </body>
         </html>
    
  2. 在使用 postman 并仅发出 post 请求后,我发现它没有将我重定向到该页面,但预览看起来像这样: Preview from postman

因此,在研究了 r2.text 之后,我更改了代码并再次尝试使用以下信息:

info = {'pass1':'a_password#38','pass2':'a_password#38'}

不幸的是,结果是一样的,我对到底发生了什么感到非常困惑。

所以,我的问题是(最重要的是第三个问题):

  1. 为什么一个简单的 post 请求不足以提交新密码(或密码和密码确认)?
  2. 为什么当我从我的浏览器尝试它时,我被重定向到一个包含 1 个字段的页面(我在第一个图片链接中显示的那个),而邮递员和从一个简单的 get 请求返回到 http 的代码://localhost/wordpress_5_4_2_try3/wp-login.php?action=rp&key=theKey&login=user_name 表示需要 2 个字段?
  3. 您知道如何通过请求或其他工具/库来表达自己的意思吗?我使用 Python 请求,但当然也欢迎使用其他语言。我的目标是不使用实际打开浏览器的工具,这比我愿意提供的要花费大量时间和资源(我想并行发出一些请求并测量性能)。

感谢任何帮助!谢谢。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res