@@ -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
12450type 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
418355func 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