Skip to content

Commit

Permalink
Initial release, tested, and working with webex
Browse files Browse the repository at this point in the history
  • Loading branch information
eforbus committed Feb 26, 2021
1 parent 253bbbc commit b297936
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 32 deletions.
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Created by https://www.toptal.com/developers/gitignore/api/go
# Edit at https://www.toptal.com/developers/gitignore?templates=go

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

### Go Patch ###
/vendor/
/Godeps/

# End of https://www.toptal.com/developers/gitignore/api/go
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
builds:
- binary: discat
- binary: webexcat
main: main.go
goos:
- linux
Expand All @@ -10,7 +10,7 @@ builds:
- 386
- arm
- arm64

archives:
- id: tgz
format: tar.gz
Expand Down
36 changes: 17 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
# discat
# webexcat

A simple way of sending messages from the CLI output to your Discord channel with webhook.
> Actually, this is a fork version of [slackcat](https://github.com/dwisiswant0/slackcat) that I made too!
A simple way of sending messages from the CLI output to your Webex space with webhook.
> Actually, this is a fork version of [discat](https://github.com/dwisiswant0/discat) which is a fork of [slackcat](https://github.com/dwisiswant0/slackcat).
## Installation

- Download a prebuilt binary from [releases page](https://github.com/dwisiswant0/discat/releases/latest), unpack and run! or
- If you have go1.13+ compiler installed: `go get dw1.みんな/discat`.
- Download a prebuilt binary from [releases page](https://github.com/eforbus/webexcat/releases/latest), unpack and run! or
- If you have go1.13+ compiler installed: `go get github.com/eforbus/webexcat`.

## Configuration

**Step 1:** Get yours Discord channel webhook URL [here](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks).
**Step 1:** Get your Webex space webhook URL [here](https://apphub.webex.com/messaging/applications/incoming-webhooks-cisco-systems-38054)

**Step 2** _(optional)_**:** Set `DISCORD_WEBHOOK_URL` environment variable.
**Step 2** _(optional)_**:** Set `WEBEX_WEBHOOK_URL` environment variable.
```bash
export DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/xnxx/xxx-xxx"
export WEBEX_WEBHOOK_URL="https://webexapis.com/v1/webhooks/incoming/XXX"
```

## Usage

It's very simple!

```bash
echo -e "Hello,\nworld!" | discat
echo -e "Hello,\nworld!" | webexcat
```

### Flags

```
Usage of discat:
Usage of webexcat:
-1 Send message line-by-line
-u string
Discord Webhook URL
Webex Webhook URL
-v Verbose mode
```

Expand All @@ -40,27 +40,25 @@ Usage of discat:
The goal is to get automated alerts for interesting stuff!

```bash
▶ assetfinder twitter.com | anew | discat -u https://hooks.discord.com/services/xxx/xxx/xxx
▶ assetfinder twitter.com | anew | webexcat -u https://webexapis.com/v1/webhooks/incoming/XXX
```

The `-u` flag is optional if you've defined `DISCORD_WEBHOOK_URL` environment variable.
The `-u` flag is optional if you've defined `WEBEX_WEBHOOK_URL` environment variable.

Discat also strips the ANSI colors from stdin to send messages, so you'll receive a clean message on your Discord!
webexcat also strips the ANSI colors from stdin to send messages, so you'll receive a clean message on your space!

```bash
▶ nuclei -l urls.txt -t cves/ | discat
▶ nuclei -l urls.txt -t cves/ | webexcat
```

![Proof](https://user-images.githubusercontent.com/25837540/108782401-1571e380-759e-11eb-8d20-dfcc9294a30a.png)

### Line-by-line

Instead of have to wait for previously executed program to finish, use the `-1` flag if you want to send messages on a line by line _(default: false)_.

```bash
▶ amass track -d domain.tld | discat -1
▶ amass track -d domain.tld | webexcat -1
```

## License

`discat` is distributed under MIT License.
`webexcat` is distributed under MIT License.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module dw1.みんな/discat
module github.com/eforbus/webexcat

go 1.13
go 1.15

require github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
14 changes: 7 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ func main() {
var oneLine, verboseMode bool
var webhookURL, lines string

flag.StringVar(&webhookURL, "u", "", "Discord Webhook URL")
flag.StringVar(&webhookURL, "u", "", "Webex Webhook URL")
flag.BoolVar(&oneLine, "1", false, "Send message line-by-line")
flag.BoolVar(&verboseMode, "v", false, "Verbose mode")
flag.Parse()

webhookEnv := os.Getenv("DISCORD_WEBHOOK_URL")
webhookEnv := os.Getenv("WEBEX_WEBHOOK_URL")
if webhookEnv != "" {
webhookURL = webhookEnv
} else {
if webhookURL == "" {
if verboseMode {
fmt.Println("Discord Webhook URL not set!")
fmt.Println("Webex Webhook URL not set!")
}
}
}
Expand All @@ -47,7 +47,7 @@ func main() {
if oneLine {
if webhookURL != "" {
wg.Add(1)
go disCat(webhookURL, line)
go webexCat(webhookURL, line)
}
} else {
lines += line
Expand All @@ -57,7 +57,7 @@ func main() {

if !oneLine {
wg.Add(1)
go disCat(webhookURL, lines)
go webexCat(webhookURL, lines)
}
wg.Wait()
}
Expand All @@ -76,10 +76,10 @@ func isStdin() bool {
}

type data struct {
Content string `json:"content"`
Content string `json:"markdown"`
}

func disCat(url string, line string) {
func webexCat(url string, line string) {
data, _ := json.Marshal(data{Content: stripansi.Strip(line)})
http.Post(url, "application/json", strings.NewReader(string(data)))
wg.Done()
Expand Down
Binary file renamed discat → webexcat
Binary file not shown.

0 comments on commit b297936

Please sign in to comment.