Skip to content

Commit 4e86d00

Browse files
authored
Replace Pelican with Zola (#32)
Fixes #31
1 parent a816170 commit 4e86d00

File tree

215 files changed

+2562
-1133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+2562
-1133
lines changed

scripts/get_release_info.py renamed to .github/scripts/get_release_info.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,36 @@
99
- `BLOG_POST_SLUG_TITLE` :
1010
- `BLOG_POST_AUTHOR` :
1111
"""
12-
import requests
12+
13+
from dataclasses import dataclass
14+
from typing import Optional
15+
import httpx
1316
import bs4
1417
import time
1518
import os
1619

1720
ROOT: str = "https://blahcat.github.io"
18-
URL: str = f"{ROOT}/feeds/all.atom.xml"
21+
ATOM_FEED_URL: str = f"{ROOT}/feeds/all.atom.xml"
22+
23+
24+
@dataclass
25+
class SocialMedia:
26+
twitter: Optional[str]
27+
mastodon: Optional[str]
28+
discord: Optional[str]
29+
github: Optional[str]
30+
1931

20-
time.sleep(10)
32+
AUTHORS = {
33+
"hugsy": SocialMedia("@_hugsy_", "@[email protected]", "@crazy.hugsy", "hugsy")
34+
}
2135

22-
h = requests.get(URL)
36+
time.sleep(2)
37+
38+
h = httpx.get(ATOM_FEED_URL)
2339
assert h.status_code == 200
2440

25-
soup = bs4.BeautifulSoup(h.text, "lxml")
41+
soup = bs4.BeautifulSoup(h.text, "xml")
2642
node = soup.find("entry")
2743
assert node is not None
2844

@@ -34,33 +50,29 @@ def get(x: str):
3450

3551

3652
def strip_html(html: str):
37-
s = bs4.BeautifulSoup(html, features="html.parser")
53+
s = bs4.BeautifulSoup(html, features="xml")
3854
return s.get_text()
3955

4056

57+
def env(x: str):
58+
os.system(f"echo {x} >> $GITHUB_ENV")
59+
60+
4161
title = get("title").text
4262
authors = [x.text for x in get("author").find_all("name")]
4363
published = get("published").text
44-
url = ROOT + get("link")["href"]
45-
slug = get("link")["href"][18:-5]
64+
url = str(get("link")["href"])
65+
slug = str(get("link")["href"].rsplit("/")[-1])
4666
summary = strip_html(get("summary").text)[:-3] + " [...]"
4767

48-
author_twitters = []
49-
for author in authors:
50-
if author == "hugsy":
51-
author_twitters.append("@_hugsy_")
52-
# TODO automate this
53-
68+
author_twitters = [
69+
AUTHORS[n].twitter for n in authors if n in AUTHORS and AUTHORS[n].twitter
70+
]
5471
twitter_body = (
5572
f"""New blog post: '{title}' by {' and '.join(author_twitters)} - {url}"""
5673
)
5774
twitter_body = twitter_body[:280]
5875

59-
60-
def env(x: str):
61-
os.system(f"echo {x} >> $GITHUB_ENV")
62-
63-
6476
env(f"""BLOG_POST_TITLE="{title}" """)
6577
env(f"""BLOG_POST_PUBLISHED_DATE="{published}" """)
6678
env(f"""BLOG_POST_URL={url}""")

.github/scripts/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
httpx[cli]
2+
bs4

.github/spellcheck.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ matrix:
88
- .github/wordlist.txt
99
encoding: utf-8
1010
pipeline:
11+
- pyspelling.filters.context:
12+
context_visible_first: true
13+
escapes: \\[\\`~]
14+
delimiters:
15+
# Ignore anything in {{ }}
16+
- open: '(?s)(?P<open> *\{{2})'
17+
close: '^(?P=open)$'
18+
- open: '(?P<open>\}{2})'
19+
close: '(?P=open)'
20+
# Ignore frontmatter (+++ / +++)
21+
- open: '(?s)^(?P<open> *\+{3})$'
22+
close: '^(?P=open)$'
23+
- open: '(?P<open>\+{3})$'
24+
close: '(?P=open)'
1125
- pyspelling.filters.markdown:
1226
markdown_extensions:
1327
- pymdownx.superfences

.github/workflows/build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v4
2222
with:
23+
submodules: true
2324
token: ${{ secrets.GITHUB_TOKEN }}
2425
- uses: actions/setup-python@v5
2526
with:
26-
python-version: '3.10'
27+
python-version: '3.11'
2728
architecture: 'x64'
2829
cache: 'pip'
2930
- name: Build and publish the site
@@ -32,8 +33,6 @@ jobs:
3233
source ~/.bashrc
3334
git config --global user.name "hugsy"
3435
git config --global user.email "[email protected]"
35-
git clone https://github.com/hugsy/attila.git /tmp/themes/attila
36-
pelican-themes --install /tmp/themes/attila
37-
pelican content -o output -s pelicanconf.py
36+
zola build -o output
3837
ghp-import output --no-jekyll --branch=gh-pages --message="Generated new content"
3938
git push --force origin gh-pages

.github/workflows/check.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
steps:
2121
- name: checkout
2222
uses: actions/[email protected]
23+
with:
24+
submodules: true
2325

2426
- name: Restore lychee cache
2527
uses: actions/[email protected]
@@ -33,9 +35,19 @@ jobs:
3335
env:
3436
GITHUB_TOKEN: ${{secrets.LYCHEE_TOKEN}}
3537
with:
36-
args: --exclude='^http://rawpixels.net/.*$' --exclude='^http://rawpixels.net/.*$' --exclude='^https://twitter.com/.*$' --exclude='^https://ctftime.org/.*$' --cache --max-cache-age 1w --exclude-all-private --threads 10 --timeout 30 --retry-wait-time 60 --user-agent 'Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0' --no-progress 'content/**/*.md'
38+
args: --exclude='^file://.*$' --exclude='^http://rawpixels.net/.*$' --exclude='^http://rawpixels.net/.*$' --exclude='^https://twitter.com/.*$' --exclude='^https://ctftime.org/.*$' --cache --max-cache-age 1w --exclude-all-private --threads 10 --timeout 30 --retry-wait-time 60 --user-agent 'Mozilla/5.0 (Windows NT x.y; rv:10.0) Gecko/20100101 Firefox/10.0' --no-progress 'content/**/*.md'
3739
fail: true
3840

41+
- name: Check anchors (setup)
42+
uses: taiki-e/install-action@v2
43+
with:
44+
45+
46+
- name: Check anchors (setup)
47+
run: |
48+
zola check
49+
50+
3951
spellcheck:
4052
name: Spell Checker
4153
runs-on: ubuntu-latest
@@ -46,7 +58,7 @@ jobs:
4658
uses: actions/[email protected]
4759

4860
- name: Spellcheck
49-
uses: rojopolis/spellcheck-github-actions@0.36.0
61+
uses: rojopolis/spellcheck-github-actions@0.38.0
5062
with:
5163
task_name: Markdown
5264
config_path: .github/spellcheck.yml
@@ -55,5 +67,5 @@ jobs:
5567
- if: '!cancelled()'
5668
run: |
5769
if [ -f spellcheck-output.txt ]; then
58-
python scripts/ci_spellcheck_format.py spellcheck-output.txt >> ${GITHUB_STEP_SUMMARY}
70+
python .github/scripts/ci_spellcheck_format.py spellcheck-output.txt >> ${GITHUB_STEP_SUMMARY}
5971
fi

.github/workflows/notify.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ jobs:
2323
- uses: actions/checkout@v4
2424
- uses: actions/setup-python@v4
2525
with:
26-
python-version: '3.10'
26+
python-version: '3.11'
2727
architecture: 'x64'
2828
cache: 'pip'
2929
- shell: bash
3030
run: |
31-
python -m pip install -r scripts/requirements.txt
32-
python scripts/get_release_info.py
31+
python -m pip install -r .github/scripts/requirements.txt
32+
python .github/scripts/get_release_info.py
3333
- uses: nearform-actions/[email protected]
3434
with:
3535
twitter-app-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
- uses: actions/checkout@v4
2323
- uses: actions/setup-python@v4
2424
with:
25-
python-version: '3.10'
25+
python-version: '3.11'
2626
architecture: 'x64'
2727
cache: 'pip'
2828
- shell: bash
2929
run: |
3030
python -m pip install -r scripts/requirements.txt
31-
python scripts/get_release_info.py
31+
python .github/scripts/get_release_info.py
3232
- uses: ncipollo/release-action@v1
3333
with:
3434
token: ${{ secrets.GITHUB_TOKEN }}
@@ -45,13 +45,13 @@ jobs:
4545
- uses: actions/checkout@v4
4646
- uses: actions/setup-python@v4
4747
with:
48-
python-version: '3.10'
48+
python-version: '3.11'
4949
architecture: 'x64'
5050
cache: 'pip'
5151
- shell: bash
5252
run: |
5353
python -m pip install -r scripts/requirements.txt
54-
python scripts/get_release_info.py
54+
python .github/scripts/get_release_info.py
5555
- name: Create the new GitHub Discussion
5656
uses: abirismyname/[email protected]
5757
env:

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "themes/zola-clean-blog"]
2+
path = themes/zola-clean-blog
3+
url = https://github.com/dave-tucker/zola-clean-blog

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"themes/*/templates/*.html": "jinja-html"
4+
},
5+
}

README.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

config.toml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# https://www.getzola.org/documentation/getting-started/configuration/
2+
base_url = "https://blahcat.github.io"
3+
title = "BlahCats Blog"
4+
description = "Tales of a binary encoded life..."
5+
theme = "zola-clean-blog"
6+
generate_feeds = true
7+
feed_filenames = ["atom.xml", "rss.xml"]
8+
author = "hugsy"
9+
compile_sass = true
10+
build_search_index = true
11+
minify_html = true
12+
13+
taxonomies = [
14+
{ name = "categories", rss = true, paginate_by = 10 },
15+
{ name = "tags", rss = true, paginate_by = 10 },
16+
{ name = "authors" },
17+
]
18+
19+
[markdown]
20+
highlight_code = true
21+
highlight_theme = "base16-ocean-dark" # https://www.getzola.org/documentation/getting-started/configuration/#syntax-highlighting
22+
render_emoji = true
23+
bottom_footnotes = true
24+
smart_punctuation = true
25+
external_links_target_blank = true
26+
external_links_no_follow = true
27+
external_links_no_referrer = true
28+
29+
[slugify]
30+
paths = "on"
31+
taxonomies = "on"
32+
anchors = "on"
33+
paths_keep_dates = true
34+
35+
[link_checker]
36+
internal_level = "error"
37+
external_level = "warn"
38+
39+
[extra]
40+
clean_default_bg_cover = "/img/blog-cover.png"
41+
42+
clean_blog_menu = [
43+
{ url = "$BASE_URL", name = "Home" },
44+
{ url = "$BASE_URL/series", name = "Series" },
45+
{ url = "$BASE_URL/notes", name = "Notes" },
46+
{ url = "$BASE_URL/about", name = "About" },
47+
{ url = "$BASE_URL/qemu", name = "Qemu VMs" },
48+
]
49+
50+
clean_blog_social = [
51+
{ icon = "fas fa-rss", url = "$BASE_URL/atom.xml" },
52+
{ icon = "fab fa-twitter", url = "https://twitter.com/ctf_blahcat" },
53+
{ icon = "fab fa-github", url = "https://github.com/blahcat" },
54+
{ icon = "fab fa-youtube", url = "https://www.youtube.com/channel/UCDrgY65mRZWVoMiB5-VMqfg" },
55+
{ icon = "fab fa-discord", url = "https://discord.gg/hSbqxxBgRX" },
56+
]

content/2013-06-20-I_feel_lucky.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
title: I feel lucky - or why I wrote a FreeBSD 1-day in one day
2-
author: hugsy
3-
category: research
4-
tags: freebsd, 1day, lpe
5-
date: 2013-06-20 00:00 +0000
6-
modified: 2013-06-20 00:00 +0000
1+
+++
2+
title = "I feel lucky - or why I wrote a FreeBSD 1-day in one day"
3+
authors = ["hugsy"]
4+
date = 2013-06-20T00:00:00Z
5+
updated = 2013-06-20T00:00:00Z
76

7+
[taxonomies]
8+
categories = ["research"]
9+
tags = ["freebsd", "1day", "lpe"]
10+
+++
811

912
Sometimes life gives you eggs for free, you just need to spend some time making an omelet. That's exactly what happened to me on a recent engagement for a client: a typical PHP webapp full of holes left me with a nice stable shell access.
1013

@@ -40,7 +43,9 @@ Index: sys/vm/vm_map.c
4043

4144
It kindda gave a good pointer of where to start: the usual rule for setuid dictates that a write access should immediately imply losing the elevated privilege. But this is where the bug was: by `mmap` a setuid binary (which any user can do), I can then choose to `ptrace` the process, and use `PT_WRITE` command to overwrite the `mmap`-ed memory, effectively overwriting the setuid binary!
4245

43-
<div markdown="span" class="alert-info"><i class="fa fa-info-circle">&nbsp;Note:</i> I was in a rush, so my exploit is partially destructive as I overwrite directly the setuid binary. If you choose to use it, please make a copy to be able to restore it.</div>
46+
{% note() %}
47+
I was in a rush, so my exploit is partially destructive as I overwrite directly the setuid binary. If you choose to use it, please make a copy to be able to restore it.
48+
{% end %}
4449

4550
My exploit was in 4 parts:
4651

@@ -86,7 +91,7 @@ My exploit was in 4 parts:
8691

8792
Done! Simply execute the target binary to get a root shell.
8893

89-
```shell
94+
```bash
9095
$ id
9196
uid=1001(user) gid=1001(user) groups=1001(user)
9297
$ gcc -Wall ./mmap.c && ./a.out

content/2013-12-23-read_write_process_memory_on_linux.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
title: Using new syscalls for read/write arbitrary memory on Linux.
2-
author: hugsy
3-
tags: linux, kernel, seccomp
4-
date: 2013-12-23 00:00 +0000
5-
modified: 2013-12-23 00:00 +0000
6-
category: research
1+
+++
2+
title = "Using new syscalls for read/write arbitrary memory on Linux."
3+
authors = ["hugsy"]
4+
date = 2013-12-23T00:00:00Z
5+
updated = 2013-12-23T00:00:00Z
6+
7+
[taxonomies]
8+
tags = ["linux", "kernel", "seccomp"]
9+
categories = ["research"]
10+
+++
711

812
Even though well known methods exist to bypass ptrace deactivation on a process when spawning (fake `ptrace()` preloading, breakpoint on `ptrace()`, etc... ), it is trickier when process is already protected.
913

10-
Thankfully Linux 3.2+ was generous enough to provide read/write capabilities to another process with 2 new system calls: `sys_process_vm_readv` and `sys_process_vm_writev`. (see [the source code](https://github.com/torvalds/linux/blob/master/arch/x86/entry/syscalls/syscall_64.tbl#L319)). For our Windows friend, those new syscalls are similar to `ReadProcessMemory()` and `WriteProcessMemory()`.
14+
Thankfully Linux 3.2+ was generous enough to provide read/write capabilities to another process with 2 new system calls: `sys_process_vm_readv` and `sys_process_vm_writev`. (see [the source code](https://github.com/torvalds/linux/blob/975f3b6da18020f1c8a7667ccb08fa542928ec03/arch/x86/entry/syscalls/syscall_64.tbl#L321)). For our Windows friend, those new syscalls are similar to `ReadProcessMemory()` and `WriteProcessMemory()`.
1115

1216
The manual says:
1317
> These system calls transfer data between the address space of the calling process ("the local process") and the process identified by pid ("the remote process"). The data moves directly between the address spaces of the two processes, without passing through kernel space.

0 commit comments

Comments
 (0)