2017-10-11 65 views
0
if self.class.include?(Msf::Payload::Single) and 
    self.class.include?(Msf::Payload::Stager) 
    self.module_info['Stage'] = {} 

我試圖執行「puts self.class」輸出是「Object」。提前致謝。什麼是「self.class.include?」是指在這裏?

+4

'的object.method(?:包括)'揭示了該方法的[?'模塊#包括'](http://ruby-doc.org/core- 2.4.2/Module.html#method-i-include-3F) - 它檢查給定模塊是否包含在接收器中。 – Stefan

+1

@pushpamk有一些上下文總是有幫助的。添加項目名稱並(如果可能)提供有關代碼的鏈接。 – Stefan

回答

2

self.class,在實例方法內調用,返回對象類的引用。如果作爲參數傳遞的模塊包含在當前模塊中,則Module#include?方法返回true

換句話說,您引用的代碼實際上是檢查您正在操作的實例的類是否混合了SingleStager類。

下面是一個例子:

module One 
end 

class Two 
    include One 
end 

class Three 
end 

t = Two.new 
t.class.include?(One) 
# => true 

t = Three.new 
t.class.include?(One) 
# => false