Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Go version and dependencies, refine build steps and add flags … #12

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
check-latest: true
cache: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.21'
cache: true

- uses: goreleaser/goreleaser-action@v5
Expand Down
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="Center"> CoWitness </h1>
<h1 style="text-align: center"> CoWitness </h1>

<h3 align="center">
<h3 style="text-align: center">

![Images\CoWitness.png](https://github.com/officialjm/cowitness/blob/main/Images/CoWitness.png)

Expand Down Expand Up @@ -28,11 +28,11 @@

Before using CoWitness, ensure that you have the following requirements:

- Go programming language installed on your system, get it [HERE](https://go.dev/).
- Go programming language installed on your system, get it [HERE](https://go.dev/) go 1.21 required if building from source.
- Internet access to download Go dependencies.
- A remote server with a public IP address.

## Installation 👨🏼‍🔧
## Build 👨🏼‍🔧

Follow these steps to install and compile CoWitness:

Expand All @@ -51,12 +51,12 @@ cd CoWitness
3. Build the CoWitness executable:

```bash
go build cowitness.go
make -f Makefile build
```
This command compiles the CoWitness source code and creates an executable file.
This command compiles the CoWitness source code and creates an executable file for amd64 and arm64.


## Usage 👨🏻‍💻
## Installation 👨🏻‍💻

**To use CoWitness on a remote server, follow these steps**:

Expand All @@ -72,22 +72,20 @@ Connect to the remote server via SSH:
```bash
ssh username@your-server-ip
```
Navigate to the directory where you transferred the CoWitness executable and run the CoWitness executable:

Easy way to install cowitness is to get the automated package build from [here](https://github.com/stolenusername/cowitness/releases/latest)
which you can then curl or wget to your system or scp the file over from your system.
```bash
./CoWitness
cowitness
```

## Customization ⚒️

You can customize CoWitness to fit your specific needs. Here are some possible modifications:

- **Change the default ports**: Modify the constants `HTTPPort`, `HTTPSPort`, and `DNSPort` in the source code to use different port numbers.
- **Change the default ports**: See the usage help for the cli flags to change the default ports

- **Modify the log file paths**: You can change the paths for the HTTP and DNS log files (http.log and dns.log) by updating the `os.OpenFile` calls in the source code.

- **Customize the banner**: You can modify the ASCII art banner displayed when CoWitness starts by editing the displayBanner function in the source code.

<br></br>
### Community & Contributions

Expand Down
56 changes: 34 additions & 22 deletions cowitness.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"log"
"net"
Expand All @@ -13,27 +14,50 @@ import (
"github.com/miekg/dns"
)

const (
HTTPPort = 80
HTTPSPort = 443
DNSPort = 53
)

var (
DNSResponseIP string
DNSResponseName string
DefaultTTL int
DisplayBanner bool
DisplayVersion bool
HTTPPort int
HTTPSPort int
DNSPort int
)

func main() {
displayBanner()
func version() string {
return "v1.3"
}

func main() {
rootDir, err := os.Getwd()
if err != nil {
log.Fatal(err)
}

requestUserInputs()
flag.StringVar(&DNSResponseIP, "i", "", "The DNS response IP(required).")
flag.StringVar(&DNSResponseName, "n", "", "The DNS response name(required).")
flag.IntVar(&HTTPPort, "http", 80, "HTTP port")
flag.IntVar(&HTTPSPort, "https", 443, "HTTPS port")
flag.IntVar(&DNSPort, "dns", 53, "DNS port")
flag.IntVar(&DefaultTTL, "t", 3600, "The Time To Live.")
flag.BoolVar(&DisplayBanner, "q", false, "Disable banner output")
flag.BoolVar(&DisplayVersion, "v", false, "Print program version")
flag.Parse()

if DisplayVersion {
fmt.Print(version())
os.Exit(0)
}

if DisplayBanner != false {
} else {
displayBanner()
}

if DNSResponseIP == "" || DNSResponseName == "" {
log.Fatal("-i and -n are required. Please see help output with -h")
}

httpLogFile, dnsLogFile := createLogFiles()
defer closeLogFiles(httpLogFile, dnsLogFile)
Expand Down Expand Up @@ -68,17 +92,6 @@ func main() {
select {}
}

func requestUserInputs() {
fmt.Print("Enter the DNS response IP: ")
fmt.Scanln(&DNSResponseIP)

fmt.Print("Enter the DNS response name: ")
fmt.Scanln(&DNSResponseName)

fmt.Print("Enter the Default TTL: ")
fmt.Scanln(&DefaultTTL)
}

func createLogFiles() (*os.File, *os.File) {
httpLogFile, err := os.OpenFile("./http.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
Expand Down Expand Up @@ -196,7 +209,6 @@ func killDNSonExit() {
func displayBanner() {
red := "\033[31m"
reset := "\033[0m"
cowitnessVersion := "v1.1"
banner := red + `
⢠⡄
⣠⣤⣾⣷⣤⣄⡀⠀⠀⠀⠀
Expand All @@ -210,6 +222,6 @@ func displayBanner() {
` + reset

fmt.Print(banner)
fmt.Println(" CoWitness", cowitnessVersion, "- Tool for HTTP, HTTPS, and DNS Server")
fmt.Println(" CoWitness", version(), "- Tool for HTTP, HTTPS, and DNS Server")
fmt.Println()
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module cowitness

go 1.20
go 1.21

require github.com/miekg/dns v1.1.56
require github.com/miekg/dns v1.1.57

require (
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/tools v0.13.0 // indirect
)
15 changes: 8 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE=
github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY=
github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM=
github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=