Windowsãããã¯ãŒã¯ã®æ·±æ·µãèŠãRPCã€ã³ã¿ãŒãã§ãŒã¹ã¹ãã£ããŒ
ãããã¯ãŒã¯ã»ãã¥ãªãã£ã®äžçãç¹ã«Windowsç°å¢ã®ãããã¬ãŒã·ã§ã³ãã¹ããã»ãã¥ãªãã£è©äŸ¡ã«ãããŠãMicrosoft Remote Procedure Call (MSRPC) ã¯éèŠãªåœ¹å²ãæãããŸããMSRPCã¯ããããã¯ãŒã¯äžã®ç°ãªãã³ã³ãã¥ãŒã¿éã§ããã°ã©ã ãäºãã«ãµãŒãã¹ãèŠæ±ããããã®ãããã³ã«ã§ããããã«ãããã¯ã©ã€ã¢ã³ãã¯ãªã¢ãŒãã·ã¹ãã äžã®ããã»ã¹ãããŒã«ã«ã«ãããã®ããã«åŒã³åºãããšãã§ããŸãããããããã®äŸ¿å©ãªæ©èœã¯æ»æè ã«ãšã£ãŠãé åçãªã¿ãŒã²ãããšãªãåŸãŸããð
ããã§ç»å Žããã®ããImpacketãšãã匷åãªPythonããŒã«ãããã§ããImpacketã¯ããããã¯ãŒã¯ãããã³ã«ãæ±ãããã®Pythonã¯ã©ã¹ã®ã³ã¬ã¯ã·ã§ã³ã§ãããç¹ã«SMB (Server Message Block) ãMSRPCã®å®è£
ãæäŸããŠããŸãããã®è±å¯ãªããŒã«çŸ€ã®äžã«ãä»å泚ç®ãã rpcmap.py
ãå«ãŸããŠããŸãã
rpcmap.py
ã¯ãã¿ãŒã²ããã·ã¹ãã äžã§åŸ
ã¡åããŠããDCE/RPC (Distributed Computing Environment/Remote Procedure Call) ã€ã³ã¿ãŒãã§ãŒã¹ãã¹ãã£ã³ããããã®ã¹ã¯ãªããã§ããå
·äœçã«ã¯ãMSRPCã®ãšã³ããã€ã³ãããã㌠(éåžžTCPããŒã135ã§åäœ) ããSMB (TCPããŒã139, 445) çµç±ãããã«ã¯HTTP (TCPããŒã593) çµç±ã§ã¢ã¯ã»ã¹å¯èœãªRPCãµãŒãã¹ã«é¢ããæ
å ±ãåéããŸãã
ãã®ããã°èšäºã§ã¯ãrpcmap.py
ã®åºæ¬çãªäœ¿ãæ¹ãããããé«åºŠãªãªãã·ã§ã³ãåºåçµæã®è§£éããããŠã»ãã¥ãªãã£äžã®æå³åããŸã§ãå
æ¬çã«è§£èª¬ããŠãããŸããWindowsãããã¯ãŒã¯ã®å
éšæ§é ãç解ããæœåšçãªè匱æ§ãç¹å®ããããã«ãrpcmap.py
ãã©ã®ããã«æŽ»çšã§ãããèŠãŠãããŸããããð
MSRPCãšãšã³ããã€ã³ãããããŒã®åºç€ç¥è ð§
rpcmap.py
ãç解ããäžã§ãMSRPCãšãã®äžå¿çãªã³ã³ããŒãã³ãã§ããããšã³ããã€ã³ãããããŒãã«ã€ããŠåºæ¬çãªç¥èãæã€ããšãéèŠã§ãã
MSRPCãšã¯ïŒ
Microsoft Remote Procedure Call (MSRPC) ã¯ãåæ£ã³ã³ãã¥ãŒãã£ã³ã°ç°å¢ã«ãããããã»ã¹ééä¿¡ (IPC) ã®ããã®ãããã³ã«ã§ããç°¡åã«èšãã°ãããã³ã³ãã¥ãŒã¿äžã®ããã°ã©ã ïŒã¯ã©ã€ã¢ã³ãïŒãããããã¯ãŒã¯äžã®å¥ã®ã³ã³ãã¥ãŒã¿ïŒãµãŒããŒïŒã«ããæç¶ãïŒé¢æ°ãã¡ãœããïŒãå®è¡ãããããã®ä»çµã¿ã§ããããã«ããããããã¯ãŒã¯ãä»ããã·ãŒã ã¬ã¹ãªæ©èœé£æºãå¯èœã«ãªããŸããWindowsç°å¢ã§ã¯ããã¡ã€ã«å ±æãããªã³ã¿å ±æãActive Directoryæäœããªã¢ãŒãã§ã®ãµãŒãã¹ç®¡çãªã©ãå€ãã®åºæ¬çãªæ©èœãMSRPCã«äŸåããŠããŸãã
ãšã³ããã€ã³ãããã㌠(epmapper)
RPCãµãŒãã¹ã¯ãç¹å®ã®ãã€ã³ã¿ãŒãã§ãŒã¹ã (æäŸããæ©èœçŸ€ãå®çŸ©) ãšããšã³ããã€ã³ãã (éä¿¡ãåãä»ããå ·äœçãªã¢ãã¬ã¹ãããŒãçªå·ããŸãã¯ååä»ããã€ã) ãæã¡ãŸããããããç¹ã«TCP/IPã䜿çšããå ŽåããµãŒããŒäžã®RPCãµãŒãã¹ã䜿çšããããŒãçªå·ã¯åçã«å²ãåœãŠãããããšããããŸããã¯ã©ã€ã¢ã³ãã¯ãæ¥ç¶ããããµãŒãã¹ãçŸåšã©ã®ããŒãã§åŸ ã¡åããŠããããç¥ãå¿ èŠããããŸãã
ããã§ããšã³ããã€ã³ãããããŒã (epmapper) ãç»å ŽããŸããããã¯ããµãŒããŒäžã§åäœããç¹å¥ãªRPCãµãŒãã¹ã§ãä»ã®RPCãµãŒãã¹ãèªèº«ãç»é²ããå Žæã§ããã¯ã©ã€ã¢ã³ãã¯ãŸããæ¢ç¥ã®ããŒã (éåžžã¯TCP 135) ã§åäœããŠãããšã³ããã€ã³ãããããŒã«åãåãããŸããç®çã®ãµãŒãã¹ã®ã€ã³ã¿ãŒãã§ãŒã¹UUID (Universally Unique Identifier) ãäŒãããšããšã³ããã€ã³ãããããŒã¯ãã®ãµãŒãã¹ãçŸåšåŸ ã¡åããŠããå ·äœçãªãšã³ããã€ã³ãæ å ± (äŸ: TCPããŒãçªå·) ãè¿ããŸããã¯ã©ã€ã¢ã³ãã¯ããã®æ å ±ã䜿ã£ãŠç®çã®ãµãŒãã¹ã«çŽæ¥æ¥ç¶ããŸãã
MSRPCã®éä¿¡ã¯ãäž»ã«ä»¥äžã®ãã©ã³ã¹ããŒãçµç±ã§è¡ãããŸãïŒ
- TCP/IP: ãšã³ããã€ã³ãããã㌠(TCP 135) ãšãåçãŸãã¯éçã«å²ãåœãŠãããé«äœããŒãã䜿çšã
- SMB (Named Pipes): SMBãããã³ã« (TCP 139, 445) äžã®ååä»ããã€ãã䜿çšã
- HTTP: RPC over HTTP (TCP 593) ã䜿çšãã€ã³ã¿ãŒãããè¶ãã®éä¿¡ãªã©ã«å©çšãããã
rpcmap.py
ã¯ããããã®ãã©ã³ã¹ããŒããå©çšããŠãšã³ããã€ã³ãããããŒã«æ¥ç¶ããç»é²ãããŠããã€ã³ã¿ãŒãã§ãŒã¹æ
å ±ãååŸããããšè©Šã¿ãŸãã
åææ¡ä»¶ãšã€ã³ã¹ããŒã« ð ïž
rpcmap.py
ã䜿çšããã«ã¯ãImpacketã©ã€ãã©ãªãã€ã³ã¹ããŒã«ãããŠããå¿
èŠããããŸããImpacketã¯Pythonã§æžãããŠãããããPython 3ã®ç°å¢ãå¿
èŠã§ãã
å€ãã®å ŽåãKali Linuxãªã©ã®ãããã¬ãŒã·ã§ã³ãã¹ãçšãã£ã¹ããªãã¥ãŒã·ã§ã³ã«ã¯Impacketãããªã€ã³ã¹ããŒã«ãããŠããŸãïŒimpacket-scripts
ããã±ãŒãžãªã©ïŒã
ããã€ã³ã¹ããŒã«ãããŠããªãå Žåã¯ãpipã䜿ã£ãŠç°¡åã«ã€ã³ã¹ããŒã«ã§ããŸãã
pip install impacket
ãŸãã¯ãGitHubãªããžããªãããœãŒã¹ã³ãŒããååŸããŠã€ã³ã¹ããŒã«ããããšãå¯èœã§ãã
git clone https://github.com/fortra/impacket.git
cd impacket/
python setup.py install
ã€ã³ã¹ããŒã«åŸãrpcmap.py
ã¹ã¯ãªããã¯éåžžãImpacketã® examples
ãã£ã¬ã¯ããªå
ããããã¯ã·ã¹ãã ã®PATHãéã£ãå Žæ (Kaliã®å Žåãªã©) ã«é
眮ãããŸãã
泚æ: Impacketã®ããŒã«çŸ€ã¯ãæ£åœãªç®çïŒã»ãã¥ãªãã£è©äŸ¡ãæè²ãç 究ãªã©ïŒã§ã®ã¿äœ¿çšããŠãã ãããèš±å¯ãªãä»è ã®ã·ã¹ãã ã«å¯ŸããŠäœ¿çšããããšã¯ãæ³åŸã§çŠæ¢ãããŠããå ŽåããããŸãã
rpcmap.py ã®åºæ¬çãªäœ¿ãæ¹ ð
rpcmap.py
ã®æãåºæ¬çãªäœ¿ãæ¹ã¯ãã¿ãŒã²ããã®IPã¢ãã¬ã¹ãšãæ¥ç¶ã«äœ¿çšããRPCæååãã€ã³ãã£ã³ã°ãæå®ããããšã§ããæååãã€ã³ãã£ã³ã°ã¯ã䜿çšãããããã³ã«ããããã¯ãŒã¯ã¢ãã¬ã¹ããšã³ããã€ã³ãïŒããŒãçªå·ããã€ãåãªã©ïŒãæå®ãã圢åŒã§ãã
æãäžè¬çãªã®ã¯ãTCPããŒã135ã®ãšã³ããã€ã³ãããããŒã«æ¥ç¶ããã±ãŒã¹ã§ãã
rpcmap.py <ã¿ãŒã²ããIPã¢ãã¬ã¹>
ãŸãã¯ãããæ瀺çã«ãããã³ã«ã·ãŒã±ã³ã¹ãæå®ããå ŽåïŒ
rpcmap.py ncacn_ip_tcp:<ã¿ãŒã²ããIPã¢ãã¬ã¹>
ãã㧠ncacn_ip_tcp
ã¯ãTCP/IPãããã³ã«ã䜿çšããããšã瀺ããŸããrpcmap.py
ã¯ãæå®ãããã¿ãŒã²ããã®ãšã³ããã€ã³ãããããŒïŒããã©ã«ãã§ã¯ããŒã135ïŒã«æ¥ç¶ããç»é²ãããŠããRPCã€ã³ã¿ãŒãã§ãŒã¹ãšãã®ãšã³ããã€ã³ãæ
å ±ããªã¹ãã¢ããããããšããŸãã
äŸãã°ãIPã¢ãã¬ã¹ 192.168.1.100
ã®ãã¹ãã«å¯ŸããŠå®è¡ããå ŽåïŒ
rpcmap.py 192.168.1.100
ãããã¯
rpcmap.py ncacn_ip_tcp:192.168.1.100
ããã«ãããã¿ãŒã²ãããã¹ãã§å ¬éãããŠããRPCã€ã³ã¿ãŒãã§ãŒã¹ã«é¢ããæ å ±ã衚瀺ãããŸããèªèšŒãå¿ èŠãªå Žåããç¹å®ã®ããŒããæå®ãããå Žåã¯ãåŸè¿°ãããªãã·ã§ã³ã䜿çšããŸãã
ð¡ ãã³ã: rpcmap.py
ã¯ããŸã MGMT (Management) ã€ã³ã¿ãŒãã§ãŒã¹ã«ãã€ã³ãããŠã€ã³ã¿ãŒãã§ãŒã¹UUIDã®ãªã¹ããååŸããããšããŸãããããå©çšã§ããªãå Žåãrpcmap.py
ã¯æ¢ç¥ã®äžè¬çãªã€ã³ã¿ãŒãã§ãŒã¹UUIDã®ãªã¹ãã䜿çšãããããããžã®ãã€ã³ããè©Šã¿ãŸãã
äž»èŠãªã³ãã³ãã©ã€ã³ãªãã·ã§ã³ âïž
rpcmap.py
ã¯ãã¹ãã£ã³åäœãã«ã¹ã¿ãã€ãºããããã®æ§ã
ãªãªãã·ã§ã³ãæäŸããŠããŸããrpcmap.py -h
ã§ãã«ãã¡ãã»ãŒãžã衚瀺ã§ããŸãã以äžã«äž»èŠãªãªãã·ã§ã³ã解説ããŸãã
ãªãã·ã§ã³ | 説æ | äŸ |
---|---|---|
target (äœçœ®åŒæ°) |
ã¿ãŒã²ãããæå®ããŸããIPã¢ãã¬ã¹ããã¹ãåããŸãã¯å®å
šãªæååãã€ã³ãã£ã³ã° (äŸ: ncacn_ip_tcp:192.168.1.100[135] ) ã§æå®ã§ããŸãã |
192.168.1.100 dc01.corp.local ncacn_np:192.168.1.100[\pipe\epmapper] |
-h, --help |
ãã«ãã¡ãã»ãŒãžã衚瀺ããŠçµäºããŸãã | rpcmap.py -h |
-port <ããŒãçªå·> |
æ¥ç¶å
ã®ããŒãçªå·ãæå®ããŸããããã©ã«ãã¯ããããã³ã«ã·ãŒã±ã³ã¹ã«åºã¥ããŠæ±ºå®ãããŸã (äŸ: ncacn_ip_tcp ã§ã¯ 135)ãSMB (ncacn_np ) ã®å Žå㯠445 ã䜿ãããããšãå€ãã§ãã |
rpcmap.py ncacn_ip_tcp:192.168.1.100 -port 135 |
-stringbinding <æååãã€ã³ãã£ã³ã°> |
æ¥ç¶ããMSRPCã€ã³ã¿ãŒãã§ãŒã¹ã®æååãã€ã³ãã£ã³ã°ãçŽæ¥æå®ããŸããäœçœ®åŒæ°ã§ã¿ãŒã²ãããæå®ãã代ããã«äœ¿çšã§ããŸãã | rpcmap.py -stringbinding 'ncacn_ip_tcp:192.168.1.100[49152]' |
-target-ip <IPã¢ãã¬ã¹> |
ã¿ãŒã²ããã®IPã¢ãã¬ã¹ãæ瀺çã«æå®ããŸããã¿ãŒã²ããåãNetBIOSåãªã©ã§ãåå解決ãã§ããªãå Žåã«äŸ¿å©ã§ãã | rpcmap.py CORP-DC01 -target-ip 10.0.0.5 |
-auth-level <ã¬ãã«> |
RPCèªèšŒã¬ãã«ãæå®ããŸã (äŸ: connect , call , pkt , pkt_integrity , pkt_privacy )ãããã©ã«ã㯠connect ã§ãã |
rpcmap.py target -auth-level pkt_privacy |
-brute-uuids |
äžè¬çãªUUIDã®ãªã¹ãã䜿çšããŠãã€ã³ã¿ãŒãã§ãŒã¹ãžã®ãã€ã³ããè©Šã¿ãŸããMGMTã€ã³ã¿ãŒãã§ãŒã¹ãå©çšã§ããªãå Žåã«åœ¹ç«ã¡ãŸãã | rpcmap.py target -brute-uuids |
-brute-opnums |
èŠã€ãã£ãåUUIDã«å¯ŸããŠããªãã¬ãŒã·ã§ã³çªå· (opnum) ã®ãã«ãŒããã©ãŒã¹ãè©Šã¿ãŸããããã«ãããã€ã³ã¿ãŒãã§ãŒã¹ãã©ã®ãããªé¢æ°åŒã³åºããåãä»ããããæ¢ãããšãã§ããŸããâ ïž æ³šæ: å€ãã®æ¥ç¶ãçºçããå¯èœæ§ããããŸãã | rpcmap.py target -brute-opnums |
-opnum-max <æ°å€> |
-brute-opnums ãšäœµçšããè©Šè¡ããæ倧ã®opnumãæå®ããŸããããã©ã«ãã¯256ã§ãã |
rpcmap.py target -brute-opnums -opnum-max 100 |
-brute-versions |
èŠã€ãã£ãåUUIDã«å¯ŸããŠãç°ãªãã€ã³ã¿ãŒãã§ãŒã¹ããŒãžã§ã³ã§ã®ãã€ã³ããè©Šã¿ãŸãã | rpcmap.py target -brute-versions |
-version-max <æ°å€> |
-brute-versions ãšäœµçšããè©Šè¡ããæ倧ã®ããŒãžã§ã³çªå· (ãã€ããŒããŒãžã§ã³) ãæå®ããŸããããã©ã«ãã¯2ã§ãã |
rpcmap.py target -brute-versions -version-max 5 |
-uuid <UUID> |
ç¹å®ã®ã€ã³ã¿ãŒãã§ãŒã¹UUIDã®ã¿ãã¹ãã£ã³å¯Ÿè±¡ãšããŸãã | rpcmap.py target -uuid e1af8308-5d1f-11c9-91a4-08002b14a0fa |
-debug |
ãããã°ã¢ãŒããæå¹ã«ãã詳现ãªãã°æ å ±ã衚瀺ããŸãããã©ãã«ã·ã¥ãŒãã£ã³ã°ã«åœ¹ç«ã¡ãŸãã | rpcmap.py target -debug |
èªèšŒé¢é£ãªãã·ã§ã³ | ||
<ãã¡ã€ã³>/<ãŠãŒã¶ãŒå>:<ãã¹ã¯ãŒã>@<ã¿ãŒã²ãã> |
ãŠãŒã¶ãŒåãšãã¹ã¯ãŒãã§èªèšŒããŸãã | rpcmap.py CORP/Administrator:Password123@192.168.1.100 |
-hashes <LMHASH:NTHASH> |
ãã¹ã¯ãŒãã®ä»£ããã«LMããã·ã¥ãšNTããã·ã¥ã䜿çšããŠèªèšŒããŸã (Pass-the-Hash)ã | rpcmap.py CORP/Administrator@192.168.1.100 -hashes aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0 |
-no-pass |
ãã¹ã¯ãŒãã®å ¥åãæ±ããŸãã (äŸ: -k ãªãã·ã§ã³äœ¿çšæ)ã | rpcmap.py -k -no-pass target |
-k |
KerberosèªèšŒã䜿çšããŸããäºåã«æå¹ãªKerberosãã±ãããã£ãã·ã¥ (ccache) ãå¿ èŠã§ã (ç°å¢å€æ° KRB5CCNAME ã§æå®)ã | export KRB5CCNAME=/tmp/kerberos.ccache rpcmap.py -k -no-pass target |
-aesKey <ãããµããŒ> |
KerberosèªèšŒçšã®AESã㌠(128/192/256ããã) ãæå®ããŸã (Pass-the-Key)ã | rpcmap.py -k -no-pass -aesKey deadbeef... target |
ãããã®ãªãã·ã§ã³ãçµã¿åãããããšã§ãç¹å®ã®ç¶æ³ã«åãããŠRPCã€ã³ã¿ãŒãã§ãŒã¹ã®ã¹ãã£ã³ã詳现ã«å¶åŸ¡ã§ããŸããäŸãã°ãç¹å®ã®ãŠãŒã¶ãŒã®èªèšŒæ å ±ã䜿çšããŠãSMBçµç±ã§RPCã€ã³ã¿ãŒãã§ãŒã¹ã調æ»ããå Žåã¯ã次ã®ããã«ããŸãã
rpcmap.py -port 445 ncacn_np:192.168.1.100 CORP/User1:Pa$$w0rd@192.168.1.100
åºåçµæã®è§£é ð
rpcmap.py
ã®å®è¡çµæã¯ãã¿ãŒã²ããã·ã¹ãã ã§çºèŠãããRPCã€ã³ã¿ãŒãã§ãŒã¹ã«é¢ããæ
å ±ãæäŸããŸããå
žåçãªåºåã¯ä»¥äžã®ããã«ãªããŸãã
Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
[*] Retrieving endpoint list from ncacn_ip_tcp:192.168.1.100
[*] Trying ncacn_ip_tcp:192.168.1.100[135]
Protocol: ncacn_ip_tcp
Provider: rpcss.dll
UUID: e1af8308-5d1f-11c9-91a4-08002b14a0fa v3.0
Annotation: Remote Procedure Call Endpoint Mapper
Bindings:
ncacn_ip_tcp:192.168.1.100[135] Status: ACTIVE
ncacn_np:192.168.1.100[\PIPE\epmapper] Status: ACTIVE
ncacn_ip_tcp:192.168.1.100[49664] Status: ACTIVE
ncacn_ip_tcp:192.168.1.100[593] Status: ACTIVE
Protocol: ncacn_ip_tcp
Provider: scmr.dll
UUID: 367abb81-9844-35f1-ad32-98f038001003 v2.0
Annotation: Service Control Manager Remote Protocol
Bindings:
ncacn_ip_tcp:192.168.1.100[49667] Status: ACTIVE
ncacn_np:192.168.1.100[\PIPE\svcctl] Status: ACTIVE
... (ä»ã®ã€ã³ã¿ãŒãã§ãŒã¹æ
å ±ãç¶ã) ...
åºåã®äž»èŠãªèŠçŽ ã解説ããŸãã
[*] Retrieving endpoint list from ...
: ã©ã®ã¿ãŒã²ãããšãããã³ã«ã·ãŒã±ã³ã¹ã«å¯ŸããŠã¹ãã£ã³ãéå§ãããã瀺ããŸãã[*] Trying ...
: å ·äœçã«ã©ã®ãšã³ããã€ã³ãã«æ¥ç¶ãè©Šã¿ãŠãããã瀺ããŸããProtocol:
ãã®ã€ã³ã¿ãŒãã§ãŒã¹ãéä¿¡ã«äœ¿çšããŠãããããã³ã«ã·ãŒã±ã³ã¹ (äŸ:ncacn_ip_tcp
,ncacn_np
)ãProvider:
ãã®RPCã€ã³ã¿ãŒãã§ãŒã¹ãæäŸããDLLãã¡ã€ã«åïŒå€æããŠããå ŽåïŒãããã¯ãµãŒãã¹ã®ç¹å®ã«åœ¹ç«ã¡ãŸããUUID:
ã€ã³ã¿ãŒãã§ãŒã¹ã®äžæèå¥å (Universally Unique Identifier) ãšããŒãžã§ã³çªå· (äŸ:v3.0
)ãUUIDã¯ã€ã³ã¿ãŒãã§ãŒã¹ã®çš®é¡ãç¹å®ããããã®éµãšãªããŸããAnnotation:
ã€ã³ã¿ãŒãã§ãŒã¹ã«é¢ããç°¡åãªèª¬æãæ¢ç¥ã®å称 (äŸ: “Remote Procedure Call Endpoint Mapper”, “Service Control Manager Remote Protocol”)ãBindings:
ãã®ã€ã³ã¿ãŒãã§ãŒã¹ãå®éã«åŸ ã¡åããŠããå ·äœçãªãšã³ããã€ã³ãã®ãªã¹ããåãã€ã³ãã£ã³ã°ã«ã¯ããããã³ã«ã·ãŒã±ã³ã¹ããããã¯ãŒã¯ã¢ãã¬ã¹ããšã³ããã€ã³ãïŒããŒãçªå·ããã€ãåïŒãããã³ã¹ããŒã¿ã¹ïŒéåžžã¯ACTIVE
ïŒãå«ãŸããŸãã
ãã®æ
å ±ãããæ»æè
ã¯ã¿ãŒã²ããã·ã¹ãã ã§ã©ã®ãããªãµãŒãã¹ãåäœããŠããããããã«ã©ã®ããã«æ¥ç¶ã§ããããææ¡ã§ããŸããäŸãã°ãäžèšã®äŸã§ã¯ãEndpoint Mapper (UUID: e1af8308...
) ã TCPããŒã 135, 49664, 593 ããã³ Named Pipe \PIPE\epmapper
ã§åŸ
ã¡åããŠããããšãããããŸãããŸããService Control Manager (UUID: 367abb81...
) 㯠TCPããŒã 49667 ããã³ Named Pipe \PIPE\svcctl
ã§ã¢ã¯ã»ã¹å¯èœã§ãã
ç¹å®ã®UUIDãäœãè¡šããã«ã€ããŠã¯ãMicrosoftã®[MS-RPCE]: Remote Procedure Call Protocol Extensionsãªã©ã®ããã¥ã¡ã³ãããWebæ€çŽ¢ã§èª¿ã¹ãããšãã§ããŸããããã«ãããçºèŠãããã€ã³ã¿ãŒãã§ãŒã¹ãã©ã®ãããªæ©èœãæäŸããæœåšçãªæ»æ察象ãšãªãããããè©äŸ¡ã§ããŸããð
é«åºŠãªäœ¿çšäŸãšå¿çšã·ããªãª ð€
èªèšŒä»ãã¹ãã£ã³
NULLã»ãã·ã§ã³ã§ã¯ã¢ã¯ã»ã¹ã§ããªãã€ã³ã¿ãŒãã§ãŒã¹æ å ±ãååŸããããã«ãæå¹ãªèªèšŒæ å ±ã䜿çšããŸãã
# ãã¹ã¯ãŒãèªèšŒ
rpcmap.py CORP\\svc_account:MyPassword@10.0.0.10
# Pass-the-Hash
rpcmap.py -hashes :NTHashValue CORP\\Administrator@10.0.0.10
# KerberosèªèšŒ (äºåã« kinit ãªã©ã§ãã±ããååŸ)
export KRB5CCNAME=/tmp/krb5cc_myticket
rpcmap.py -k -no-pass 10.0.0.10
èªèšŒãããã»ãã·ã§ã³ã§ã¯ãããå€ãã®ããããã¯ããæ©å¯æ§ã®é«ãRPCã€ã³ã¿ãŒãã§ãŒã¹æ å ±ãæããã«ãªãå¯èœæ§ããããŸãã
ç¹å®ã®ã€ã³ã¿ãŒãã§ãŒã¹ã®æ¢çŽ¢
ç¹å®ã®è匱æ§ã«é¢é£ããã€ã³ã¿ãŒãã§ãŒã¹ããé¢å¿ã®ãããµãŒãã¹ (äŸ: Print Spooler (MS-RPRN), Task Scheduler (MS-TSCH)) ãååšãããã確èªãããå Žåã-uuid
ãªãã·ã§ã³ã䜿çšããŸãã
# Print Spooler (MS-RPRN) ã®UUIDãæå®ããŠã¹ãã£ã³
rpcmap.py 192.168.1.100 -uuid 12345678-1234-abcd-ef00-0123456789ab
ïŒæ³š: äžèšUUIDã¯äŸã§ããå®éã®MS-RPRNã®UUIDã䜿çšããŠãã ãããïŒ
ãŸããrpcdump.py
ïŒåããImpacketã®ããŒã«ïŒãšçµã¿åãããŠäœ¿ãããšãæå¹ã§ããrpcdump.py
ã¯ãšã³ããã€ã³ããšãã®ãã€ã³ãã£ã³ã°ããªã¹ãã¢ããããrpcmap.py
ã¯ç¹å®ã®ã€ã³ã¿ãŒãã§ãŒã¹ãå®éã«ãã€ã³ãå¯èœãã確èªããŸãã
# rpcdumpã§ãšã³ããã€ã³ããªã¹ããååŸ
rpcdump.py @192.168.1.100
# rpcdumpã®çµæããç¹å®ã®ãšã³ããã€ã³ããrpcmapã§èª¿æ»
rpcmap.py ncacn_ip_tcp:192.168.1.100[49152]
ãã«ãŒããã©ãŒã¹ãªãã·ã§ã³ã®æŽ»çš
-brute-uuids
, -brute-opnums
, -brute-versions
ã¯ãæªç¥ã®ããããã¯ææžåãããŠããªãã€ã³ã¿ãŒãã§ãŒã¹ãæ©èœãçºèŠããããã«äœ¿çšã§ããŸããã泚æãå¿
èŠã§ãã
# äžè¬çãªUUIDãè©Šã
rpcmap.py 192.168.1.100 -brute-uuids
# ç¹å®ã®ã€ã³ã¿ãŒãã§ãŒã¹ã®Opnumã0ãã50ãŸã§è©Šã
rpcmap.py 192.168.1.100 -uuid 367abb81-9844-35f1-ad32-98f038001003 -brute-opnums -opnum-max 50
ðš èŠå: ãã«ãŒããã©ãŒã¹ãªãã·ã§ã³ãç¹ã« -brute-opnums
ã¯ãã¿ãŒã²ããã·ã¹ãã ã«å¯ŸããŠå€§éã®æ¥ç¶è©Šè¡ãçºçãããŸããããã¯ã·ã¹ãã ã®ããã©ãŒãã³ã¹ã«åœ±é¿ãäžããããã»ãã¥ãªãã£ç£èŠã·ã¹ãã ã«ãã£ãŠæ€ç¥ããããããå¯èœæ§ããããŸãã䜿çšããéã¯ã圱é¿ãååã«ç解ããèš±å¯ãããç°å¢ã§ã®ã¿å®è¡ããŠãã ããã
ãããã¬ãŒã·ã§ã³ãã¹ãã«ããã圹å²
rpcmap.py
ã¯ããããã¬ãŒã·ã§ã³ãã¹ãã®æ
å ±åéãã§ãŒãºã§éåžžã«åœ¹ç«ã¡ãŸãã
- ãµãŒãã¹ç¹å®: ã¿ãŒã²ããã§ã©ã®ãããªWindowsãµãŒãã¹ãåäœããŠããããç¹å®ããŸã (äŸ: Service Control Manager, Task Scheduler, Remote Registry)ã
- æ»æçµè·¯ã®çºèŠ: ç¹å®ããããµãŒãã¹ãã€ã³ã¿ãŒãã§ãŒã¹ã«é¢é£ããæ¢ç¥ã®èåŒ±æ§ (äŸ: PrintNightmare (MS-RPRN), ZeroLogon (MS-NRPC)) ã®ååšã瀺åããå¯èœæ§ããããŸãã
- ã¢ã¯ã»ã¹å¶åŸ¡ã®è©äŸ¡: èªèšŒãªã (NULLã»ãã·ã§ã³) ã§ã¢ã¯ã»ã¹å¯èœãªã€ã³ã¿ãŒãã§ãŒã¹ãšãèªèšŒãå¿ èŠãªã€ã³ã¿ãŒãã§ãŒã¹ãåºå¥ããããšã§ãã·ã¹ãã ã®ã¢ã¯ã»ã¹å¶åŸ¡èšå®ã®å ç¢æ§ãè©äŸ¡ããŸãã
- ã©ãã©ã«ã ãŒãã¡ã³ãã®è¶³ããã: çºèŠãããRPCã€ã³ã¿ãŒãã§ãŒã¹ã¯ãä»ã®ImpacketããŒã« (äŸ:
services.py
,atexec.py
,wmiexec.py
) ã䜿çšããã©ãã©ã«ã ãŒãã¡ã³ãïŒæšªæ¹åãžã®äŸµå®³æ¡å€§ïŒã®ã¿ãŒã²ãããšãªãåŸãŸãã
äŸãã°ãrpcmap.py
㧠\PIPE\svcctl
(Service Control Manager) ãã¢ã¯ã»ã¹å¯èœã§ããããšããããã°ãservices.py
ã䜿ã£ãŠãªã¢ãŒãã§ãµãŒãã¹ãæäœã§ããå¯èœæ§ããããŸãã
ã»ãã¥ãªãã£äžã®æå³åããšå¯Ÿç ð¡ïž
rpcmap.py
ã«ãã£ãŠåéãããæ
å ±ã¯ãæ»æè
ã«ãšã£ãŠéåžžã«äŸ¡å€ããããŸããå
¬éãããŠããRPCã€ã³ã¿ãŒãã§ãŒã¹ã¯ãæœåšçãªæ»æ察象é å (Attack Surface) ã瀺ããŠããŸããç¹ã«ãèªèšŒãªãã§ã¢ã¯ã»ã¹å¯èœãªã€ã³ã¿ãŒãã§ãŒã¹ããæ¢ç¥ã®è匱æ§ãæã€ã€ã³ã¿ãŒãã§ãŒã¹ã¯ãã·ã¹ãã 䟵害ã®ãªã¹ã¯ãé«ããŸãã
ãªã¹ã¯
- æ å ±æŒæŽ©: ã·ã¹ãã æ§æãå®è¡äžã®ãµãŒãã¹ãå Žåã«ãã£ãŠã¯ãŠãŒã¶ãŒæ å ±ãªã©ãæŒæŽ©ããå¯èœæ§ããããŸãã
- è匱æ§ã®æªçš: ç¹å®ãããã€ã³ã¿ãŒãã§ãŒã¹ã«ååšããæ¢ç¥ãŸãã¯æªç¥ã®è匱æ§ãæªçšããããªã¢ãŒãã³ãŒãå®è¡ãæš©éææ Œã«ã€ãªããå¯èœæ§ããããŸã (äŸ: 2022幎ã®CVE-2022-26809 MSRPCè匱æ§)ã
- ãµãŒãã¹éçšåŠšå®³ (DoS):
-brute-opnums
ã®ãããªã¹ãã£ã³ã¯ãæå³ãããšãã¿ãŒã²ãããµãŒãã¹ã«è² è·ããããå¿çäžèœã«ããå¯èœæ§ããããŸãã - ã©ãã©ã«ã ãŒãã¡ã³ã: æ»æè ããããã¯ãŒã¯å éšã«äŸµå ¥ããåŸãRPCã€ã³ã¿ãŒãã§ãŒã¹ãå©çšããŠä»ã®ã·ã¹ãã ãžäŸµå®³ãæ¡å€§ãã足ããããšãããããšããããŸãã
察ç
RPCã€ã³ã¿ãŒãã§ãŒã¹ã«é¢é£ãããªã¹ã¯ã軜æžããããã«ã¯ã以äžã®ãããªå¯ŸçãèããããŸãã
- ãã¡ã€ã¢ãŠã©ãŒã«ã«ããã¢ã¯ã»ã¹å¶åŸ¡: äžèŠãªRPCããŒã (ç¹ã«TCP 135, 139, 445, 593 ããã³åçRPCããŒãç¯å²) ãžã®ã¢ã¯ã»ã¹ããä¿¡é Œããããããã¯ãŒã¯ããã¹ãããã®ã¿ã«å¶éããŸãã
- RPCãã£ã«ã¿ãŒã®èšå®: Windowsãã¡ã€ã¢ãŠã©ãŒã«ãªã©ã®æ©èœã䜿çšããŠãç¹å®ã®RPCã€ã³ã¿ãŒãã§ãŒã¹UUIDãžã®ã¢ã¯ã»ã¹ãå¶åŸ¡ããŸããäžèŠãªã€ã³ã¿ãŒãã§ãŒã¹ãžã®ã¢ã¯ã»ã¹ããããã¯ããŸãã
- èªèšŒã®èŠæ±: RPCã€ã³ã¿ãŒãã§ãŒã¹ãžã®ã¢ã¯ã»ã¹ã«ã¯ãåžžã«èªèšŒãèŠæ±ããããã«èšå®ããŸããNULLã»ãã·ã§ã³ã§ã®ã¢ã¯ã»ã¹ãç¡å¹åããŸã (ãã ããäºææ§ã®åé¡ã«æ³šæãå¿ èŠã§ã)ã
- äžèŠãªãµãŒãã¹ã®ç¡å¹å: ã·ã¹ãã äžã§äžèŠãªãµãŒãã¹ã¯åæ¢ããç¡å¹åããŸããããã«ãããé¢é£ããRPCã€ã³ã¿ãŒãã§ãŒã¹ãå ¬éãããªããªããŸãã
- ãããé©çš: OSãã¢ããªã±ãŒã·ã§ã³ã«ååšããæ¢ç¥ã®è匱æ§ãä¿®æ£ãããããã»ãã¥ãªãã£ããããè¿ éã«é©çšããŸãã
- ãããã¯ãŒã¯ã»ã°ã¡ã³ããŒã·ã§ã³: ãããã¯ãŒã¯ãã»ã°ã¡ã³ãåããéèŠãªãµãŒããŒãžã®ã¢ã¯ã»ã¹ãå¶éããŸãã
- ã»ãã¥ãªãã£ç£èŠ: RPCé¢é£ã®ç°åžžãªãã©ãã£ãã¯ãæ¥ç¶è©Šè¡ãç£èŠããæ€ç¥ããä»çµã¿ãå°å ¥ããŸã (äŸ: EDR, SIEM)ã
rpcmap.py
ã®ãããªããŒã«ã¯ããããã®å¯Ÿçãé©åã«æ©èœããŠãããã確èªããããã®ç£æ»ããŒã«ãšããŠãæå¹æŽ»çšã§ããŸããå®æçãªã¹ãã£ã³ã«ãããæå³ããå
¬éãããŠããã€ã³ã¿ãŒãã§ãŒã¹ãèšå®ãã¹ãçºèŠããããšãã§ããŸããâ
ãŸãšã âš
Impacketã® rpcmap.py
ã¯ãWindowsãããã¯ãŒã¯ç°å¢ã«ãããMSRPCã€ã³ã¿ãŒãã§ãŒã¹ã®èª¿æ»ã«äžå¯æ¬ ãªããŒã«ã§ããã¿ãŒã²ããã·ã¹ãã ã§å
¬éãããŠããRPCãµãŒãã¹ãšãã®ãšã³ããã€ã³ããç¹å®ããã·ã¹ãã ã®æ»æ察象é åãç解ããäžã§éèŠãªæ
å ±ãæäŸããŸãã
åºæ¬çãªäœ¿ãæ¹ãããèªèšŒãªãã·ã§ã³ããã«ãŒããã©ãŒã¹æ©èœãŸã§ãrpcmap.py
ã¯å€æ§ãªã¹ãã£ã³ã·ããªãªã«å¯Ÿå¿ã§ããŸãããããããã®åŒ·åãããã«ã䜿çšã«ã¯æ³šæãå¿
èŠã§ããç¹ã«ãã«ãŒããã©ãŒã¹ãªãã·ã§ã³ã¯ãã¿ãŒã²ããã·ã¹ãã ãžã®åœ±é¿ãæ€ç¥ãªã¹ã¯ã䌎ããŸãã
ã»ãã¥ãªãã£å°é家ã¯ãrpcmap.py
ãçšããŠèªçµç¹ã®ã·ã¹ãã ã®è匱æ§ãè©äŸ¡ããé©åãªã¢ã¯ã»ã¹å¶åŸ¡ããããé©çšãšãã£ã察çãè¬ããããšãæšå¥šãããŸããäžæ¹ã§ãæ»æè
ãåæ§ã®ããŒã«ã䜿çšããŠåŒ±ç¹ãæ¢ããŠããããšãèªèããé²åŸ¡çãç¶ç¶çã«èŠçŽãå¿
èŠããããŸãã
ãã®èšäºããrpcmap.py
ã®ç解ãšãWindowsãããã¯ãŒã¯ã»ãã¥ãªãã£ã®åäžã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸããð¡ïž Happy Hacking (ethically, of course)! ð
ã³ã¡ã³ã