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

Adding responder + impacket wrappers #59

Merged
merged 19 commits into from
Sep 3, 2021
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
3 changes: 3 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
Expand All @@ -20,6 +21,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
Expand All @@ -29,6 +31,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16

- name: Check out code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.16
-
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
Expand Down
36 changes: 22 additions & 14 deletions cmd/interactsh-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ import (
"github.com/projectdiscovery/interactsh/pkg/server"
)

var (
serverURL = flag.String("url", "https://interact.sh", "URL of the interactsh server")
n = flag.Int("n", 1, "Number of interactable URLs to generate")
output = flag.String("o", "", "File to write output to")
json = flag.Bool("json", false, "Show JSON output")
verbose = flag.Bool("v", false, "Show verbose output")
pollInterval = flag.Int("poll-interval", 5, "Number of seconds between each poll request")
persistent = flag.Bool("persist", false, "Enables persistent interactsh sessions")
dnsOnly = flag.Bool("dns-only", false, "Display only dns requests in verbose output")
httpOnly = flag.Bool("http-only", false, "Display only http requests in verbose output")
smtpOnly = flag.Bool("smtp-only", false, "Display smtp interactions")
token = flag.String("token", "", "Authentication token for the server")
)

const banner = `
_ __ __ __
(_)___ / /____ _________ ______/ /______/ /_
Expand All @@ -45,6 +31,20 @@ func showBanner() {
}

func main() {

flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
serverURL := flag.String("url", "https://interact.sh", "URL of the interactsh server")
n := flag.Int("n", 1, "Number of interactable URLs to generate")
output := flag.String("o", "", "File to write output to")
json := flag.Bool("json", false, "Show JSON output")
verbose := flag.Bool("v", false, "Show verbose output")
pollInterval := flag.Int("poll-interval", 5, "Number of seconds between each poll request")
persistent := flag.Bool("persist", false, "Enables persistent interactsh sessions")
dnsOnly := flag.Bool("dns-only", false, "Display only dns requests in verbose output")
httpOnly := flag.Bool("http-only", false, "Display only http requests in verbose output")
smtpOnly := flag.Bool("smtp-only", false, "Display smtp interactions")
token := flag.String("token", "", "Authentication token for the server")

flag.Parse()

showBanner()
Expand Down Expand Up @@ -104,6 +104,14 @@ func main() {
}
writeOutput(outputFile, builder)
}
case "responder", "smb":
if noFilter {
builder.WriteString(fmt.Sprintf("Received Responder/Smb interaction at %s", interaction.Timestamp.Format("2006-01-02 15:04:05")))
if *verbose {
builder.WriteString(fmt.Sprintf("\n------------\nResponder/SMB Interaction\n------------\n\n%s\n\n", interaction.RawRequest))
}
writeOutput(outputFile, builder)
}
}
} else {
b, err := jsonpkg.MarshalIndent(interaction, "", "\t")
Expand Down
10 changes: 10 additions & 0 deletions cmd/interactsh-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.8-alpine as compile
WORKDIR /opt
RUN apk add --no-cache git gcc musl-dev python3-dev libffi-dev openssl-dev cargo
RUN python3 -m pip install virtualenv
RUN virtualenv -p python venv
ENV PATH="/opt/venv/bin:$PATH"
RUN git clone --depth 1 https://github.com/SecureAuthCorp/impacket.git
RUN python3 -m pip install impacket/
RUN git clone --depth 1 https://github.com/lgandx/Responder.git
ENTRYPOINT ["python3","/opt/Responder/Responder.py","-I","eth0"]
40 changes: 39 additions & 1 deletion cmd/interactsh-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ import (

func main() {
var eviction int
var debug bool
var debug, smb, responder bool

options := &server.Options{}
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
flag.BoolVar(&debug, "debug", false, "Use interactsh in debug mode")
flag.StringVar(&options.Domain, "domain", "", "Domain to use for interactsh server")
flag.StringVar(&options.IPAddress, "ip", "", "IP Address to use for interactsh server")
flag.StringVar(&options.ListenIP, "listen-ip", "0.0.0.0", "IP Address to listen on")
flag.StringVar(&options.Hostmaster, "hostmaster", "", "Hostmaster email to use for interactsh server")
flag.IntVar(&eviction, "eviction", 7, "Number of days to persist interactions for")
flag.BoolVar(&responder, "responder", false, "Start a responder agent - docker must be installed")
flag.BoolVar(&smb, "smb", false, "Start a smb agent - impacket and python 3 must be installed")
flag.BoolVar(&options.Auth, "auth", false, "Require a token from the client to retrieve interactions")
flag.StringVar(&options.Token, "token", "", "Generate a token that the client must provide to retrieve interactions")
flag.BoolVar(&options.RootTLD, "root-tld", false, "Enable support for *.domain.tld interaction")
Expand All @@ -40,10 +43,22 @@ func main() {
gologger.DefaultLogger.SetWriter(&noopWriter{})
}

// responder and smb can't be active at the same time
if responder && smb {
fmt.Printf("responder and smb can't be active at the same time\n")
os.Exit(1)
}

// Requires auth if token is specified or enables it automatically for responder and smb options
if options.Token != "" || responder || smb {
options.Auth = true
}

// if root-tld is enabled we enable auth - This ensure that any client has the token
if options.RootTLD {
options.Auth = true
}

// of in case a custom token is specified
if options.Token != "" {
options.Auth = true
Expand All @@ -61,6 +76,10 @@ func main() {
store := storage.New(time.Duration(eviction) * time.Hour * 24)
options.Storage = store

if options.Auth {
_ = options.Storage.SetID(options.Token)
}

// If riit-tld is enabled create a singleton unencrypted record in the store
if options.RootTLD {
_ = store.SetID(options.Domain)
Expand All @@ -80,6 +99,7 @@ func main() {
gologger.Warning().Msgf("An error occurred while applying for an certificate, error: %v", err)
gologger.Warning().Msgf("Could not generate certs for auto TLS, https will be disabled")
}

httpServer, err := server.NewHTTPServer(options)
if err != nil {
gologger.Fatal().Msgf("Could not create HTTP server")
Expand All @@ -92,6 +112,24 @@ func main() {
}
go smtpServer.ListenAndServe(autoTLS)

if responder {
responderServer, err := server.NewResponderServer(options)
if err != nil {
gologger.Fatal().Msgf("Could not create SMB server")
}
go responderServer.ListenAndServe() //nolint
defer responderServer.Close()
}

if smb {
smbServer, err := server.NewSMBServer(options)
if err != nil {
gologger.Fatal().Msgf("Could not create SMB server")
}
go smbServer.ListenAndServe() //nolint
defer smbServer.Close()
}

log.Printf("Listening on DNS, SMTP and HTTP ports\n")

c := make(chan os.Signal, 1)
Expand Down
9 changes: 9 additions & 0 deletions cmd/interactsh-server/smb_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys
from impacket import smbserver

server = smbserver.SimpleSMBServer(listenAddress="0.0.0.0", listenPort=445)
server.setSMB2Support(True)
server.addShare("interactsh", "/interactsh")
server.setSMBChallenge('')
server.setLogFile(sys.argv[1])
server.start()
27 changes: 25 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,41 @@ go 1.15

require (
git.mills.io/prologic/smtpd v0.0.0-20210710122116-a525b76c287a
github.com/DataDog/zstd v1.4.8 // indirect
github.com/akrylysov/pogreb v0.10.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cockroachdb/errors v1.8.6 // indirect
github.com/cockroachdb/pebble v0.0.0-20210827150156-ff43a5880feb // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/eggsampler/acme/v3 v3.2.1
github.com/golang/glog v1.0.0 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.0
github.com/jasonlvhit/gocron v0.0.1
github.com/json-iterator/go v1.1.11
github.com/karlseguin/ccache/v2 v2.0.8
github.com/klauspost/compress v1.13.4 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/miekg/dns v1.1.43
github.com/pkg/errors v0.9.1
github.com/projectdiscovery/fastdialer v0.0.13-0.20210727180624-4b8261cc6d2a
github.com/projectdiscovery/fileutil v0.0.0-20210601061022-8ef4fc6fbfb6
github.com/projectdiscovery/fastdialer v0.0.13-0.20210824195254-0113c1406542
github.com/projectdiscovery/fileutil v0.0.0-20210804142714-ebba15fa53ca
github.com/projectdiscovery/gologger v1.1.4
github.com/projectdiscovery/hmap v0.0.2-0.20210825180603-fca7166c158f // indirect
github.com/projectdiscovery/iputil v0.0.0-20210804143329-3a30fcde43f3 // indirect
github.com/projectdiscovery/mapcidr v0.0.8 // indirect
github.com/projectdiscovery/retryabledns v1.0.12 // indirect
github.com/projectdiscovery/retryablehttp-go v1.0.2
github.com/projectdiscovery/stringsutil v0.0.0-20210823090203-2f5f137e8e1d
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/rs/xid v1.3.0
github.com/stretchr/testify v1.7.0
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/exp v0.0.0-20210826195003-46c773283d9d // indirect
golang.org/x/net v0.0.0-20210825183410-e898025ed96a // indirect
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/corvus-ch/zbase32.v1 v1.0.0
)
Loading