├── .DS_Store ├── README.md ├── ServerMain └── server │ ├── 3.2.1.121-0.0.0.015_稳定版.dll │ ├── 3.2.1.121-0.0.0.018.dll │ ├── 3.3.0.115-0.0.0.001.dll │ ├── 3.6.0.18-0.0.0.004.dll │ ├── readme.md │ ├── version2.8.0.121-3.5.7.66.dll │ ├── version2.9.0.123-4.5.7.73.dll │ ├── version3.1.0.66-0.0.0.13.dll │ └── 微信DLL注入器V1.0.3.exe ├── config └── config.ini ├── httpcli ├── __init__.py ├── __pycache__ │ ├── __init__.cpython-310.pyc │ ├── __init__.cpython-39.pyc │ ├── everyday_news.cpython-310.pyc │ ├── everyday_news.cpython-39.pyc │ ├── http_server.cpython-310.pyc │ ├── http_server.cpython-39.pyc │ ├── openai.cpython-310.pyc │ ├── output.cpython-310.pyc │ └── output.cpython-39.pyc ├── everyday_news.py ├── help.py ├── http_server.py ├── openai.py └── output.py ├── images ├── image-20220915181623688.png ├── image-20220915181940797.png ├── image-20220915182047130.png ├── image-20221023202452175.png └── image-20221023202551321.png ├── main.py ├── requirements.txt └── servercli ├── __init__.py ├── __pycache__ ├── __init__.cpython-310.pyc ├── __init__.cpython-39.pyc ├── server.cpython-310.pyc └── server.cpython-39.pyc └── server.py /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WechatBot 2 | 一个基于PC版的微信机器人,采用hook的形式进行消息拦截,内存信息读取的形式获取通讯录,用户信息等 3 | 4 | 感谢@cixingguangming55555开发的server端以及集成化的hook利用程序,本项目是基于@cixingguangming55555大佬的开源项目进行的二开(玩法很多我慢慢开发吧,就这样吧) 5 | 6 | 这里需要使用的微信版本是**3.2.1.121**版本,历史版本下载地址 7 | 8 | - https://github.com/tom-snow/wechat-windows-versions 9 | 10 | ## 部署教程 11 | 12 | 安装微信**3.2.1.121**版本,然后再打开ServerMain/server中的微信DLL注入器V1.0.3.exe工具进行dll注入 13 | 14 | ![image-20220915181623688](images/image-20220915181623688.png) 15 | 16 | ***注入完成使用命令curl http://127.0.0.1:5555 去测试一下是否注入成功,如果015不成功可以尝试使用018来注入或者下面其他的** 17 | 18 | ***或者可以使用微信版本为3.6.0.18,然后再使用对应的dll文件进行注入** 19 | 20 | 点击注入即可,然后接下来就是项目的config目录下面的config.ini的配置 21 | 22 | ***注意编辑config文件不要用txt打开会改变文件的类型,导致报错!!!** 23 | 24 | config.ini详解 25 | 26 | ``` 27 | [server] 28 | # 微信机器人服务端的配置文件 29 | ip = 127.0.0.1 30 | port = 5555 31 | # 管理员wxid 32 | admin_id = wxid_kb0e7h9icqqv22,wxid_6vxrrvjff6pg22,wxid_fys2fico9put22,wxid_lb33d6uyarmv22, 33 | # 推送的微信群聊地址 34 | room_id = 23117228686@chatroom,24472020852@chatroom,20809144388@chatroom,22261634025@chatroom,22868513156@chatroom,25348406777@chatroom,22108828312@chatroom,24749035253@chatroom,19752248739@chatroom,24303327388@chatroom,25455028831@chatroom 35 | # 视频权限群聊地址 36 | video_list_room_id = 19820015740@chatroom,23117228686@chatroom,25348406777@chatroom,20809144388@chatroom,25142607072@chatroom,39218917883@chatroom,24749035253@chatroom,19752248739@chatroom 37 | # 群娱乐功能黑名单 38 | blacklist_room_id = 24472020852@chatroom, 39 | # 早报自动推送时间 40 | set_time_am = 09:00 41 | # 晚间资讯自动推送时间 42 | set_time_pm = 17:00 43 | # 推送今日黄历 44 | set_time_am_today = 08:30 45 | # 推送摸鱼日历 46 | set_fish_time = 15:00 47 | # 下班时间 48 | after_work_time = 18:00 49 | # 发工资日期 50 | salary_day = 10 51 | 52 | [apiService] 53 | # openai用户key 54 | openai_key = 55 | # 微步社区的key 56 | threatbook_key = 自己去微步社区个人中心查看 57 | threatbook_url = https://api.threatbook.cn/v3/scene/ip_reputation 58 | # MD5解密接口 59 | md5_url = 60 | # 舔狗日记接口 61 | dog_url = http://api.tianapi.com/tiangou/index?key=自己的key 62 | # 彩虹屁接口 63 | fart_url = http://api.tianapi.com/caihongpi/index?key=自己的key 64 | # 60s读懂世界 65 | history_url = https://api.qqsuu.cn/api/dm-60s 66 | # 查询天气接口 67 | weather_url = https://www.tianqiapi.com/free/day?appid=自己的key&appsecret=自己的key&city= 68 | # 美女视频接口 69 | girl_videos_url = https://tucdn.wpon.cn/api-girl/ 70 | # 当日安全资讯 71 | xz_url = https://xz.aliyun.com/feed 72 | freebuf_url = https://www.freebuf.com/feed 73 | qax_url = https://forum.butian.net/Rss 74 | anquanke_url = https://www.anquanke.com/knowledge 75 | # 搞笑段子接口 76 | smile_url = https://www.mxnzp.com/api/jokes/list?app_id=自己的key&app_secret=自己的key&page= 77 | # 今日黄历接口 78 | zodiac_url = https://www.mxnzp.com/api/holiday/single/ 79 | allow_token = ?ignoreHoliday=false&app_id=自己的key&app_secret=自己的key 80 | # 早安寄语接口 81 | morning_url = https://api.qqsuu.cn/api/dm-zaoan 82 | # 星座运势 83 | constellation_url = http://api.tianapi.com/star/index?key=自己的key&astro= 84 | # ai对话机器人接口 85 | ai_reply_url = http://api.qingyunke.com/api.php?key=free&msg= 86 | ``` 87 | 88 | **admin_id是管理员ID,在程序跑起来之后你给机器人发送一个消息即可看见** 89 | 90 | ![image-20220915181940797](images/image-20220915181940797.png) 91 | 92 | 这个就是你的管理身份账号 93 | 94 | ***其中群里地址就是roomid在控制台中打印的msg中就能看见** 95 | 96 | ![image-20221023202452175](images/image-20221023202452175.png) 97 | 98 | ![image-20221023202551321](images/image-20221023202551321.png) 99 | 100 | **舔狗日记和彩虹屁接口信息可以到https://www.tianapi.com进行注册获取** 101 | 102 | ## 项目启动 103 | 104 | 首先使用命令安装依赖 105 | 106 | ```bash 107 | pip3 install -r requirements.txt 108 | ``` 109 | 110 | 如果出现WebSocketApp no modle的报错,使用命令安装此依赖即可 111 | 112 | ```bash 113 | pip3 install websocket-client-py3 114 | ``` 115 | 116 | 然后使用命令即可启动项目 117 | 118 | ```bash 119 | python3 main.py 120 | ``` 121 | 122 | ***建议使用python3.8以上** 123 | 124 | **如果其中有不需要的功能就不用配置config.ini中的api接口信息,其中config.ini中的配置文件和前面的一个处理函数是关联关系,删除或者注释config.ini的配置文件会引起报错项目无法启动,如果不需要可以将相关的处理函数注释点即可,如果有什么新的玩法可以提交Pr** 125 | 126 | ## 项目结构 127 | 128 | ### config 129 | 130 | 为项目的配置文件目录 131 | 132 | ### servercli 133 | 134 | 为项目的核心处理逻辑目录,主要是使用的websocket和http协议进行的通信 135 | 136 | ### httpcli 137 | 138 | 主要为接口的一些处理逻辑文件的目录,大部分的配置文件都是config目录中的,二者是关联关系 139 | 140 | ## 后续开发计划 141 | 142 | - 实现每日咨询自动定时推送(暂时只可以管理员指定获取)(已完成) 143 | - 新增黄历,段子,天气查询,美女视频等 (已完成) 144 | - 新增AI只能对话功能,摸鱼日历功能等 (已完成) 145 | - **已恢复舔狗日记** 146 | - ***2022-11-04新增恶意ip查询,调用的微步接口,每天限制50次,修改早晚日报,修改部分代码逻辑** 147 | - ***修复摸鱼日记diff算法错误,修改一处接口调用** 148 | - ***开发计划:预计本月添加openai机器人,目前我阳了,等我转阴后实现此功能。** 149 | - ***2023-02-01新增功能openai机器人功能** 150 | - ***2023-02-22 bug修复功能说明,openai的调用关键词是Hey或者hey,出现不回复的情况一般是官方问题。同时发现一个bug,不支持英文版本的wechat,使用openai可以不用科学上网。** 151 | - ***2023-03-20 新增chatgpt3.5,私聊支持连续对话,以及角色扮演,该代码提供由@[Xciny](https://github.com/NewBeginning6)提供** 152 | - 实现GitHub实时监控 153 | - 实现第三方工具实时推送 154 | - 待定,有需求可以提交lessus 155 | 156 | ## 最后 157 | 158 | 代码写的烂,轻点喷,毕竟我这么菜,后续项目迭代看心情吧,就这样 159 | 160 | ## 温馨提示 161 | 162 | 尽量使用git命令进行克隆,不要使用zip压缩包下载模式,可能会造成程序跑不起来 163 | 164 | git命令 165 | 166 | ``` 167 | git clone https://github.com/zhizhuoshuma/WechatBot.git 168 | ``` 169 | 170 | 国内git加速命令 171 | 172 | ``` 173 | git clone https://github.91chi.fun/https://github.com/zhizhuoshuma/WechatBot.git 174 | ``` 175 | 176 | 如果程序跑不起来,可以提交lessus,或者微信联系我,给我ssh或者rdp我上去帮你远程调试 177 | 178 | ## 参考资料 179 | 180 | - https://github.com/Le0nsec/SecCrawler 181 | - https://github.com/tom-snow/wechat-windows-versions 182 | -------------------------------------------------------------------------------- /ServerMain/server/3.2.1.121-0.0.0.015_稳定版.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/3.2.1.121-0.0.0.015_稳定版.dll -------------------------------------------------------------------------------- /ServerMain/server/3.2.1.121-0.0.0.018.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/3.2.1.121-0.0.0.018.dll -------------------------------------------------------------------------------- /ServerMain/server/3.3.0.115-0.0.0.001.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/3.3.0.115-0.0.0.001.dll -------------------------------------------------------------------------------- /ServerMain/server/3.6.0.18-0.0.0.004.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/3.6.0.18-0.0.0.004.dll -------------------------------------------------------------------------------- /ServerMain/server/readme.md: -------------------------------------------------------------------------------- 1 | 2 | # 使用说明 3 | ## 环境准备 4 | 1、必须是微信PC 5 | 6 | ## 启动微信 7 | 1、请在windows下启动PC微信,并成功登录 8 | ## 开启服务端 9 | 1、打开微信DLL注入器,如图 10 | ![启动机器人服务](https://www.showdoc.cc/server/api/common/visitfile/sign/4c1d3698dba487adb2ae9af9e41451a8?showdoc=.jpg) 11 | 12 | 2、点击注入DLL即可 13 | ## 开启客户端 14 | 可以使用提供的C++客户端和JS客户端进行测试 15 | -------------------------------------------------------------------------------- /ServerMain/server/version2.8.0.121-3.5.7.66.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/version2.8.0.121-3.5.7.66.dll -------------------------------------------------------------------------------- /ServerMain/server/version2.9.0.123-4.5.7.73.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/version2.9.0.123-4.5.7.73.dll -------------------------------------------------------------------------------- /ServerMain/server/version3.1.0.66-0.0.0.13.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/version3.1.0.66-0.0.0.13.dll -------------------------------------------------------------------------------- /ServerMain/server/微信DLL注入器V1.0.3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/ServerMain/server/微信DLL注入器V1.0.3.exe -------------------------------------------------------------------------------- /config/config.ini: -------------------------------------------------------------------------------- 1 | [server] 2 | # 微信机器人服务端的配置文件 3 | ip = 127.0.0.1 4 | port = 5555 5 | # 管理员wxid 6 | admin_id = wxid_kb0e7h9icqqv22,wxid_6vxrrvjff6pg22,wxid_fys2fico9put22,wxid_lb33d6uyarmv22, 7 | # 推送的微信群聊地址 8 | room_id = 23117228686@chatroom,24472020852@chatroom,20809144388@chatroom,22261634025@chatroom,22868513156@chatroom,25348406777@chatroom,22108828312@chatroom,24749035253@chatroom,19752248739@chatroom,24303327388@chatroom,25455028831@chatroom,43343286233@chatroom,44871285762@chatroom 9 | # 视频权限群聊地址 10 | video_list_room_id = 19820015740@chatroom,23117228686@chatroom,25348406777@chatroom,20809144388@chatroom,25142607072@chatroom,39218917883@chatroom,24749035253@chatroom,19752248739@chatroom,43343286233@chatroom 11 | # 群娱乐功能黑名单 12 | blacklist_room_id = 24472020852@chatroom, 13 | # openai黑名单 14 | openai_room_id = 21774936440@chatroom,19294553461@chatroom, 15 | # [None,None,None,09,15] 为年月日时分顺序 16 | # 早报自动推送时间 17 | set_time_am = [None,None,None,9,15] 18 | # 晚间资讯自动推送时间 19 | set_time_pm = [None,None,None,17,00] 20 | # 推送今日黄历 21 | set_time_am_today = [None,None,None,9,15] 22 | # 推送摸鱼日历 23 | set_fish_time = [None,None,None,15,00] 24 | # 下班时间 25 | after_work_time = [None,None,None,18,00] 26 | # 发工资日期 27 | salary_day = 10 28 | 29 | [apiService] 30 | # openai用户key 31 | openai_key = 32 | # fofamap 33 | fofamap = https://amap.fofa.info/host/ 34 | # 微步社区的key 35 | threatbook_key = 36 | threatbook_url = https://api.threatbook.cn/v3/scene/ip_reputation 37 | # MD5解密接口 38 | md5_url = https://api.pmd5.com/pmd5api/pmd5?userid=&pwd= 39 | # 舔狗日记接口 40 | dog_url = http://api.tianapi.com/tiangou/index?key= 41 | # 彩虹屁接口 42 | fart_url = http://api.tianapi.com/caihongpi/index?key= 43 | # 60s读懂世界 44 | history_url = https://api.qqsuu.cn/api/dm-60s 45 | # 查询天气接口 46 | weather_url = https://www.tianqiapi.com/free/day?appid=&appsecret=&city= 47 | # 美女视频接口 48 | girl_videos_url = https://tucdn.wpon.cn/api-girl/ 49 | # 当日安全资讯 50 | xz_url = https://xz.aliyun.com/feed 51 | freebuf_url = https://www.freebuf.com/feed 52 | qax_url = https://forum.butian.net/Rss 53 | anquanke_url = https://www.anquanke.com/knowledge 54 | y4tacker_url = https://y4tacker.github.io/atom.xml 55 | # 搞笑段子接口 56 | smile_url = https://www.mxnzp.com/api/jokes/list?app_id=&app_secret=&page= 57 | # 今日黄历接口 58 | zodiac_url = https://www.mxnzp.com/api/holiday/single/ 59 | allow_token = ?ignoreHoliday=false&app_id=&app_secret= 60 | # 早安寄语接口 61 | morning_url = https://api.qqsuu.cn/api/dm-zaoan 62 | # 星座运势 63 | constellation_url = http://api.tianapi.com/star/index?key=&astro= 64 | # ai对话机器人接口 65 | ai_reply_url = http://api.qingyunke.com/api.php?key=free&msg= -------------------------------------------------------------------------------- /httpcli/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__init__.py -------------------------------------------------------------------------------- /httpcli/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/everyday_news.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/everyday_news.cpython-310.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/everyday_news.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/everyday_news.cpython-39.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/http_server.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/http_server.cpython-310.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/http_server.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/http_server.cpython-39.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/openai.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/openai.cpython-310.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/output.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/output.cpython-310.pyc -------------------------------------------------------------------------------- /httpcli/__pycache__/output.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/expzhizhuo/WechatBot/51edf021bea1745bc59815a895ef9f4295a1043d/httpcli/__pycache__/output.cpython-39.pyc -------------------------------------------------------------------------------- /httpcli/everyday_news.py: -------------------------------------------------------------------------------- 1 | import configparser 2 | import os 3 | import re 4 | import warnings 5 | 6 | import feedparser 7 | import requests 8 | 9 | from httpcli.output import * 10 | 11 | warnings.filterwarnings('ignore') 12 | 13 | # 读取本地的配置文件 14 | current_path = os.path.dirname(__file__) 15 | config_path = os.path.join(current_path, "../config/config.ini") 16 | config = configparser.ConfigParser() # 类实例化 17 | config.read(config_path, encoding="utf-8") 18 | xz_url = config.get("apiService", "xz_url") 19 | freebuf_url = config.get("apiService", "freebuf_url") 20 | qax_url = config.get("apiService", "qax_url") 21 | anquanke_url = config.get("apiService", "anquanke_url") 22 | y4tacker_url = config.get("apiService", "y4tacker_url") 23 | 24 | news_list = "" 25 | # 全局header头 26 | headers = { 27 | "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36", 28 | "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", 29 | "Accept-Language": "zh-CN,zh;q=0.9", 30 | "Accept-Encoding": "gzip, deflate, br", 31 | # 'Connection':'keep-alive',#默认时链接一次,多次爬取之后不能产生新的链接就会产生报错Max retries exceeded with url 32 | "Upgrade-Insecure-Requests": "1", 33 | "Pragma": "no-cache", 34 | "Cache-Control": "no-cache", 35 | "Connection": "close", # 解决Max retries exceeded with url报错 36 | } 37 | 38 | 39 | # 先知社区 40 | def get_xz_news(): 41 | global news_list 42 | str_list = "" 43 | news_list += "#先知社区" 44 | try: 45 | rs1 = feedparser.parse(xz_url) 46 | length = len(rs1.entries) 47 | for buf in range(length): 48 | try: 49 | if str(time.strftime("%Y-%m-%d")) in str(rs1.entries[buf]["published"]): 50 | url_f = rs1.entries[buf]["link"] 51 | title_f = rs1.entries[buf]["title_detail"]["value"] 52 | link4 = "\n" + title_f + "\n" + url_f + "\n" 53 | str_list += link4 54 | else: 55 | pass 56 | except Exception as e: 57 | output("ERROR:{}".format(e)) 58 | break 59 | if len(str_list) > 0: 60 | news_list += str_list 61 | else: 62 | link6 = "\n今日暂无文章" 63 | news_list += link6 64 | except Exception as e: 65 | link6 = "\n今日暂无文章" 66 | news_list += link6 67 | output("ERROR:先知社区 {}".format(e)) 68 | return "xz is no ok" 69 | 70 | 71 | # freebuf 源 72 | def get_freebuf_news(): 73 | # global news_list 74 | str_list = "" 75 | str_list += "#FreeBuf早报\n" 76 | try: 77 | rs1 = feedparser.parse(freebuf_url) 78 | length = len(rs1.entries) 79 | for buf in range(length): 80 | try: 81 | if ( 82 | f'tm_year={int(time.strftime("%Y"))}' 83 | in str(rs1.entries[buf]["published_parsed"]) 84 | and f'tm_mon={int(time.strftime("%m"))}' 85 | in str(rs1.entries[buf]["published_parsed"]) 86 | and f'tm_mday={str(int(time.strftime("%d")) - 1)}' 87 | in str(rs1.entries[buf]["published_parsed"]) 88 | ): 89 | url_f = rs1.entries[buf]["link"] 90 | title_f = ( 91 | rs1.entries[buf]["title_detail"]["value"] 92 | .replace("FreeBuf早报 |", "") 93 | .replace(" ", "") 94 | ) 95 | link4 = "\n" + title_f + "\n" + url_f + "\n" 96 | str_list += link4 97 | else: 98 | pass 99 | except Exception as e: 100 | output("ERROR:{}".format(e)) 101 | break 102 | if len(str_list) == 0: 103 | link6 = "\n今日暂无文章" 104 | str_list += link6 105 | else: 106 | pass 107 | except Exception as e: 108 | link6 = "\n今日暂无文章" 109 | str_list += link6 110 | output("ERROR:freebuf {}".format(e)) 111 | str_list += "\nCreated by zhizhuo \n{}".format(time.strftime("%Y-%m-%d %X")) 112 | return str_list 113 | 114 | 115 | # 奇安信攻防社区 116 | def get_qax_news(): 117 | global news_list 118 | str_list = "" 119 | news_list += "\n#奇安信攻防社区" 120 | try: 121 | rs1 = feedparser.parse(qax_url) 122 | length = len(rs1.entries) 123 | for buf in range(length): 124 | try: 125 | if str(time.strftime("%Y-%m-%d")) in str(rs1.entries[buf]["published"]): 126 | url_f = rs1.entries[buf]["link"] 127 | title_f = rs1.entries[buf]["title_detail"]["value"] 128 | link4 = "\n" + title_f + "\n" + url_f + "\n" 129 | str_list += link4 130 | else: 131 | pass 132 | except Exception as e: 133 | output("ERROR:{}".format(e)) 134 | break 135 | if len(str_list) > 0: 136 | news_list += str_list 137 | else: 138 | link6 = "\n今日暂无文章" 139 | news_list += link6 140 | except Exception as e: 141 | link6 = "\n今日暂无文章" 142 | news_list += link6 143 | output("ERROR:奇安信攻防社区 {}".format(e)) 144 | return "qax is no ok" 145 | 146 | 147 | # 安全客 148 | def get_anquanke_news(): 149 | global news_list 150 | str_list = "" 151 | news_list += "\n#安全客" 152 | try: 153 | rs1 = requests.get(anquanke_url, timeout=5, verify=False) 154 | rs1.encoding = "utf-8" 155 | resp_text = ( 156 | rs1.text.replace("\xa9", "") 157 | .replace("\n", "") 158 | .replace(">", "") 159 | .replace(" ", "") 160 | .replace(" ", "") 161 | .replace(" ", "") 162 | ) 163 | newlist = re.findall( 164 | '(.*?)', 165 | resp_text, 166 | re.S, 167 | ) 168 | timelist = re.findall( 169 | '(.*?)', 170 | resp_text, 171 | re.S, 172 | ) 173 | for a in range(len(timelist)): 174 | try: 175 | if time.strftime("%Y-%m-%d") in timelist[a]: 176 | link1 = str(newlist[a][1]) 177 | link2 = "https://www.anquanke.com" + str(newlist[a][0]) 178 | link3 = "\n" + str(link1) + "\n" + str(link2) + "\n" 179 | str_list += link3 180 | else: 181 | pass 182 | except Exception as e: 183 | output("ERROR:{}".format(e)) 184 | break 185 | if len(str_list) > 0: 186 | news_list += str_list 187 | else: 188 | link6 = "\n今日暂无文章" 189 | news_list += link6 190 | except Exception as e: 191 | link6 = "\n今日暂无文章" 192 | news_list += link6 193 | output("ERROR:安全客 {}".format(e)) 194 | return "安全客 is no ok" 195 | 196 | 197 | # Y4tacker Blog 198 | def get_y4tacker_news(): 199 | global news_list 200 | str_list = "" 201 | news_list += "\n#Y4tacker Blog" 202 | # today = datetime.date.today() 203 | # yesterday = today - datetime.timedelta(days=1) 204 | # formatted_yesterday = yesterday.strftime("%Y-%m-%d") 205 | try: 206 | rs1 = feedparser.parse(y4tacker_url) 207 | length = len(rs1.entries) 208 | for buf in range(length): 209 | try: 210 | # print(time.strftime("%Y-%m-%d")) 211 | # print(formatted_yesterday) 212 | # print(time.strftime("%Y-%m-%d %H:%M:%S", rs1.entries[buf]["published_parsed"])) 213 | if str(time.strftime("%Y-%m-%d")) in str( 214 | time.strftime("%Y-%m-%d %H:%M:%S", rs1.entries[buf]["updated_parsed"])): 215 | url_f = rs1.entries[buf]['links'][0]['href'] 216 | title_f = rs1.entries[buf]["title"] 217 | link4 = "\n" + title_f + "\n" + url_f + "\n" 218 | str_list += link4 219 | else: 220 | pass 221 | except Exception as e: 222 | output("ERROR:{}".format(e)) 223 | break 224 | if len(str_list) > 0: 225 | news_list += str_list 226 | else: 227 | link6 = "\n今日暂无文章" 228 | news_list += link6 229 | except Exception as e: 230 | link6 = "\n今日暂无文章" 231 | news_list += link6 232 | output("ERROR:Y4tacker Blog {}".format(e)) 233 | return "Y4tacker Blog is no ok" 234 | 235 | 236 | def get_safety_news(): 237 | output("GET safety News") 238 | global news_list 239 | news_list = "" 240 | get_xz_news() 241 | # get_freebuf_news() 242 | # get_qax_news() 243 | get_anquanke_news() 244 | get_y4tacker_news() 245 | output("获取成功") 246 | news_list += "\nCreated by zhizhuo \n{}".format(time.strftime("%Y-%m-%d %X")) 247 | return news_list 248 | 249 | 250 | if __name__ == "__main__": 251 | news = get_safety_news() 252 | print(news) 253 | -------------------------------------------------------------------------------- /httpcli/help.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project :WechatBot 3 | @File :openai.py 4 | @IDE :PyCharm 5 | @Author :Xciny 6 | @Date :2023/2/1 16:03 7 | """ 8 | import configparser 9 | import os 10 | 11 | import openai 12 | 13 | from httpcli.output import * 14 | 15 | current_path = os.path.dirname(__file__) 16 | config_path = os.path.join(current_path, "../config/config.ini") 17 | config = configparser.ConfigParser() # 类实例化 18 | config.read(config_path, encoding="utf-8") 19 | openai_key = config.get("apiService", "openai_key") 20 | openai.api_key = openai_key 21 | 22 | 23 | def gethelp(): 24 | try: 25 | msg = "智障机器人使用说明:\n" 26 | msg += "智能机器人问答:@chatgpt {问题}\n" 27 | msg += "查看机器人状态(管理员权限):test\n" 28 | msg += "获取一篇舔狗日记:舔狗日记\n" 29 | msg += "获取今日新闻(管理员权限):今日新闻\n" 30 | msg += "查询城市天气:查询{城市名}天气\n" 31 | msg += "查询星座运势:查询{星座名}运势\n" 32 | msg += "获取当天摸鱼日历:摸鱼日历\n" 33 | msg += "获取安全资讯:安全资讯\n" 34 | msg += "查询ip归属地:查询ip {ip地址}\n" 35 | msg += "网络资产端口探测:端口扫描{域名/ip}\n" 36 | msg += "设置人格对话:设置人格 {AI助手} {助手乐于助人、富有创意、聪明而且非常友好。}\n" 37 | msg += "重置人格:重置人格\n" 38 | msg += "开启对话聊天:对话模式\n" 39 | msg += "结束对话聊天:结束对话\n" 40 | msg += "设置闹钟提醒(管理员权限):提醒{微信名}{时间}{事件}\n" 41 | msg += "清空闹钟所有闹钟(管理员权限):清空闹钟" 42 | except Exception as e: 43 | output(f"ERROR:{e.message}") 44 | msg = e 45 | return msg 46 | -------------------------------------------------------------------------------- /httpcli/http_server.py: -------------------------------------------------------------------------------- 1 | import configparser 2 | import datetime 3 | import os 4 | import random 5 | import re 6 | from urllib.parse import urlparse 7 | 8 | import requests 9 | from zhdate import ZhDate as lunar_date 10 | 11 | from httpcli.output import * 12 | 13 | # 读取本地的配置文件 14 | current_path = os.path.dirname(__file__) 15 | config_path = os.path.join(current_path, "../config/config.ini") 16 | config = configparser.ConfigParser() # 类实例化 17 | config.read(config_path, encoding="utf-8") 18 | History_url = config.get("apiService", "history_url") 19 | md5_url = config.get("apiService", "md5_url") 20 | cmd5_url = config.get("apiService", "cmd5_url") 21 | dog_url = config.get("apiService", "dog_url") 22 | fart_url = config.get("apiService", "fart_url") 23 | girl_videos_url = config.get("apiService", "girl_videos_url") 24 | weather_url = config.get("apiService", "weather_url") 25 | smile_url = config.get("apiService", "smile_url") 26 | zodiac_url = config.get("apiService", "zodiac_url") 27 | allow_token = config.get("apiService", "allow_token") 28 | constellation_url = config.get("apiService", "constellation_url") 29 | morning_url = config.get("apiService", "morning_url") 30 | ai_reply_url = config.get("apiService", "ai_reply_url") 31 | after_work_time = config.get("server", "after_work_time") 32 | salary_day = config.get("server", "salary_day") 33 | threatbook_key = config.get("apiService", "threatbook_key") 34 | threatbook_url = config.get("apiService", "threatbook_url") 35 | fofamap = config.get("apiService", "fofamap") 36 | 37 | user_agent_list = [ 38 | "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", 39 | "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", 40 | "Mozilla/5.0 (Windows NT 10.0; WOW64) Gecko/20100101 Firefox/61.0", 41 | "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36", 42 | "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36", 43 | "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36", 44 | "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)", 45 | "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15", 46 | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36", 47 | ] 48 | 49 | 50 | # 获取历史的今天事件 51 | def get_history_event(): 52 | output("Get History Today event") 53 | try: 54 | resp = requests.get( 55 | History_url, 56 | timeout=5, 57 | verify=False, 58 | ) 59 | if resp.status_code == 200: 60 | path = os.path.abspath("./img") 61 | img_name = int(time.time() * 1000) 62 | # 以时间轴的形式给图片命名 63 | with open(f"{path}\\{img_name}.jpg", "wb+") as f: 64 | # 写入文件夹 65 | f.write(resp.content) # 如果这句话一直报错,很有可能是你的网址url不对 66 | # 关闭文件夹 67 | f.close() 68 | video_path = os.path.abspath(f"{path}\\{img_name}.jpg") 69 | msg = video_path.replace("\\", "\\\\") 70 | else: 71 | msg = "历史上的今天接口调用超时" 72 | except Exception as e: 73 | msg = "历史上的今天接口调用出错,错误信息:{}".format(e) 74 | return msg 75 | 76 | 77 | # 获取舔狗日记 78 | def get_lick_the_dog_diary(): 79 | output("Get Lick the dog diary") 80 | try: 81 | resp = requests.get( 82 | dog_url, 83 | timeout=5, 84 | verify=False, 85 | ) 86 | if resp.status_code == 200 and resp.json()["code"] == 200: 87 | msg = resp.json()["newslist"][0]["content"] 88 | else: 89 | msg = "舔狗日记接口调用超时" 90 | except Exception as e: 91 | msg = "舔狗日记接口调用出错,错误信息:{}".format(e) 92 | return msg 93 | 94 | 95 | # 获取今天的天气 96 | def get_today_weather(self): 97 | output("Get Today Weather") 98 | try: 99 | city_list = re.findall("查询(.*?)天气", self) 100 | if len(city_list) > 0: 101 | city = city_list[0] 102 | resp = requests.get(weather_url + str(city), timeout=5, verify=False) 103 | if resp.status_code == 200 and "errcode" not in resp.text: 104 | msg = f'今日{city}的天气\n日期:{resp.json()["date"]}\n当前温度:{resp.json()["tem"]}\n最高气温:{resp.json()["tem_day"]}\n最低气温:{resp.json()["tem_night"]}\n风向:{resp.json()["win"]}\n风速:{resp.json()["win_meter"]}\n天气:{resp.json()["wea"]}\n湿度:{resp.json()["humidity"]}\n\nBy zhizhuo\n更新时间:{resp.json()["update_time"]}' 105 | elif "errcode" in resp.text and resp.json()["errcode"] == 100: 106 | output(f'天气查询接口出错,请稍后重试,接口状态{resp.json()["errmsg"]}') 107 | msg = resp.json()["errmsg"].replace("city", "城市中") 108 | else: 109 | msg = f"天气查询接口出错,请稍后重试,接口状态{resp.status_code}" 110 | else: 111 | msg = "语法错误,请输入查询xx天气" 112 | except Exception as e: 113 | output(f"ERROR: {e}") 114 | msg = "天气查询接口出错,ERROR:{}".format(e) 115 | return msg 116 | 117 | 118 | # 获取彩虹屁 119 | def get_rainbow_fart(): 120 | output("Get Rainbow fart") 121 | try: 122 | resp = requests.get( 123 | fart_url, 124 | timeout=4, 125 | verify=False, 126 | ) 127 | if resp.status_code == 200 and resp.json()["code"] == 200: 128 | msg = resp.json()["newslist"][-1]["content"] 129 | else: 130 | msg = "彩虹屁接口调用超时" 131 | except Exception as e: 132 | msg = "彩虹屁接口调用出错,错误信息:{}".format(e) 133 | return msg 134 | 135 | 136 | # 获取鸡汤 137 | def get_chicken_soup(): 138 | output("Get Chicken soup") 139 | try: 140 | resp = requests.get( 141 | "https://api.oick.cn/dutang/api.php", timeout=5, verify=False 142 | ) 143 | if resp.status_code == 200: 144 | msg = resp.text.replace('"', "") 145 | else: 146 | msg = "鸡汤接口请求超时" 147 | except Exception as e: 148 | msg = "鸡汤接口调用出错,错误信息:{}".format(e) 149 | return msg 150 | 151 | 152 | # md5解密接口 153 | def get_md5(self): 154 | output("Get MD5 Clear") 155 | try: 156 | md5_list = self.split(":") 157 | md5_list = self.split(":") 158 | md5_list = self.split(" ") 159 | if len(md5_list) > 1 and len(md5_list[1]) > 5: 160 | pmd5_url = str(md5_url) + str(md5_list[1]) 161 | resp = requests.get(pmd5_url, timeout=5, verify=False) 162 | if resp.status_code == 200 and len(resp.json()["result"]) > 0: 163 | msg = "密文:{}\nMD5解密结果为:{}".format( 164 | str(md5_list[1]), 165 | resp.json()["result"]["{}".format(str(md5_list[1]))], 166 | ) 167 | elif resp.status_code != 200: 168 | msg = "MD5解密接口调用超时" 169 | else: 170 | msg = "MD5解密失败" 171 | else: 172 | msg = "请使用语句md5解密 密文" 173 | pass 174 | except Exception as e: 175 | msg = "PMD5解密接口调用出错,错误信息:{}".format(e) 176 | return msg 177 | 178 | 179 | def get_cmd5(self): 180 | output("Get CMD5 Clear") 181 | headers = { 182 | 'User-Agent': user_agent_list[random.randint(0, len(user_agent_list) - 1)], 183 | 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 184 | 'Accept-Language': 'zh-CN,zh;q=0.9', 185 | 'Accept-Encoding': 'gzip, deflate, br', 186 | 'Pragma': 'no-cache', 187 | 'Cache-Control': 'no-cache', 188 | 'Connection': 'close', 189 | } 190 | try: 191 | cmd5_list = self.split(":") 192 | cmd5_list = self.split(":") 193 | cmd5_list = self.split(" ") 194 | if len(cmd5_list) > 1 and len(cmd5_list[1]) > 5: 195 | base_cmd5_url = str(cmd5_url) + str(cmd5_list[1]) 196 | resp = requests.get(url=base_cmd5_url, headers=headers, timeout=20, verify=False) 197 | if resp.status_code == 200 and 0 < len(resp.text) < 10240 and 'CMD5-ERROR' not in resp.text: 198 | msg = f"密文:{str(cmd5_list[1])}\nMD5解密结果为:{resp.text}" 199 | 200 | elif 'CMD5-ERROR:0' in resp.text: 201 | msg = "CMD5解密失败" 202 | elif 'CMD5-ERROR:-1' in resp.text: 203 | msg = "CMD5解密失败,无效的用户名密码" 204 | elif 'CMD5-ERROR:-2' in resp.text: 205 | msg = "CMD5解密失败,账户余额不足" 206 | elif 'CMD5-ERROR:-3' in resp.text: 207 | msg = "CMD5解密失败,解密服务器故障" 208 | elif 'CMD5-ERROR:-4' in resp.text: 209 | msg = "CMD5解密失败,不识别的密文" 210 | elif 'CMD5-ERROR:-7' in resp.text: 211 | msg = "CMD5解密失败,不支持的类型" 212 | elif 'CMD5-ERROR:-8' in resp.text: 213 | msg = "CMD5解密失败,api权限被禁止" 214 | elif 'CMD5-ERROR:-9' in resp.text: 215 | msg = "CMD5解密失败,条数超过200条" 216 | elif 'CMD5-ERROR:-999' in resp.text: 217 | msg = "CMD5解密失败,其它错误" 218 | elif resp.status_code != 200: 219 | msg = f"CMD5解密接口站点异常,站点状态:{resp.status_code}" 220 | else: 221 | msg = f"CMD5解密失败,发生位置错误,错误信息:{resp.text}" 222 | else: 223 | msg = "请使用语句cmd5解密 密文" 224 | pass 225 | except Exception as e: 226 | msg = "CMD5解密接口调用出错,错误信息:{}".format(e) 227 | return msg 228 | 229 | 230 | # 获取美女视频接口 231 | def get_girl_videos(): 232 | output("Get Girl Videos") 233 | try: 234 | resp = requests.get(girl_videos_url, timeout=5, verify=False) 235 | if resp.status_code == 200: 236 | videos_url = re.findall( 237 | '