Skip to content

Commit dbecd4f

Browse files
committed
feat: update default theme to include animations
1 parent f3ac3da commit dbecd4f

9 files changed

Lines changed: 1049 additions & 78 deletions

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type Config struct {
6868
showErrors bool // returns the standard output even if the command exits with a non-zero exit code
6969
includeStderr bool // also returns output written to stderr (default is stdout only)
7070
intServerErr bool // return 500 error if shell status code != 0
71+
noAnimations bool // disable UI animations
7172
formCheckRe *regexp.Regexp // regexp for check form fields
7273
}
7374

@@ -108,6 +109,7 @@ func getConfig() (*Config, error) {
108109
flag.StringVar(&cfg.key, "key", "", "SSL private key `/path/...`")
109110
flag.Var(&cfg.auth, "basic-auth", "setup HTTP Basic Authentication (\"user_name:password\"), can be used several times")
110111
flag.IntVar(&cfg.timeout, "timeout", 0, "set `timeout` for execute shell command (in seconds)")
112+
flag.BoolVar(&cfg.noAnimations, "no-animations", false, "disable UI animations on the index page")
111113

112114
formCheck := flag.String("form-check", "", "regexp for check form fields (pass only vars that match the regexp)")
113115

images/Bounty-Jackal-card.png

270 KB
Loading

images/Chatty-Spider.png

54.6 KB
Loading

images/Punk-Spider-card.png

253 KB
Loading

images/favicon-16.png

586 Bytes
Loading

images/favicon-32.png

1.28 KB
Loading

images/liminal-panda-card.png

449 KB
Loading

shell2http.go

Lines changed: 19 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -46,80 +46,6 @@ const (
4646
maxMemoryForUploadFile = 65536
4747
)
4848

49-
// indexTmpl - template for index page
50-
const indexTmpl = `<!DOCTYPE html>
51-
<!-- Served by shell2http/%s -->
52-
<html>
53-
<head>
54-
<title>❯ CrowdStrike's VulnApp</title>
55-
<link rel="icon" href="/images/logo.png">
56-
<style>
57-
body {
58-
font-family: sans-serif;
59-
background-color: #17161a;
60-
}
61-
li {
62-
list-style-type: none;
63-
}
64-
li:before {
65-
content: "❯";
66-
padding-right: 5px;
67-
}
68-
h1, h2, h3 {
69-
color: #fff;
70-
opacity: 0.87;
71-
}
72-
p {
73-
color: #fff;
74-
opacity: 0.75;
75-
}
76-
.links, a {
77-
color: #fff;
78-
};
79-
.hero {
80-
margin: auto;
81-
width: 100%%;
82-
flex-shrink: 1;
83-
}
84-
.welcome {
85-
margin: auto;
86-
max-width: 600px;
87-
}
88-
.container {
89-
display: flex;
90-
flex-direction: row;
91-
flex-grow: 1;
92-
flex-wrap: wrap;
93-
background-color: #000;
94-
</style>
95-
</head>
96-
<header>
97-
<div class="header" style="display: flex; flex-direction: row; align-items: center;">
98-
<img class="logo" style="height: 75%%; padding-top: 8px" src="images/logo_crowdstrike.png">
99-
<span class="separator" style="color: #fff; padding: 10px;"> | </span>
100-
<h2>VulnApp</h2>
101-
</div>
102-
</header>
103-
<body>
104-
<div class="container">
105-
<div class="welcome">
106-
<h1>Welcome to vulnerable.example.com</h1>
107-
108-
<p>This web application runs on a Kubernetes cluster utilizing CrowdStrke's Falcon sensor running via DaemonSet or as a Sidecar.</p>
109-
<p>The web application will allow you to execute various exploitation techniques as if it was an attacker exploiting the application. The Falcon sensor will recognize this malicious behavior and report it back to the Falcon Console.</p>
110-
111-
<p>You can view output of <a class="links" href="/ps">ps command</a> to see view process running within the same pod as this application.</p>
112-
</div>
113-
<img class="hero" src="images/hero-homepage.png">
114-
</div>
115-
<h3>Detections</h3>
116-
<ul>
117-
%s
118-
</ul>
119-
</body>
120-
</html>
121-
`
122-
12349
// command - one command
12450
type command struct {
12551
path string
@@ -225,7 +151,7 @@ func getShellHandler(appConfig Config, shell string, params []string, cacheTTL r
225151
rw.WriteHeader(http.StatusInternalServerError)
226152
}
227153

228-
responseWrite(rw, outText)
154+
responseWrite(rw, stripANSI(outText))
229155
}
230156
}
231157

@@ -357,7 +283,7 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB
357283
if row.httpMethod != "" {
358284
methodDesc = row.httpMethod + ": "
359285
}
360-
indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s%s</a> <span style="color: #888">- %s<span></li>`, path, methodDesc, path, describeCmd(cmd))
286+
indexLiHTML += fmt.Sprintf(`<li><a href=".%s">%s%s</a> <span>- %s<span></li>`, path, methodDesc, path, describeCmd(cmd))
361287
cmdsForLog[path] = append(cmdsForLog[path], cmd)
362288

363289
handler := mwMethodOnly(getShellHandler(appConfig, shell, params, cacheTTL), row.httpMethod)
@@ -395,7 +321,11 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB
395321

396322
// --------------
397323
if !appConfig.noIndex && !existsRootPath {
398-
indexHTML := fmt.Sprintf(indexTmpl, version, indexLiHTML)
324+
animAttr := ""
325+
if appConfig.noAnimations {
326+
animAttr = ` data-animations="off"`
327+
}
328+
indexHTML := fmt.Sprintf(indexTmpl, version, animAttr, indexLiHTML)
399329
resultHandlers = append(resultHandlers, command{
400330
path: "/",
401331
cmd: "index page",
@@ -414,6 +344,13 @@ func setupHandlers(cmdHandlers []command, appConfig Config, cacheTTL raphanus.DB
414344
return resultHandlers, nil
415345
}
416346

347+
var reANSI = regexp.MustCompile(`\x1b\[[0-9;]*[a-zA-Z]`)
348+
349+
// stripANSI removes ANSI escape sequences from s.
350+
func stripANSI(s string) string {
351+
return reANSI.ReplaceAllString(s, "")
352+
}
353+
417354
// responseWrite - write text to response
418355
func responseWrite(rw io.Writer, text string) {
419356
if _, err := io.WriteString(rw, text); err != nil {
@@ -677,7 +614,11 @@ func main() {
677614
http.HandleFunc(handler.path, handlerFunc)
678615
log.Printf("register: %s (%s)\n", handler.path, handler.cmd)
679616
}
680-
fs := http.FileServer(http.Dir("/images"))
617+
imagesDir := "/images"
618+
if _, err := os.Stat(imagesDir); os.IsNotExist(err) {
619+
imagesDir = "images"
620+
}
621+
fs := http.FileServer(http.Dir(imagesDir))
681622
http.Handle("/images/", http.StripPrefix("/images/", fs))
682623

683624
listener, err := net.Listen("tcp", net.JoinHostPort(appConfig.host, strconv.Itoa(appConfig.port)))

0 commit comments

Comments
 (0)