Practical Recon Techniques for Pen Testers
Practical Recon Techniques for Pen Testers
Dismiss
Join GitHub today
GitHub is home to over 36 million developers working together to host
and review code, manage projects, and build software together.
Sign up
1 contributor
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
LevelUp 0x02 | May 26th 2018
About me
Bharath Kumar
Live from Bangalore, India
Security Engineer @Appsecco
Offensive Security Certified Professional(OSCP)
Demo environment
Feel free to run the DNS & DNSSEC attacks mentioned in this talk against the following nameservers and
domain names
**Nameservers**
ns1.insecuredns.com
ns2.insecuredns.com
This talk is about practical recon techniques that are useful for bug bounty hunters and penetration testers
The objective of this talk is to cover exhaustive number of practical recon techniques, tools of trade and
tips/tricks
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Note: By practical I mean that these techniques covered can actually be used during a security assessment. The
talk will be crisp and concise. We demonstrate quick and effective ways to apply a technique in such a way that the
audience can use them in their assessments right away
WHAT IS RECONNAISSANCE?
Reconnaissance is the act of gathering preliminary data or intelligence on your target. The data is
gathered in order to better plan for your attack. Reconnaissance can be performed actively or passively.
Enumerating domains
The objective is to find/correlate all domain names owned by a single entity of our interest.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://0xpatrik.com/asset-discovery/
Sub-domain enumeration is the process of finding subdomains for one or more domain(s).
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Search engines like Google and Bing supports various advanced search operators to refine search queries.
site: is helpful in doing vertical domain correlation(sub-domains)
https://www.virustotal.com/#/home/search
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Script - https://git.io/vhqBF
Quick tip
find-subdomains-vt()
{ curl -s https://www.virustotal.com/ui/domains/$1/subdomains\?limit\=$2 | jq .data[].id; }
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Using 3rd party information aggregators
viewdns.info is a handy service for all the DNS and WHOIS related recon
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Certificate Transparency
Under CT, a Certificate Authority(CA) will have to publish all SSL/TLS certificates they issue in a public log
Anyone can look through the CT logs and find certificates issued for a domain
Details of known CT log files - https://www.certificate-transparency.org/known-logs
https://blog.appsecco.com/certificate-transparency-part-2-the-bright-side-c0b99ebf31a8
https://blog.appsecco.com/certificate-transparency-part-3-the-dark-side-9d401809b025
A script that searches SSL/TLS certificates issued for a domain using crt.sh
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Script - https://git.io/vhqRd
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://developers.facebook.com/tools/ct/
https://blog.appsecco.com/a-penetration-testers-guide-to-sub-domain-enumeration-7d842d5570f6
CT logs + massdns
You can use tools like massdns along with CT logs script to quickly identify resolvable domain names.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Using certspotter
find-cert()
{ curl -s https://certspotter.com/api/v0/certs?domain=$1 | jq -c '.[].dns_names' | grep -o '"[^"]\+
Using certdb.com
While crt.sh gets the data from CT logs only where "legit" CA submit the certs to a log; CertDB is based on
the scanning the IPv4 segment, domains and "finding & analyzing" all the certificates
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://certdb.com
Censys.io
Censys aggregates SSL certificates that are a result of SSL scans on IPv4 address space and also from
Certificate Transparency (CT) logs
This is a good source of domains and also email addresses
https://0xpatrik.com/censys-guide/
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://github.com/0xbharath/censys-enumeration
Content Security Policy(CSP) defines the Content-Security-Policy HTTP header, which allows us to create
a whitelist of sources of trusted content, and instructs the browser to only execute or render resources from
those sources
So basically, Content-Security-Policy header will list a bunch of sources(domains) that might be of interest to
us as an attackers.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Extract domains from CSP headers
https://github.com/0xbharath/domains-from-csp
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://justi.cz/security/2018/05/23/cdn-tar-oops.html
A Sender Policy Framework(SPF) record and is used to indicate to recieving mail exchanges which hosts are
authorized to send mail for a given domain
Simply put, an SPF record lists all the hosts that are authorised send emails on behalf of a domain
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://github.com/0xbharath/assets-from-spf
In DNS, when client queries for a non-existent domain, the server must deny the existence of that domain. It is
harder to do that in DNSSEC due to cryptographic signing.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Zone walking NSEC - LDNS
The ldns-walk (part of ldnsutils ) can be used to zone walk DNSSEC signed zone that uses NSEC.
Installing ldnsutils
# On Debian/Ubuntu
$ sudo apt-get install ldnsutils
# On Redhat/CentOS
$ sudo yum install ldns
# You may need to do
$ sudo yum install -y epel-release
NSEC3
The NSEC3 record is like an NSEC record, but, NSEC3 provides a signed gap of hashes of domain names.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Returning hashes was intended to prevent zone enumeration(or make it expensive).
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
# Checking the number of sucessfully cracked sub-domain hashes
$ cat icann.org.unhash | grep "icann" | wc -l
182
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
syd.icann.org.
upk.icann.org.
vip.icann.org.
crm.icann.org.
dns.icann.org.
liao.icann.org.
redis.icann.org.
svn.icann.org.
admin.icann.org.
orbis.icann.org.
jira.icann.org.
omblog.icann.org.
pptr.icann.org.
splunk.icann.org.
nomcom.icann.org.
rssac.icann.org.
sftp.icann.org.
netscan.icann.org.
Installing nsec3walker
# Installing nsec3walker
$ wget https://dnscurve.org/nsec3walker-20101223.tar.gz
$ tar -xzf nsec3walker-20101223.tar.gz
$ cd nsec3walker-20101223
$ make
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Few things that changed with the advent of DevOps
1. Storage
2. Authentication
3. More and more code
4. CI/CD pipelines
Cloud storage
Cloud storage has gotten inexpensive, easy to setup and gained popularity
Object storage is ideal for storing static, unstructured data like audio, video, documents, images and logs as
well as large amounts of text.
i. AWS S3 buckets
ii. Digital Ocean Spaces
Amazon S3 buckets
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
AWS S3 is an object storage service by Amazon
Buckets allow users to store and serve large amounts of data.
https://www.upguard.com/breaches/cloud-leak-accenture
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Hunting for publicly accessible S3 buckets
Users can store Files(Objects) in a Bucket
Each Bucket will get an unique, predictable URL and each file in a Bucket will get an unique URL as well
There are Access controls mechanisms available at both Bucket and Object level.
site:s3.amazonaws.com file:pdf
site:s3.amazonaws.com password
i. AWSBucketDump
ii. Slurp
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Spaces API aims to be interoperable with Amazon’s AWS S3 API.
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
A Space is typically considered “private” if the Space’s contents can only be listed or written by certain users
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Spaces finder
Spaces API is interoperable with Amazon’s S3 API, we tweaked AWSBucketDump to work with DO Spaces
Spaces finder is a tool that can look for publicly accessible DO Spaces using a wordlist, list all the accessible
files on a public Space and download the files.
https://github.com/appsecco/spaces-finder
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://github.com/appsecco/spaces-finder
Authentication
With almost every service exposing an API, keys have become critical in authenticating
API keys are treated as keys to the kingdom
For applications, API keys tend to be achilles heel
https://danielmiessler.com/blog/apis-2fas-achilles-heel/
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Code repos can reveal a lot from credentials, potential vulnerabilities to infrastructure details
Repositories
Code
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Commits(My fav!)
Issues
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Mass Cloning on Github
You can ideally clone all the target organization's repos and analyze them locally
GitHubCloner by @mazen160 comes very handy to automate the process
https://gist.github.com/EdOverflow/922549f610b258f459b219a32f92d10b
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Static code analysis
Once the repos are cloned, you can do a static code analysis
There are language specific tools to speed up and automate the process
Once you have the repos cloned. You can understand the code, language used and architecture
- API and key. (Get some more endpoints and find API keys.)
- token
- secret
- vulnerable
- http://
There are various tools available to find juicy information in source code.
1. Truffle Hog
2. git-all-secrets
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Github dorks
Github dorks are the new Google dorks
Github search is quite powerful feature & can be used to find sensitive data on the repos
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Name Description Price
Sonar FDNS, RDNS, UDP, TCP, TLS, HTTP, HTTPS scan data FREE
CT TLS FREE
https://github.com/fathom6/inetdata
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://github.com/fathom6/inetdata
https://github.com/fathom6/inetdata
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
cat 2018-04-21-1524297601-fdns_any.json.gz | pigz -dc | grep "\.example\.com" | jq .name
https://opendata.rapid7.com/about/
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
https://github.com/appsecco/bugcrowd-levelup-subdomain-enumeration
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ICANN.ORG subdomains
Number of unique, resolvable sub-domains each enumeration technique found independently against icann.org
TALK MATERIAL
https://github.com/appsecco/practical-recon-levelup0x02
Take away
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
A gitbook on sub-domain enumeration
https://appsecco.com/books/subdomain-enumeration/
References
- https://www.certificate-transparency.org/ - https://www.cloudflare.com/dns/dnssec/how-dnssec-works/ -
https://www.cloudflare.com/dns/dnssec/dnssec-complexities-and-considerations/ -
http://info.menandmice.com/blog/bid/73645/Take-your-DNSSEC-with-a-grain-of-salt -
https://github.com/rapid7/sonar/wiki/Forward-DNS
Thanks
@0xbharath
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD