😀Reconnaissance

"Hackers make the mistake of paying attention to the exploitation process, and neglecting the information gathering stage “

So i will talk about Reconnaissance ..

💭 Whoami :

I'm[ Abdelrahman Ali H3ckt00r] , Jr. Penetration Tester

🛫 Plan

Full simple Reconnaissance

Most hackers, when they set a specific target, do not know where to start! So, let me explain my path in the reconnaissance process ..

I am seeking to obtain the following:

My principle is from start to finish ..

1-IPs

2-Subdomains

3-Js Files

4-Directories

5-Parameters

6-Emails

With the 6 elements, I can get 6 files, as a basic infrastructure for my reconnaissance project. Yes, this is only the basic stage and then I start the next phase..

Then, how do I get my project’s Infrastructure ?


1) AS Number :

Autonomous System Number (ASN) is a globally unique identifier that defines a group of one or more IP prefixes run by one or more network operators that maintain a single, clearly-defined routing policy. These groups of IP prefixes are known as autonomous systems. The ASN allows the autonomous systems to exchange routing information with other autonomous systems.

I can get the asn with several ways :

1) theHarvester

b) Amass


2) CIDR :

After completing the previous stage, the stage of collecting the ASN of the target.. I will convert ASNs to CIDR group

How i Resolve AS Number to CIDRs ..?

a) whois

2- BGP


3) Network Sweeping :

After completing the stage of collecting some CIDRs, I want to convert the CIDR to the IP Address .. whichever is host up or host down ?

Now , i have File.txt containing Handreds of IP A , all of them is Host Up , .. but wait ..

Are all hosts down IP really host down? Or the firewall plays a malicious role?

Normally, the firewall is blocking any requests, and the Host is Up but I see it as Host Down.. So, let's deceive this problem

We will perform the Port Scanning process, and then we will mark the Host Up ..

Now we Have IP.txt all of them is Host Up !


4- Subdomain Enumeration


(a) Subfinder

Subfinder is a subdomain discovery tool that discovers valid subdomains for websites. Designed as a passive framework to be useful for bug bounties and safe for penetration testing.

• In the Subfinder Github Repository it was mentioned that some of the services will not work until you set it up.

• So i started looking into it to set-up the config-file with the API Keys that are mentioned to see what is the major difference in the results of subdomain

cat config.yaml to see the config file

• We can see many of the API Key services are Empty , so now are going to fill the necessary API Keys as source for Subdomain Enumeration.

Note The below following API Keys are Free Of Cost and has a Limited number of request in it.

  • binaryedge

  • censys

  • certspotter

  • chaos

  • dnsdb

  • github

  • intelx

  • passivetotal

  • robtex

  • securitytrails

  • shodan

  • spyse

  • urlscan

  • virustotal

  • zoomeye

Binaryedge

1 : Sign up for a free account, and verify the account.

2 : Login into the account and Navigate to this URL https://app.binaryedge.io/account/api and give a name to the TOKEN and Click on Generate Token.

Censys

1 : Sign up for a free account, and verify the account.

2 : Login into the account and Navigate to this URL https://censys.io/account/api and you will be able to get API ID and Secret

Certspotter

1 : Sign up for a free account.

2 : Login into the account and Navigate to this URL https://sslmate.com/account/api_credentials and you will be able to get the API Key

Note : 100 queries an hour is free.

Chaos

1 : Navigate to this URL https://chaos.projectdiscovery.io/#/

2 : Early access is provided basis on signup and queue and Invite are send out Weekly basis.

