Skip to content

Commit bb8fbf2

Browse files
committed
update: add templates for host, service, and user
1 parent 7f56c27 commit bb8fbf2

File tree

5 files changed

+112
-76
lines changed

5 files changed

+112
-76
lines changed

.foam/templates/host.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: ${1:$TM_FILENAME_BASE}
3+
tags: host
4+
foam_template:
5+
filepath: 'hosts/$FOAM_TITLE/$FOAM_TITLE.md'
6+
name: 'host'
7+
description: 'note when hacking a host'
8+
---
9+
10+
### ${1:$TM_FILENAME_BASE}
11+
12+
#### host alias
13+
14+
- ${1:$TM_FILENAME_BASE}
15+
- ip:
16+
17+
#### ports
18+
19+
##### 80
20+
21+
#### information
22+
23+
1. Linux/Windows
24+
2. Kernel version
25+
3. ...
26+
27+
##### Nmap
28+
```
29+
30+
```
31+
32+
#### vulnerabilities / exploits
33+
34+
privsec problem with user xxxx and using exploit
35+
36+
#### related information
37+
38+
##### services
39+
40+
##### users
41+
42+
#### proof
43+
44+
local proof? machine proof? screenshot?

.foam/templates/service.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: ${1:$TM_FILENAME_BASE}
3+
tags: service
4+
foam_template:
5+
filepath: 'services/$FOAM_TITLE/$FOAM_TITLE.md'
6+
name: 'service'
7+
description: 'note when access/hacking a service'
8+
---
9+
10+
### ${1:$TM_FILENAME_BASE}
11+
12+
#### service alias
13+
14+
- ${1:$TM_FILENAME_BASE}
15+
16+
#### location
17+
18+
On host yyy port xxx
19+
20+
#### information
21+
22+
1.
23+
2.
24+
3.
25+
26+
#### vulnerabilities / exploits

.foam/templates/user.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: ${1:$TM_FILENAME_BASE}
3+
tags: user
4+
foam_template:
5+
filepath: 'users/$FOAM_TITLE/$FOAM_TITLE.md'
6+
name: 'user'
7+
description: 'note when getting a user'
8+
---
9+
10+
### ${1:$TM_FILENAME_BASE}
11+
12+
#### validated credentials
13+
14+
```yaml
15+
- login: ${FOAM_TITLE/^(\S*)@//}
16+
user: ${FOAM_TITLE/@(\S*)$//}
17+
password: pass
18+
```
19+
20+
#### information
21+
22+
1.
23+
2.
24+
3.
25+
26+
#### Privileges / roles / groups
27+
28+
29+
30+
31+
32+

.vscode/.zshrc

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -174,81 +174,6 @@ function clean_project_structure () {
174174
echo "Project Folder sturcture cleaned completed!"
175175
}
176176

177-
function new-user () {
178-
local name=$1
179-
echo "Creating new user..."
180-
if [[ -z "${name}" ]]; then
181-
echo "Usage: $0 <name>";
182-
return -1;
183-
fi
184-
mkdir ${PROJECT_FOLDER}/users/$name
185-
echo "# $name" > ${PROJECT_FOLDER}/users/$name/$name.md
186-
echo "* [[$name]]" >> ${PROJECT_FOLDER}/users/user-list.md
187-
echo "User $name created!"
188-
}
189-
190-
function del-user () {
191-
local name=$1
192-
echo "Deleting user..."
193-
if [[ -z "${name}" ]]; then
194-
echo "Usage: $0 <name>";
195-
return -1;
196-
fi
197-
rm -rf ${PROJECT_FOLDER}/users/$name
198-
sed -i '' -e "/\* \[\[$name\]\]/d" ${PROJECT_FOLDER}/users/user-list.md
199-
echo "User $name deleted!"
200-
}
201-
202-
function new-host () {
203-
local name=$1
204-
echo "Creating new host..."
205-
if [[ -z "${name}" ]]; then
206-
echo "Usage: $0 <name>";
207-
return -1;
208-
fi
209-
mkdir ${PROJECT_FOLDER}/hosts/$name
210-
echo "# $name" > ${PROJECT_FOLDER}/hosts/$name/$name.md
211-
echo "* [[$name]]" >> ${PROJECT_FOLDER}/hosts/host-list.md
212-
echo "Host $name created!"
213-
}
214-
215-
function del-host () {
216-
local name=$1
217-
echo "Deleting host..."
218-
if [[ -z "${name}" ]]; then
219-
echo "Usage: $0 <name>";
220-
return -1;
221-
fi
222-
rm -rf ${PROJECT_FOLDER}/hosts/$name
223-
sed -i "" -e "/\* \[\[$name\]\]/d" ${PROJECT_FOLDER}/hosts/host-list.md
224-
echo "Host $name deleted!"
225-
}
226-
227-
function new-service () {
228-
local name=$1
229-
echo "Creating new service..."
230-
if [[ -z "${name}" ]]; then
231-
echo "Usage: $0 <name>";
232-
return -1;
233-
fi
234-
mkdir ${PROJECT_FOLDER}/services/$name
235-
echo "# $name" > ${PROJECT_FOLDER}/services/$name/$name.md
236-
echo "* [[$name]]" >> ${PROJECT_FOLDER}/services/service-list.md
237-
echo "Service $name created!"
238-
}
239-
240-
function del-service () {
241-
local name=$1
242-
echo "Deleting service..."
243-
if [[ -z "${name}" ]]; then
244-
echo "Usage: $0 <name>";
245-
return -1;
246-
fi
247-
rm -rf ${PROJECT_FOLDER}/services/$name
248-
sed -i "" -e "/\* \[\[$name\]\]/d" ${PROJECT_FOLDER}/services/service-list.md
249-
echo "Service $name deleted!"
250-
}
251-
252177
# change hist file location in project.
253178
HISTSIZE=100000000
254179
SAVEHIST=100000000

craft.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ def read_file(filename):
3232

3333
vscode_path = ".vscode"
3434

35+
foam_template = ".foam/templates"
36+
3537
template_head = """#!/bin/zsh
3638
# __ __ __ ______ ____ _
3739
# \ \ / /__ __ _ _ __ ___ _ _\ \ / / ___| / ___|___ __| | ___
@@ -54,6 +56,7 @@ def read_file(filename):
5456
return 1
5557
fi
5658
mkdir -p $1/.vscode
59+
mkdir -p $1/.foam/templates
5760
"""
5861

5962
template_body = """
@@ -63,6 +66,7 @@ def read_file(filename):
6366

6467
template_tail = """
6568
echo "*" > $1/.vscode/.gitignore
69+
echo "*" > $1/.foam/.gitignore
6670
echo "!env.zsh" >> $1/.vscode/.gitignore
6771
echo "!metasploit_handler.rc" >> $1/.vscode/.gitignore
6872
echo "!msfconsole.rc" >> $1/.vscode/.gitignore
@@ -92,7 +96,12 @@ def generate_bash_script():
9296
replace("__KEY__", filename_to_variable_name(key)). \
9397
replace("__VALUE__", value). \
9498
replace("__FILEPATH__", key)
95-
99+
for key, value in create_value_map(foam_template).items():
100+
bash_script_content += \
101+
template_body. \
102+
replace("__KEY__", filename_to_variable_name(key)). \
103+
replace("__VALUE__", value). \
104+
replace("__FILEPATH__", key)
96105
bash_script_content += template_tail. \
97106
replace("__LAUNCH_HELPER__", read_file("launch_helper.zsh"))
98107

0 commit comments

Comments
 (0)