吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 423|回复: 4
收起左侧

[学习记录] Automa-查询SSL过期日期

[复制链接]
mengnimen 发表于 2024-7-2 16:43
今天在公司聊天的时候,发现公司运维有一个需求,就是SSL到期日期。为了节省费用公司使用的免费的证书,那就有到期提醒的需求。到期之前进行正常的证书续期。既然有需求了,那就开始搞吧~
image.png
利用三个HTTP请求模块,进行数据循环,对一个api接口进行请求,从而获取到期时间、证书颁发机构、域名。方法很简单,就是请求API接口获得需要的数据,从而在JavaScript模块进行弹窗展示。
image.png
对于运维人员还是有用的,定期执行这个脚本,就能很清楚的看到过期时间。便于日常维护。代码如下
[HTML] 纯文本查看 复制代码
{
"extVersion": "1.28.27",
"name": "SSL证书到期查询",
"icon": "riGlobalLine",
"table": [
{
"id": "WJsFg",
"name": "subject_name",
"type": "string"
},
{
"id": "zPKtD",
"name": "valid_to",
"type": "string"
},
{
"id": "a8Gds",
"name": "issuer_organization",
"type": "string"
}
],
"version": "1.28.27",
"drawflow": {
"nodes": [
{
"type": "BlockBasic",
"data": {
"disableBlock": false,
"description": "",
"type": "manual",
"interval": 60,
"delay": 5,
"date": "",
"time": "00:00",
"url": "",
"shortcut": "",
"activeInInput": false,
"isUrlRegex": false,
"days": [],
"contextMenuName": "",
"contextTypes": [],
"parameters": [],
"preferParamsInTab": false,
"observeElement": {
"selector": "",
"baseSelector": "",
"matchPattern": "",
"targetOptions": {
"subtree": false,
"childList": true,
"attributes": false,
"attributeFilter": [],
"characterData": false
},
"baseElOptions": {
"subtree": false,
"childList": true,
"attributes": false,
"attributeFilter": [],
"characterData": false
}
}
},
"events": {},
"position": {
"x": 100,
"y": 325.5
},
"id": "TAtB6Rp1QtawJVS07x2GR",
"label": "trigger"
},
{
"type": "BlockBasicWithFallback",
"data": {
"disableBlock": false,
"description": "",
"url": "https://api.ahfi.cn/api/checkssl?url={{loopData.v7uqXT}}",
"body": "{}",
"headers": [],
"method": "GET",
"timeout": 10000,
"dataPath": "data.subject_name",
"contentType": "json",
"variableName": "",
"assignVariable": false,
"saveData": true,
"dataColumn": "WJsFg",
"responseType": "json"
},
"events": {},
"position": {
"x": 427,
"y": 283.72367123117107
},
"label": "webhook",
"id": "h5mkb4l"
},
{
"type": "BlockBasic",
"data": {
"disableBlock": false,
"loopId": "v7uqXT",
"maxLoop": 0,
"toNumber": 10,
"fromNumber": 1,
"startIndex": 0,
"loopData": "[\"baidu.com\",\"zhihu.com\",\"xiaohongshu.com\"]",
"description": "",
"variableName": "",
"referenceKey": "",
"reverseLoop": false,
"elementSelector": "",
"waitForSelector": false,
"waitSelectorTimeout": 5000,
"resumeLastWorkflow": false,
"loopThrough": "custom-data"
},
"events": {},
"position": {
"x": 137,
"y": 183
},
"label": "loop-data",
"id": "6yq9xbd"
},
{
"type": "BlockLoopBreakpoint",
"data": {
"disableBlock": false,
"loopId": "v7uqXT",
"clearLoop": false
},
"events": {},
"position": {
"x": 807.6903452463462,
"y": 351.0413974349145
},
"label": "loop-breakpoint",
"id": "d184qyy"
},
{
"type": "BlockBasicWithFallback",
"data": {
"disableBlock": false,
"description": "",
"url": "https://api.ahfi.cn/api/checkssl?url={{loopData.v7uqXT}}",
"body": "{}",
"headers": [],
"method": "GET",
"timeout": 10000,
"dataPath": "data.valid_to",
"contentType": "json",
"variableName": "",
"assignVariable": false,
"saveData": true,
"dataColumn": "zPKtD",
"responseType": "json"
},
"events": {},
"label": "webhook",
"id": "at11gro",
"position": {
"x": 487.0386613542844,
"y": 97.12805957508661
}
},
{
"type": "BlockBasicWithFallback",
"data": {
"disableBlock": false,
"description": "",
"url": "https://api.ahfi.cn/api/checkssl?url={{loopData.v7uqXT}}",
"body": "{}",
"headers": [],
"method": "GET",
"timeout": 10000,
"dataPath": "data.issuer_organization",
"contentType": "json",
"variableName": "",
"assignVariable": false,
"saveData": true,
"dataColumn": "a8Gds",
"responseType": "json"
},
"events": {},
"label": "webhook",
"id": "wyjaqpa",
"position": {
"x": 810.3449866800272,
"y": 93.99704070699872
}
},
{
"type": "BlockBasic",
"data": {
"disableBlock": false,
"description": "",
"timeout": 20000,
"context": "website",
"code": "// 显示带图片的自定义弹窗的函数\nfunction showCustomAlert(message, imageUrl) {\n // 创建遮罩层\n const overlay = document.createElement('div');\n overlay.style.position = 'fixed';\n overlay.style.top = '0';\n overlay.style.left = '0';\n overlay.style.width = '100%';\n overlay.style.height = '100%';\n overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';\n overlay.style.zIndex = '1000';\n document.body.appendChild(overlay);\n\n // 创建弹窗容器\n const alertBoxContainer = document.createElement('div');\n alertBoxContainer.style.position = 'fixed';\n alertBoxContainer.style.top = '10px';\n alertBoxContainer.style.right = '10px';\n alertBoxContainer.style.width = '330px';\n alertBoxContainer.style.zIndex = '1001';\n alertBoxContainer.style.boxShadow = '0 2px 10px rgba(0,0,0,0.1)';\n alertBoxContainer.style.boxSizing = 'border-box';\n alertBoxContainer.style.borderRadius = '10px'; // 添加圆角\n document.body.appendChild(alertBoxContainer);\n\n const alertBox = document.createElement('div');\n alertBox.style.backgroundColor = 'white';\n alertBox.style.border = '1px solid #ccc';\n alertBox.style.padding = '20px';\n alertBox.style.maxHeight = '400px'; // 设置最大高度\n alertBox.style.overflow = 'auto'; // 添加滚动条\n alertBox.style.borderRadius = '10px'; // 添加圆角\n alertBoxContainer.appendChild(alertBox);\n\n // 创建关闭按钮\n const closeButton = document.createElement('button');\n closeButton.innerText = 'X';\n closeButton.style.position = 'absolute';\n closeButton.style.top = '10px';\n closeButton.style.right = '10px';\n closeButton.style.border = 'none';\n closeButton.style.background = 'none';\n closeButton.style.cursor = 'pointer';\n closeButton.style.fontSize = '16px';\n closeButton.onclick = function() {\n document.body.removeChild(alertBoxContainer);\n document.body.removeChild(overlay);\n };\n alertBoxContainer.appendChild(closeButton);\n\n // 创建标题\n const title = document.createElement('h2');\n title.innerText = 'SSL到期查询';\n title.style.textAlign = 'center'; // 标题居中\n title.style.marginBottom = '20px'; // 标题下方留白\n alertBox.appendChild(title);\n\n // 创建消息段落,并处理换行\n const msgParagraph = document.createElement('p');\n msgParagraph.style.fontSize = '14px'; // 设置文字大小\n msgParagraph.style.color = '#333'; // 设置文字颜色\n msgParagraph.innerHTML = message; // 使用 innerHTML 以支持 HTML 内容\n msgParagraph.style.marginTop = '30px'; // 确保不与关闭按钮重叠\n alertBox.appendChild(msgParagraph);\n\n // 创建图片元素\n const imgElement = document.createElement('img');\n imgElement.src = imageUrl;\n imgElement.style.maxWidth = '100%';\n imgElement.style.height = 'auto';\n alertBox.appendChild(imgElement);\n}\n\n// 获取表格数据\nconst table = automaRefData('table');\n\n// 合并表格数据为一个字符串,并设置值为红色\nlet combinedMessage = '';\ntable.forEach(row => {\n const subjectName = `网站域名:<span style=\"color: red;\">${row.subject_name}</span>`;\n const validTo = `域名SSL到期日期:<span style=\"color: red;\">${row.valid_to}</span>`;\n const issuerOrganization = `证书颁发机构:<span style=\"color: red;\">${row.issuer_organization}</span>`;\n combinedMessage += `${subjectName}<br>${issuerOrganization}<br>${validTo}<br><br>`;\n});\n\n// 这里设置一个示例图片链接,如果有实际的图片链接可以替换\nconst imageUrl = '';\n\n// 调用函数显示自定义弹窗\nshowCustomAlert(combinedMessage.trim(), imageUrl);\n\n// 继续执行下一个块\nautomaNextBlock();\n",
"preloadScripts": [],
"everyNewTab": false,
"runBeforeLoad": false
},
"events": {},
"position": {
"x": 409.0899555092823,
"y": 496.2520211035303
},
"label": "javascript-code",
"id": "suqj5pb"
},
{
"type": "BlockBasic",
"data": {
"disableBlock": false
},
"events": {},
"position": {
"x": 118.08699621628091,
"y": 494.8807344501557
},
"label": "active-tab",
"id": "wyqyvvi"
}
],
"edges": [
{
"sourceHandle": "TAtB6Rp1QtawJVS07x2GR-output-1",
"targetHandle": "6yq9xbd-input-1",
"type": "custom",
"source": "TAtB6Rp1QtawJVS07x2GR",
"target": "6yq9xbd",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-TAtB6Rp1QtawJVS07x2GRTAtB6Rp1QtawJVS07x2GR-output-1-6yq9xbd6yq9xbd-input-1",
"sourceX": 312.0000365583911,
"sourceY": 361.4999923858251,
"targetX": 117.00003111230075,
"targetY": 218.9999923858251
},
{
"sourceHandle": "6yq9xbd-output-1",
"targetHandle": "h5mkb4l-input-1",
"type": "custom",
"source": "6yq9xbd",
"target": "h5mkb4l",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-6yq9xbd6yq9xbd-output-1-h5mkb4lh5mkb4l-input-1",
"sourceX": 349.0001264160065,
"sourceY": 218.9999923858251,
"targetX": 406.9999412546854,
"targetY": 331.72365393537723
},
{
"sourceHandle": "h5mkb4l-output-1",
"targetHandle": "at11gro-input-1",
"type": "custom",
"source": "h5mkb4l",
"target": "at11gro",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-h5mkb4lh5mkb4l-output-1-at11groat11gro-input-1",
"sourceX": 638.9999467007757,
"sourceY": 331.72365393537723,
"targetX": 467.03860260896977,
"targetY": 145.12808720810048
},
{
"sourceHandle": "at11gro-output-1",
"targetHandle": "wyjaqpa-input-1",
"type": "custom",
"source": "at11gro",
"target": "wyjaqpa",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-at11groat11gro-output-1-wyjaqpawyjaqpa-input-1",
"sourceX": 699.0386979126755,
"sourceY": 145.12808720810048,
"targetX": 790.345017792328,
"targetY": 141.99704587560876
},
{
"sourceHandle": "wyjaqpa-output-1",
"targetHandle": "d184qyy-input-1",
"type": "custom",
"source": "wyjaqpa",
"target": "d184qyy",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-wyjaqpawyjaqpa-output-1-d184qyyd184qyy-input-1",
"sourceX": 1022.3451130960336,
"sourceY": 141.99704587560876,
"targetX": 787.690376358647,
"targetY": 426.627308633231
},
{
"sourceHandle": "d184qyy-output-1",
"targetHandle": "wyqyvvi-input-1",
"type": "custom",
"source": "d184qyy",
"target": "wyqyvvi",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-d184qyyd184qyy-output-1-wyqyvviwyqyvvi-input-1",
"sourceX": 1019.6902919471219,
"sourceY": 426.627308633231,
"targetX": 98.08702732858166,
"targetY": 530.8807717647885
},
{
"sourceHandle": "wyqyvvi-output-1",
"targetHandle": "suqj5pb-input-1",
"type": "custom",
"source": "wyqyvvi",
"target": "suqj5pb",
"updatable": true,
"selectable": true,
"data": {},
"events": {},
"markerEnd": "arrowclosed",
"id": "vueflow__edge-wyqyvviwyqyvvi-output-1-suqj5pbsuqj5pb-input-1",
"sourceX": 330.087032774672,
"sourceY": 530.8807717647885,
"targetX": 389.08989676396766,
"targetY": 532.2520134893554,
"class": "connected-edges"
}
],
"position": [
79.9187008604224,
98.98923306910513
],
"zoom": 0.6792431422744721,
"viewport": {
"x": 79.9187008604224,
"y": 98.98923306910513,
"zoom": 0.6792431422744721
}
},
"settings": {
"publicId": "",
"blockDelay": 0,
"saveLog": true,
"debugMode": false,
"restartTimes": 3,
"notification": true,
"execContext": "popup",
"reuseLastState": false,
"inputAutocomplete": true,
"onError": "stop-workflow",
"executedBlockOnWeb": false,
"insertDefaultColumn": false,
"defaultColumnName": "column"
},
"globalData": "{\n\t\"key\": \"value\"\n}",
"description": "",
"includedWorkflows": {}
}

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

放羊的狼 发表于 2024-7-2 17:58
很少见有用automa的
vistal 发表于 2024-7-2 20:32
freessl 到期会有免费提醒有一年的 。。或者找那个自动延期脚本
三滑稽甲苯 发表于 2024-7-2 21:19
 楼主| mengnimen 发表于 2024-7-3 10:22
三滑稽甲苯 发表于 2024-7-2 21:19
还是习惯用 Python 做这种简单的小工具

这东西就是会者不难,难者不会,对于automa来说,毕竟一个插件,学习成本比Python要低很多
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-24 15:41

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表