WDavid404 / Note_tryhackme

0 stars 0 forks source link

Red Team Recon/Weaponization #5

Open WDavid404 opened 1 year ago

WDavid404 commented 1 year ago

Red Team Recon

Topics:

Objectives:

WDavid404 commented 1 year ago

Taxonomy(分類学) of Reconnaissance

Reconnaissance (recon) can be classified into two parts:

Passive recon: relies on publicly available information that is collected and maintained by a third party. Open Source Intelligence (OSINT) is used to collect information about the target.

Active Recon: External Recon and Internal Recon.

Built-in Tools

whois:

WHOIS is a request and response protocol that follows the RFC 3912 specification. A WHOIS server listens on TCP port 43 for incoming requests. whois will query the WHOIS server to provide all saved records. whois thmredteam.com whois thmredteam.com -h <whois server's IP>

Netcraft (from OSCP)

Netcraft's DNS search page (https://searchdns.netcraft.com) to gather information.

Netcraft1 is an internet service company, based in England, offering a free web portal that performs various information gathering functions such as discovering which technologies are running on a given website and finding which other hosts share the same IP netblock.

Gitlab search (from OSCP)

e.g. Let's search MegaCorp One's repos for interesting information. We can use path:users to search for any files with the word "users" in the filename and press ENTER. image

Security Headers and SSL/TLS

Security Headers (https://securityheaders.com/)

DNS queries

. dig

dig provides a lot of query options and even allows you to specify a different DNS server to use. For example, we can use Cloudflare's DNS server: dig @1.1.1.1 tryhackme.com

host:

host cafe.thmredteam.com

// Using host to find the MX records for megacorpone.com
kali@kali:~$ host -t mx megacorpone.com
megacorpone.com mail is handled by 10 fb.mail.gandi.net.
megacorpone.com mail is handled by 20 spool.mail.gandi.net.
megacorpone.com mail is handled by 50 mail.megacorpone.com.
megacorpone.com mail is handled by 60 mail2.megacorpone.com.

//Using host to find the TXT records for megacorpone.com
kali@kali:~$ host -t txt megacorpone.com
megacorpone.com descriptive text "Try Harder"
megacorpone.com descriptive text "google-site-verification=U7B_b0HNeBtY4qYGQZNsEYXfCJ32hMNV3GtC0wWq5pA"

//Using Bash to brute force forward DNS name lookups
kali@kali:~$ for ip in $(cat list.txt); do host $ip.megacorpone.com; done

//by showing only entries that do not contain "not found".
kali@kali:~$ for ip in $(seq 200 254); do host 51.222.169.$ip; done | grep -v "not found"

DNSRecon

DNSRecon5 is an advanced DNS enumeration script written in Python. Let's run dnsrecon against megacorpone.com, using the -d option to specify a domain name and -t to specify the type of enumeration to perform (in this case, a standard scan). kali@kali:~$ dnsrecon -d megacorpone.com -t std use the -d option to specify a domain name, -D to specify a file name containing potential subdomain strings, and -t to specify the type of enumeration to perform, in this case brt for brute force. dnsrecon -d megacorpone.com -D ~/list.txt -t brt

DNSnum

DNSEnum is another popular DNS enumeration tool that can be used to further automate DNS enumeration of the specified domain. dnsenum megacorpone.com

nslookup

nslookup mail.megacorptwo.com
nslookup -type=TXT info.megacorptwo.com 192.168.50.151
//note: DNS server (192.168.50.151) 

Traces the route taken by the packets from our system to the target host

traceroute (Linux), tracert (Windows)

Advanced Searching

下面文法有助于更精准地在搜索引擎上搜索 Symbol / Syntax Function
"search phrase" Find results with exact search phrase
xxx filetype:pdf Find files of type PDF related to a certain term.
xxxx site:blog.tryhackme.com Limit search results to a specific site.
xxxx -site:example.com Exclude a specific site from results
xxxx intitle:TryHackMe Find pages with a specific term in the page title.
xxxx inurl:tryhackme Find pages with a specific term in the page URL

搜索引擎: Google Advanced Search. Google Refine Web Searches, DuckDuckGo Search Syntax, Bing Advanced Search Options.

Google Hacking Database (GHDB)

Footholds

Specialized Search Engines

ViewDNS.info Threat Intelligence Platform Censys Search Shodan: shodan host 172.67.212.249 https://cli.shodan.io/

WDavid404 commented 1 year ago

Recon-ng

Creating a Workspace

Run workspaces create WORKSPACE_NAME

recon-ng -w WORKSPACE_NAME starts recon-ng with the specific workspace.

Seeding the Database

We want to insert the domain name thmredteam.com into the domains table. We can do this using the command db insert domains.

pentester@TryHackMe$ recon-ng -w thmredteam
[...]
[recon-ng][thmredteam] > db insert domains
domain (TEXT): thmredteam.com
notes (TEXT): 
[*] 1 rows affected.
[recon-ng][thmredteam] > marketplace search

To check the names of the tables in our database, we can run db schema To query domain: db query select * from domains To query host: db query select * from hosts

Recon-ng Marketplace

We can install the module we want with the command marketplace install MODULE, for example, marketplace install google_site_web.

Working with Installed Modules

To run it, we need to set the required options.

Keys

Some modules cannot be used without a key for the respective service API. K indicates that you need to provide the relevant service key to use the module in question.

WDavid404 commented 1 year ago

Maltego

an application that blends mind-mapping with OSINT. In general, you would start with a domain name, company name, person’s name, email address, etc. Then you can let this piece of information go through various transforms.

In Maltego’s terminology, a transform is a piece of code that would query an API to retrieve information related to a specific entity. image Every transform might lead to several new values. For instance, if we start from the “DNS Name” cafe.thmredteam.com, we expect to get new kinds of entities based on the transform we use. For instance, “To IP Address” is expected to return IP addresses as shown next. image

Transform hub: https://www.maltego.com/transform-hub/

image
WDavid404 commented 1 year ago

Weaponization

Weaponization

Weaponization is the second stage of the Cyber Kill Chain model. In this stage, the attacker generates and develops their own malicious code using deliverable payloads such as word documents, PDFs, etc.

Most organizations block or monitor the execution of .exe files within their controlled environment. For that reason, red teamers rely on executing payloads using other techniques, such as built-in windows scripting technologies. Therefore, this task focuses on various popular and effective scripting techniques, including:

Command And Control - (C2 Or C&C)

C2 frameworks are post-exploitation frameworks that allow red teamers to collaborate and control compromised machines. C2 is considered one of the most important tools for red teamers during offensive cyber operations.

Some popular C2 frameworks that we'll briefly highlight are

Delivery Techniques