Skip to content

Instantly share code, notes, and snippets.

def decrypt(self, encrypted_text):
encrypted_text = b64decode(encrypted_text)
iv = encrypted_text[:self.block_size]
cipher = AES.new(self.key, AES.MODE_CBC, iv)
plain_text = cipher.decrypt(encrypted_text[self.block_size:]).decode("utf-8")
return self.__unpad(plain_text)
def encrypt(self, plain_text):
plain_text = self.__pad(plain_text)
iv = Random.new().read(self.block_size)
cipher = AES.new(self.key, AES.MODE_CBC, iv)
encrypted_text = cipher.encrypt(plain_text.encode())
return b64encode(iv + encrypted_text).decode("utf-8")
@PaburoTC
PaburoTC / pad.py
Last active April 23, 2020 08:38
Pad&UnPad
def __pad(self, plain_text):
number_of_bytes_to_pad = self.block_size - len(plain_text) % self.block_size
ascii_string = chr(number_of_bytes_to_pad)
padding_str = number_of_bytes_to_pad * ascii_string
padded_plain_text = plain_text + padding_str
return padded_plain_text
class AESCipher(object):
def __init__(self, key):
self.block_size = AES.block_size
self.key = hashlib.sha256(key.encode()).digest()
@PaburoTC
PaburoTC / imports.py
Last active April 23, 2020 08:39
AESimports
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
from base64 import b64encode, b64decode
def __login(self, username, pswd):
sleep(2)
username_input = self.driver.find_element_by_xpath("//input[@name=\"username\"]")
username_input.send_keys(username)
pswd_input = self.driver.find_element_by_xpath("//input[@name=\"password\"]")
pswd_input.send_keys(pswd)
login = self.driver.find_element_by_xpath("//button[@type=\"submit\"]")
class InstaBot:
def __init__(self):
self.driver = webdriver.Chrome()
self.driver.get("https://instagram.com")
self.__login("patoo301","thisIsNotMyPassword")
while True:
pass
def __login(self, username, pswd):
[...]
from selenium import webdriver
from time import sleep
@PaburoTC
PaburoTC / TBot1.py
Created April 30, 2020 16:31
TBot1
class TBot:
def __init__(self):
self.driver = webdriver.Chrome()
self.driver.get("https://twitter.com/login")
while True:
pass
def __login(self, username, pswd):
sleep(2)
username_input = self.driver.find_element_by_xpath("//input[@name=\"session[username_or_email]\"]")
username_input.send_keys(username)
pswd_input = self.driver.find_element_by_xpath("//input[@name=\"session[password]\"]")
pswd_input.send_keys(pswd)
login = self.driver.find_element_by_xpath("//div[@data-testid=\"LoginForm_Login_Button\"]/div")