2022年4月26日星期二

Frp内网穿透使用

Frp 一个简单、高效的内网穿透工具

Frps/frpc客户端管理命令
# 更新配置
systemctl daemon-reload
# 开机启动
systemctl enable frpc.service
systemctl enable frpc-2.service
# 停止服务
systemctl stop frpc.service
systemctl stop frpc-2.service
# 启动服务
systemctl start frpc.service
systemctl start frpc-2.service
# 查看状态
systemctl status frpc.service
systemctl status frpc-2.service
# 重启服务
systemctl restart frpc.service
systemctl restart frpc-2.service
#删除启动项
systemctl disable frpc.service
systemctl disable frpc-2.service

#安装Frps服务端
程序路径/usr/local/app/frps
# 开机启动
systemctl enable frps.service
# 启动服务
systemctl start frps.service
# 查看状态
systemctl status frps.service
# 重启服务
systemctl restart frps.service
#删除启动项
systemctl disable frps.service


官方网站:https://gofrp.org
官方发布地址:https://github.com/fatedier/frp/releases

开始使用!

编写配置文件,先在服务器端文件目录通过 ./frps -c ./frps.ini 启动服务端,再通过客户端文件目录 ./frpc -c ./frpc.ini 启动客户端。如果需要在后台长期运行,建议结合其他工具使用,例如 systemd 和 supervisor。

配置校验
通过执行 frpc verify -c ./frpc.ini 或 frps verify -c ./frps.ini 可以对配置文件中的参数进行预先校验。
frpc: the configuration file ./frpc.ini syntax is ok
如果出现此结果,则说明新的配置文件没有错误,否则会输出具体的错误信息。

自定义二级域名

在多人同时使用一个 frps 时,通过自定义二级域名的方式来使用会更加方便。

通过在 frps 的配置文件中配置 subdomain_host,就可以启用该特性。之后在 frpc 的 http、https 类型的代理中可以不配置 custom_domains,而是配置一个 subdomain 参数。

只需要将 *.{subdomain_host} 解析到 frps 所在服务器。之后用户可以通过 subdomain 自行指定自己的 web 服务所需要使用的二级域名,通过 {subdomain}.{subdomain_host} 来访问自己的 web 服务。

# frps.ini
[common]
subdomain_host = frps.com
将泛域名 *.frps.com 解析到 frps 所在服务器的 IP 地址。

# frpc.ini
[web]
type = http
local_port = 80
subdomain = test
frps 和 frpc 都启动成功后,通过 test.frps.com 就可以访问到内网的 web 服务。

注:如果 frps 配置了 subdomain_host,则 custom_domains 中不能是属于 subdomain_host 的子域名或者泛域名。
同一个 HTTP 或 HTTPS 类型的代理中 custom_domains 和 subdomain 可以同时配置。

frpc配置实现转发多个http站点

frps.ini正常配置(包括加vhost_http_port或者没有加vhost_http_port),
frpc.ini多加几个[web]项,
将新加的[web]项type改为tcp,后面不用加域名或者ip。
frpc会直接将其当作tcp数据包处理,只处理到了传输层(tcp),而没有到应用层(http)。


2022年4月23日星期六

使用首页进行301跳转

PHP代码

<?php
// zd.example.com和example.com跳转到http://example.com:555
$the_host = $_SERVER['HTTP_HOST'];
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if(($the_host == 'zd.example.com')or($the_host == 'example.com'))
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://zd.example.com:555'.$request_uri);//
}
// tz.example.com 则跳转到http://example.com/tz.php
elseif($the_host =="tz.example.com")
{
header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://example.com/tz.php");
}
// 其他则跳转到404页面
else
{
Header("Location: /404.html");
}
?>

HTML代码

