正在测验新版glype(http://www.glype.com/)网络署理程序(我不得不说一下这款署理程序是游走内网必备神器,没有之一)的时分用NMAP对本地内网80端口做了个简略的扫描(nmap -T5 10.10.0.0/24 -p80 –open),可是人生处处有惊喜。
本地存在MyAdmin程序,运用默许口令root/root进入后台。
- 这儿或许存在槽点,但请你记住:在内网中运用默许装备,默许口令的开发或许办理人员是安全的软肋。
- 在拿到WENSHELL后除了吃透本机“资源”,下一步要做的便是对内网其他WEB主机运用惯例办法浸透,或许你能在某台机子上抓到域控暗码(意图)。
进入数据库办理后台,咱们要做的便是运用数据库句子select into outfile写WEBSHELL,可是在这儿咱们不知道网站根目录,这个的确有点淡疼。
- 许多时分WEB服务器选用默许装置形式,所以运用网站途径字典写入测验,相似sqlmap的–os-shell 参数
- 运用MYSQL UDF(User defined Function,用户界说函数)履行体系指令。
可是先让咱们详细分析下咱们一切的资源,不可的时分再考虑以上办法。网站目录中存在chunge.zip,不论是什么先下载下来看看,终究在LOG目录中找到程序日志文件,网站绝对途径也就出来了。so,开端咱们的写马旅程吧!
写入一句话
检查当时权限
Default
[] 基本信息 [ C:D: Windows NT USER-20190513DS 6.1 build 7601 (Windows 7 Ultimate Edition Service Pack 1) i586(SYSTEM) ]
Default
C:gt; whoami
nt authoritysystem
既然是system权限,那想干什么就干什么呗!说的好,可是我最想干的事看看小伙伴在作什么,然后给他taskkill,呵呵呵。所以咱们首要需求截个屏幕,一下引荐几个指令行下的截屏小程序,或许会帮到你哦。
- NirCmd v2.81
http://www.nirsoft.net/utils/nircmd.zip
NirCmd is a small command-line utility that allows you to do some useful tasks without displaying any user interface.
Useage:
nircmd.exe cmdwait 2000 savescreenshot “f:empshot.png”
- CmdCapture 2.0
http://www.ducklink.com/free-command-line-screen-capture.
CmdCapture is a free command line screen capture software.
Download CmdCapture.exe (Win32 character-mode application. Console applications are given a console by the operating system.)
Download CmdCaptureWin.exe (Application does not require a console.首选静默形式)
- boxcutter 1.5
http://keepnote.org/boxcutter/
boxcutter is a simple command line-driven screenshot program for Microsoft Windows.
这个小东西能够当截图运用,还支撑鼠标选取区域,不带途径默许保存到剪贴板中,不过坑爹的是需求回车一下才会结束进程。
Default
Useage:
boxcutter -f c: uo.png
4,powershell 脚本
Default
Capturing a screenshot
Param(
[Parameter(Mandatory true)][string]Path
)
FileName "env:COMPUTERNAME - (get-date -f yyyy-MM-dd_HHmmss).bmp"
File "PathFileName"
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
Gather Screen resolution information
Screen [System.Windows.Forms.SystemInformation]::VirtualScreen
Width Screen.Width
Height Screen.Height
Left Screen.Left
Top Screen.Top
Create bitmap using the top-left and bottom-right bounds
bitmap nbsp;New-Objectnbsp;System.Drawing.Bitmap Width, Height
Create Graphics object
graphic [System.Drawing.Graphics]::FromImage(bitmap)
Capture screen
graphic.CopyFromScreen(Left, Top, 0, 0, bitmap.Size)
Save to file
bitmap.Save(File)
Useage:
Powershell.exe -file sc.ps1 -path c:
截图东西有了,需求截取当时登录用户的屏幕还需求切换到登陆的用户,首要我能想到的便是runas。
1,RUNAS
RUNAS是WINDOWS体系自带的答应用户用其他权限运转指定的东西和程序,而不是用户当时登录供给的权限。
Useage:
Default
runas /user: administrator "nircmd.exe savescreenshot shot.png"
runas是交互式的,需求输入暗码,无法抛弃。
2,RUNAS + Sanur
http://www.commandline.co.uk/sanur_unsupported/index.html
Sanur is a tiny Win32 console utility that ‘pipes’ a password into the Windows 2000/P/2003 Runas utility, thereby making Runas scriptable.
Useage:
Default
runas /u:domainusername program.exe | sanur password
Win7下测验无反响,而且在暗码为空的时分很蛋疼(体系回绝登陆)。
3,CPAU
Useage:
Default
cpau -u administrator -p " " -ex "nircmd.exe savescreenshot shot.png" -lwp
很有用的一个小东西,Win7下测验经过。
可是在菜刀中履行报错,不能从LocalSystem发动。
Default
CPAU V01.11.00cpp Joe Richards (joejoeware.net) November 2005
Current Security Context: NT AUTHORITYSYSTEM
ERROR:
ERROR: CPAU doesn't support running from LocalSystem.
ERROR:
经过过错关键字百度搜索,找到一篇很老可是很有用的文章,作者沉痛的叙说了客户坑爹无礼的要求后终究给完成了(日了狗)。
http://blog.superliufa.com/2008/04/
权且以为次东西无法从SYSTEM的权限下面切换用户,终究用API CreateProcessAsUser完成功用,然后搜索CreateProcessAsUser函数,找到篇” localsystem以指定用户身份运转程序“,作者和我需求有些相似,此致咱们知道了session 0 阻隔的问题。
http://blog.csdn.net/laotse/article/details/6331368
“system运转的服务直接截图那么用的便是system的handle,所以是个黑屏或许底子无法截,这时就需求程序在用户账号下运转,能够在服务里嵌入一个exe,然后在账户身份下运转这个exe截图并回来给服务回来给长途衔接者,下面便是在system账号下如何故指定用户身份运转程序的办法。
大体便是用wts的终端服务api枚举一切用户的sessionid,然后query出token来……终究用createprocessasuser运转程序,这样程序就以某用户身份运转了,关键是createprocessasuser是用的能够query出来的token而不是用户名和暗码,这样就处理了不知道该用户用户名暗码的情况下“让他运转程序”了。”
-引证自原文,我怎样觉得这么乱呢
Default
WTSEnumerateSessions -gt; WTSQueryUserToken -gt; CreateEnvironmentBlock -gt;CreateProcessAsUser
Session 0 阻隔
://technet.microsoft.com/zh-cn/ee791007.aspx
Windows 7服务的Session 0阻隔
在Windows P、Windows Server 2003,以及更老版别的Windows操作体系中,服务和应用程序运用相同的会话(Session)运转,而这个会话是由第一个登录到操控台的用户发动的。该会话就叫做Session 0,如下图所示,在Windows Vista之前,Session 0不只包括服务,也包括规范用户应用程序。
将服务和用户应用程序一同在Session 0中运转会导致安全危险,由于服务会运用提高后的权限运转,而用户应用程序运用用户特权(大部分都对错办理员用户)运转,这会使得歹意软件以某个服务为进犯方针,经过“绑架”该服务,到达提高自己权限等级的意图。
从Windows Vista开端,只要服务能够托管到Session 0中,用户应用程序和服务之间会被阻隔,并需求运转在用户登录到体系时创立的后续会话中。例如第一个登录的用户创立 Session 1,第二个登录的用户创立Session 2,以此类推,如下图所示。
运用不同会话运转的实体(应用程序或服务)假如不将自己清晰标示为大局命名空间,并供给相应的拜访操控设置,将无法相互发送音讯,同享UI元素,或同享内核目标。这一进程如下图所示:
我的简略了解是:
- LocalSystem发动的程序或许服务默许是在session 0 中的,无法与session 1 中的用户形式交互,当然在vista之前不存在这个问题,所以CPAU能四通八达。
- 要越过这层维护,这也是有必要的,远控编程必备技术,咱们需求调用CreateProcessAsUser 或其他办法(WCF、.NET长途处理等)进行跨Session 通讯。
下面咱们需求了解几个有必要的API
WTSEnumerateSessions
Retrieves a list of sessions on a Remote Desktop Session Host (RD Session Host) server.
枚举长途桌面session列表。
WTSQueryUserToken
Obtains the primary access token of the logged-on user specified by the session ID. To call function successfully, the calling application must be running within the context of the LocalSystem account and have thenbsp;SE_TCB_NAMEnbsp;privilege.
经过session ID获取access token。这个函数很重要,它需求要求程序是 LocalSystem account(组内)用户发动的而且还要有SE_TCB_NAME权限,所以在当时vs下调试这个函数是无法履行的。
CreateProcessAsUser
Creates a new process and its primary thread. The new process runs in the security context of the user represented by the specified token.
这个项目编写结束(见下载地址),本地测验。
由于习惯性把东西传到C:Recycle.Bin目录下,在测验的时分老不生成文件,powershell脚本也报无签名不答应履行,终究放到C:Windowsemp 下履行成功,估量本地用户对C:Recycle.Bin目录的拜访存在权限问题。
Default
C:Recycle.Bingt; powershell.exe -file sc2.ps1 -path C:
无法加载文件 C:Recycle.Binsc2.ps1。文件 C:Recycle.Binsc2.ps1 的内容或许已
被篡改,由于该文件的哈希代码与数字签名中存储的哈希代码不匹配。体系将不履行该脚本
。有关详细信息,请参阅 “get-help about_signing”。。
Default
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordE
xception
+ FullyQualifiedErrorId : RuntimeException
C:Windowsempgt; powershell.exe -file sc2.ps1 -path C:
运用“5”个参数调用“CopyFromScreen”时发作反常:“句柄无效。”
所在位置 C:Windowsempsc2.ps1:28 字符: 24
+ graphic.CopyFromScreen lt;lt;lt;lt; (Left, Top, 0, 0, bitmap.Size)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Done