Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
shlu committed Dec 30, 2024
1 parent d334716 commit 0941cca
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 29 deletions.
147 changes: 146 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,150 @@
- 📁 [Swing/](./Swing/)
- 📁 [UI/](./UI/)
- 📁 [VMWare/](./VMWare/)
- 📁 _site/
- 📁 010editor/
- 📁 Templates/
- 📄 [bt编写规则](./_site/010editor/Templates/bt%E7%BC%96%E5%86%99%E8%A7%84%E5%88%99.md)
- 📁 Android/
- 📁 AIDL/
- 📄 [AIDL调用回溯](./_site/Android/AIDL/AIDL%E8%B0%83%E7%94%A8%E5%9B%9E%E6%BA%AF.md)
- 📄 [Android逆向面试题](./_site/Android/Android%E9%80%86%E5%90%91%E9%9D%A2%E8%AF%95%E9%A2%98.md)
- 📄 [App的N种退出方式](./_site/Android/App%E7%9A%84N%E7%A7%8D%E9%80%80%E5%87%BA%E6%96%B9%E5%BC%8F.md)
- 📄 [Pixel 2 XL 解除激活锁](./_site/Android/Pixel%202%20XL%20%E8%A7%A3%E9%99%A4%E6%BF%80%E6%B4%BB%E9%94%81.md)
- 📄 [Pixel 循环重启问题](./_site/Android/Pixel%20%E5%BE%AA%E7%8E%AF%E9%87%8D%E5%90%AF%E9%97%AE%E9%A2%98.md)
- 📄 [Version](./_site/Android/Version.md)
- 📁 adb/
- 📄 [adb禁用app](./_site/Android/adb/adb%E7%A6%81%E7%94%A8app.md)
- 📄 [pm](./_site/Android/adb/pm.md)
- 📁 android studio/
- 📄 [External_Tools](./_site/Android/android%20studio/External_Tools.md)
- 📄 [修改第三方库最优解](./_site/Android/android%20studio/%E4%BF%AE%E6%94%B9%E7%AC%AC%E4%B8%89%E6%96%B9%E5%BA%93%E6%9C%80%E4%BC%98%E8%A7%A3.md)
- 📄 [pixel手机Wifi网络受限问题解决](./_site/Android/pixel%E6%89%8B%E6%9C%BAWifi%E7%BD%91%E7%BB%9C%E5%8F%97%E9%99%90%E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3.md)
- 📄 [产品反馈工具](./_site/Android/%E4%BA%A7%E5%93%81%E5%8F%8D%E9%A6%88%E5%B7%A5%E5%85%B7.md)
- 📄 [安装开发常用库](./_site/Android/%E5%AE%89%E8%A3%85%E5%BC%80%E5%8F%91%E5%B8%B8%E7%94%A8%E5%BA%93.md)
- 📄 [注册Google voice虚拟号码](./_site/Android/%E6%B3%A8%E5%86%8CGoogle%20voice%E8%99%9A%E6%8B%9F%E5%8F%B7%E7%A0%81.md)
- 📁 源码编译/
- 📁 android-10.0.0_r2/
- 📄 [修改system.img](./_site/Android/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91/android-10.0.0_r2/%E4%BF%AE%E6%94%B9system.img.md)
- 📁 wsl2/
- 📁 ubuntu18.04/
- 📄 [源码一条龙](./_site/Android/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91/wsl2/ubuntu18.04/%E6%BA%90%E7%A0%81%E4%B8%80%E6%9D%A1%E9%BE%99.md)
- 📄 [草稿](./_site/Android/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91/wsl2/ubuntu18.04/%E8%8D%89%E7%A8%BF.md)
- 📄 [漏洞Index](./_site/Android/%E6%BC%8F%E6%B4%9EIndex.md)
- 📁 脱壳/
- 📁 腾讯御安全/
- 📄 [2020-6-26](./_site/Android/%E8%84%B1%E5%A3%B3/%E8%85%BE%E8%AE%AF%E5%BE%A1%E5%AE%89%E5%85%A8/2020-6-26.md)
- 📄 [谷歌账户切换地区](./_site/Android/%E8%B0%B7%E6%AD%8C%E8%B4%A6%E6%88%B7%E5%88%87%E6%8D%A2%E5%9C%B0%E5%8C%BA.md)
- 📄 [跨语言调用跟踪](./_site/Android/%E8%B7%A8%E8%AF%AD%E8%A8%80%E8%B0%83%E7%94%A8%E8%B7%9F%E8%B8%AA.md)
- 📄 [进程间调用跟踪](./_site/Android/%E8%BF%9B%E7%A8%8B%E9%97%B4%E8%B0%83%E7%94%A8%E8%B7%9F%E8%B8%AA.md)
- 📄 [逆向填坑](./_site/Android/%E9%80%86%E5%90%91%E5%A1%AB%E5%9D%91.md)
- 📄 [AppCenter](./_site/AppCenter.md)
- 📁 Common/
- 📁 sql/
- 📁 sqlcipher/
- 📄 [SQLcipher加密机制分析](./_site/Common/sql/sqlcipher/SQLcipher%E5%8A%A0%E5%AF%86%E6%9C%BA%E5%88%B6%E5%88%86%E6%9E%90.md)
- 📄 [SqlCipher源码分析](./_site/Common/sql/sqlcipher/SqlCipher%E6%BA%90%E7%A0%81%E5%88%86%E6%9E%90.md)
- 📄 [sqlcipher编译](./_site/Common/sql/sqlcipher/sqlcipher%E7%BC%96%E8%AF%91.md)
- 📁 IDA/
- 📄 [IDA小知识点集合](./_site/IDA/IDA%E5%B0%8F%E7%9F%A5%E8%AF%86%E7%82%B9%E9%9B%86%E5%90%88.md)
- 📄 [IDA汇编指令分析](./_site/IDA/IDA%E6%B1%87%E7%BC%96%E6%8C%87%E4%BB%A4%E5%88%86%E6%9E%90.md)
- 📁 IDEA/
- 📄 [Android Studio](./_site/IDEA/Android%20Studio.md)
- 📁 Clion/
- 📄 [Toolchains](./_site/IDEA/Clion/Toolchains.md)
- 📄 [WSL&Clion](./_site/IDEA/Clion/WSL%26Clion.md)
- 📁 IDEA插件编写指南/
- 📄 [pre_readme](./_site/IDEA/IDEA%E6%8F%92%E4%BB%B6%E7%BC%96%E5%86%99%E6%8C%87%E5%8D%97/pre_readme.md)
- 📄 [PyCharm](./_site/IDEA/PyCharm.md)
- 📄 [open source license](./_site/IDEA/open%20source%20license.md)
- 📄 [plugin](./_site/IDEA/plugin.md)
- 📄 [regex](./_site/IDEA/regex.md)
- 📄 [webstrom](./_site/IDEA/webstrom.md)
- 📄 [乱码问题](./_site/IDEA/%E4%B9%B1%E7%A0%81%E9%97%AE%E9%A2%98.md)
- 📄 [Navigation](./_site/Navigation.md)
- 📁 PacketCapture/
- 📄 [路由器转发抓包](./_site/PacketCapture/%E8%B7%AF%E7%94%B1%E5%99%A8%E8%BD%AC%E5%8F%91%E6%8A%93%E5%8C%85.md)
- 📁 Serialization/
- 📄 [序列化方案选型对比](./_site/Serialization/%E5%BA%8F%E5%88%97%E5%8C%96%E6%96%B9%E6%A1%88%E9%80%89%E5%9E%8B%E5%AF%B9%E6%AF%94.md)
- 📁 ast/
- 📁 010editor/
- 📄 [pfp](./_site/ast/010editor/pfp.md)
- 📁 cloud/
- 📁 gcloud/
- 📄 [sql](./_site/cloud/gcloud/sql.md)
- 📁 cloudflare/
- 📄 [warp](./_site/cloudflare/warp.md)
- 📄 [开启防攻击模式](./_site/cloudflare/%E5%BC%80%E5%90%AF%E9%98%B2%E6%94%BB%E5%87%BB%E6%A8%A1%E5%BC%8F.md)
- 📁 docker/
- 📄 [change-docker-root](./_site/docker/change-docker-root.md)
- 📁 docs/
- 📄 [index](./_site/docs/index.md)
- 📁 frida/
- 📄 [compile](./_site/frida/compile.md)
- 📁 iOS/
- 📄 [frida-trace](./_site/frida/iOS/frida-trace.md)
- 📄 [openssl](./_site/frida/openssl.md)
- 📁 git/
- 📄 [gitignore](./_site/git/gitignore.md)
- 📄 [git提交规范](./_site/git/git%E6%8F%90%E4%BA%A4%E8%A7%84%E8%8C%83.md)
- 📁 github/
- 📄 [Google网页索引](./_site/github/Google%E7%BD%91%E9%A1%B5%E7%B4%A2%E5%BC%95.md)
- 📄 [jekyll Front Matter 变量有哪些?](./_site/github/jekyll%20Front%20Matter%20%E5%8F%98%E9%87%8F%E6%9C%89%E5%93%AA%E4%BA%9B%EF%BC%9F.md)
- 📄 [为Jekyll添加评论系统](./_site/github/%E4%B8%BAJekyll%E6%B7%BB%E5%8A%A0%E8%AF%84%E8%AE%BA%E7%B3%BB%E7%BB%9F.md)
- 📄 [将github仓库无侵入转换为github-pages](./_site/github/%E5%B0%86github%E4%BB%93%E5%BA%93%E6%97%A0%E4%BE%B5%E5%85%A5%E8%BD%AC%E6%8D%A2%E4%B8%BAgithub-pages.md)
- 📁 iOS/
- 📄 [old](./_site/iOS/old.md)
- 📄 [常用api](./_site/iOS/%E5%B8%B8%E7%94%A8api.md)
- 📁 kali-linux/
- 📄 [android](./_site/kali-linux/android.md)
- 📁 language/
- 📁 c/
- 📄 [常用函数](./_site/language/c/%E5%B8%B8%E7%94%A8%E5%87%BD%E6%95%B0.md)
- 📄 [常用库](./_site/language/c/%E5%B8%B8%E7%94%A8%E5%BA%93.md)
- 📁 golang/
- 📄 [cgo](./_site/language/golang/cgo.md)
- 📄 [code](./_site/language/golang/code.md)
- 📁 python/
- 📁 ubuntu/
- 📄 [ubuntu16.04安装python3.6](./_site/language/python/ubuntu/ubuntu16.04%E5%AE%89%E8%A3%85python3.6.md)
- 📄 [常用小功能函数](./_site/language/python/%E5%B8%B8%E7%94%A8%E5%B0%8F%E5%8A%9F%E8%83%BD%E5%87%BD%E6%95%B0.md)
- 📁 lldb/
- 📄 [lldb脚本参数里的result怎么用?](./_site/lldb/lldb%E8%84%9A%E6%9C%AC%E5%8F%82%E6%95%B0%E9%87%8C%E7%9A%84result%E6%80%8E%E4%B9%88%E7%94%A8%EF%BC%9F.md)
- 📁 macOS/
- 📄 [brew](./_site/macOS/brew.md)
- 📁 nodejs/
- 📄 [nodejs](./_site/nodejs/nodejs.md)
- 📄 [ts](./_site/nodejs/ts.md)
- 📁 proxy/
- 📄 [curl](./_site/proxy/curl.md)
- 📄 [git](./_site/proxy/git.md)
- 📄 [mirror](./_site/proxy/mirror.md)
- 📄 [repo](./_site/proxy/repo.md)
- 📄 [v2](./_site/proxy/v2.md)
- 📄 [reverse](./_site/reverse.md)
- 📁 rom/
- 📄 [boot](./_site/rom/boot.md)
- 📁 software-top100/
- 📄 [Android](./_site/software-top100/Android.md)
- 📄 [Linux](./_site/software-top100/Linux.md)
- 📄 [web](./_site/software-top100/web.md)
- 📄 [window](./_site/software-top100/window.md)
- 📁 ubuntu/
- 📄 [ubuntu-server-20.04](./_site/ubuntu/ubuntu-server-20.04.md)
- 📁 unicorn/
- 📄 [syscall表](./_site/unicorn/syscall%E8%A1%A8.md)
- 📁 wechat/
- 📄 [Should We Chat, Too Security Analysis of WeChat’s MMTLS Encryption Protocol](./_site/wechat/Should%20We%20Chat%2C%20Too%20Security%20Analysis%20of%20WeChat%E2%80%99s%20MMTLS%20Encryption%20Protocol.md)
- 📁 window/
- 📄 [bat](./_site/window/bat.md)
- 📄 [cmd](./_site/window/cmd.md)
- 📁 od/
- 📄 [win32逆向分析](./_site/window/od/win32%E9%80%86%E5%90%91%E5%88%86%E6%9E%90.md)
- 📄 [pe](./_site/window/pe.md)
- 📄 [powershell](./_site/window/powershell.md)
- 📄 [startup](./_site/window/startup.md)
- 📄 [vbs](./_site/window/vbs.md)
- 📄 [wakeup](./_site/window/wakeup.md)
- 📁 [ads/](./ads/)
- 📁 [mopub/](./ads/mopub/)
- 📁 [unity3d/](./ads/unity3d/)
Expand Down Expand Up @@ -187,6 +331,7 @@
- 📄 [gitignore](./git/gitignore.md)
- 📄 [git提交规范](./git/git%E6%8F%90%E4%BA%A4%E8%A7%84%E8%8C%83.md)
- 📁 [github/](./github/)
- 📄 [Google网页索引](./github/Google%E7%BD%91%E9%A1%B5%E7%B4%A2%E5%BC%95.md)
- 📄 [jekyll Front Matter 变量有哪些?](./github/jekyll%20Front%20Matter%20%E5%8F%98%E9%87%8F%E6%9C%89%E5%93%AA%E4%BA%9B%EF%BC%9F.md)
- 📄 [为Jekyll添加评论系统](./github/%E4%B8%BAJekyll%E6%B7%BB%E5%8A%A0%E8%AF%84%E8%AE%BA%E7%B3%BB%E7%BB%9F.md)
- 📄 [将github仓库无侵入转换为github-pages](./github/%E5%B0%86github%E4%BB%93%E5%BA%93%E6%97%A0%E4%BE%B5%E5%85%A5%E8%BD%AC%E6%8D%A2%E4%B8%BAgithub-pages.md)
Expand Down Expand Up @@ -292,7 +437,6 @@
- 📄 [syscall表](./unicorn/syscall%E8%A1%A8.md)
- 📁 [unidbg/](./unicorn/unidbg/)
- 📁 [usb/](./usb/)
- 📄 [2018-05-13-usb-reverse-engineering-down-the-rabbit-hole](./usb/2018-05-13-usb-reverse-engineering-down-the-rabbit-hole.md)
- 📁 [virtualbox/](./virtualbox/)
- 📁 [vixl/](./vixl/)
- 📁 [vscode/](./vscode/)
Expand Down Expand Up @@ -326,6 +470,7 @@




