├── Bitcoin List with filter pop up (needs fixing).py ├── Bitcoin List.py ├── Bitcoin_List.py ├── README.md ├── Target Addresses.txt ├── gpu_sha256.py ├── requirements.txt ├── sha256.cl └── sha256_class.py /Bitcoin List with filter pop up (needs fixing).py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QApplication, QTableView, QVBoxLayout, QWidget, QHeaderView, QAbstractItemView, QAction, QStyledItemDelegate, QLineEdit, QHBoxLayout, QMessageBox, QPushButton, QTableWidget, QTableWidgetItem 2 | from PyQt5.QtGui import QKeySequence, QColor, QDesktopServices, QBrush, QPalette, QFont 3 | from PyQt5.QtCore import Qt, QAbstractTableModel, QVariant, QModelIndex, QUrl 4 | from ecdsa import SigningKey, SECP256k1 5 | import hashlib 6 | import base58 7 | import pyopencl as cl 8 | import numpy as np 9 | import os 10 | 11 | os.environ["PYOPENCL_CTX"] = "0" 12 | 13 | class MyModel(QAbstractTableModel): 14 | def __init__(self, parent=None): 15 | super().__init__(parent) 16 | self.buffer_size = 10000 17 | self.starting_point = int('0000000000000000000000000000000000000000000000000000000000000001', 16) 18 | self.buffer = list(range(self.starting_point, self.starting_point + self.buffer_size)) 19 | self.addresses_c = {} # Compressed addresses 20 | self.addresses_u = {} # Uncompressed addresses 21 | self.target_addresses = set() 22 | self.load_target_addresses() # Load target addresses from a file 23 | self.found_targets = set() # Store found target addresses 24 | # OpenCL setup 25 | self.ctx = cl.create_some_context() 26 | self.queue = cl.CommandQueue(self.ctx) 27 | # Load and compile the OpenCL kernel 28 | with open("sha256.cl", "r") as kernel_file: 29 | kernel_source = kernel_file.read() 30 | self.program = cl.Program(self.ctx, kernel_source).build() 31 | # Filter text for each column 32 | self.filter_text = { 33 | 0: "", # Filter text for column 0 34 | 1: "", # Filter text for column 1 35 | 2: "", # Filter text for column 2 36 | 3: "", # Filter text for column 3 37 | } 38 | 39 | def load_target_addresses(self): 40 | with open("Target Addresses.txt", "r") as target_file: 41 | for line in target_file: 42 | self.target_addresses.add(line.strip()) 43 | 44 | def calculate_sha256(self, private_key): 45 | # Convert private_key to bytes 46 | private_key_bytes = private_key.to_bytes(32, 'big') 47 | # Create OpenCL buffers for input and output data 48 | input_buffer = cl.Buffer(self.ctx, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=private_key_bytes) 49 | output_buffer = cl.Buffer(self.ctx, cl.mem_flags.WRITE_ONLY, 32) 50 | # Execute the OpenCL kernel 51 | self.program.func_sha256(self.queue, private_key_bytes.shape, None, input_buffer, output_buffer) 52 | # Read the result from the OpenCL buffer 53 | hash_result = np.empty(8, dtype=np.uint32) 54 | cl.enqueue_copy(self.queue, hash_result, output_buffer).wait() 55 | 56 | return hash_result 57 | 58 | def rowCount(self, parent=None): 59 | return len(self.buffer) 60 | 61 | def columnCount(self, parent=None): 62 | return 4 63 | 64 | def data(self, index, role=Qt.DisplayRole): 65 | if role == Qt.DisplayRole: 66 | if index.column() == 0: 67 | value = str(self.buffer[index.row()]) 68 | elif index.column() == 1: 69 | value = format(self.buffer[index.row()], '064x') 70 | elif index.column() in [2, 3]: 71 | hex_number = format(self.buffer[index.row()], '064x') 72 | key = SigningKey.from_string(bytes.fromhex(hex_number), curve=SECP256k1) 73 | public_key = key.get_verifying_key().to_string('compressed' if index.column() == 2 else 'uncompressed') 74 | h = hashlib.sha256(public_key).digest() 75 | r = hashlib.new('ripemd160', h).digest() 76 | value = base58.b58encode_check(b"\x00" + r).decode('utf-8') 77 | if index.column() == 2: 78 | self.addresses_c[self.buffer[index.row()]] = value 79 | else: 80 | self.addresses_u[self.buffer[index.row()]] = value 81 | # Apply filters based on filter_text 82 | if self.filter_text[index.column()] and self.filter_text[index.column()] not in value: 83 | return None # Filtered out if the text doesn't match 84 | return value 85 | elif role == Qt.BackgroundRole: 86 | address = self.data(index, Qt.DisplayRole) 87 | if address in self.target_addresses and address not in self.found_targets: 88 | self.found_targets.add(address) 89 | private_key_hex = format(self.buffer[index.row()], '064x') 90 | message = f"Found target address: {address} - Private Key: {private_key_hex}" 91 | QMessageBox.information(None, "Target Address Found", message) 92 | print(message) # Print to the terminal 93 | return QColor(Qt.white) # Highlight the target address cell in white 94 | return QVariant() 95 | 96 | def headerData(self, section, orientation, role=Qt.DisplayRole): 97 | if role == Qt.DisplayRole and orientation == Qt.Horizontal: 98 | return ["Row Number", "Private Key Hex", "P2PKH(c)", "P2PKH(u)"][section] 99 | return QVariant() 100 | 101 | def canFetchMore(self, index): 102 | return not self.found_targets.issuperset(self.target_addresses) 103 | 104 | def fetchMore(self, index): 105 | if self.canFetchMore(index): 106 | self.beginInsertRows(QModelIndex(), self.rowCount(), self.rowCount() + self.buffer_size - 1) 107 | self.starting_point += self.buffer_size 108 | new_data = list(range(self.starting_point, self.starting_point + self.buffer_size)) 109 | self.buffer.extend(new_data) 110 | self.endInsertRows() 111 | if len(self.buffer) > self.buffer_size: 112 | self.beginRemoveRows(QModelIndex(), 0, self.buffer_size - 1) 113 | self.buffer = self.buffer[self.buffer_size:] 114 | self.endRemoveRows() 115 | 116 | def getFilteredData(self): 117 | # Initialize empty filtered data 118 | filtered_data = {0: [], 1: [], 2: [], 3: []} 119 | # Iterate over all data 120 | for i in range(self.rowCount()): 121 | for j in range(self.columnCount()): 122 | index = self.index(i, j) 123 | data = self.data(index, Qt.DisplayRole) 124 | # If data is not None, add it to the filtered data 125 | if data is not None: 126 | filtered_data[j].append(data) 127 | return filtered_data 128 | 129 | class AlternatingRowDelegate(QStyledItemDelegate): 130 | def initStyleOption(self, option, index): 131 | super().initStyleOption(option, index) 132 | if index.row() % 2 == 0: 133 | option.backgroundBrush = QBrush(QColor(173, 216, 230)) # Light blue background for even rows 134 | else: 135 | option.backgroundBrush = QBrush(QColor(173, 216, 230)) # Blue background for odd rows 136 | # Make the font bold 137 | option.font.setBold(True) 138 | 139 | class CustomTableView(QTableView): 140 | def __init__(self, *args, **kwargs): 141 | super().__init__(*args, **kwargs) 142 | 143 | def resizeEvent(self, event): 144 | if self.model(): 145 | max_compressed_address_length = max(len(self.model().addresses_c[address]) for address in self.model().addresses_c) 146 | max_uncompressed_address_length = max(len(self.model().addresses_u[address]) for address in self.model().addresses_u) 147 | max_length = max(max_compressed_address_length, max_uncompressed_address_length) 148 | 149 | if max_length > 0: 150 | for column in [2, 3]: # Columns 2 and 3 (compressed and uncompressed addresses) 151 | column_width = self.columnWidth(column) 152 | new_column_width = max(column_width, max_length * 7) # Adjust the factor (7) based on your font and style 153 | self.setColumnWidth(column, new_column_width) 154 | super().resizeEvent(event) 155 | 156 | class FilteredResultsWidget(QWidget): 157 | def __init__(self, parent=None): 158 | super().__init__(parent) 159 | self.table = QTableWidget() 160 | self.table.setColumnCount(4) 161 | self.table.setHorizontalHeaderLabels(["Row Number", "Private Key Hex", "P2PKH(c)", "P2PKH(u)"]) 162 | self.table.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) 163 | self.table.verticalHeader().hide() 164 | self.table.setSelectionMode(QAbstractItemView.NoSelection) 165 | self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) 166 | self.table.setColumnWidth(2, 150) 167 | self.table.setColumnWidth(3, 150) 168 | 169 | layout = QVBoxLayout() 170 | layout.addWidget(self.table) 171 | self.setLayout(layout) 172 | 173 | def updateFilteredResults(self, filtered_data): 174 | self.table.setRowCount(0) 175 | for row in zip(*filtered_data.values()): 176 | self.table.insertRow(self.table.rowCount()) 177 | for col, value in enumerate(row): 178 | item = QTableWidgetItem(value) 179 | self.table.setItem(self.table.rowCount() - 1, col, item) 180 | 181 | class Window(QWidget): 182 | def __init__(self): 183 | super().__init__() 184 | self.initUI() 185 | 186 | def initUI(self): 187 | layout = QVBoxLayout() 188 | self.table = CustomTableView() 189 | self.model = MyModel() 190 | self.table.setModel(self.model) 191 | delegate = AlternatingRowDelegate() # Note the parentheses here 192 | self.table.setItemDelegate(delegate) 193 | self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) 194 | self.table.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeToContents) 195 | self.table.setColumnWidth(2, 150) 196 | self.table.setColumnWidth(3, 150) 197 | self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) 198 | self.table.clicked.connect(self.cellClicked) 199 | 200 | layout.addWidget(self.table) 201 | 202 | header_palette = QPalette() 203 | header_palette.setColor(QPalette.Window, QColor(79, 129, 189)) 204 | self.table.horizontalHeader().setPalette(header_palette) 205 | 206 | selected_palette = QPalette() 207 | selected_palette.setColor(QPalette.Highlight, QColor(173, 216, 230)) 208 | self.table.setPalette(selected_palette) 209 | 210 | self.filter_inputs = [] 211 | for i in range(4): 212 | filter_input = QLineEdit(self) 213 | filter_input.setPlaceholderText(f"Filter Column {i}") 214 | filter_input.textChanged.connect(lambda text, col=i: self.applyFilter(col, text)) 215 | self.filter_inputs.append(filter_input) 216 | 217 | filter_layout = QHBoxLayout() 218 | for filter_input in self.filter_inputs: 219 | filter_layout.addWidget(filter_input) 220 | 221 | layout.addLayout(filter_layout) 222 | 223 | # Add "Clear Filters" button 224 | clear_filters_btn = QPushButton("Clear Filters") 225 | clear_filters_btn.clicked.connect(self.clearFilters) 226 | layout.addWidget(clear_filters_btn) 227 | 228 | self.setLayout(layout) 229 | 230 | # Create and initialize the filtered results widget 231 | self.filtered_results_widget = FilteredResultsWidget() 232 | layout.addWidget(self.filtered_results_widget) 233 | self.filtered_results_widget.hide() # Initially, hide the filtered results widget 234 | 235 | def cellClicked(self, index): 236 | if index.column() == 1: # Check if the clicked cell is in column 1 (Private Key Hex) 237 | private_key_hex = index.data() 238 | if private_key_hex: 239 | # Construct the privatekeyfinder.io URL with the private key appended 240 | privatekeyfinder_url = f"https://privatekeyfinder.io/private-keys/bitcoin/?private-key={private_key_hex}" 241 | # Open the privatekeyfinder.io URL in the default web browser 242 | QDesktopServices.openUrl(QUrl(privatekeyfinder_url)) 243 | elif index.column() in [2, 3]: # Check if the clicked cell is in columns 2 or 3 244 | address = index.data() 245 | if address: 246 | # Construct the Blockchair URL with the clicked address 247 | blockchair_url = f"https://blockchair.com/bitcoin/address/{address}" 248 | # Open the Blockchair URL in the default web browser 249 | QDesktopServices.openUrl(QUrl(blockchair_url)) 250 | 251 | def applyFilter(self, column, text): 252 | self.model.filter_text[column] = text 253 | self.model.layoutChanged.emit() 254 | if column == 2: # Only update the filtered results widget for the "P2PKH(c)" column 255 | filtered_data = self.model.getFilteredData() 256 | self.filtered_results_widget.updateFilteredResults(filtered_data) 257 | if text: 258 | self.filtered_results_widget.show() 259 | else: 260 | self.filtered_results_widget.hide() 261 | 262 | def clearFilters(self): 263 | for column in range(4): 264 | self.model.filter_text[column] = "" 265 | self.filter_inputs[column].clear() 266 | self.model.layoutChanged.emit() 267 | self.filtered_results_widget.hide() # Hide the filtered results widget when filters are cleared 268 | 269 | app = QApplication([]) 270 | window = Window() 271 | window.setWindowTitle("Bitcoin Address Table") 272 | window.showMaximized() # Maximize the main window 273 | app.exec_() 274 | -------------------------------------------------------------------------------- /Bitcoin List.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QApplication, QTableView, QVBoxLayout, QWidget, QHeaderView, QAbstractItemView, QAction, QStyledItemDelegate, QLineEdit, QHBoxLayout, QMessageBox, QPushButton 2 | from PyQt5.QtGui import QKeySequence, QColor, QDesktopServices, QBrush, QPalette, QFont 3 | from PyQt5.QtCore import Qt, QAbstractTableModel, QVariant, QModelIndex, QUrl 4 | from ecdsa import SigningKey, SECP256k1 5 | import hashlib 6 | import base58 7 | import pyopencl as cl 8 | import numpy as np 9 | import os 10 | 11 | os.environ["PYOPENCL_CTX"] = "0" 12 | 13 | 14 | class MyModel(QAbstractTableModel): 15 | def __init__(self, parent=None): 16 | super().__init__(parent) 17 | self.buffer_size = 2000 18 | self.starting_point = int('0000000000000000000000000000000000000000000000000000000000000001', 16) 19 | self.buffer = list(range(self.starting_point, self.starting_point + self.buffer_size)) 20 | self.addresses_c = {} # Compressed addresses 21 | self.addresses_u = {} # Uncompressed addresses 22 | self.target_addresses = set() 23 | self.load_target_addresses() # Load target addresses from a file 24 | self.found_targets = set() # Store found target addresses 25 | # Initialize ctx and program to None 26 | self.ctx = None 27 | self.program = None 28 | 29 | try: 30 | self.ctx = cl.create_some_context() 31 | self.queue = cl.CommandQueue(self.ctx) 32 | # Load and compile the OpenCL kernel 33 | with open("sha256.cl", "r") as kernel_file: 34 | kernel_source = kernel_file.read() 35 | self.program = cl.Program(self.ctx, kernel_source).build() 36 | except Exception as e: 37 | print("Error initializing OpenCL:", e) 38 | self.ctx = None # Set ctx to None to indicate that GPU is not available 39 | 40 | # Filter text for each column 41 | self.filter_text = { 42 | 0: "", # Filter text for column 0 43 | 1: "", # Filter text for column 1 44 | 2: "", # Filter text for column 2 45 | 3: "", # Filter text for column 3 46 | } 47 | 48 | 49 | def load_target_addresses(self): 50 | with open("Target Addresses.txt", "r") as target_file: 51 | for line in target_file: 52 | self.target_addresses.add(line.strip()) 53 | 54 | def calculate_sha256(self, private_key): 55 | if self.ctx is None: 56 | # Use CPU-based computation as GPU is not available 57 | private_key_bytes = private_key.to_bytes(32, 'big') 58 | hash_result = hashlib.sha256(private_key_bytes).digest() 59 | return np.frombuffer(hash_result, dtype=np.uint32) 60 | 61 | # Convert private_key to bytes 62 | private_key_bytes = private_key.to_bytes(32, 'big') 63 | # Create OpenCL buffers for input and output data 64 | input_buffer = cl.Buffer(self.ctx, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=private_key_bytes) 65 | output_buffer = cl.Buffer(self.ctx, cl.mem_flags.WRITE_ONLY, 32) 66 | # Execute the OpenCL kernel 67 | self.program.func_sha256(self.queue, private_key_bytes.shape, None, input_buffer, output_buffer) 68 | # Read the result from the OpenCL buffer 69 | hash_result = np.empty(8, dtype=np.uint32) 70 | cl.enqueue_copy(self.queue, hash_result, output_buffer).wait() 71 | 72 | return hash_result 73 | 74 | 75 | def rowCount(self, parent=None): 76 | return len(self.buffer) 77 | 78 | def columnCount(self, parent=None): 79 | return 4 80 | 81 | def data(self, index, role=Qt.DisplayRole): 82 | if role == Qt.DisplayRole: 83 | if index.column() == 0: 84 | value = str(self.buffer[index.row()]) 85 | elif index.column() == 1: 86 | value = format(self.buffer[index.row()], '064x') 87 | elif index.column() in [2, 3]: 88 | hex_number = format(self.buffer[index.row()], '064x') 89 | key = SigningKey.from_string(bytes.fromhex(hex_number), curve=SECP256k1) 90 | public_key = key.get_verifying_key().to_string('compressed' if index.column() == 2 else 'uncompressed') 91 | h = hashlib.sha256(public_key).digest() 92 | r = hashlib.new('ripemd160', h).digest() 93 | value = base58.b58encode_check(b"\x00" + r).decode('utf-8') 94 | if index.column() == 2: 95 | self.addresses_c[self.buffer[index.row()]] = value 96 | else: 97 | self.addresses_u[self.buffer[index.row()]] = value 98 | # Apply filters based on filter_text 99 | if self.filter_text[index.column()] and self.filter_text[index.column()] not in value: 100 | return None # Filtered out if the text doesn't match 101 | return value 102 | elif role == Qt.BackgroundRole: 103 | address = self.data(index, Qt.DisplayRole) 104 | if address in self.target_addresses and address not in self.found_targets: 105 | self.found_targets.add(address) 106 | private_key_hex = format(self.buffer[index.row()], '064x') 107 | message = f"Found target address: {address} - Private Key: {private_key_hex}" 108 | QMessageBox.information(None, "Target Address Found", message) 109 | print(message) # Print to the terminal 110 | return QColor(Qt.white) # Highlight the target address cell in white 111 | return QVariant() 112 | 113 | def headerData(self, section, orientation, role=Qt.DisplayRole): 114 | if role == Qt.DisplayRole and orientation == Qt.Horizontal: 115 | return ["Row Number", "Private Key Hex", "P2PKH(c)", "P2PKH(u)"][section] 116 | return QVariant() 117 | 118 | def canFetchMore(self, index): 119 | return not self.found_targets.issuperset(self.target_addresses) 120 | 121 | def fetchMore(self, index): 122 | if self.canFetchMore(index): 123 | self.beginInsertRows(QModelIndex(), self.rowCount(), self.rowCount() + self.buffer_size - 1) 124 | self.starting_point += self.buffer_size 125 | new_data = list(range(self.starting_point, self.starting_point + self.buffer_size)) 126 | self.buffer.extend(new_data) 127 | self.endInsertRows() 128 | if len(self.buffer) > self.buffer_size: 129 | self.beginRemoveRows(QModelIndex(), 0, self.buffer_size - 1) 130 | self.buffer = self.buffer[self.buffer_size:] 131 | self.endRemoveRows() 132 | 133 | class AlternatingRowDelegate(QStyledItemDelegate): 134 | def initStyleOption(self, option, index): 135 | super().initStyleOption(option, index) 136 | if index.row() % 2 == 0: 137 | option.backgroundBrush = QBrush(QColor(173, 216, 230)) # Light blue background for even rows 138 | else: 139 | option.backgroundBrush = QBrush(QColor(173, 216, 230)) # Blue background for odd rows 140 | # Make the font bold 141 | option.font.setBold(True) 142 | 143 | class CustomTableView(QTableView): 144 | def __init__(self, *args, **kwargs): 145 | super().__init__(*args, **kwargs) 146 | 147 | def resizeEvent(self, event): 148 | if self.model(): 149 | max_compressed_address_length = max(len(self.model().addresses_c[address]) for address in self.model().addresses_c) 150 | max_uncompressed_address_length = max(len(self.model().addresses_u[address]) for address in self.model().addresses_u) 151 | max_length = max(max_compressed_address_length, max_uncompressed_address_length) 152 | 153 | if max_length > 0: 154 | for column in [2, 3]: # Columns 2 and 3 (compressed and uncompressed addresses) 155 | column_width = self.columnWidth(column) 156 | new_column_width = max(column_width, max_length * 7) # Adjust the factor (7) based on your font and style 157 | self.setColumnWidth(column, new_column_width) 158 | super().resizeEvent(event) 159 | 160 | class Window(QWidget): 161 | def __init__(self): 162 | super().__init__() 163 | self.initUI() 164 | 165 | def initUI(self): 166 | layout = QVBoxLayout() 167 | self.table = CustomTableView() 168 | self.model = MyModel() 169 | self.table.setModel(self.model) 170 | delegate = AlternatingRowDelegate() # Note the parentheses here 171 | self.table.setItemDelegate(delegate) 172 | self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) 173 | self.table.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeToContents) 174 | self.table.setColumnWidth(2, 150) 175 | self.table.setColumnWidth(3, 150) 176 | self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) 177 | self.table.clicked.connect(self.cellClicked) 178 | layout.addWidget(self.table) 179 | self.setLayout(layout) 180 | header_palette = QPalette() 181 | header_palette.setColor(QPalette.Window, QColor(79, 129, 189)) 182 | self.table.horizontalHeader().setPalette(header_palette) 183 | selected_palette = QPalette() 184 | selected_palette.setColor(QPalette.Highlight, QColor(173, 216, 230)) 185 | self.table.setPalette(selected_palette) 186 | self.filter_inputs = [] 187 | for i in range(4): 188 | filter_input = QLineEdit(self) 189 | filter_input.setPlaceholderText(f"Filter Column {i}") 190 | filter_input.textChanged.connect(lambda text, col=i: self.applyFilter(col, text)) 191 | self.filter_inputs.append(filter_input) 192 | filter_layout = QHBoxLayout() 193 | for filter_input in self.filter_inputs: 194 | filter_layout.addWidget(filter_input) 195 | layout.addLayout(filter_layout) 196 | # Add "Clear Filters" button 197 | clear_filters_btn = QPushButton("Clear Filters") 198 | clear_filters_btn.clicked.connect(self.clearFilters) 199 | layout.addWidget(clear_filters_btn) 200 | layout.addWidget(self.table) 201 | 202 | def cellClicked(self, index): 203 | if index.column() == 1: # Check if the clicked cell is in column 1 (Private Key Hex) 204 | private_key_hex = index.data() 205 | if private_key_hex: 206 | # Construct the privatekeyfinder.io URL with the private key appended 207 | privatekeyfinder_url = f"https://privatekeyfinder.io/private-keys/bitcoin/?private-key={private_key_hex}" 208 | # Open the privatekeyfinder.io URL in the default web browser 209 | QDesktopServices.openUrl(QUrl(privatekeyfinder_url)) 210 | elif index.column() in [2, 3]: # Check if the clicked cell is in columns 2 or 3 211 | address = index.data() 212 | if address: 213 | # Construct the Blockchair URL with the clicked address 214 | blockchair_url = f"https://blockchair.com/bitcoin/address/{address}" 215 | # Open the Blockchair URL in the default web browser 216 | QDesktopServices.openUrl(QUrl(blockchair_url)) 217 | 218 | def applyFilter(self, column, text): 219 | # Update the filter text for the specified column 220 | self.model.filter_text[column] = text 221 | # Refresh the table to apply the filter 222 | self.model.layoutChanged.emit() 223 | 224 | def clearFilters(self): 225 | # Clear the filter text for all columns 226 | for column in range(4): 227 | self.model.filter_text[column] = "" 228 | # Clear the text in the filter input fields 229 | for filter_input in self.filter_inputs: 230 | filter_input.setText("") 231 | # Refresh the table to apply the cleared filters 232 | self.model.layoutChanged.emit() 233 | 234 | app = QApplication([]) 235 | window = Window() 236 | window.setWindowTitle("Bitcoin Address Table") 237 | window.showMaximized() # Maximize the main window 238 | app.exec_() 239 | -------------------------------------------------------------------------------- /Bitcoin_List.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QApplication, QTableView, QVBoxLayout, QWidget, QHeaderView, QAbstractItemView, QAction, QStyledItemDelegate, QLineEdit, QHBoxLayout, QMessageBox, QPushButton 2 | from PyQt5.QtGui import QKeySequence, QColor, QDesktopServices, QBrush, QPalette, QFont 3 | from PyQt5.QtCore import Qt, QAbstractTableModel, QVariant, QModelIndex, QUrl 4 | from ecdsa import SigningKey, SECP256k1 5 | import hashlib 6 | import base58 7 | import pyopencl as cl 8 | import numpy as np 9 | import os 10 | 11 | os.environ["PYOPENCL_CTX"] = "0" 12 | 13 | 14 | class MyModel(QAbstractTableModel): 15 | def __init__(self, parent=None): 16 | super().__init__(parent) 17 | self.buffer_size = 2000 18 | self.starting_point = int('0000000000000000000000000000000000000000000000000000000000000001', 16) 19 | self.buffer = list(range(self.starting_point, self.starting_point + self.buffer_size)) 20 | self.addresses_c = {} # Compressed addresses 21 | self.addresses_u = {} # Uncompressed addresses 22 | self.target_addresses = set() 23 | self.load_target_addresses() # Load target addresses from a file 24 | self.found_targets = set() # Store found target addresses 25 | # Initialize ctx and program to None 26 | self.ctx = None 27 | self.program = None 28 | 29 | try: 30 | self.ctx = cl.create_some_context() 31 | self.queue = cl.CommandQueue(self.ctx) 32 | # Load and compile the OpenCL kernel 33 | with open("sha256.cl", "r") as kernel_file: 34 | kernel_source = kernel_file.read() 35 | self.program = cl.Program(self.ctx, kernel_source).build() 36 | except Exception as e: 37 | print("Error initializing OpenCL:", e) 38 | self.ctx = None # Set ctx to None to indicate that GPU is not available 39 | 40 | # Filter text for each column 41 | self.filter_text = { 42 | 0: "", # Filter text for column 0 43 | 1: "", # Filter text for column 1 44 | 2: "", # Filter text for column 2 45 | 3: "", # Filter text for column 3 46 | } 47 | 48 | 49 | def load_target_addresses(self): 50 | with open("Target Addresses.txt", "r") as target_file: 51 | for line in target_file: 52 | self.target_addresses.add(line.strip()) 53 | 54 | def calculate_sha256(self, private_key): 55 | if self.ctx is None: 56 | # Use CPU-based computation as GPU is not available 57 | private_key_bytes = private_key.to_bytes(32, 'big') 58 | hash_result = hashlib.sha256(private_key_bytes).digest() 59 | return np.frombuffer(hash_result, dtype=np.uint32) 60 | 61 | # Convert private_key to bytes 62 | private_key_bytes = private_key.to_bytes(32, 'big') 63 | # Create OpenCL buffers for input and output data 64 | input_buffer = cl.Buffer(self.ctx, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=private_key_bytes) 65 | output_buffer = cl.Buffer(self.ctx, cl.mem_flags.WRITE_ONLY, 32) 66 | # Execute the OpenCL kernel 67 | self.program.func_sha256(self.queue, private_key_bytes.shape, None, input_buffer, output_buffer) 68 | # Read the result from the OpenCL buffer 69 | hash_result = np.empty(8, dtype=np.uint32) 70 | cl.enqueue_copy(self.queue, hash_result, output_buffer).wait() 71 | 72 | return hash_result 73 | 74 | 75 | def rowCount(self, parent=None): 76 | return len(self.buffer) 77 | 78 | def columnCount(self, parent=None): 79 | return 4 80 | 81 | def data(self, index, role=Qt.DisplayRole): 82 | if role == Qt.DisplayRole: 83 | if index.column() == 0: 84 | value = str(self.buffer[index.row()]) 85 | elif index.column() == 1: 86 | value = format(self.buffer[index.row()], '064x') 87 | elif index.column() in [2, 3]: 88 | hex_number = format(self.buffer[index.row()], '064x') 89 | key = SigningKey.from_string(bytes.fromhex(hex_number), curve=SECP256k1) 90 | public_key = key.get_verifying_key().to_string('compressed' if index.column() == 2 else 'uncompressed') 91 | h = hashlib.sha256(public_key).digest() 92 | r = hashlib.new('ripemd160', h).digest() 93 | value = base58.b58encode_check(b"\x00" + r).decode('utf-8') 94 | if index.column() == 2: 95 | self.addresses_c[self.buffer[index.row()]] = value 96 | else: 97 | self.addresses_u[self.buffer[index.row()]] = value 98 | # Apply filters based on filter_text 99 | if self.filter_text[index.column()] and self.filter_text[index.column()] not in value: 100 | return None # Filtered out if the text doesn't match 101 | return value 102 | elif role == Qt.BackgroundRole: 103 | address = self.data(index, Qt.DisplayRole) 104 | if address in self.target_addresses and address not in self.found_targets: 105 | self.found_targets.add(address) 106 | private_key_hex = format(self.buffer[index.row()], '064x') 107 | message = f"Found target address: {address} - Private Key: {private_key_hex}" 108 | QMessageBox.information(None, "Target Address Found", message) 109 | print(message) # Print to the terminal 110 | return QColor(Qt.white) # Highlight the target address cell in white 111 | return QVariant() 112 | 113 | def headerData(self, section, orientation, role=Qt.DisplayRole): 114 | if role == Qt.DisplayRole and orientation == Qt.Horizontal: 115 | return ["Row Number", "Private Key Hex", "P2PKH(c)", "P2PKH(u)"][section] 116 | return QVariant() 117 | 118 | def canFetchMore(self, index): 119 | return not self.found_targets.issuperset(self.target_addresses) 120 | 121 | def fetchMore(self, index): 122 | if self.canFetchMore(index): 123 | self.beginInsertRows(QModelIndex(), self.rowCount(), self.rowCount() + self.buffer_size - 1) 124 | self.starting_point += self.buffer_size 125 | new_data = list(range(self.starting_point, self.starting_point + self.buffer_size)) 126 | self.buffer.extend(new_data) 127 | self.endInsertRows() 128 | if len(self.buffer) > self.buffer_size: 129 | self.beginRemoveRows(QModelIndex(), 0, self.buffer_size - 1) 130 | self.buffer = self.buffer[self.buffer_size:] 131 | self.endRemoveRows() 132 | 133 | class AlternatingRowDelegate(QStyledItemDelegate): 134 | def initStyleOption(self, option, index): 135 | super().initStyleOption(option, index) 136 | if index.row() % 2 == 0: 137 | option.backgroundBrush = QBrush(QColor(173, 216, 230)) # Light blue background for even rows 138 | else: 139 | option.backgroundBrush = QBrush(QColor(173, 216, 230)) # Blue background for odd rows 140 | # Make the font bold 141 | option.font.setBold(True) 142 | 143 | class CustomTableView(QTableView): 144 | def __init__(self, *args, **kwargs): 145 | super().__init__(*args, **kwargs) 146 | 147 | def resizeEvent(self, event): 148 | if self.model(): 149 | max_compressed_address_length = max(len(self.model().addresses_c[address]) for address in self.model().addresses_c) 150 | max_uncompressed_address_length = max(len(self.model().addresses_u[address]) for address in self.model().addresses_u) 151 | max_length = max(max_compressed_address_length, max_uncompressed_address_length) 152 | 153 | if max_length > 0: 154 | for column in [2, 3]: # Columns 2 and 3 (compressed and uncompressed addresses) 155 | column_width = self.columnWidth(column) 156 | new_column_width = max(column_width, max_length * 7) # Adjust the factor (7) based on your font and style 157 | self.setColumnWidth(column, new_column_width) 158 | super().resizeEvent(event) 159 | 160 | class Window(QWidget): 161 | def __init__(self): 162 | super().__init__() 163 | self.initUI() 164 | 165 | def initUI(self): 166 | layout = QVBoxLayout() 167 | self.table = CustomTableView() 168 | self.model = MyModel() 169 | self.table.setModel(self.model) 170 | delegate = AlternatingRowDelegate() # Note the parentheses here 171 | self.table.setItemDelegate(delegate) 172 | self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeToContents) 173 | self.table.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeToContents) 174 | self.table.setColumnWidth(2, 150) 175 | self.table.setColumnWidth(3, 150) 176 | self.table.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) 177 | self.table.clicked.connect(self.cellClicked) 178 | layout.addWidget(self.table) 179 | self.setLayout(layout) 180 | header_palette = QPalette() 181 | header_palette.setColor(QPalette.Window, QColor(79, 129, 189)) 182 | self.table.horizontalHeader().setPalette(header_palette) 183 | selected_palette = QPalette() 184 | selected_palette.setColor(QPalette.Highlight, QColor(173, 216, 230)) 185 | self.table.setPalette(selected_palette) 186 | self.filter_inputs = [] 187 | for i in range(4): 188 | filter_input = QLineEdit(self) 189 | filter_input.setPlaceholderText(f"Filter Column {i}") 190 | filter_input.textChanged.connect(lambda text, col=i: self.applyFilter(col, text)) 191 | self.filter_inputs.append(filter_input) 192 | filter_layout = QHBoxLayout() 193 | for filter_input in self.filter_inputs: 194 | filter_layout.addWidget(filter_input) 195 | layout.addLayout(filter_layout) 196 | # Add "Clear Filters" button 197 | clear_filters_btn = QPushButton("Clear Filters") 198 | clear_filters_btn.clicked.connect(self.clearFilters) 199 | layout.addWidget(clear_filters_btn) 200 | layout.addWidget(self.table) 201 | 202 | def cellClicked(self, index): 203 | if index.column() == 1: # Check if the clicked cell is in column 1 (Private Key Hex) 204 | private_key_hex = index.data() 205 | if private_key_hex: 206 | # Construct the privatekeyfinder.io URL with the private key appended 207 | privatekeyfinder_url = f"https://privatekeyfinder.io/private-keys/bitcoin/?private-key={private_key_hex}" 208 | # Open the privatekeyfinder.io URL in the default web browser 209 | QDesktopServices.openUrl(QUrl(privatekeyfinder_url)) 210 | elif index.column() in [2, 3]: # Check if the clicked cell is in columns 2 or 3 211 | address = index.data() 212 | if address: 213 | # Construct the Blockchair URL with the clicked address 214 | blockchair_url = f"https://blockchair.com/bitcoin/address/{address}" 215 | # Open the Blockchair URL in the default web browser 216 | QDesktopServices.openUrl(QUrl(blockchair_url)) 217 | 218 | def applyFilter(self, column, text): 219 | # Update the filter text for the specified column 220 | self.model.filter_text[column] = text 221 | # Refresh the table to apply the filter 222 | self.model.layoutChanged.emit() 223 | 224 | def clearFilters(self): 225 | # Clear the filter text for all columns 226 | for column in range(4): 227 | self.model.filter_text[column] = "" 228 | # Clear the text in the filter input fields 229 | for filter_input in self.filter_inputs: 230 | filter_input.setText("") 231 | # Refresh the table to apply the cleared filters 232 | self.model.layoutChanged.emit() 233 | 234 | app = QApplication([]) 235 | window = Window() 236 | window.setWindowTitle("Bitcoin Address Table") 237 | window.showMaximized() # Maximize the main window 238 | app.exec_() 239 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # All-Bitcoin-Private-key-Table 2 | # You must pip install the modules in the requirements.txt file if you don't have them already, for the script to run properly. 3 | pip install -r requirements.txt 4 | # Lists Every Bitcoin Private Key in Hex Format, along with both p2pkh addresses. 5 | You Can: 6 | - Click on any Bitcoin Address to check its balance. 7 | - Click on any Private Key Hex to check if any of its corresponding addresses have a balance. 8 | - Filter though either bitcoin p2pkh column (columns 2,3) by typing in what the bitcoin address might contains or you can explicitly filter (search) for the full address your looking for. 9 | - Comlum sizes are adustable by double clicking the top of the column in between where the columns meet, to veiw the full column. (If the Private Keys or Row Numbers are cut off) or you can just click and drag the column to the size you prefer 10 | - You can specify a specific Bitcoin Address or multiple addresses (p2pkh only) in the Target Addresses.txt file and the script will be automatically searching for it in the background. 11 | - If a target address is in the current buffer or field of view, the private key of the found target address will pop up on the screen and it will print to the terminal. 12 | - The script is also preset to lock in the current buffer that the target address is in, so that when its found you don't accidentally scroll past it without knowing. 13 | # Change the buffer size and the starting private key. 14 | self.buffer_size = 2000 15 | self.starting_point = int('0000000000000000000000000000000000000000000000000000000000000001', 16) 16 | - Bigger buffer size = more RAM 17 | - This does not save any data, it just loads in the amount of rows that the buffer size is set to and starts from the stated private key. (It does not have to start from 1) 18 | - As you scroll through the list, your RAM usage should stay steady, allowing you to scroll into the abyss of Private Keys Endlessly and Visually. 19 | -------------------------------------------------------------------------------- /Target Addresses.txt: -------------------------------------------------------------------------------- 1 | 1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF 2 | 12ib7dApVFvg82TXKycWBNpN8kFyiAN1dr 3 | 13zb1hQbWVsc2S7ZTZnP2G4undNNpdh5so 4 | 1LdRcdxfbSnmCYYNdeYpUnztiYzVfBEQeC 5 | 1AC4fMwgY8j9onSbXEWeH6Zan8QGMSdmtA 6 | 12tkqA9xSoowkzoERHMWNKsTey55YEBqkv 7 | 1PeizMg76Cf96nUQrYg8xuoZWLQozU5zGW 8 | 1F34duy2eeMz5mSrvFepVzy7Y1rBsnAyWC 9 | 1f1miYFQWTzdLiCBxtHHnNiW7WAWPUccr 10 | 1BAFWQhH9pNkz3mZDQ1tWrtKkSHVCkc3fV 11 | 14YK4mzJGo5NKkNnmVJeuEAQftLt795Gec 12 | 1Ki3WTEEqTLPNsN5cGTsMkL2sJ4m5mdCXT 13 | 1KbrSKrT3GeEruTuuYYUSQ35JwKbrAWJYm 14 | 1P1iThxBH542Gmk1kZNXyji4E4iwpvSbrt 15 | 12tLs9c9RsALt4ockxa1hB4iTCTSmxj2me 16 | 1ucXXZQSEf4zny2HRwAQKtVpkLPTUKRtt 17 | 1CPaziTqeEixPoSFtJxu74uDGbpEAotZom 18 | 1HLvaTs3zR3oev9ya7Pzp3GB9Gqfg6XYJT 19 | 167ZWTT8n6s4ya8cGjqNNQjDwDGY31vmHg 20 | 18zuLTKQnLjp987LdxuYvjekYnNAvXif2b 21 | 198aMn6ZYAczwrE5NvNTUMyJ5qkfy4g3Hi 22 | 15Z5YJaaNSxeynvr6uW6jQZLwq3n1Hu6RX 23 | 1DzjE3ANaKLasY2n6e5ToJ4CQCXrvDvwsf 24 | 1FJuzzQFVMbiMGw6JtcXefdD64amy7mSCF 25 | 1AYLzYN7SGu5FQLBTADBzqKm4b6Udt6Bw6 26 | 1JxmKkNK1b3p7r8DDPtnNmGeLZDcgPadJb 27 | 1LBBmkr9muf7RjjBbzQQvzNQpRRaVEnavs 28 | 1BeouDc6jtHpitvPz3gR3LQnBGb7dKRrtC 29 | 1ARWCREnmdKyHgNg2c9qih8UzRr4MMQEQS 30 | 1DaCQDfStUgkPQXcf53Teeo6LPiKcVMBM9 31 | 19z6WynrjHeD5MMv6919BuQRwybuen1sRv 32 | 1NQEV6T4avmPqUVTvgsKkeB6yc8qnSWfhR 33 | 1NJQZhzYac89fDhQCmb1khdjekKNVYLFMY 34 | 1BvNwfxEQwZNRmYQ3eno6e976XyxhCsRXj 35 | 1Miy5sJZSamDZN6xcJJidp9zYxhSrpDeJm 36 | 18Hp8j2JMvwtPs1eqNaYEEVvuFpjQJRFVY 37 | 16eb495TbiCRbRbZv4WBdaUvNGxUYJ4jed 38 | 1GX7i8jG8DD1mG85BNnz7xybVhSmw84Uii 39 | 1N5NqDWiLVqtU8mEzCNEeEbQVHwuGGChJs 40 | 1VeMPNgEtQGurwjW2WsYXQaw4boAX5k6S 41 | 18eY9oWL2mkXCL1VVwPme2NMmAVhX6EfyM 42 | 1ALXLVNj7yKRU2Yki3K3yQGB5TBPof7jyo 43 | 1LwBdypLh3WPawK1WUqGZXgs4V8neHHqb7 44 | 15MZvKjqeNz4AVz2QrHumQcRJq2JVHjFUz 45 | 1GMFSWQQQhCQyRNQcac9tDKcvqYCuripVs 46 | 14mPMrRm6TdjqHZhd7aBUbuWt5MYWReukR 47 | 1FvUkW8thcqG6HP7gAvAjcR52fR7CYodBx 48 | 1Gn1GzVa88T1X3fdhejyq6jrZs43T24xW6 49 | 1PTYXwamXXgQoAhDbmUf98rY2Pg1pYXhin 50 | 16oKJMcUZkDbq2tXDr9Fm2HwgBAkJPquyU 51 | 193zge613zys7eSkQYQVd9xubovLN8Sr6j 52 | 1EgH7EUfgjr8gAK9t1BeHLDC1ijrVvdec3 53 | 19HhmfxGsznL8K7wXjZiFnhqddQucgfZzB 54 | 15DtovKcGFiAJmyVfbjvCXHyjtyoZhyyj4 55 | 1ArZGb5V24gAgN51FeQknobi6kNyGx739r 56 | 1JjMoB212ctAiuDvURyWhs813yY4c75cap 57 | 1FDVbVJYKkWPFcJEzCxi99vpKTYxEY3zdj 58 | 1LQaq7LLoyjdfH3vczuusa17WsRokhsRvG 59 | 1PEUv3FjSWq88AgNYefeYaEhLWSiMW2vuy 60 | 19DdkMxutkLGY67REFPLu51imfxG9CUJLD 61 | 1BitcoinEaterAddressDontSendf59kuE -------------------------------------------------------------------------------- /gpu_sha256.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | @author: iceland 5 | """ 6 | 7 | import pyopencl as cl 8 | import sha256_class as opencl 9 | 10 | # ============================================================================= 11 | # def read_pass_file(): 12 | # with open('4_letter_words.txt') as f: 13 | # pass_list = f.read().rstrip('\n').split('\n') 14 | # return pass_list 15 | # 16 | # pass_list = read_pass_file() 17 | # passwordlist = [bytes(line,'utf-8') for line in pass_list] 18 | # ============================================================================= 19 | 20 | def gpu_sha256(opencl_ctx,passwordlist): 21 | opencl_ctx.compile('sha256') 22 | result = opencl_ctx.run(passwordlist) 23 | # print(result[0]) 24 | # print(result[1]) 25 | return result 26 | 27 | opencl.sha256_opencl.print_device_info() 28 | # test using given pass phrase 29 | passwordlist = [b'this is my password', b'dont touch my coins', b'0a5ff07fd8883f80cb04f3840d0efe'] 30 | 31 | platform = 0 32 | opencl_ctx = opencl.sha256_opencl(platform) 33 | results = gpu_sha256(opencl_ctx,passwordlist) 34 | print(results) -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | PyQt5 2 | ecdsa 3 | base58 4 | pyopencl 5 | numpy -------------------------------------------------------------------------------- /sha256.cl: -------------------------------------------------------------------------------- 1 | /* 2 | SHA1 OpenCL Optimized kernel 3 | (c) B. Kerler 2018 4 | MIT License 5 | */ 6 | 7 | typedef struct { 8 | unsigned int length; 9 | unsigned int buffer[32/4]; 10 | } inbuf; 11 | 12 | typedef struct { 13 | unsigned int buffer[32/4]; 14 | } outbuf; 15 | 16 | #define F1(x,y,z) (bitselect(z,y,x)) 17 | #define F0(x,y,z) (bitselect (x, y, (x ^ z))) 18 | #define mod(x,y) x-(x/y*y) 19 | #define shr32(x,n) ((x) >> (n)) 20 | #define rotl32(a,n) rotate ((a), (n)) 21 | 22 | unsigned int SWAP (unsigned int val) 23 | { 24 | return (rotate(((val) & 0x00FF00FF), 24U) | rotate(((val) & 0xFF00FF00), 8U)); 25 | } 26 | 27 | #define S0(x) (rotl32 ((x), 25u) ^ rotl32 ((x), 14u) ^ shr32 ((x), 3u)) 28 | #define S1(x) (rotl32 ((x), 15u) ^ rotl32 ((x), 13u) ^ shr32 ((x), 10u)) 29 | #define S2(x) (rotl32 ((x), 30u) ^ rotl32 ((x), 19u) ^ rotl32 ((x), 10u)) 30 | #define S3(x) (rotl32 ((x), 26u) ^ rotl32 ((x), 21u) ^ rotl32 ((x), 7u)) 31 | 32 | #define SHA256C00 0x428a2f98u 33 | #define SHA256C01 0x71374491u 34 | #define SHA256C02 0xb5c0fbcfu 35 | #define SHA256C03 0xe9b5dba5u 36 | #define SHA256C04 0x3956c25bu 37 | #define SHA256C05 0x59f111f1u 38 | #define SHA256C06 0x923f82a4u 39 | #define SHA256C07 0xab1c5ed5u 40 | #define SHA256C08 0xd807aa98u 41 | #define SHA256C09 0x12835b01u 42 | #define SHA256C0a 0x243185beu 43 | #define SHA256C0b 0x550c7dc3u 44 | #define SHA256C0c 0x72be5d74u 45 | #define SHA256C0d 0x80deb1feu 46 | #define SHA256C0e 0x9bdc06a7u 47 | #define SHA256C0f 0xc19bf174u 48 | #define SHA256C10 0xe49b69c1u 49 | #define SHA256C11 0xefbe4786u 50 | #define SHA256C12 0x0fc19dc6u 51 | #define SHA256C13 0x240ca1ccu 52 | #define SHA256C14 0x2de92c6fu 53 | #define SHA256C15 0x4a7484aau 54 | #define SHA256C16 0x5cb0a9dcu 55 | #define SHA256C17 0x76f988dau 56 | #define SHA256C18 0x983e5152u 57 | #define SHA256C19 0xa831c66du 58 | #define SHA256C1a 0xb00327c8u 59 | #define SHA256C1b 0xbf597fc7u 60 | #define SHA256C1c 0xc6e00bf3u 61 | #define SHA256C1d 0xd5a79147u 62 | #define SHA256C1e 0x06ca6351u 63 | #define SHA256C1f 0x14292967u 64 | #define SHA256C20 0x27b70a85u 65 | #define SHA256C21 0x2e1b2138u 66 | #define SHA256C22 0x4d2c6dfcu 67 | #define SHA256C23 0x53380d13u 68 | #define SHA256C24 0x650a7354u 69 | #define SHA256C25 0x766a0abbu 70 | #define SHA256C26 0x81c2c92eu 71 | #define SHA256C27 0x92722c85u 72 | #define SHA256C28 0xa2bfe8a1u 73 | #define SHA256C29 0xa81a664bu 74 | #define SHA256C2a 0xc24b8b70u 75 | #define SHA256C2b 0xc76c51a3u 76 | #define SHA256C2c 0xd192e819u 77 | #define SHA256C2d 0xd6990624u 78 | #define SHA256C2e 0xf40e3585u 79 | #define SHA256C2f 0x106aa070u 80 | #define SHA256C30 0x19a4c116u 81 | #define SHA256C31 0x1e376c08u 82 | #define SHA256C32 0x2748774cu 83 | #define SHA256C33 0x34b0bcb5u 84 | #define SHA256C34 0x391c0cb3u 85 | #define SHA256C35 0x4ed8aa4au 86 | #define SHA256C36 0x5b9cca4fu 87 | #define SHA256C37 0x682e6ff3u 88 | #define SHA256C38 0x748f82eeu 89 | #define SHA256C39 0x78a5636fu 90 | #define SHA256C3a 0x84c87814u 91 | #define SHA256C3b 0x8cc70208u 92 | #define SHA256C3c 0x90befffau 93 | #define SHA256C3d 0xa4506cebu 94 | #define SHA256C3e 0xbef9a3f7u 95 | #define SHA256C3f 0xc67178f2u 96 | 97 | __constant uint k_sha256[64] = 98 | { 99 | SHA256C00, SHA256C01, SHA256C02, SHA256C03, 100 | SHA256C04, SHA256C05, SHA256C06, SHA256C07, 101 | SHA256C08, SHA256C09, SHA256C0a, SHA256C0b, 102 | SHA256C0c, SHA256C0d, SHA256C0e, SHA256C0f, 103 | SHA256C10, SHA256C11, SHA256C12, SHA256C13, 104 | SHA256C14, SHA256C15, SHA256C16, SHA256C17, 105 | SHA256C18, SHA256C19, SHA256C1a, SHA256C1b, 106 | SHA256C1c, SHA256C1d, SHA256C1e, SHA256C1f, 107 | SHA256C20, SHA256C21, SHA256C22, SHA256C23, 108 | SHA256C24, SHA256C25, SHA256C26, SHA256C27, 109 | SHA256C28, SHA256C29, SHA256C2a, SHA256C2b, 110 | SHA256C2c, SHA256C2d, SHA256C2e, SHA256C2f, 111 | SHA256C30, SHA256C31, SHA256C32, SHA256C33, 112 | SHA256C34, SHA256C35, SHA256C36, SHA256C37, 113 | SHA256C38, SHA256C39, SHA256C3a, SHA256C3b, 114 | SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f, 115 | }; 116 | 117 | #define SHA256_STEP(F0a,F1a,a,b,c,d,e,f,g,h,x,K) \ 118 | { \ 119 | h += K; \ 120 | h += x; \ 121 | h += S3 (e); \ 122 | h += F1a (e,f,g); \ 123 | d += h; \ 124 | h += S2 (a); \ 125 | h += F0a (a,b,c); \ 126 | } 127 | 128 | #define SHA256_EXPAND(x,y,z,w) (S1 (x) + y + S0 (z) + w) 129 | 130 | static void sha256_process2 (const unsigned int *W, unsigned int *digest) 131 | { 132 | unsigned int a = digest[0]; 133 | unsigned int b = digest[1]; 134 | unsigned int c = digest[2]; 135 | unsigned int d = digest[3]; 136 | unsigned int e = digest[4]; 137 | unsigned int f = digest[5]; 138 | unsigned int g = digest[6]; 139 | unsigned int h = digest[7]; 140 | 141 | unsigned int w0_t = W[0]; 142 | unsigned int w1_t = W[1]; 143 | unsigned int w2_t = W[2]; 144 | unsigned int w3_t = W[3]; 145 | unsigned int w4_t = W[4]; 146 | unsigned int w5_t = W[5]; 147 | unsigned int w6_t = W[6]; 148 | unsigned int w7_t = W[7]; 149 | unsigned int w8_t = W[8]; 150 | unsigned int w9_t = W[9]; 151 | unsigned int wa_t = W[10]; 152 | unsigned int wb_t = W[11]; 153 | unsigned int wc_t = W[12]; 154 | unsigned int wd_t = W[13]; 155 | unsigned int we_t = W[14]; 156 | unsigned int wf_t = W[15]; 157 | 158 | #define ROUND_EXPAND(i) \ 159 | { \ 160 | w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t); \ 161 | w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t); \ 162 | w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t); \ 163 | w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t); \ 164 | w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t); \ 165 | w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t); \ 166 | w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t); \ 167 | w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t); \ 168 | w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t); \ 169 | w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t); \ 170 | wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t); \ 171 | wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t); \ 172 | wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t); \ 173 | wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t); \ 174 | we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t); \ 175 | wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t); \ 176 | } 177 | 178 | #define ROUND_STEP(i) \ 179 | { \ 180 | SHA256_STEP (F0, F1, a, b, c, d, e, f, g, h, w0_t, k_sha256[i + 0]); \ 181 | SHA256_STEP (F0, F1, h, a, b, c, d, e, f, g, w1_t, k_sha256[i + 1]); \ 182 | SHA256_STEP (F0, F1, g, h, a, b, c, d, e, f, w2_t, k_sha256[i + 2]); \ 183 | SHA256_STEP (F0, F1, f, g, h, a, b, c, d, e, w3_t, k_sha256[i + 3]); \ 184 | SHA256_STEP (F0, F1, e, f, g, h, a, b, c, d, w4_t, k_sha256[i + 4]); \ 185 | SHA256_STEP (F0, F1, d, e, f, g, h, a, b, c, w5_t, k_sha256[i + 5]); \ 186 | SHA256_STEP (F0, F1, c, d, e, f, g, h, a, b, w6_t, k_sha256[i + 6]); \ 187 | SHA256_STEP (F0, F1, b, c, d, e, f, g, h, a, w7_t, k_sha256[i + 7]); \ 188 | SHA256_STEP (F0, F1, a, b, c, d, e, f, g, h, w8_t, k_sha256[i + 8]); \ 189 | SHA256_STEP (F0, F1, h, a, b, c, d, e, f, g, w9_t, k_sha256[i + 9]); \ 190 | SHA256_STEP (F0, F1, g, h, a, b, c, d, e, f, wa_t, k_sha256[i + 10]); \ 191 | SHA256_STEP (F0, F1, f, g, h, a, b, c, d, e, wb_t, k_sha256[i + 11]); \ 192 | SHA256_STEP (F0, F1, e, f, g, h, a, b, c, d, wc_t, k_sha256[i + 12]); \ 193 | SHA256_STEP (F0, F1, d, e, f, g, h, a, b, c, wd_t, k_sha256[i + 13]); \ 194 | SHA256_STEP (F0, F1, c, d, e, f, g, h, a, b, we_t, k_sha256[i + 14]); \ 195 | SHA256_STEP (F0, F1, b, c, d, e, f, g, h, a, wf_t, k_sha256[i + 15]); \ 196 | } 197 | 198 | ROUND_STEP (0); 199 | 200 | ROUND_EXPAND(); 201 | ROUND_STEP(16); 202 | 203 | ROUND_EXPAND(); 204 | ROUND_STEP(32); 205 | 206 | ROUND_EXPAND(); 207 | ROUND_STEP(48); 208 | 209 | digest[0] += a; 210 | digest[1] += b; 211 | digest[2] += c; 212 | digest[3] += d; 213 | digest[4] += e; 214 | digest[5] += f; 215 | digest[6] += g; 216 | digest[7] += h; 217 | } 218 | 219 | static void sha256(__global const unsigned int *pass, int pass_len, unsigned int* hash) 220 | { 221 | int plen=pass_len/4; 222 | if (mod(pass_len,4)) plen++; 223 | 224 | unsigned int* p = hash; 225 | 226 | unsigned int W[0x10]={0}; 227 | int loops=plen; 228 | int curloop=0; 229 | unsigned int State[8]={0}; 230 | State[0] = 0x6a09e667; 231 | State[1] = 0xbb67ae85; 232 | State[2] = 0x3c6ef372; 233 | State[3] = 0xa54ff53a; 234 | State[4] = 0x510e527f; 235 | State[5] = 0x9b05688c; 236 | State[6] = 0x1f83d9ab; 237 | State[7] = 0x5be0cd19; 238 | 239 | while (loops>0) 240 | { 241 | W[0x0]=0x0; 242 | W[0x1]=0x0; 243 | W[0x2]=0x0; 244 | W[0x3]=0x0; 245 | W[0x4]=0x0; 246 | W[0x5]=0x0; 247 | W[0x6]=0x0; 248 | W[0x7]=0x0; 249 | W[0x8]=0x0; 250 | W[0x9]=0x0; 251 | W[0xA]=0x0; 252 | W[0xB]=0x0; 253 | W[0xC]=0x0; 254 | W[0xD]=0x0; 255 | W[0xE]=0x0; 256 | W[0xF]=0x0; 257 | 258 | 259 | for (int m=0;loops!=0 && m<16;m++) 260 | { 261 | W[m]^=SWAP(pass[m+(curloop*16)]); 262 | loops--; 263 | } 264 | 265 | if (loops==0 && mod(pass_len,64)!=0) 266 | { 267 | unsigned int padding=0x80<<(((pass_len+4)-((pass_len+4)/4*4))*8); 268 | int v=mod(pass_len,64); 269 | W[v/4]|=SWAP(padding); 270 | if ((pass_len&0x3B)!=0x3B) 271 | { 272 | // Let's add length 273 | W[0x0F]=pass_len*8; 274 | } 275 | } 276 | 277 | sha256_process2(W,State); 278 | curloop++; 279 | } 280 | 281 | if (mod(plen,16)==0) 282 | { 283 | W[0x0]=0x0; 284 | W[0x1]=0x0; 285 | W[0x2]=0x0; 286 | W[0x3]=0x0; 287 | W[0x4]=0x0; 288 | W[0x5]=0x0; 289 | W[0x6]=0x0; 290 | W[0x7]=0x0; 291 | W[0x8]=0x0; 292 | W[0x9]=0x0; 293 | W[0xA]=0x0; 294 | W[0xB]=0x0; 295 | W[0xC]=0x0; 296 | W[0xD]=0x0; 297 | W[0xE]=0x0; 298 | W[0xF]=0x0; 299 | if ((pass_len&0x3B)!=0x3B) 300 | { 301 | unsigned int padding=0x80<<(((pass_len+4)-((pass_len+4)/4*4))*8); 302 | W[0]|=SWAP(padding); 303 | } 304 | // Let's add length 305 | W[0x0F]=pass_len*8; 306 | 307 | sha256_process2(W,State); 308 | } 309 | 310 | p[0]=SWAP(State[0]); 311 | p[1]=SWAP(State[1]); 312 | p[2]=SWAP(State[2]); 313 | p[3]=SWAP(State[3]); 314 | p[4]=SWAP(State[4]); 315 | p[5]=SWAP(State[5]); 316 | p[6]=SWAP(State[6]); 317 | p[7]=SWAP(State[7]); 318 | return; 319 | } 320 | 321 | __kernel void func_sha256(__global const inbuf * inbuffer, __global outbuf * outbuffer) 322 | { 323 | unsigned int idx = get_global_id(0); 324 | unsigned int hash[32/4]={0}; 325 | sha256(inbuffer[idx].buffer, inbuffer[idx].length, hash); 326 | outbuffer[idx].buffer[0]=hash[0]; 327 | outbuffer[idx].buffer[1]=hash[1]; 328 | outbuffer[idx].buffer[2]=hash[2]; 329 | outbuffer[idx].buffer[3]=hash[3]; 330 | outbuffer[idx].buffer[4]=hash[4]; 331 | outbuffer[idx].buffer[5]=hash[5]; 332 | outbuffer[idx].buffer[6]=hash[6]; 333 | outbuffer[idx].buffer[7]=hash[7]; 334 | } -------------------------------------------------------------------------------- /sha256_class.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | 4 | """ 5 | 6 | import pyopencl as cl 7 | import numpy as np 8 | import binascii 9 | import os 10 | 11 | class sha256_opencl: 12 | 13 | def __init__(self,platform): 14 | 15 | platforms = cl.get_platforms() 16 | if (platform > len(platforms)): 17 | assert("Selected platform %d doesn't exist" % platform) 18 | 19 | hash=b'\x00'*32 20 | hash_len=32 21 | 22 | # Get platforms 23 | devices = platforms[platform].get_devices() 24 | self.workgroupsize=60000 25 | 26 | #Create context for GPU/CPU 27 | print("Using Platform %d:" % platform) 28 | self.ctx = cl.Context(devices) 29 | for device in devices: 30 | print('--------------------------------------------------------------------------') 31 | print(' Device - Name: '+ device.name) 32 | print(' Device - Type: '+ cl.device_type.to_string(device.type)) 33 | print(' Device - Compute Units: {0}'.format(device.max_compute_units)) 34 | print(' Device - Max Work Group Size: {0:.0f}'.format(device.max_work_group_size)) 35 | if (device.max_work_group_size0): 75 | pwarray = np.empty(0, dtype=np.uint32) 76 | if (totalpwsint(32)): #Only chars up to length 32 supported 86 | continue 87 | modlen=len(pw)%4 88 | if modlen!=0: 89 | pw=pw+(b'\0'*(4-modlen)) 90 | n_pw = np.frombuffer(pw, dtype=np.uint32) 91 | n_pwlen = np.array([pwlen], dtype=np.uint32) 92 | password = np.array([0]*9,dtype=np.uint32) 93 | z=0 94 | for i in range(0,len(n_pwlen)): 95 | password[z]=n_pwlen[i] 96 | z+=1 97 | max=9-len(n_pwlen) 98 | if max>len(n_pw): 99 | max=len(n_pw) 100 | for i in range(0,max): 101 | password[z+i]=n_pw[i] 102 | pwarray = np.append(pwarray, password) 103 | 104 | result = np.zeros(int(32 / 4) * pwcount, dtype=np.uint32) 105 | 106 | #Allocate memory for variables on the device 107 | pass_g = cl.Buffer(self.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=pwarray) 108 | result_g = cl.Buffer(self.ctx, mf.WRITE_ONLY, result.nbytes) 109 | 110 | #Call Kernel. Automatically takes care of block/grid distribution 111 | if (self.type=="sha256"): 112 | hashlen=0x20 113 | self.prg.func_sha256(self.queue,pwdim,None,pass_g,result_g) 114 | #SHA256 does support longer lengths, but inputbuffer and hash are limited to 32 chars 115 | cl.enqueue_copy(self.queue, result, result_g) 116 | totalpws-=pwcount 117 | pos+=pwcount 118 | hexvalue = binascii.hexlify(result) 119 | for value in range(0, len(hexvalue), 64): 120 | results.append(hexvalue[value:value + 64].decode()[0:hashlen*2]) 121 | return results 122 | 123 | def print_device_info() : 124 | print('\n' + '=' * 60 + '\nOpenCL Platforms and Devices') 125 | 126 | for platform in cl.get_platforms(): 127 | print('=' * 60) 128 | print('Platform - Name: ' + platform.name) 129 | print('Platform - Vendor: ' + platform.vendor) 130 | print('Platform - Version: ' + platform.version) 131 | print('Platform - Profile: ' + platform.profile) 132 | 133 | for device in platform.get_devices(): 134 | print(' ' + '-' * 56) 135 | print(' Device - Name: ' \ 136 | + device.name) 137 | print(' Device - Type: ' \ 138 | + cl.device_type.to_string(device.type)) 139 | print(' Device - Max Clock Speed: {0} Mhz'\ 140 | .format(device.max_clock_frequency)) 141 | print(' Device - Compute Units: {0}'\ 142 | .format(device.max_compute_units)) 143 | print(' Device - Local Memory: {0:.0f} KB'\ 144 | .format(device.local_mem_size/1024.0)) 145 | print(' Device - Constant Memory: {0:.0f} KB'\ 146 | .format(device.max_constant_buffer_size/1024.0)) 147 | print(' Device - Global Memory: {0:.0f} GB'\ 148 | .format(device.global_mem_size/1073741824.0)) 149 | print(' Device - Max Buffer/Image Size: {0:.0f} MB'\ 150 | .format(device.max_mem_alloc_size/1048576.0)) 151 | print(' Device - Max Work Group Size: {0:.0f}'\ 152 | .format(device.max_work_group_size)) 153 | print('\n') --------------------------------------------------------------------------------