3 : Contributor access is Provided on the basis of PR that is done under github.com/projectdiscovery/*.

DNSdb

1 : Sign up for a free community account.

2 : It will ask for Company Email , use Temp Email.

3 : Create an account and verify the email and get the API Key.

Note : It has 30-day renewal (with valid email confirmation)

Github

1 : Sign up for a free account, verify the account.

2 : Navigate to this URL https://github.com/settings/tokens and generate a Personal access tokens.

Intelx

1 : Sign up for a free account, verify the account.

2 : Navigate to this URL https://intelx.io/account?tab=developer and you will get the API details.

Note: Trial 1 week for Free

Passivetotal

1 : Sign up for a free account, verify the account.

2 : Login into the account and Navigate to this URL https://community.riskiq.com/settings and you will be able to get KEY and Secret .

Robtex

1 : Sign in using the google Gmail Account

2 : Navigate to this URL https://www.robtex.com/dashboard/ , you will get the API-Key details.

Security Trails

1 : Sign up for a free account, verify the account.

2 : Login into the account and Navigate to this URL https://securitytrails.com/app/account/credentials and you will be able to get API Key .

Note : Monthly Quoto is 50 API Requests.

Shodan

1 : Register for a shodan account.

2 : Login into the account and navigate to this URL https://account.shodan.io/ , you will get the API Key details.

Spyse

1 : Register for a Spyse account and verify it.

2 : Login into the account and navigate to this URL https://spyse.com/user , you will get the API Token details.

Note : It has 100 API Token valid for 5 days during the Trail Period.

UrlScan

1 : Sign up for a free account, verify the account.

2 : Login into the account and Navigate to this URL https://urlscan.io/user/profile/ and click on Create new API Key.

Virustotal

1 : Register for a Virustotal account and verify it.

2 : Login into the account and navigate to this URL https://www.virustotal.com/gui/user/username/apikey , you will get the API Key details.

Zoom Eye

1 : Register for a ZoomEye account and verify it.

2 : Login into the account and navigate to this URL https://www.zoomeye.org/profile , you will get the API Key details.

Now Let us compare the Results Before and After Adding API Keys.

Before API Key

After API Key


(b) Amass

The OWASP Amass Project performs network mapping of attack surfaces and external asset discovery using open source information gathering and active reconnaissance techniques.


(c) Assetfinder

Find domains and subdomains related to a given domain


(d) GetAllUrls [GAU]

getallurls (gau) fetches known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, Common Crawl, and URLScan for any given domain. Inspired by Tomnomnom's waybackurls.****


(e) SubEnum

bash script for Subdomain Enumeration using 4 tools and 3 online services, you have to install these tools by yourself to be able to use SubEnum.sh, or use setup.sh script to install them.


(f) theHarvester

theHarvester is a simple to use, yet powerful tool designed to be used during thereconnaissance stage of a red team assessment or penetration test. It performs open source intelligence (OSINT) gathering to help determine a domain's external threat landscape. The tool gathers names, emails, IPs, subdomains, and URLs by using multiple public resources

(j) Favicon

Did you know that we can find related domains and sub domains to our target by looking for the same favicon icon hash? This is exactly what favihash.py tool made by @m4ll0k2 does. Here’s how to use it:

favihash - discover domains with the same favicon icon hash

Simply said, favihash will allow us to discover domains that have the same favicon icon hash as our target.

Moreover, you can also search technologies using the favicon hash as explained in this blog post. That means that if you know the hash of the favicon of a vulnerable version of a web tech you can search if in shodan and find more vulnerable places:

This is how you can calculate the favicon hash of a web:

5) Filter Alive Hosts - Info - CName

a) Httpx

httpx is a fast and multi-purpose HTTP toolkit that allows running multiple probes using the retryablehttp library. It is designed to maintain result reliability with an increased number of threads.


(5) Js Files - Directory - Parameters - Robot.txt

And now this is the interesting stage for me, we will collect the following through only one tool :

  • Js Files

  • Directory

  • Parameters

  • Robot.txt

(a) Yes, it's (gau) ..

getallurls (gau) fetches known URLs from AlienVault's Open Threat Exchange, the Wayback Machine, Common Crawl, and URLScan for any given domain. Inspired by Tomnomnom's waybackurls.

(b) Js Scanner

Js File Scanner This is Js File Scanner . Which are scan in js file and find juicy information Toke,Password Etc.


(c) GoSpider

A fast web spider written in Go

(d) Find all JS File

JavaScipt files are always worth to have a look at. I always filter for URLs returning JavaScript files and I save them in an extra file for later.

A great write-up about static JavaScript analysis can be found here:

Static Analysis of Client-Side JavaScript for pen testers and bug bounty hunters


e) Katana

A next-generation crawling and spidering framework

6- Emails

With the domains and subdomains inside the scope you basically have all what you need to start searching for emails. These are the APIs and tools that have worked the best for me to find emails of a company:

API of - https://github.com/laramies/theHarvester - with api API of - https://hunter.io/ - free version API of - https://app.snov.io/ - free version API of - https://minelead.io/ - free version

Other :


Now we have the following:

  • IPs.txt

  • Subs.txt

  • Urls&Param.txt

  • JsFile.txt

  • Directory.txt

  • Emails

  • Robot.txt



II) Brute-Force & Fuzzing

I call the previous stage " the basic infrastructure stage " , now let's start the second stage .. This stage is to fully complete what we started from the first stage.

1) Subdomain Brute Force

Another active enumeration technique is called subdomain brute force, where large lists of subdomains are prepended to the target domain and sent to the resolver in order to retrieve DNS Resource Records (RR) like A for IPv4 addresses, CNAME for aliases or AAAA for IPv6 addresses.09‏/01‏/2023

a) PureDNS

Puredns is a fast domain resolver and subdomain bruteforcing tool that can accurately filter out wildcard subdomains and DNS poisoned entries.


2) Directory Fuzzing

Directory fuzzing (a.k.a. directory bruteforcing) is a technique that can find some of those "hidden" paths. Dictionaries of common paths are used to request the web app for each path until exhaustion of the list. This technique relies on the attacker using a dictionnary/wordlist.

First i want to resolve “target.com” to “https://target.com” , to Fuzzing Directory after [.com].

a) httprobe

Take a list of domains and probe for working http and https servers.****

2) FuFF

A fast web fuzzer written in Go.

3) Parameter Fuzzing

Fuzz testing or fuzzing is an automated software testing method that injects invalid, malformed, or unexpected inputs into a system to reveal software defects and vulnerabilities. A fuzzing tool injects these inputs into the system and then monitors for exceptions such as crashes or information leakage.

a) Fuff

A fast web fuzzer written in Go.


b) Parampampam

This tool for brute discover GET and POST parameters.

c) arjun

Arjun can find query parameters for URL endpoints. If you don't get what that means, it's okay, read along

4) VHost Fuzzing

some servers [ 1 IP ] contain several hosts .. lets get them

a) GoBuster

b) VHostScan


Now, I have consolidated some of the previously collected files, There are only two steps left to complete these stages :

5) Resolve IPs to Domains

a) HostHunter

HostHunter a recon tool for discovering hostnames using OSINT techniques.

GitHub Link

(includes installation instructions)

b) nmap

i will not talk about nmap ,, ;)

6) Resolve Domains to IPs

this is a simple line of bash


III ) Dorks & Secrets & Leaks , Open Source Code

1)Credintials Leaks

With the domains, subdomains, and emails you can start looking for credentials leaked in the past belonging to those emails:


2) Dorks

A dork query, sometimes just referred to as a dork, is a search string or custom query that uses advanced search operators to find information not readily available on a website.

a) GitHub Dorking With [GitRob]

Gitrob is a tool to help find potentially sensitive files pushed to public repositories on Github. Gitrob will clone repositories belonging to a user or organization down to a configurable depth and iterate through the commit history and flag files that match signatures for potentially sensitive files. The findings will be presented through a web interface for easy browsing and analysis.


b) Google Dorking

Google hacking, also named Google dorking,is a hacker technique that uses Google Search and other Google applications to find security holes in the configuration and computer code that websites are using.

I ) GooFuzz

GooFuzz is a script written in Bash Scripting that uses advanced Google search techniques to obtain sensitive information in files or directories without making requests to the web server.****

II ) DorkGen

Dorkgen is a dork query wrapper for popular search engines such as Google Search, DuckDuckGo, Yahoo and Bing. Learn more about Google Hacking. The goal of this package is to provide simple interfaces to creates valid dork queries for various search engines. This library was initially created for PhoneInfoga.

Check this great tool : ‣

III ) Pentest-Tool

Google Hacking - Free Google Dorks for Recon

Shodan Dorks

City:

Find devices in a particular city.

Country:

Find devices in a particular country.

Geo:

Find devices by giving geographical coordinates.

Location

Hostname:

Find devices matching the hostname.

Net:

Find devices based on an IP address or /x CIDR.

Organization

Autonomous System Number (ASN)

OS:

Find devices based on operating system.

Port:

Find devices based on open ports.

Before/after:

Find devices before or after between a given time.

SSL/TLS Certificates

  • Self signed certificates

  • Expired certificates

Device Type

Operating System

Product

Customer Premises Equipment (CPE)

Server

ssh fingerprints

Web

Pulse Secure

PEM Certificates

Databases

MySQL

MongoDB

elastic

Memcached

CouchDB

PostgreSQL

Riak

Redis

Cassandra

Industrial Control Systems

Samsung Electronic Billboards

Gas Station Pump Controllers

Fuel Pumps connected to internet:

No auth required to access CLI terminal.

Automatic License Plate Readers

Traffic Light Controllers / Red Light Cameras

Voting Machines in the United States

Open ATM:

Telcos Running Cisco Lawful Intercept Wiretaps

Prison Pay Phones

Tesla PowerPack Charging Status

Electric Vehicle Chargers

Maritime Satellites

Shodan made a pretty sweet Ship Tracker that maps ship locations in real time, too!

Submarine Mission Control Dashboards

CAREL PlantVisor Refrigeration Units

Nordex Wind Turbine Farms

C4 Max Commercial Vehicle GPS Trackers

DICOM Medical X-Ray Machines

Secured by default, thankfully, but these 1,700+ machines still have no business being on the internet.

GaugeTech Electricity Meters

Siemens Industrial Automation

Siemens HVAC Controllers

Door / Lock Access Controllers

Railroad Management

Tesla Powerpack charging Status:

Helps to find the charging status of tesla powerpack.

XZERES Wind Turbine

PIPS Automated License Plate Reader

Modbus

Niagara Fox

GE-SRTP

MELSEC-Q

CODESYS

S7

BACnet

HART-IP

Omron FINS

IEC 60870-5-104

DNP3

EtherNet/IP

PCWorx

Crimson v3.0

ProConOS

Remote Desktop

Unprotected VNC

Windows RDP

99.99% are secured by a secondary Windows login screen.

Network Infrastructure

Hacked routers:

Routers which got compromised

Redis open instances

Citrix:

Find Citrix Gateway.

Weave Scope Dashboards

Command-line access inside Kubernetes pods and Docker containers, and real-time visualization/monitoring of the entire infrastructure.

MongoDB

Older versions were insecure by default. Very scary.

Mongo Express Web GUI

Like the infamous phpMyAdmin but for MongoDB.

Jenkins CI

Jenkins:

Jenkins Unrestricted Dashboard

Docker APIs

Docker Private Registries

Pi-hole Open DNS Servers

Already Logged-In as root via Telnet

Telnet Access:

NO password required for telnet access.

Polycom video-conference system no-auth shell

NPort serial-to-eth / MoCA devices without password

Android Root Bridges

A tangential result of Google's sloppy fractured update approach.

Lantronix Serial-to-Ethernet Adapter Leaking Telnet Passwords

Citrix Virtual Apps

Cisco Smart Install

Vulnerable (kind of "by design," but especially when exposed).

PBX IP Phone Gateways

Polycom Video Conferencing

Telnet Configuration:

Bomgar Help Desk Portal

Intel Active Management CVE-2017-5689

HP iLO 4 CVE-2017-12542

Lantronix ethernet adapter’s admin interface without password

Wifi Passwords:

Helps to find the cleartext wifi passwords in Shodan.

Misconfigured Wordpress Sites:

The wp-config.php if accessed can give out the database credentials.

Outlook Web Access:

Exchange 2007

Exchange 2010

Exchange 2013 / 2016

Lync / Skype for Business

Network Attached Storage (NAS)

SMB (Samba) File Shares

Produces ~500,000 results...narrow down by adding "Documents" or "Videos", etc.

Specifically domain controllers:

Concerning default network shares of QuickBooks files:

FTP Servers with Anonymous Login

Iomega / LenovoEMC NAS Drives

Buffalo TeraStation NAS Drives

Logitech Media Servers

Plex Media Servers

Tautulli / PlexPy Dashboards

Home router attached USB

Webcams

Hipcam

Yawcams

webcamXP/webcam7

Android IP Webcam Server

Security DVRs

Surveillance Cams:

With username:admin and password: :P

Printers & Copiers:

HP Printers

Xerox Copiers/Printer

Epson Printer

Canon Printers

Home Devices

Yamaha Stereos

Apple AirPlay Receivers

Apple TVs, HomePods, etc.

Chromecasts / Smart TVs

Crestron Smart Home Controllers

Random Stuff

OctoPrint 3D Printer Controllers

Etherium Miner

Apache Directory Listings

Substitute .pem with any extension or a filename like phpinfo.php.

Misconfigured WordPress

Exposed wp-config.php files containing database credentials.

Too Many Minecraft Servers

Literally Everything in North Korea


Finally Don’t forget OSINT tools :

  • theHarvester

  • BBOT

  • OpenForAll

  • Vita



THIS is my FIRST write-up about RECON ..

THANKS FOR READING !!!


Last updated