mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-07-08 05:17:49 +02:00
template function for base64
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"html"
|
||||
"html/template"
|
||||
@@ -431,6 +432,9 @@ func TemplateFuncs() template.FuncMap {
|
||||
goFormat := convertDateFormat(format)
|
||||
return targetTime.Format(goFormat)
|
||||
},
|
||||
"base64": func(s string) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(s))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@
|
||||
{ label: 'URL escape', text: '{{urlEscape "content" }}' },
|
||||
{ label: 'Random alphanumeric', text: '{{randAlpha 8}}' },
|
||||
{ label: 'Random number', text: '{{randInt 1 4}}' },
|
||||
{ label: 'Date', text: '{{date "Y-m-d H:i:s" 0}}' }
|
||||
{ label: 'Date', text: '{{date "Y-m-d H:i:s" 0}}' },
|
||||
{ label: 'Base64', text: '{{base64 "text"}}' }
|
||||
]
|
||||
};
|
||||
|
||||
@@ -228,6 +229,14 @@
|
||||
});
|
||||
}
|
||||
|
||||
// handle base64 function
|
||||
if (text.includes('{{base64')) {
|
||||
const r = /{{base64\s+"([^"]+)"}}/g;
|
||||
text = text.replace(r, (match, input) => {
|
||||
return btoa(input);
|
||||
});
|
||||
}
|
||||
|
||||
// handle date function with format and optional offset
|
||||
if (text.includes('{{date')) {
|
||||
const r = /{{date\s+"([^"]+)"\s*(-?\d+)?}}/g;
|
||||
|
||||
Reference in New Issue
Block a user