|
@@ -1,4 +1,114 @@
|
|
|
+/*
|
|
|
+ GNU GENERAL PUBLIC LICENSE
|
|
|
+ Version 3, 29 June 2007
|
|
|
+
|
|
|
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
|
+ Everyone is permitted to copy and distribute verbatim copies
|
|
|
+ of this license document, but changing it is not allowed.
|
|
|
+
|
|
|
+ http-wokou, An HTTP Proxying framework for bypassing DNS Security
|
|
|
+ Copyright (C) 2024 Russell Hrubesky, ChiralWorks Software LLC
|
|
|
+
|
|
|
+ This program is free software: you can redistribute it and/or modify
|
|
|
+ it under the terms of the GNU General Public License as published by
|
|
|
+ the Free Software Foundation, either version 3 of the License, or
|
|
|
+ (at your option) any later version.
|
|
|
+
|
|
|
+ This program is distributed in the hope that it will be useful,
|
|
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
+ GNU General Public License for more details.
|
|
|
+
|
|
|
+ You should have received a copy of the GNU General Public License
|
|
|
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
+
|
|
|
+*/
|
|
|
+
|
|
|
package httpserver
|
|
|
|
|
|
-const HTTPS_PORT = 443
|
|
|
-const HTTP_PORT = 80
|
|
|
+import (
|
|
|
+ "bufio"
|
|
|
+ "fmt"
|
|
|
+ "io"
|
|
|
+ "log"
|
|
|
+ "os"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+var prompts = [...]string{
|
|
|
+ "Name of the cookie: ",
|
|
|
+ "Value to supply it: ",
|
|
|
+ "Max age of the cookie (default=0, for no expiry): ",
|
|
|
+ "URI path to include it for (default=/): ",
|
|
|
+ "Domain that the cookie belongs to: ",
|
|
|
+ "HTTPS only? (default yes) y/n: ",
|
|
|
+ "Include it in subdomains? (default=y) y/n: ",
|
|
|
+}
|
|
|
+
|
|
|
+type CookiePrompt struct {
|
|
|
+ Name map[string]string
|
|
|
+ Value map[string]string
|
|
|
+ Age map[string]string
|
|
|
+ Uri map[string]string
|
|
|
+ Domain map[string]string
|
|
|
+ Https map[string]bool
|
|
|
+ Subd map[string]bool
|
|
|
+}
|
|
|
+
|
|
|
+func NewCookiePrompt() *CookiePrompt {
|
|
|
+ return &CookiePrompt{
|
|
|
+ Name: map[string]string{
|
|
|
+ "Name of the cookie: ": "",
|
|
|
+ },
|
|
|
+ Value: map[string]string{
|
|
|
+ "Cookie value: ": "",
|
|
|
+ },
|
|
|
+ Age: map[string]string{
|
|
|
+ "Max age of the cookie (default=0, for no expiry): ": "0",
|
|
|
+ },
|
|
|
+ Uri: map[string]string{
|
|
|
+ "URI path to include it for (default=/): ": "/",
|
|
|
+ },
|
|
|
+ Domain: map[string]string{
|
|
|
+ "Domain that the cookie belongs to: ": "",
|
|
|
+ },
|
|
|
+ Https: map[string]bool{
|
|
|
+ "HTTPS only? (default yes) y/n: ": true,
|
|
|
+ },
|
|
|
+ Subd: map[string]bool{
|
|
|
+ "Include it in subdomains? (default=y) y/n: ": true,
|
|
|
+ },
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func (c *CookiePrompt) SetName(reader *io.Reader) {
|
|
|
+ fmt.Print(c.Name[0])
|
|
|
+ ans, err := reader.ReadString('\n')
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("couldnt read input: ", err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+Open an interactive prompt for a user to save cookies to
|
|
|
+*/
|
|
|
+func AddCookiePrompt() {
|
|
|
+ answers := NewCookiePrompt()
|
|
|
+ reader := bufio.NewReader(os.Stdin)
|
|
|
+ for idx := range prompts {
|
|
|
+ fmt.Print()
|
|
|
+ ans, err := reader.ReadString('\n')
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("Fatal error when reading cookie creation input: ", err)
|
|
|
+ }
|
|
|
+ ans = strings.TrimSuffix(ans, "\n")
|
|
|
+ if prompts[idx] == "HTTPS only? (default yes) y/n: " {
|
|
|
+ if ans == "y" {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for i := range answers {
|
|
|
+ fmt.Println(answers[i])
|
|
|
+ }
|
|
|
+}
|