-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
46 lines (41 loc) · 1.04 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"ARE-YOU-BOMBED/utils"
"fmt"
"log"
"os"
"strconv"
"github.com/gofiber/fiber/v2"
"github.com/joho/godotenv"
)
func home(c *fiber.Ctx) error {
return c.SendString("You're BOMBED!!!")
}
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
if len(os.Args) < 2 {
usage := "- Generate flat zip bomb\nCommand: go run main.go generate flat <number of files>\n\n- Generate nested zip bomb\nCommand: go run main.go generate nested <depth>\n\n- Run the server\nCommand: go run main.go host"
fmt.Println(usage)
return
}
Isgenerate := os.Args[1]
if Isgenerate == "generate" {
if os.Args[2] == "nested" {
levels, err := strconv.Atoi(os.Args[3])
utils.Check(err)
utils.GenerateNest(levels)
} else if os.Args[2] == "flat" {
count, err := strconv.Atoi(os.Args[3])
utils.Check(err)
utils.GenerateFlat(count)
}
} else if Isgenerate == "host" {
app := fiber.New()
app.Get("/", home)
app.Static("/static", "./bomb")
log.Fatal(app.Listen(":" + os.Getenv("PORT")))
}
}