Skip to content

Instantly share code, notes, and snippets.

@sh4dowb
sh4dowb / eba-canli-ders.md
Last active March 21, 2023 16:49
EBA canlı ders için Linux ve Mac desteği (Zoom)
@sh4dowb
sh4dowb / gist:861934f2d0472400c6f9a764b4b7589d
Last active December 9, 2021 09:02
telethon get if participant is admin
from telethon.tl.types import ChannelParticipantCreator, ChannelParticipantAdmin
from telethon.tl.functions.channels import GetParticipantRequest
#..
@client.on(events.NewMessage)
async def handler(event):
participant = await client(GetParticipantRequest(channel=event.original_update.message.to_id.channel_id,user_id=event.original_update.message.from_id))
isadmin = (type(participant.participant) == ChannelParticipantAdmin)
iscreator = (type(participant.participant) == ChannelParticipantCreator)
@sh4dowb
sh4dowb / multipleevent.py
Last active June 18, 2020 07:21
telethon capture multiple events - capture button and/or text event
def press_or_text(user_id):
return events.Raw(func=lambda e: (type(e) == UpdateNewMessage and e.message.from_id == user_id) or (type(e) == UpdateBotCallbackQuery and e.user_id == user_id and e.data != b'cancel'))
whatever = await conv.wait_event(press_or_text(sender))
if type(whatever) == UpdateBotCallbackQuery and whatever.data in [b'create', b'list']:
# button clicked
# not actual event like "CallbackQuery", you can't use .edit() etc. directly
print(whatever.data)
else:
# message sent
@sh4dowb
sh4dowb / netherlands-iban-acc-number-validate.py
Last active December 25, 2020 18:44
Netherlands IBAN account number checksum validator
# Netherlands account number algorithm uses this factor table:
# digit | factor
# 1st | 10
# 2nd | 9
# ...
# 10th | 1
#
# After multiplying digits according to the table, sum of these results must be divisible with 11
@sh4dowb
sh4dowb / decrypt_ruby_MessageEncryptor.py
Created April 8, 2021 07:34
Decrypt Ruby's ActiveSupport::MessageEncryptor on Python 3
import hashlib
import base64
from Crypto import Random
from Crypto.Cipher import AES
import rubymarshal.reader
from pbkdf2 import PBKDF2
SECRET = "a3f58debfe0c5b71edaebea3a627f4f"
SALT = "12345"
ITERATIONS = 65536
@sh4dowb
sh4dowb / decrypt_ruby_MessageEncryptor.py
Last active April 17, 2021 18:14
Decrypt Ruby's ActiveSupport::MessageEncryptor on Python 3
import hashlib
import base64
from Crypto import Random
from Crypto.Cipher import AES
import rubymarshal.reader
from pbkdf2 import PBKDF2
SECRET = "asdasd"
ITERATIONS = 65536
KEYLENGTH = 32
@sh4dowb
sh4dowb / atomic_eth.js
Created May 30, 2021 20:03
atomic wallet get eth private key / address by mnemonic seed
// fuck you atomic. why can't you just be fucking normal?
// east home innocent snake icon curtain series brave guard program history stand
// BIP39 seed:
var seed = new Uint8Array([70, 78, 5, 155, 232, 171, 38, 78, 191, 56, 142, 102, 122, 20, 65, 239, 127, 215, 39, 174, 28, 222, 17, 150, 102, 129, 182, 172, 246, 80, 15, 19, 79, 248, 113, 244, 95, 101, 33, 96, 203, 181, 243, 63, 23, 9, 71, 102, 37, 216, 196, 6, 77, 209, 18, 2, 107, 12, 239, 38, 249, 29, 107, 249]);
var s = require('ethereum-cryptography/pure/hdkey').HDKey;
var t = require('ethereumjs-wallet');
var w = s.fromMasterSeed(seed);
@sh4dowb
sh4dowb / send_usdt.py
Last active March 16, 2024 18:55
tronapi python mass USDT payment - send mass USDT payments with python
import time
from tronapi import Tron
full_node = 'https://api.trongrid.io'
solidity_node = 'https://api.trongrid.io'
event_server = 'https://api.trongrid.io'
pkey = "private_key_hex"
payments = [
@sh4dowb
sh4dowb / decrypt.py
Created September 17, 2021 19:41
Decrypt crypto-js default AES encryption with OpenSSL KDF in Python 3
# I absolutely hated crypto-js for this. non-standard configurations, weird algorithms, ...
# well obviously you can encrypt it with a better configuration which people will not
# go crazy figuring out its implementation, but in this case I wasn't encrypting the data.
import base64
from Crypto.Hash import MD5
from Crypto.Util.Padding import unpad
from Crypto.Cipher import AES
# generated using: CryptoJS.AES.encrypt('test 123456 plaintext', 'some password').toString()
@sh4dowb
sh4dowb / stake_limbo_verify.py
Created December 8, 2021 23:49
verify stake.com limbo outcome with python
import hmac
import hashlib
def getLimboOutcome(server, client, nonce):
server = server.encode()
client = client.encode()
nonce = str(nonce).encode()
round = 0
hash = hmac.new(server, client+b':'+nonce+b':'+str(round).encode('utf-8'), hashlib.sha256).digest()
first4 = hash[:4]