<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type ="text/javascript">
document.location.href="http://" + document.location.hostname +":555";
</script>
<head>
<title>document.location</title>
</head>
<body>
<div class="landing-navigation-tablet-top-adjustment"></div>
<a href="http://zd.example.com:555" target="_blank">
<font color=orange size="6px">如果没有跳转请点击(</font></center></a><br>
</a>
</body>
</html>


常用CMD命令

1、电脑名称、IP地址、MAC地址获取:

ipconfig/all
或
ipconfig/all >D:1.txt


Windows 默认系统环境变量:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

2、刷新DNS:

ipconfig /flushdns


3、Bat批处理实现代理设置与取消


设置代理

@echo off
echo Setting the proxyServer ....
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "代理IP:代理端口" /f
color 2
echo Set the proxyserver successfully !
echo Press any key to continue
pause>nul

取消代理

@echo off 
echo Removing the proxyserver ...
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
color 2
echo Remove the proxyserver successfully !
echo Press any key to continue 
pause>nul



2022年4月9日星期六

2022年3月31日星期四

Malware-Patch一键阻止常见流氓软件的运行管理权限

Malware-Patch是Github上的一个开源项目,GitHub下载地址:https://github.com/the1812/Malware-Patch/releases
作者开发此工具的主要目的就是帮助你快速屏蔽常见的国产全家桶软件,包括360/2345等系列软件,软件绿色无需安装,使用起来简单暴力。

首先,工具内置了一些可以直接被屏蔽的国产软件,你可以全选或者选中某一项进行屏蔽,对号表示允许,X号代表阻止。根据阿刚的测试,效果非常给力,例如屏蔽了360后,只要是360的产品在安装时直接提示应用已被阻止。

软件的原理是直接拉黑相关软件的证书,在运行certmgr.msc打开WIndows的证书管理器,在证书-当前用户》不信任的证书》证书,列表中即可看到被拉黑的软件证书。

Excel使用 IF 检查单元格是否为空白

 有些时候,你需要检查单元格是否为空白,通常是因为你可能不希望公式没有输入值就显示结果。

单元格 E2 中的公式是 =IF(D2=1,"Yes",IF(D2=2,"No","Maybe"))

此情况下,将 IF 与 ISBLANK 函数搭配使用:

  • =IF(ISBLANK(D2),"Blank","Not Blank")

这表示如果(D2 为空白,则返回“Blank”,否则,将返回“Not Blank”)。 还可以针对“Not Blank”条件同样轻松地使用自己的公式。 在下一个示例中,我们将使用 "",而不是 ISBLANK。 "" 实际上意味着“没有内容”。

检查单元格是否为空白 - 单元格 E2 中的公式为 =IF(ISBLANK(D2),"Blank","Not Blank")

=IF(D3="","Blank","Not Blank")

此公式表示如果(D3 没有内容,则返回“Blank”,否则返回“Not Blank”)。 下面的示例是使用 “” 防止公式在从属单元格空白时进行计算的一种十分常见的方法:

  • =IF(D3="","0",(D3))

    如果(D3 没有内容,则返回0,否则,将计算你的公式)。

2022年3月30日星期三

Windows系统host文件快速替换

 以下文本另存为.BAT文件


@echo off

::取消host的只读属性

attrib -r -a -s -h %windir%\system32\drivers\etc\hosts 

::复制host文件

copy  %~sdp0\hosts     C:\Windows\System32\drivers\etc\hosts 

::设置host的只读属性

attrib +r +a +s +h %windir%\system32\drivers\etc\hosts

::刷新

ipconfig /flushdns

::刷新

ping -n 2 127.0.0.1 >nul


需要设置的host(如下示例)另存为hosts文件并与.BAT文件在同一文件夹,右键以管理员执行


104.111.167.111 contentstorage.osi.office.net

13.107.42.13 onedrive.live.com

20.190.144.166 login.live.com

40.79.207.82 skyapi.onedrive.live.com

13.107.42.12 d.docs.live.net

52.109.48.6 contentsync.onenote.com

52.109.48.27 hierarchyapi.onenote.com

52.109.124.47 ocws.officeapps.live.com

52.109.48.0 www.onenote.com

13.107.42.16 config.edge.skype.com

52.109.124.51 roaming.officeapps.live.com

52.109.48.4 pagecontentsync.onenote.com

104.111.167.110 api.onedrive.live.com

23.57.112.223 c1-onenote-15.cdn.office.net

13.107.42.12 docs.live.net

104.44.88.28 storage.live.com

20.197.71.89 skydrive.wns.windows.com

20.198.162.78 client.wns.windows.com

52.168.112.67 mobile.pipe.aria.microsoft.com

23.57.114.164 oneclient.sfx.ms

40.79.207.82 skydrivesync.policies.live.net

13.107.42.12 api.onedrive.com

13.107.42.12 public.bn.files.1drv.com

13.107.42.12 public.dm.files.1drv.com

104.111.162.163 cdn.onenote.net

157.240.199.14 ad.atdmt.com

117.18.232.200 officeimg.vo.msecnd.net

13.107.6.171 onenote.officeapps.live.com