mirror of
https://github.com/jakejarvis/subtake.git
synced 2025-04-26 01:45:25 -04:00
Initial commit
This commit is contained in:
commit
91ff1991e5
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@ -0,0 +1,4 @@
|
||||
language: go
|
||||
go: master
|
||||
sudo: false
|
||||
script: go test ./...
|
201
LICENSE
Normal file
201
LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
44
README.md
Normal file
44
README.md
Normal file
@ -0,0 +1,44 @@
|
||||
# subtake
|
||||
|
||||
Based on [@haccer](https://github.com/haccer)'s [subjack](https://github.com/haccer/subjack) script for subdomain takeover recon.
|
||||
|
||||
## Installation
|
||||
|
||||
Requires [Go](https://golang.org/dl/).
|
||||
|
||||
`go get github.com/jakejarvis/subtake`
|
||||
|
||||
## Usage
|
||||
|
||||
### Options
|
||||
|
||||
- `-f to-check.txt` is the path to your list of subdomains to check. One subdomain per line. **Required.**
|
||||
- `-t` is the number of threads to use. (Default: 10)
|
||||
- `-a` skips CNAME check and sends requests to every URL. (Default: false, but **Highly recommended.**)
|
||||
- `-timeout` is the number seconds to wait before timing out a check (Default: 10).
|
||||
- `-o results.txt` is a filename to output results to. If the file ends with `.json`, subtake will automatically switch to JSON format.
|
||||
- `-v` enables verbose mode. Displays all checks including not vulnerable URLs.
|
||||
- `-c` Path to file containing JSON fingerprint configuration. (Default: `./fingerprints.json`)
|
||||
- `-ssl` enforces HTTPS requests which may return a different set of results and increase accuracy.
|
||||
|
||||
### Resources
|
||||
|
||||
`sonar.sh` can be used first to gather a list of CNAMEs collected by Rapid7/scan.io's [Project Sonar](https://opendata.rapid7.com/sonar.fdns_v2/). This list can then be passed into subtake to return subdomains not in use. `sonar.sh` is based off of [`scanio.sh`](https://gist.github.com/haccer/3698ff6927fc00c8fe533fc977f850f8).
|
||||
|
||||
`fingerprints.json` can be modified to add or remove hosted platforms to probe for. Many obscure platforms are included, and removing fingerprints for services that are uninteresting to you can speed up the scan.
|
||||
|
||||
### Examples
|
||||
|
||||
`./sonar.sh 2018-10-27-1540655191-fdns_cname.json.gz sonar_all_cnames.txt`
|
||||
|
||||
`./subtake -f sonar_all_cnames.txt -t 50 -ssl -a -o vulnerable.txt`
|
||||
|
||||
## Subdomain Takeovers
|
||||
|
||||
- A great explanation of the risks of takeovers and steps to responsibly disclose takeovers to companies: https://0xpatrik.com/subdomain-takeover/
|
||||
- A comprehensive list of what services are vulnerable and how to proceed once finding them: https://github.com/EdOverflow/can-i-take-over-xyz
|
||||
|
||||
## To-Do
|
||||
|
||||
- Integrate `sonar.sh` into the main Go script as an option instead of input file.
|
||||
- All-in-one Docker image to automatically download the latest FDNS Project Sonar file and check for takeover possibilities.
|
224
fingerprints.json
Normal file
224
fingerprints.json
Normal file
@ -0,0 +1,224 @@
|
||||
[
|
||||
{
|
||||
"service": "azure",
|
||||
"cname": [
|
||||
".azurewebsites.net",
|
||||
".cloudapp.net",
|
||||
".cloudapp.azure.com",
|
||||
".trafficmanager.net",
|
||||
".blob.core.windows.net",
|
||||
".azure-api.net",
|
||||
".azurehdinsight.net",
|
||||
".azureedge.net"
|
||||
],
|
||||
"fingerprint": [],
|
||||
"nxdomain": true
|
||||
},
|
||||
{
|
||||
"service": "github",
|
||||
"cname": [
|
||||
"github.io",
|
||||
"github.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"There isn't a GitHub Pages site here."
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "s3 bucket",
|
||||
"cname": [
|
||||
"s3-bucket"
|
||||
],
|
||||
"fingerprint": [
|
||||
"The specified bucket does not exist"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "fastly",
|
||||
"cname": [
|
||||
"fastly"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Fastly error: unknown domain"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "heroku",
|
||||
"cname": [
|
||||
"herokuapp"
|
||||
],
|
||||
"fingerprint": [
|
||||
"herokucdn.com/error-pages/no-such-app.html"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "pantheon",
|
||||
"cname": [
|
||||
"pantheonsite.io"
|
||||
],
|
||||
"fingerprint": [
|
||||
"The gods are wise, but do not know of the site which you seek."
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "tumblr",
|
||||
"cname": [
|
||||
"domains.tumblr.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Whatever you were looking for doesn't currently exist at this address."
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "wordpress",
|
||||
"cname": [
|
||||
"wordpress.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Do you want to register"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "ghost",
|
||||
"cname": [
|
||||
"ghost.io"
|
||||
],
|
||||
"fingerprint": [
|
||||
"The thing you were looking for is no longer here, or never was"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "shopify",
|
||||
"cname": [
|
||||
"myshopify.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Sorry, this shop is currently unavailable."
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "statuspage",
|
||||
"cname": [
|
||||
"statuspage.io"
|
||||
],
|
||||
"fingerprint": [
|
||||
"You are being <a href=\"https://www.statuspage.io\">redirected"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "uservoice",
|
||||
"cname": [
|
||||
"uservoice.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"This UserVoice subdomain is currently available!"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "surge",
|
||||
"cname": [
|
||||
"surge.sh"
|
||||
],
|
||||
"fingerprint": [
|
||||
"project not found"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "bitbucket",
|
||||
"cname": [
|
||||
"bitbucket.io"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Repository not found"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "brightcove",
|
||||
"cname": [
|
||||
"bcvp0rtal.com",
|
||||
"brightcovegallery.com",
|
||||
"gallery.video"
|
||||
],
|
||||
"fingerprint": [
|
||||
"<p class=\"bc-gallery-error-code\">Error Code: 404</p>"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "bigcartel",
|
||||
"cname": [
|
||||
"bigcartel.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"<h1>Oops! We could’t find that page.</h1>"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "acquia",
|
||||
"cname": [
|
||||
"acquia-test.co"
|
||||
],
|
||||
"fingerprint": [
|
||||
"The site you are looking for could not be found."
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "zendesk",
|
||||
"cname": [
|
||||
"zendesk.com"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Help Center Closed"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "readme",
|
||||
"cname": [
|
||||
"readme.io"
|
||||
],
|
||||
"fingerprint": [
|
||||
"Project doesnt exist... yet!"
|
||||
],
|
||||
"nxdomain": false
|
||||
},
|
||||
{
|
||||
"service": "maxcdn",
|
||||
"cname": [
|
||||
".netdna-cdn.com"
|
||||
],
|
||||
"fingerprint": [],
|
||||
"nxdomain": true
|
||||
},
|
||||
{
|
||||
"service": "apigee",
|
||||
"cname": [
|
||||
"-portal.apigee.net"
|
||||
],
|
||||
"fingerprint": [],
|
||||
"nxdomain": true
|
||||
},
|
||||
{
|
||||
"service": "smugmug",
|
||||
"cname": [
|
||||
"domains.smugmug.com"
|
||||
],
|
||||
"fingerprint": [],
|
||||
"nxdomain": true
|
||||
}
|
||||
]
|
38
main.go
Normal file
38
main.go
Normal file
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/jakejarvis/subtake/subtake"
|
||||
)
|
||||
|
||||
func main() {
|
||||
configFile := "fingerprints.json"
|
||||
|
||||
o := subtake.Options{}
|
||||
|
||||
flag.StringVar(&o.Domains, "f", "", "Path to domains file")
|
||||
flag.IntVar(&o.Threads, "t", 10, "Number of concurrent threads")
|
||||
flag.IntVar(&o.Timeout, "timeout", 10, "Seconds to wait before connection timeout")
|
||||
flag.BoolVar(&o.Ssl, "ssl", false, "Force HTTPS connections")
|
||||
flag.BoolVar(&o.All, "a", false, "Send requests to every URL, even without identified CNAME")
|
||||
flag.BoolVar(&o.Verbose, "v", false, "Display all results including not vunerable URLs")
|
||||
flag.StringVar(&o.Output, "o", "", "Output results to specified file (writes JSON if file ends with '.json')")
|
||||
flag.StringVar(&o.Config, "c", configFile, "Path to configuration file")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
flag.Usage = func() {
|
||||
fmt.Printf("Usage of %s:\n", os.Args[0])
|
||||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
if flag.NFlag() == 0 {
|
||||
flag.Usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
subtake.Process(&o)
|
||||
}
|
130
sonar.sh
Executable file
130
sonar.sh
Executable file
@ -0,0 +1,130 @@
|
||||
#!/bin/bash
|
||||
# Usage : ./sonar.sh <version number> <file>
|
||||
# Example: ./sonar.sh 2018-10-27-1540655191-fdns_cname.json.gz cname_list.txt
|
||||
|
||||
# Premium
|
||||
function ech() {
|
||||
spinner=( "|" "/" "-" "\\" )
|
||||
while true; do
|
||||
for i in ${spinner[@]}; do
|
||||
echo -ne "\r[$i] $1"
|
||||
sleep 0.15
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Joining elements together
|
||||
function join_by() {
|
||||
local IFS=$1
|
||||
shift
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
# Kill function
|
||||
function die() {
|
||||
disown $1
|
||||
kill -9 $1
|
||||
|
||||
length=$(echo -n $3 | wc -m)
|
||||
Count=$(($length + 5))
|
||||
Clear=$(head -c $Count < /dev/zero | tr '\0' '\040')
|
||||
echo -ne "\r $Clear"
|
||||
echo -e "\r[*] $2"
|
||||
}
|
||||
|
||||
function run() {
|
||||
ech "$1" &
|
||||
pid=$!
|
||||
eval "$2"
|
||||
die $pid "$3" "$1"
|
||||
}
|
||||
|
||||
# Gathering data from scans.io / Rapid7 Project Sonar
|
||||
# Find the latest filename listed at https://opendata.rapid7.com/sonar.fdns_v2/ ending with fdns_cname.json.gz and pass in as first argument
|
||||
#file=$(echo "2018-10-27-1540655191-fdns_cname.json.gz")
|
||||
#latest=$(curl -s "https://opendata.rapid7.com/sonar.fdns_v2/" | grep "<td><a" | tail -1 | cut -d'"' -f2)
|
||||
#file=$(echo $latest | cut -d'/' -f3)
|
||||
#cmd="wget -q https://opendata.rapid7.com$latest"
|
||||
#run "Downloading $file (This may take a while)." "$cmd" "Finished Downloading $file"
|
||||
cmd="wget -q https://opendata.rapid7.com/sonar.fdns_v2/$1"
|
||||
run "Downloading $1, this may take a while..." "$cmd" "Finished downloading $1."
|
||||
|
||||
# Parsing it into a file called cname_scanio
|
||||
msg="Grepping for CNAME records."
|
||||
ech $msg &
|
||||
pid=$!
|
||||
zcat < $file | grep 'type":"cname' | awk -F'":"' '{print $3, $5}' | \
|
||||
awk -F'"' '{print $1, $3}' | sed -e s/" type "/" "/g >> cname_scanio
|
||||
die $pid "CNAME records grepped." $msg
|
||||
|
||||
# List of CNAMEs we're going to grep for
|
||||
declare -a arr=(
|
||||
"\.cloudfront.net"
|
||||
"\.s3-website"
|
||||
"\.s3.amazonaws.com"
|
||||
"w.amazonaws.com"
|
||||
"1.amazonaws.com"
|
||||
"2.amazonaws.com"
|
||||
"s3-external"
|
||||
"s3-accelerate.amazonaws.com"
|
||||
"\.herokuapp.com"
|
||||
"\.herokudns.com"
|
||||
"\.wordpress.com"
|
||||
"\.pantheonsite.io"
|
||||
"domains.tumblr.com"
|
||||
"\.zendesk.com"
|
||||
"\.github.io"
|
||||
"\.global.fastly.net"
|
||||
"\.helpjuice.com"
|
||||
"\.helpscoutdocs.com"
|
||||
"\.ghost.io"
|
||||
"cargocollective.com"
|
||||
"redirect.feedpress.me"
|
||||
"\.myshopify.com"
|
||||
"\.statuspage.io"
|
||||
"\.uservoice.com"
|
||||
"\.surge.sh"
|
||||
"\.bitbucket.io"
|
||||
"custom.intercom.help"
|
||||
"proxy.webflow.com"
|
||||
"landing.subscribepage.com"
|
||||
"endpoint.mykajabi.com"
|
||||
"\.teamwork.com"
|
||||
"\.thinkific.com"
|
||||
"clientaccess.tave.com"
|
||||
"wishpond.com"
|
||||
"\.aftership.com"
|
||||
"ideas.aha.io"
|
||||
"domains.tictail.com"
|
||||
"cname.mendix.net"
|
||||
"\.bcvp0rtal.com"
|
||||
"\.brightcovegallery.com"
|
||||
"\.gallery.video"
|
||||
"\.bigcartel.com"
|
||||
"\.activehosted.com"
|
||||
"\.createsend.com"
|
||||
"\.acquia-test.co"
|
||||
"\.proposify.biz"
|
||||
"simplebooklet.com"
|
||||
"\.gr8.com"
|
||||
"\.vendecommerce.com"
|
||||
"\.azurewebsites.net"
|
||||
"\.cloudapp.net"
|
||||
"\.trafficmanager.net"
|
||||
"\.blob.core.windows.net"
|
||||
)
|
||||
|
||||
# Prepare CNAME grep
|
||||
DOMAINS=$(join_by '|' ${arr[@]})
|
||||
|
||||
# Grepping CNAMEs from the array
|
||||
cmd="grep -Ei '${DOMAINS}' cname_scanio >> cname_db"
|
||||
run "Sorting CNAME records." "$cmd" "CNAME records sorted."
|
||||
|
||||
# Sorting the CNAME list
|
||||
cmd="cat cname_db | cut -d' ' -f1 | sort | uniq >> $1"
|
||||
run "Cleaning up." "$cmd" "Cleaned up."
|
||||
|
||||
# RM files.
|
||||
rm cname_db cname_scanio
|
||||
echo "[+] Finished."
|
84
subtake/dns.go
Normal file
84
subtake/dns.go
Normal file
@ -0,0 +1,84 @@
|
||||
package subtake
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
func (s *Subdomain) dns(o *Options) {
|
||||
config := fingerprints(o.Config)
|
||||
|
||||
if o.All {
|
||||
detect(s.Url, o.Output, o.Ssl, o.Verbose, o.Timeout, config)
|
||||
} else {
|
||||
if VerifyCNAME(s.Url, config) {
|
||||
detect(s.Url, o.Output, o.Ssl, o.Verbose, o.Timeout, config)
|
||||
}
|
||||
|
||||
if o.Verbose {
|
||||
result := fmt.Sprintf("[Not Vulnerable] %s\n", s.Url)
|
||||
c := "\u001b[31;1mNot Vulnerable\u001b[0m"
|
||||
out := strings.Replace(result, "Not Vulnerable", c, -1)
|
||||
fmt.Printf(out)
|
||||
|
||||
if o.Output != "" {
|
||||
if chkJSON(o.Output) {
|
||||
writeJSON("", s.Url, o.Output)
|
||||
} else {
|
||||
write(result, o.Output)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolve(url string) (cname string) {
|
||||
cname = ""
|
||||
d := new(dns.Msg)
|
||||
d.SetQuestion(url+".", dns.TypeCNAME)
|
||||
ret, err := dns.Exchange(d, "1.1.1.1:53")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, a := range ret.Answer {
|
||||
if t, ok := a.(*dns.CNAME); ok {
|
||||
cname = t.Target
|
||||
}
|
||||
}
|
||||
|
||||
return cname
|
||||
}
|
||||
|
||||
func nslookup(domain string) (nameservers []string) {
|
||||
m := new(dns.Msg)
|
||||
m.SetQuestion(dotDomain(domain), dns.TypeNS)
|
||||
ret, err := dns.Exchange(m, "1.1.1.1:53")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
nameservers = []string{}
|
||||
|
||||
for _, a := range ret.Answer {
|
||||
if t, ok := a.(*dns.NS); ok {
|
||||
nameservers = append(nameservers, t.Ns)
|
||||
}
|
||||
}
|
||||
|
||||
return nameservers
|
||||
}
|
||||
|
||||
func nxdomain(nameserver string) bool {
|
||||
if _, err := net.LookupHost(nameserver); err != nil {
|
||||
if strings.Contains(fmt.Sprintln(err), "no such host") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
9
subtake/dot.go
Normal file
9
subtake/dot.go
Normal file
@ -0,0 +1,9 @@
|
||||
package subtake
|
||||
|
||||
func dotDomain(domain string) string {
|
||||
return domain + "."
|
||||
}
|
||||
|
||||
func joinHost(server string) string {
|
||||
return server + ":53"
|
||||
}
|
124
subtake/file.go
Normal file
124
subtake/file.go
Normal file
@ -0,0 +1,124 @@
|
||||
package subtake
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Results struct {
|
||||
Subdomain string `json:"subdomain"`
|
||||
Vulnerable bool `json:"vulnerable"`
|
||||
Service string `json:"service,omitempty"`
|
||||
Domain string `json:"nonexist_domain,omitempty"`
|
||||
}
|
||||
|
||||
func open(path string) (lines []string, Error error) {
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
|
||||
for scanner.Scan() {
|
||||
lines = append(lines, scanner.Text())
|
||||
}
|
||||
|
||||
return lines, scanner.Err()
|
||||
}
|
||||
|
||||
func chkJSON(output string) (json bool) {
|
||||
json = false
|
||||
|
||||
if strings.Contains(output, ".json") {
|
||||
if output[len(output)-5:] == ".json" {
|
||||
json = true
|
||||
}
|
||||
}
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
func write(result, output string) {
|
||||
f, err := os.OpenFile(output, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0600)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.WriteString(result)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
func writeJSON(service, url, output string) {
|
||||
var r Results
|
||||
if strings.Contains(service, "DOMAIN") {
|
||||
r = Results{
|
||||
Subdomain: strings.ToLower(url),
|
||||
Vulnerable: true,
|
||||
Service: "unregistered domain",
|
||||
Domain: strings.Split(service, " - ")[1],
|
||||
}
|
||||
} else {
|
||||
if service != "" {
|
||||
r = Results{
|
||||
Subdomain: strings.ToLower(url),
|
||||
Vulnerable: true,
|
||||
Service: strings.ToLower(service),
|
||||
}
|
||||
} else {
|
||||
r = Results{
|
||||
Subdomain: strings.ToLower(url),
|
||||
Vulnerable: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(output, os.O_CREATE|os.O_RDWR, 0600)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
|
||||
file, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
var data []Results
|
||||
json.Unmarshal(file, &data)
|
||||
data = append(data, r)
|
||||
|
||||
results, _ := json.Marshal(data)
|
||||
|
||||
wf, err := os.OpenFile(output, os.O_CREATE|os.O_RDWR, 0600)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
wf.Write(results)
|
||||
}
|
||||
|
||||
func fingerprints(file string) (data []Fingerprints) {
|
||||
config, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
err = json.Unmarshal(config, &data)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
168
subtake/fingerprint.go
Normal file
168
subtake/fingerprint.go
Normal file
@ -0,0 +1,168 @@
|
||||
package subtake
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Verify struct {
|
||||
Body string `json:"body"`
|
||||
Size int `json:"size"`
|
||||
Ssl bool `json:"ssl"`
|
||||
Cname bool `json:"cname"`
|
||||
}
|
||||
|
||||
type Fingerprints struct {
|
||||
Service string `json:"service"`
|
||||
Cname []string `json:"cname"`
|
||||
Fingerprint []string `json:"fingerprint"`
|
||||
Nxdomain bool `json:"nxdomain"`
|
||||
Checks Verify `json:"verify"`
|
||||
}
|
||||
|
||||
/*
|
||||
* Triage step to check whether the CNAME matches
|
||||
* the fingerprinted CNAME of a vulnerable cloud service.
|
||||
*/
|
||||
func VerifyCNAME(subdomain string, config []Fingerprints) (match bool) {
|
||||
match = false
|
||||
cname := resolve(subdomain)
|
||||
|
||||
VERIFY:
|
||||
for n := range config {
|
||||
for c := range config[n].Cname {
|
||||
if strings.Contains(subdomain, config[n].Cname[c]) {
|
||||
match = false
|
||||
break VERIFY
|
||||
}
|
||||
}
|
||||
|
||||
for c := range config[n].Cname {
|
||||
if strings.Contains(cname, config[n].Cname[c]) {
|
||||
// fmt.Printf(config[n].Cname[c])
|
||||
match = true
|
||||
break VERIFY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return match
|
||||
}
|
||||
|
||||
func detect(url, output string, ssl bool, verbose bool, timeout int, config []Fingerprints) {
|
||||
service := Identify(url, ssl, timeout, config)
|
||||
|
||||
if service != "" {
|
||||
result := fmt.Sprintf("[%s]\t\t%s\n", service, url)
|
||||
c := fmt.Sprintf("\u001b[32;1m%s\u001b[0m", service)
|
||||
out := strings.Replace(result, service, c, -1)
|
||||
fmt.Printf(out)
|
||||
|
||||
if output != "" {
|
||||
if chkJSON(output) {
|
||||
writeJSON(service, url, output)
|
||||
} else {
|
||||
write(result, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if service == "" && verbose {
|
||||
result := fmt.Sprintf("[Not Vulnerable]\t\t%s\n", url)
|
||||
c := "\u001b[31;1mNot Vulnerable\u001b[0m"
|
||||
out := strings.Replace(result, "Not Vulnerable", c, -1)
|
||||
fmt.Printf(out)
|
||||
|
||||
if output != "" {
|
||||
if chkJSON(output) {
|
||||
writeJSON(service, url, output)
|
||||
} else {
|
||||
write(result, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This function aims to identify whether the subdomain
|
||||
* is attached to a vulnerable cloud service and able to
|
||||
* be taken over.
|
||||
*/
|
||||
func Identify(subdomain string, forceSSL bool, timeout int, fingerprints []Fingerprints) (service string) {
|
||||
body := get(subdomain, forceSSL, timeout)
|
||||
|
||||
cname := resolve(subdomain)
|
||||
|
||||
if len(cname) <= 3 {
|
||||
cname = ""
|
||||
}
|
||||
|
||||
service = ""
|
||||
nx := nxdomain(subdomain)
|
||||
|
||||
IDENTIFY:
|
||||
for f := range fingerprints {
|
||||
|
||||
// Begin subdomain checks if the subdomain returns NXDOMAIN
|
||||
if nx {
|
||||
// Check if subdomain matches fingerprinted cname
|
||||
if fingerprints[f].Nxdomain {
|
||||
for n := range fingerprints[f].Cname {
|
||||
if strings.Contains(cname, fingerprints[f].Cname[n]) {
|
||||
service = fmt.Sprintf("%s: %s", fingerprints[f].Service, cname)
|
||||
break IDENTIFY
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if body matches fingerprinted response
|
||||
for n := range fingerprints[f].Fingerprint {
|
||||
if bytes.Contains(body, []byte(fingerprints[f].Fingerprint[n])) {
|
||||
service = fmt.Sprintf("%s: %s", fingerprints[f].Service, cname)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* This next section is for if we need to do a
|
||||
* 2nd verification check defined in the config. */
|
||||
|
||||
/* Double check for another fingerprint in response
|
||||
* Or check if requesting with HTTPS has a similar
|
||||
* response */
|
||||
if fingerprints[f].Checks.Body != "" {
|
||||
if !bytes.Contains(body, []byte(fingerprints[f].Checks.Body)) {
|
||||
service = ""
|
||||
}
|
||||
|
||||
if fingerprints[f].Checks.Ssl {
|
||||
if !forceSSL {
|
||||
bd := https(subdomain, forceSSL, timeout)
|
||||
if len(bd) != 0 && !bytes.Contains(body, []byte(fingerprints[f].Checks.Body)) {
|
||||
service = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if response matches fingerprinted length.
|
||||
if fingerprints[f].Checks.Size != 0 {
|
||||
if len(body) != fingerprints[f].Checks.Size {
|
||||
service = ""
|
||||
}
|
||||
}
|
||||
|
||||
/* For now this just checks whether a CNAME is actually attached.
|
||||
* Was having some issues using strings.Contains(cname, fingerprints[f].Cname[0])
|
||||
*/
|
||||
if fingerprints[f].Checks.Cname {
|
||||
if cname == "" {
|
||||
service = ""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return service
|
||||
}
|
34
subtake/requests.go
Normal file
34
subtake/requests.go
Normal file
@ -0,0 +1,34 @@
|
||||
package subtake
|
||||
|
||||
import (
|
||||
"github.com/valyala/fasthttp"
|
||||
"time"
|
||||
)
|
||||
|
||||
func get(url string, ssl bool, timeout int) (body []byte) {
|
||||
req := fasthttp.AcquireRequest()
|
||||
req.SetRequestURI(site(url, ssl))
|
||||
req.Header.Add("Connection", "close")
|
||||
resp := fasthttp.AcquireResponse()
|
||||
|
||||
client := &fasthttp.Client{}
|
||||
client.DoTimeout(req, resp, time.Duration(timeout)*time.Second)
|
||||
|
||||
return resp.Body()
|
||||
}
|
||||
|
||||
func https(url string, ssl bool, timeout int) (body []byte) {
|
||||
newUrl := "https://" + url
|
||||
body = get(newUrl, ssl, timeout)
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
func site(url string, ssl bool) (site string) {
|
||||
site = "http://" + url
|
||||
if ssl {
|
||||
site = "https://" + url
|
||||
}
|
||||
|
||||
return site
|
||||
}
|
50
subtake/subtake.go
Normal file
50
subtake/subtake.go
Normal file
@ -0,0 +1,50 @@
|
||||
package subtake
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Domains string
|
||||
Threads int
|
||||
Timeout int
|
||||
Output string
|
||||
Ssl bool
|
||||
All bool
|
||||
Verbose bool
|
||||
Config string
|
||||
}
|
||||
|
||||
type Subdomain struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
/* Start processing from the defined options. */
|
||||
func Process(o *Options) {
|
||||
urls := make(chan *Subdomain, o.Threads*10)
|
||||
list, err := open(o.Domains)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
wg := new(sync.WaitGroup)
|
||||
|
||||
for i := 0; i < o.Threads; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
for url := range urls {
|
||||
url.dns(o)
|
||||
}
|
||||
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
for i := 0; i < len(list); i++ {
|
||||
urls <- &Subdomain{Url: list[i]}
|
||||
}
|
||||
|
||||
close(urls)
|
||||
wg.Wait()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user