WEBSHELL_ASP_Runtime_Compile
Description
ASP webshell compiling payload in memory at runtime, e.g. sharpyshell
Query · yara
strings:
$payload_reflection1 = "System" fullword nocase wide ascii
$payload_reflection2 = "Reflection" fullword nocase wide ascii
$payload_reflection3 = "Assembly" fullword nocase wide ascii
$payload_load_reflection1 = /[."']Load\b/ nocase wide ascii
// only match on "load" or variable which might contain "load"
$payload_load_reflection2 = /\bGetMethod\(("load|\w)/ nocase wide ascii
$payload_compile1 = "GenerateInMemory" nocase wide ascii
$payload_compile2 = "CompileAssemblyFromSource" nocase wide ascii
$payload_invoke1 = "Invoke" fullword nocase wide ascii
$payload_invoke2 = "CreateInstance" fullword nocase wide ascii
$payload_xamlreader1 = "XamlReader" fullword nocase wide ascii
$payload_xamlreader2 = "Parse" fullword nocase wide ascii
$payload_xamlreader3 = "assembly=" nocase wide ascii
$payload_powershell1 = "PSObject" fullword nocase wide ascii
$payload_powershell2 = "Invoke" fullword nocase wide ascii
$payload_powershell3 = "CreateRunspace" fullword nocase wide ascii
$rc_fp1 = "Request.MapPath"
$rc_fp2 = "<body><mono:MonoSamplesHeader runat=\"server\"/>" wide ascii
//strings from private rule capa_asp_input
// Request.BinaryRead
// Request.Form
$asp_input1 = "request" fullword nocase wide ascii
$asp_input2 = "Page_Load" fullword nocase wide ascii
// base64 of Request.Form(
$asp_input3 = "UmVxdWVzdC5Gb3JtK" fullword wide ascii
$asp_input4 = "\\u0065\\u0071\\u0075" wide ascii // equ of Request
$asp_input5 = "\\u0065\\u0073\\u0074" wide ascii // est of Request
$asp_xml_http = "Microsoft.XMLHTTP" fullword nocase wide ascii
$asp_xml_method1 = "GET" fullword wide ascii
$asp_xml_method2 = "POST" fullword wide ascii
$asp_xml_method3 = "HEAD" fullword wide ascii
// dynamic form
$asp_form1 = "<form " wide ascii
$asp_form2 = "<Form " wide ascii
$asp_form3 = "<FORM " wide ascii
$asp_asp = "<asp:" wide ascii
$asp_text1 = ".text" wide ascii
$asp_text2 = ".Text" wide ascii
$sus_refl1 = " ^= " wide ascii
$sus_refl2 = "SharPy" wide ascii
condition:
//any of them or
(
(
filesize < 50KB and
any of ( $sus_refl* )
) or
filesize < 10KB
) and
(
any of ( $asp_input* ) or
(
$asp_xml_http and
any of ( $asp_xml_method* )
) or
(
any of ( $asp_form* ) and
any of ( $asp_text* ) and
$asp_asp
)
)
and not any of ( $rc_fp* ) and
(
(
all of ( $payload_reflection* ) and
any of ( $payload_load_reflection* )
)
or
(
all of ( $payload_compile* ) and
any of ( $payload_invoke* )
)
or all of ( $payload_xamlreader* )
or all of ( $payload_powershell* )
)