[![Update README Directory Index](https://github.com/xpko/xpko.github.io/actions/workflows/update-readme-index.yml/badge.svg)](https://github.com/xpko/xpko.github.io/actions/workflows/update-readme-index.yml) [![Deploy Jekyll with GitHub Pages dependencies preinstalled](https://github.com/xpko/xpko.github.io/actions/workflows/jekyll-gh-pages.yml/badge.svg)](https://github.com/xpko/xpko.github.io/actions/workflows/jekyll-gh-pages.yml) ![GitHub Created At](https://img.shields.io/github/created-at/xpko/xpko.github.io) ![Gitea Last Commit](https://img.shields.io/github/last-commit/xpko/xpko.github.io) ![GitHub License](https://img.shields.io/github/license/xpko/xpko.github.io) ![GitHub commit activity](https://img.shields.io/github/commit-activity/t/xpko/xpko.github.io) ![GitHub Repo stars](https://img.shields.io/github/stars/xpko/xpko.github.io)


Expand Down
122 changes: 103 additions & 19 deletions generate_directory_index.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
import os
import urllib.parse

def read_blogignore(dir_path):
"""
从指定目录下读取 .blogignore 文件,返回需要排除的文件或目录名称列表。
- 忽略空行和以 '#' 开头的注释行
"""
blogignore_path = os.path.join(dir_path, '.blogignore')
if not os.path.isfile(blogignore_path):
return []

ignore_list = []
with open(blogignore_path, 'r', encoding='utf-8') as f:
for line in f:
line = line.strip()
# 跳过空行与注释行
if not line or line.startswith('#'):
continue
ignore_list.append(line)
return ignore_list

def has_readme(directory):
"""检查目录中是否存在 README.md(不区分大小写)"""
for item in os.listdir(directory):
Expand All @@ -12,17 +31,45 @@ def is_markdown_file(filename):
"""检查文件是否为 Markdown 文件(不区分大小写)"""
return filename.lower().endswith('.md')

def generate_markdown_index(base_path, current_path='.', level=0, exclude_dirs=None):
def generate_markdown_index(
base_path,
current_path='.',
level=0,
exclude_dirs=None,
exclude_files=None
):
"""
递归生成 Markdown 目录索引,包含:
- 仅包含 README.md 的目录,链接指向目录本身。
- 其他 Markdown 文件,链接指向文件本身,链接文本为文件名(不含 .md)。
- 仅包含 README.md 的目录,链接指向目录本身;
- 其他 Markdown 文件,链接指向文件本身,链接文本为文件名(不含 .md);
- 同时可排除指定目录和指定文件;
- 若当前目录下存在 .blogignore 文件,则读取其中指定的排除目标(可以是文件或目录)。
"""
# 默认的全局排除目录
if exclude_dirs is None:
exclude_dirs = ['.git', '.github', 'node_modules', '__pycache__']
# 默认的全局排除文件
if exclude_files is None:
exclude_files = []

markdown = ""
full_path = os.path.join(base_path, current_path)

# 1. 读取当前目录下的 .blogignore 文件
local_ignores = read_blogignore(full_path)

# 2. 将 .blogignore 中的条目分别加入排除列表(可能是文件也可能是文件夹)
combined_exclude_dirs = set(exclude_dirs) # 用集合来合并
combined_exclude_files = set(exclude_files)

for item in local_ignores:
item_path = os.path.join(full_path, item)
if os.path.isdir(item_path):
combined_exclude_dirs.add(item)
else:
combined_exclude_files.add(item)

# 开始读取目录内容
try:
items = sorted(os.listdir(full_path))
except PermissionError:
Expand All @@ -31,38 +78,71 @@ def generate_markdown_index(base_path, current_path='.', level=0, exclude_dirs=N
for item in items:
item_path = os.path.join(full_path, item)
relative_path = os.path.join(current_path, item).replace('\\', '/')
if os.path.isdir(item_path) and item not in exclude_dirs:

# 如果命中了目录排除,直接跳过
if item in combined_exclude_dirs and os.path.isdir(item_path):
continue

# 如果是子目录(并且不在排除名单中)
if os.path.isdir(item_path) and item not in combined_exclude_dirs:
if has_readme(item_path):
indent = ' ' * level
# 确保目录路径以 '/' 结尾,并进行 URL 编码
dir_link = urllib.parse.quote(relative_path.rstrip('/') + '/')
markdown += f"{indent}- 📁 [{item}/]({dir_link})\n"
# 递归查找子目录
markdown += generate_markdown_index(base_path, relative_path, level + 1, exclude_dirs)
markdown += generate_markdown_index(
base_path,
relative_path,
level + 1,
exclude_dirs=combined_exclude_dirs,
exclude_files=combined_exclude_files
)
else:
# 没有 README.md 的目录,如果递归下仍有内容,才显示该目录名称
indent = ' ' * level
# 递归查找子目录
sub=generate_markdown_index(base_path, relative_path, level + 1, exclude_dirs)
if sub and sub != "":
# 不包含 README.md 的目录,仅显示目录名称,不包含链接,并且需要在子目录有内容的情况下才显示
sub = generate_markdown_index(
base_path,
relative_path,
level + 1,
exclude_dirs=combined_exclude_dirs,
exclude_files=combined_exclude_files
)
if sub.strip():
markdown += f"{indent}- 📁 {item}/\n"
markdown += sub
elif os.path.isfile(item_path) and is_markdown_file(item) and item.lower() != 'readme.md':
indent = ' ' * level
# 文件名不包含后缀
file_name = os.path.splitext(item)[0]
# 进行 URL 编码
file_link = urllib.parse.quote(relative_path)
markdown += f"{indent}- 📄 [{file_name}]({file_link})\n"

# 如果是文件,并且是 Markdown 文件,且未被排除
elif os.path.isfile(item_path):
# 如果命中了文件排除,直接跳过
if item in combined_exclude_files:
continue

if is_markdown_file(item) and item.lower() != 'readme.md':
indent = ' ' * level
file_name = os.path.splitext(item)[0]
file_link = urllib.parse.quote(relative_path)
markdown += f"{indent}- 📄 [{file_name}]({file_link})\n"

return markdown

def main():
base_path = '.' # 仓库根目录

# 全局排除的目录和文件(可自行按需设置)
exclude_dirs = ['.git', '.github', 'node_modules', '__pycache__']
exclude_files = [] # 如需全局排除特定文件,可在此添加

start_marker = '<!-- DIRECTORY INDEX START -->'
end_marker = '<!-- DIRECTORY INDEX END -->'

directory_index = generate_markdown_index(base_path)
directory_index = generate_markdown_index(
base_path=base_path,
current_path='.',
level=0,
exclude_dirs=exclude_dirs,
exclude_files=exclude_files
)

directory_section = f"{start_marker}\n{directory_index}{end_marker}\n"

Expand All @@ -81,12 +161,16 @@ def main():
parts = readme_content.split(start_marker)
if len(parts) > 1:
before = parts[0]
after = parts[1].split(end_marker, 1)[1] if end_marker in parts[1] else ''
after_part = parts[1]
if end_marker in after_part:
after = after_part.split(end_marker, 1)[1]
else:
after = ''
new_readme = before + directory_section + after
else:
new_readme = readme_content + "\n" + directory_section
else:
# 添加目录索引到 README.md
# 如果 README.md 中还没有这两个标记,则直接加到文件末尾
new_readme = readme_content + "\n" + directory_section

# 写回 README.md
Expand Down
Empty file added github/Google网页索引.md
Empty file.
1 change: 1 addition & 0 deletions usb/.blogignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2018-05-13-usb-reverse-engineering-down-the-rabbit-hole.md
Loading

0 comments on commit 0941cca

Please sign in to comment.