开发者

Alternative to eval()

开发者 https://www.devze.com 2023-01-16 19:35 出处:网络
I\'m looking for an alternative 开发者_运维百科to that code: expl = eval \"BeEF::Modules::Exploits::#{klass.capitalize}.new\"

I'm looking for an alternative 开发者_运维百科to that code:

 expl = eval "BeEF::Modules::Exploits::#{klass.capitalize}.new"

Here the eval is totally insecure. Is there an alternative I could use to generate dynamically classes without using eval? As in, klass is always different. So my code stays generic.

Thanks for your time.


You can use Module#const_get:

expl = BeEF::Modules::Exploits.const_get(klass.capitalize).new
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号