Skip to content

Commit

Permalink
Update writeup template
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-leitner committed Apr 30, 2022
1 parent 515ef12 commit d6ce763
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
17 changes: 12 additions & 5 deletions .templates/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# <LAB_NAME>
# Writeup: <LAB_NAME> @ PortSwigger Academy

![logo](img/logo.png)

This is a writeup for the lab "<LAB_NAME>" from PortSwiggers Web Security Academy:

<<LAB_LINK>>

Lab-Link: <<LAB_LINK>>
Difficulty: <LAB_LEVEL>
Python script: [script.py](script.py)

## Known information
## Lab description

-

### Goals

-
- Goals:
-

## Steps

Expand Down
Binary file added .templates/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 13 additions & 10 deletions create.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import os
import requests
from shutil import copy
from shutil import copytree
import sys


Expand Down Expand Up @@ -60,17 +60,20 @@ def get_details(url):
def create_skeleton(details):
template_dir = f'{os.path.dirname(os.path.realpath(__file__))}/.templates'
target_dir = os.path.join(os.getcwd(), details['title'][5:].replace(' ', '_'))
os.mkdir(target_dir)

for file in os.listdir(template_dir):
if os.path.isfile(f'{template_dir}/{file}'):
copy(f'{template_dir}/{file}', target_dir)
copytree(template_dir, target_dir)

for line in fileinput.input(f'{target_dir}/{file}', inplace=1):
line = line.replace('<LAB_NAME>', details['title'])
line = line.replace('<LAB_LINK>', details['url'])
line = line.replace('<LAB_LEVEL>', details['level'])
print(line, end='')
for file in os.listdir(target_dir):
logging.debug(f'file: {file}')

if not os.path.isfile(f'{target_dir}/{file}'):
continue

for line in fileinput.input(f'{target_dir}/{file}', inplace=1):
line = line.replace('<LAB_NAME>', details['title'][5:])
line = line.replace('<LAB_LINK>', details['url'])
line = line.replace('<LAB_LEVEL>', details['level'])
print(line, end='')


def main():
Expand Down

0 comments on commit d6ce763

Please sign in to comment.