-
Notifications
You must be signed in to change notification settings - Fork 13
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
Added ipv4cat service to help inspect breakouts #4
Open
GOAT-FARM3R
wants to merge
1
commit into
sensepost:master
Choose a base branch
from
GOAT-FARM3R:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -15,6 +15,8 @@ import ( | |
"io/ioutil" | ||
"log" | ||
"math/rand" | ||
"net" | ||
"bufio" | ||
"net/http" | ||
"net/url" | ||
"os" | ||
|
@@ -52,6 +54,7 @@ type service struct { | |
var services = map[string]service{ | ||
"letmeout": service{url: "go-out.letmeoutofyour.net", match: "w00tw00t"}, | ||
"allports": service{url: "allports.exposed", match: "<p>Open Port</p>"}, | ||
"ipv4cat": service{url: "ipv4.cat", match: ""}, | ||
} | ||
|
||
// maxedWaitGroup is a type to control the maximum | ||
|
@@ -132,7 +135,7 @@ func (service *service) testHTTPEgress(port int) { | |
if *invertPtr { | ||
_, err := client.Get(url.String()) | ||
if err != nil { | ||
fmt.Printf("[!] Looks like we have no egress using %s on port %d\n", url.String(), port) | ||
fmt.Printf("[!] Looks like we have no egress using %s on port %d.\n", url.String(), port) | ||
} | ||
return | ||
} | ||
|
@@ -146,19 +149,52 @@ func (service *service) testHTTPEgress(port int) { | |
panic(err) | ||
} | ||
if strings.Contains(string(body), service.match) && !*invertPtr { | ||
fmt.Printf("[!] Looks like we have egress using %s on port %d\n", url.String(), port) | ||
fmt.Printf("[!] Looks like we have egress using %s on port %d.\n", url.String(), port) | ||
} | ||
} | ||
|
||
// testTCPEgress tests if a specific port is allowed to connect | ||
// to the internet via a raw TCP connection by and keeps note of the | ||
// breakout IP address | ||
func (service *service) testTCPEgress(port int) { | ||
|
||
timeout := time.Duration(*timeoutPtr) * time.Second | ||
|
||
connection := net.Dialer{Timeout: timeout} | ||
|
||
conn, err := connection.Dial("tcp", service.url + ":" + strconv.Itoa(port)) | ||
|
||
if err != nil { | ||
if *invertPtr { | ||
_, err := connection.Dial("tcp", service.url + ":" + strconv.Itoa(port)) | ||
if err != nil { | ||
fmt.Printf("[!] Looks like we have no TCP egress using %s on port %d.\n", service.url, port) | ||
} | ||
return | ||
} | ||
|
||
return // if the first one errored already, don't continue | ||
} | ||
|
||
message, _ := bufio.NewReader(conn).ReadString('\n') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets check the error here in case we never reach the |
||
|
||
addr := net.ParseIP(strings.TrimSuffix(message, "\n")) | ||
|
||
if addr.To4() != nil && addr.To16() != nil && !*invertPtr { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
fmt.Printf("[!] Looks like we have TCP egress using %s on port %d and it broke out from %s\n", service.url, port, strings.TrimSuffix(message, "\n")) | ||
} | ||
|
||
} | ||
|
||
func validateFlags() bool { | ||
|
||
// Flag Validation | ||
if !validService(servicePtr) { | ||
fmt.Printf("%s is an invalid service. Please choose 'letmeout' or 'allports'\n", *servicePtr) | ||
fmt.Printf("%s is an invalid service. Please choose 'letmeout', 'allports' or 'ipv4cat'.\n", *servicePtr) | ||
return false | ||
} | ||
|
||
if *useHTTPSPtr && *servicePtr != "letmeout" { | ||
if *useHTTPSPtr && *servicePtr != "letmeout" && *servicePtr != "ipv4cat" { | ||
fmt.Println("Only the 'letmeout' service supports HTTPS, disabling HTTPS checking.") | ||
*useHTTPSPtr = false | ||
} | ||
|
@@ -183,7 +219,7 @@ func validateFlags() bool { | |
|
||
func main() { | ||
|
||
servicePtr = flag.String("service", "letmeout", "Use 'letmeout' or 'allports' for this run.") | ||
servicePtr = flag.String("service", "letmeout", "Use 'letmeout', 'allports' or 'ipv4cat' for this run.") | ||
startPortPtr = flag.Int("start", 1, "The start port to use.") | ||
endPortPtr = flag.Int("end", 65535, "The end port to use.") | ||
concurrentPtr = flag.Int("w", 5, "Number of concurrent workers to spawn.") | ||
|
@@ -255,7 +291,12 @@ func main() { | |
time.Sleep(time.Second * time.Duration(rand.Intn(10))) | ||
} | ||
|
||
tester.testHTTPEgress(p) | ||
if *servicePtr == "ipv4cat" { | ||
tester.testTCPEgress(p) | ||
} else { | ||
tester.testHTTPEgress(p) | ||
} | ||
|
||
atomic.AddInt64(&status.Done, 1) | ||
atomic.AddInt64(&status.Updated, 1) | ||
bar.Render(os.Stdout) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets extract TCP services to their own type.