-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 253bbbc
Showing
10 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ko_fi: dwisiswant0 | ||
custom: ["https://paypal.me/dw1s", "https://saweria.co/dwisiswant0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.11 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build | ||
run: go build . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release | ||
on: | ||
create: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Check out code" | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Set up Go" | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.13 | ||
|
||
- name: "Create release on GitHub" | ||
uses: goreleaser/goreleaser-action@v2 | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
with: | ||
args: "release --rm-dist" | ||
version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
builds: | ||
- binary: discat | ||
main: main.go | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- 386 | ||
- arm | ||
- arm64 | ||
|
||
archives: | ||
- id: tgz | ||
format: tar.gz | ||
replacements: | ||
darwin: macOS | ||
format_overrides: | ||
- goos: windows | ||
format: zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 dwisiswant0 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# discat | ||
|
||
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! | ||
## 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`. | ||
|
||
## Configuration | ||
|
||
**Step 1:** Get yours Discord channel webhook URL [here](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks). | ||
|
||
**Step 2** _(optional)_**:** Set `DISCORD_WEBHOOK_URL` environment variable. | ||
```bash | ||
export DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/xnxx/xxx-xxx" | ||
``` | ||
|
||
## Usage | ||
|
||
It's very simple! | ||
|
||
```bash | ||
▶ echo -e "Hello,\nworld!" | discat | ||
``` | ||
|
||
### Flags | ||
|
||
``` | ||
Usage of discat: | ||
-1 Send message line-by-line | ||
-u string | ||
Discord Webhook URL | ||
-v Verbose mode | ||
``` | ||
|
||
### Workaround | ||
|
||
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 | ||
``` | ||
|
||
The `-u` flag is optional if you've defined `DISCORD_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! | ||
|
||
```bash | ||
▶ nuclei -l urls.txt -t cves/ | discat | ||
``` | ||
|
||
![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 | ||
``` | ||
|
||
## License | ||
|
||
`discat` is distributed under MIT License. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module dw1.みんな/discat | ||
|
||
go 1.13 | ||
|
||
require github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d h1:licZJFw2RwpHMqeKTCYkitsPqHNxTmd4SNR5r94FGM8= | ||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"encoding/json" | ||
"flag" | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"strings" | ||
"sync" | ||
|
||
"github.com/acarl005/stripansi" | ||
) | ||
|
||
var wg sync.WaitGroup | ||
|
||
func main() { | ||
var oneLine, verboseMode bool | ||
var webhookURL, lines string | ||
|
||
flag.StringVar(&webhookURL, "u", "", "Discord 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") | ||
if webhookEnv != "" { | ||
webhookURL = webhookEnv | ||
} else { | ||
if webhookURL == "" { | ||
if verboseMode { | ||
fmt.Println("Discord Webhook URL not set!") | ||
} | ||
} | ||
} | ||
|
||
if !isStdin() { | ||
os.Exit(1) | ||
} | ||
|
||
sc := bufio.NewScanner(os.Stdin) | ||
for sc.Scan() { | ||
line := sc.Text() | ||
|
||
fmt.Println(line) | ||
if oneLine { | ||
if webhookURL != "" { | ||
wg.Add(1) | ||
go disCat(webhookURL, line) | ||
} | ||
} else { | ||
lines += line | ||
lines += "\n" | ||
} | ||
} | ||
|
||
if !oneLine { | ||
wg.Add(1) | ||
go disCat(webhookURL, lines) | ||
} | ||
wg.Wait() | ||
} | ||
|
||
func isStdin() bool { | ||
f, e := os.Stdin.Stat() | ||
if e != nil { | ||
return false | ||
} | ||
|
||
if f.Mode()&os.ModeNamedPipe == 0 { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
type data struct { | ||
Content string `json:"content"` | ||
} | ||
|
||
func disCat(url string, line string) { | ||
data, _ := json.Marshal(data{Content: stripansi.Strip(line)}) | ||
http.Post(url, "application/json", strings.NewReader(string(data))) | ||
wg.Done() | ||
} |