feat: nix build

This commit is contained in:
qvalentin 2025-03-04 20:31:28 +01:00
parent f796973fbd
commit 5417d4d475
4 changed files with 34 additions and 1 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ __debug_bin*
.vscode
.coverage
result

16
default.nix Normal file
View file

@ -0,0 +1,16 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.buildGoModule {
pname = "wormspace";
version = "1.0.0";
src = pkgs.lib.cleanSource ./.;
vendorHash = "sha256-p0W/ubYYbIpmq7D7AN6CIF421nnURbZUX5rGAkbmwiI=";
meta = {
description = "XSS Worm demo";
homepage = "https://tea.filefighter.de/qvalentin/wormspace";
};
}

15
main.go
View file

@ -4,6 +4,8 @@ import (
"bytes"
"database/sql"
"fmt"
"os"
"strconv"
"strings"
"unicode"
@ -229,6 +231,7 @@ func profilePage(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.New("profile").Parse(`
<html><body>
<!-- contribute at https://tea.filefighter.de/qvalentin/wormspace -->
<nav>
<a href="/home">Home</a> | <a href="/profile?name={{.User.Name}}">My Profile</a>
</nav>
@ -259,6 +262,7 @@ func homePage(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.New("home").Parse(`
<html><body>
<!-- contribute at https://tea.filefighter.de/qvalentin/wormspace -->
<nav>
<a href="/home">Home</a> | <a href="/profile?name={{.User.Name}}">My Profile</a>
</nav>
@ -276,6 +280,7 @@ func homePage(w http.ResponseWriter, r *http.Request) {
func indexPage(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.New("index").Parse(`
<html><body>
<!-- contribute at https://tea.filefighter.de/qvalentin/wormspace -->
<h1>Welcome to Wormspace</h1>
<form action="/setuser" method="POST">
<input name="username" placeholder="Enter your username">
@ -294,5 +299,13 @@ func main() {
http.HandleFunc("/addpost", addPost)
http.HandleFunc("/addhero", addHero)
http.ListenAndServe(":8080", nil)
port := 8080
// get port from arg
if len(os.Args) > 1 {
port, _ = strconv.Atoi(os.Args[1])
}
fmt.Println("Listening on http://localhost:" + strconv.Itoa(port))
http.ListenAndServe(":"+strconv.Itoa(port), nil)
}

3
readme.md Normal file
View file

@ -0,0 +1,3 @@
# XSS-Wormdemo based on "The MySpace Worm"
https://samy.pl/myspace/tech.html