记一次使用 ThinkPHP 5 框架被挂马 作者: Shine 时间: 2020-07-09 分类: 唠嗑闲聊 评论 # 前言 ### 全怪自己没有跟进更新 ThinkPHP 版本,导致被挂马,用的版本是 `ThinkPHP V5.1.29 LTS` # 我是怎么发现的 也是听别人提起我这个网站,我才知道我还有这个网站,然后习惯的登录下看看,结果发现只有首页能打开,其它都 404,我还以为网站配置问题,我又删除了重新建立站点,发现还是一样 直到我看了下 `public/` 目录 ![Snipaste_2020-07-09_13-19-22.png][1] 我才发现 `index.php` 文件被删了,只留下 `index.html` 文件,其文件部分内容是: ``` 皇冠BET369,皇冠bet安卓版下载,皇冠bet手机版下载 ``` # 我还以为是自己写的某个后台没有鉴权,导致上传文件出现漏洞 然后我又网上查了下 `ThinkPHP 5 漏洞`,然后就找到了这篇文章:[ThinkPHP5.x漏洞复现][2] # 自己试了试,真能执行任意函数 ![ThinkPHP V5.1.29 LTS 执行任意函数][3] 看到这我就知道了,是 ThinkPHP 的漏洞,也怪自己不及时更新框架,这个框架从18年11月,使用 Composer 安装后,我就没有更新过了,一年半过去了我才知道... # 怎么解决 执行 `composer update topthink/framework` 更新 ![执行 composer update topthink/framework 更新][4] 然后问题就解决了 ![然后问题就解决了][5] [1]: https://cdn.nowtime.cc/2020/07/09/2790040883.png [2]: https://www.freebuf.com/articles/web/230787.html [3]: https://cdn.nowtime.cc/2020/07/09/1667353005.png [4]: https://cdn.nowtime.cc/2020/07/09/1475891042.png [5]: https://cdn.nowtime.cc/2020/07/09/3678407928.png
PHP 使用匿名函数 实现 base64/32/16 加密解密(encode/decode) 作者: Shine 时间: 2020-07-02 分类: PHP 评论 > base16/32 加密解密 是在网上找的拼凑的 ``` function ($str) { $encode = ''; $chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']; for ($i = 0; $i < strlen($str); $i++) { $encode .= $chars[(ord($str[$i]) & 0b11110000) >> 4] . $chars[ord($str[$i]) & 0b00001111]; } return $encode; }, 32 => function ($str) { $BASE32_ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567'; $output = ''; $v = 0; $vbits = 0; for ($i = 0, $j = strlen($str); $i < $j; $i++) { $v <<= 8; $v += ord($str[$i]); $vbits += 8; while ($vbits >= 5) { $vbits -= 5; $output .= $BASE32_ALPHABET[$v >> $vbits]; $v &= ((1 << $vbits) - 1); } } if ($vbits > 0) { $v <<= (5-$vbits); $output .= $BASE32_ALPHABET[$v]; } return $output; }, 64 => function ($str) { return base64_encode($str); }, ]; $decode = [ 16 => function ($str) { $result = ''; for ($i = 0; $i < strlen($str) / 2; $i++) { $result .= chr(intval(substr($str, $i * 2, 2), 16)); } return $result; }, 32 => function ($str) { $output = ''; $v = 0; $vbits = 0; for($i = 0, $j = strlen($str); $i < $j; $i++) { $v <<= 5; if ($str[$i] >= 'a' && $str[$i] <= 'z') { $v += (ord($str[$i]) - 97); } elseif ($str[$i] >= '2' && $str[$i] <= '7') { $v += (24 + $str[$i]); } else { exit(1); } $vbits += 5; while($vbits >= 8){ $vbits -= 8; $output .= chr($v >> $vbits); $v &= ((1 << $vbits) - 1); } } return $output; }, 64 => function ($str) { return base64_decode($str); }, ]; var_dump($encode[16]('chuwen')); var_dump($encode[32]('chuwen')); var_dump($encode[64]('chuwen')); echo PHP_EOL; var_dump($decode[16]($encode[16]('chuwen'))); var_dump($decode[32]($encode[32]('chuwen'))); var_dump($decode[64]($encode[64]('chuwen'))); ```
Ubuntu 编译安装 PHP 8.0-Alpha 过程 作者: Shine 时间: 2020-06-26 分类: PHP 评论 ``` apt install libsqlite3-dev ``` ## configure: error: Please reinstall the BZip2 distribution 那就去安装 ``` sudo apt-get install libbz2-dev ``` ## No package 'libcurl' found ``` apt-get install libcurl4-openssl-dev ``` ## configure: error: GNU MP Library version 4.2 or greater required. ``` apt install libgmp-dev ``` ## No package 'oniguruma' found ``` apt install libonig-dev ``` ## configure: error: Please reinstall readline - I cannot find readline.h ``` sudo apt-get install libreadline6-dev ``` --- ``` apt install libsqlite3-dev apt-get install libbz2-dev apt-get install libcurl4-openssl-dev apt install libgmp-dev apt install libonig-dev apt-get install libreadline6-dev ``` ``` +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. configure: WARNING: unrecognized options: --enable-inline-optimization, --with-libxml-dir, --with-xmlrpc, --with-pcre-regex, --with-pcre-dir, --with-gd, --with-jpeg-dir, --with-png-dir, --with-freetype-dir, --with-onig, --enable-zip, --enable-wddx ```
PHP 版超星学习通自动签到,支持多用户签到、手势、二维码、位置签到、HTTP API 调用,二次开发便捷! 作者: Shine 时间: 2020-05-01 分类: PHP 3 条评论 # ⭐ ChaoxingSign | 超星学习通签到 PHP 版超星学习用自动签到,支持多用户签到,二次开发便捷! `PHP 7.3` 测试通过,理应 `PHP 5.4` 及以上都能够使用 - 登录方式: 支持手机号码登录,暂时不支持学号登陆!!! - 签到功能: 支持普通签到,手势签到,二维码签到,位置签到,拍照签到 # ? 更新日志 2020/06/13 - 修复 #2 的问题,配置了 Server酱但不推送的问题 - 更改 判断时间区间的方法 - 添加 获取课程列表失败,重试2次以判断是API错误 2020/05/27 - 修复 #1 - 更改 获取课程、签到 API - 添加 手势、位置、二维码一键签到 - 添加 Server酱 微信推送,需要配置 `config.php` 文件 2020/05/25 - 更改 登录接口,原接口已经失效 # ? TODO - [] 接入钉钉机器人 API # ? 使用方法 1. 下载源码: 直接下载:https://github.com/PrintNow/ChaoxingSign/archive/master.zip 克隆源码:`git clone https://github.com/PrintNow/ChaoxingSign` 2. ? 运行 1. 上传到**网站根目录**运行 然后访问 `http://你的域名/main.php?account=你的超星账号&password=你的超星密码` 2. 或者使用**命令行**运行 ``` php main.php -A "你的超星账号" -P "你的超星密码" ``` 3. ⚙ 实现自动签到 > 推荐大于等于 **10 分钟** 执行一次,避免出现异常 > > 我已经硬编仅能在每天的 08:00 ~ 22:00 之间运行, > 如果要取消或修改这一限制,请删除或注释 > `main.php` 第 7~9 行 1. 如果以**网页方式**运行,定时监控 `http://你的域名/main.php?account=你的超星账号&password=你的超星密码` 即可 2. 如果使用**命令行方式**运行,添加 `crontab` 任务即可,具体添加 `crontab 任务` 方法可以网上搜。 每天 早上8点到晚上22点之间,每10分钟签到一次 crontab 表达式:`0 */10 8-22 * * * *` # √ 运行输出 签到成功: ``` 正在签到:陈半仙@测试班级 [2020-06-13 11:44:14]签到成功 Server酱 消息推送成功 ``` 没有签到任务: ``` 没有待签到的任务 ``` # ❗ 注意 超星**可能**屏蔽了如 阿里云、腾讯云、百度云... 等 IDC IP 地址,故有可能出现未知的错误(我没测试,我仅在家庭宽带中测试成功) # ? 感谢 > 本项目的实现参考了以下文章 - https://www.z2blog.com/index.php/learn/423.html - https://www.z2blog.com/index.php/default/459.html > 本项目中使用到的 `Selector.php` 来自 [PHPSpider](https://github.com/owner888/phpspider) # License 遵循 [MIT License](./LICENSE) 协议 ## 其它版本签到脚本推荐 > 排名不分先后 | 项目地址 | 开发语言 | 备注 | | ------------------------------------------------------- | ---------- | ------------------------------------------ | | https://github.com/mkdir700/chaoxing_auto_sign | Python | 超星学习通自动签到脚本&多用户多任务&API | | https://github.com/Wzb3422/auto-sign-chaoxing | TypeScript | 超星学习通自动签到,梦中刷网课 | | https://github.com/aihuahua-522/chaoxing-testforAndroid | Java | 学习通(超星)自动签到 | | https://github.com/yuban10703/chaoxingsign | Python | 超星学习通自动签到 | | https://github.com/Huangyan0804/AutoCheckin | Python | 学习通自动签到,支持手势,二维码,位置,拍照等 |
搜题库(so.NowTool.cn), 大学生的好助手 支持超星、智慧树、学习强国 答案搜索 作者: Shine 时间: 2020-04-16 分类: PHP 评论 # 搜题库 #支持超星、智慧树、*学习强国 答案搜索 ## 网址:https://so.nowtool.cn/ > ### 主要面向的是大学生、学习强国用户,建议用使用空格分割关键字,查询内容尽量简短(虽然模糊查找准确率很高)。目前题库量在 `94855` 题,今天更新了学习强国 挑战题库 > *学习强国:题库仅包含挑战答题 欢迎反馈不能查找的题目,或提交题库,感谢你的使用! ![搜题库 so.NowTool.cn #支持超星、智慧树、*学习强国 答案搜索][1] ![蝶恋花 搜索结果 —— 搜题库 so.NowTool.cn][2] # 用到的技术 & 优缺点 - ThinkPHP 框架 - Bootstrap V3 - PHP - MySQL - 专门为搜索进行优化,基本保证模糊搜索准确率高、查找速度快(从九万多条数据中匹配,传统搜索需要耗费一两秒,现在优化后只需要几毫秒至十几毫秒) [1]: https://cdn.nowtime.cc/2020/04/16/2561811399.png [2]: https://cdn.nowtime.cc/2020/04/16/1325735822.png