Skip to content

Commit 2c4b52c

Browse files
author
tkokhing
committed
re-org kill-chain into sub-folders, api routing, defined const to dynamically display IP_addr, beautify blog
1 parent 1d3ab43 commit 2c4b52c

7 files changed

Lines changed: 79 additions & 12 deletions

File tree

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/_components/post_gen/post-body-client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default function PostBodyClient({ children }: { children: React.ReactNode
1515
prose-strong:font-extrabold
1616
prose-em:text-sky-900 dark:prose-em:text-violet-100
1717
prose-em:font-extrabold
18+
prose-li:text-gray-600 dark:prose-li:text-slate-300
1819
prose-ul:text-gray-600 dark:prose-ul:text-slate-300
1920
prose-table:text-zinc-700 dark:prose-table:text-zinc-300
2021
prose-code:before:content-[''] prose-code:after:content-['']

src/app/_components/preference/toggle-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function ToggleFrame({ label, children, defaultOpen = false }: Props) {
3131
<button
3232
type="button"
3333
onClick={handleToggle}
34-
className="text-left text-lg font-semibold underline text-blue-800 dark:text-blue-300 hover:text-tkokhing-blue hover:dark:text-tkokhing-dark transition"
34+
className="text-left text-xs font-semibold underline text-blue-800 dark:text-blue-300 hover:text-tkokhing-blue hover:dark:text-tkokhing-dark transition"
3535
>
3636
{label}&nbsp;{isOpen ? "▼" : "▶"}
3737
</button>

src/app/heptagoning/kill-chain/recon/[slug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// [tkokhing/frontier_post/_frontier_post/_frontier] MDX_FOLDER
1+
// [tkokhing/heptagoning/_heptagoning/_kill-chain/_recon] MDX_FOLDER
22
import { Metadata } from "next";
33
import { notFound } from "next/navigation";
44
import Container from "@/app/_components/preference/container";
@@ -12,7 +12,7 @@ import Alert from "@/app/_components/blog_frame/alert";
1212
import Note from "@/app/_components/blog_frame/note";
1313
import Tip from "@/app/_components/blog_frame/tip";
1414

15-
const MDX_FOLDER = "_heptagoning/_kill-chain";
15+
const MDX_FOLDER = "_heptagoning/_kill-chain/_recon";
1616

1717
type Params = {
1818
params: Promise<{
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// [tkokhing/heptagoning/_heptagoning/_kill-chain/_weaponise] MDX_FOLDER
2+
import { Metadata } from "next";
3+
import { notFound } from "next/navigation";
4+
import Container from "@/app/_components/preference/container";
5+
import { PostHeader } from "@/app/_components/post_gen/post-header";
6+
import { PostBody } from "@/app/_components/post_gen/post-body";
7+
import { getPostBySlug } from "@/lib/share/api";
8+
import { generatePageMetadata } from "@/lib/share/generatePageMetadata";
9+
import { generatePageStaticParams } from "@/lib/share/generatePageStaticParams";
10+
import { NMAP_Overview } from "@/lib/_data_exporter/data_kiil-chain/kill-chain_exporter";
11+
import Alert from "@/app/_components/blog_frame/alert";
12+
import Note from "@/app/_components/blog_frame/note";
13+
import Tip from "@/app/_components/blog_frame/tip";
14+
15+
const MDX_FOLDER = "_heptagoning/_kill-chain/_weaponise";
16+
17+
type Params = {
18+
params: Promise<{
19+
slug: string;
20+
}>;
21+
};
22+
23+
export default async function Post(props: Params) {
24+
const params = await props.params;
25+
const ImportComponents = {
26+
Tip,
27+
Note,
28+
Alert,
29+
NMAP_Overview,
30+
};
31+
const post = getPostBySlug(params.slug, MDX_FOLDER);
32+
if (!post || post.subPath != 'heptagoning/kill-chain/weaponise') return notFound();
33+
34+
return (
35+
<main>
36+
<Container>
37+
<article className="mb-32">
38+
<PostHeader
39+
title={post.title}
40+
coverImage={post.coverImage}
41+
date={post.date}
42+
author={post.author}
43+
subPath={post.subPath}
44+
postStatus={post.postStatus}
45+
/>
46+
<PostBody content={post.content} components={ImportComponents}/>
47+
</article>
48+
</Container>
49+
</main>
50+
);
51+
}
52+
53+
export async function generateMetadata(props: Params): Promise<Metadata> {
54+
const params = await props.params;
55+
return generatePageMetadata(params.slug, MDX_FOLDER);
56+
}
57+
58+
export async function generateStaticParams() {
59+
return generatePageStaticParams(MDX_FOLDER);
60+
}

src/lib/share/api.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,31 @@ function postsDirectory(mdx_folder: string): string{
1818
}
1919

2020
function getPostSlugs(mdx_folder: string) {
21-
return fs.readdirSync(postsDirectory(mdx_folder));
21+
return fs
22+
.readdirSync(postsDirectory(mdx_folder), { withFileTypes: true })
23+
.filter(entry => entry.isFile() && entry.name.endsWith(".mdx"))
24+
.map(entry => entry.name);
2225
}
2326

24-
export function getPostBySlug(slug: string, mdx_folder: string){
27+
export function getPostBySlug(slug: string, mdx_folder: string) {
2528
const realSlug = slug.replace(/\.mdx?$/, "");
2629
const fullPath = join(postsDirectory(mdx_folder), `${realSlug}.mdx`);
30+
2731
const fileContents = fs.readFileSync(fullPath, "utf8");
2832
const { data, content } = matter(fileContents);
33+
2934
const BASE_PATH = useBasePath();
30-
35+
3136
// Update URLs based on the environment
3237
data.coverImage = data.coverImage.startsWith(BASE_PATH) ? data.coverImage : `${BASE_PATH}${data.coverImage}`;
3338
data.author.picture = data.author.picture.startsWith(BASE_PATH) ? data.author.picture : `${BASE_PATH}${data.author.picture}`;
3439
data.ogImage.url = data.ogImage.url.startsWith(BASE_PATH) ? data.ogImage.url : `${BASE_PATH}${data.ogImage.url}`;
40+
3541
return { ...data, slug: realSlug, content } as Post;
3642
}
3743

3844
export function getAllPosts(mdx_folder: string): Post[] {
3945
const slugs = getPostSlugs(mdx_folder);
40-
const posts = slugs.map((slug) => getPostBySlug(slug, mdx_folder));
46+
const posts = slugs.map(slug => getPostBySlug(slug, mdx_folder));
4147
return posts.sort((post1, post2) => (post1.date > post2.date ? -1 : 1));
4248
}

src/lib/share/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const LOGO_PATH = "/img/logo";
55
export const REPO_NAME = ""; // for future expansion use
66
export const T_ANI_GIF_URL = `${LOGO_PATH}/tkokhing.gif`;
77
export const TKOKHING_LOGO_SVG_URL = `${LOGO_PATH}/tkokhing.svg`;
8-
export const VICTIM1_IP = "10.10.4.6";
9-
export const VICTIM1_PORT = "80";
8+
export const VICTIM1_IP = "172.17.0.2";
9+
export const VICTIM1_PORT = "8080";
1010
export const ATTACKER_IP = "10.4.6.114";
1111
export const ATTACKER_PORT = "4444";

0 commit comments

Comments
 (0)