Skip to content

Commit 7584285

Browse files
committed
progress on 'generate' command
1 parent b4c193c commit 7584285

File tree

5 files changed

+141
-33
lines changed

5 files changed

+141
-33
lines changed

Payload_Type/sliverapi/sliverapi/SliverRequests/SliverAPI.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from tabulate import tabulate
22
from mythic_container.MythicCommandBase import *
33
from mythic_container.MythicRPC import SendMythicRPCFileGetContent, MythicRPCFileGetContentMessage
4-
from sliver import SliverClientConfig, SliverClient
4+
from sliver import SliverClientConfig, SliverClient, client_pb2
55
from mythic_container.MythicCommandBase import *
66
from mythic_container.MythicRPC import *
77
from mythic_container.PayloadBuilder import *
@@ -115,7 +115,6 @@ async def version(taskData: PTTaskMessageAllData):
115115

116116
return f"{version_results}"
117117

118-
119118
async def jobs_kill(taskData: PTTaskMessageAllData, job_id: int):
120119
client = await create_sliver_client(taskData)
121120
kill_response = await client.kill_job(job_id=job_id)
@@ -186,14 +185,14 @@ async def use(taskData: PTTaskMessageAllData, sliver_id: int):
186185
payload_type="sliverimplant",
187186
uuid=sliver_id,
188187
selected_os=sliver_os_table[implant_info.OS],
189-
description=f"sliver {'beaconing' if isBeacon else 'interactive'} implant for {sliver_id}",
188+
description=f"(no download) using sliver {'beaconing' if isBeacon else 'interactive'} implant for {sliver_id}",
190189
build_parameters=[],
191190
c2_profiles=[],
192191
# TODO: figure out if possible to not specify these manually
193192
commands=['ifconfig', 'download', 'upload', 'ls', 'ps', 'ping', 'whoami', 'screenshot', 'netstat', 'getgid', 'getuid', 'getpid', 'cat', 'cd', 'pwd', 'info', 'execute', 'mkdir', 'shell', 'terminate', 'rm']
194193
),
195194
)
196-
await SendMythicRPCPayloadCreateFromScratch(new_payload)
195+
scratchBuild = await SendMythicRPCPayloadCreateFromScratch(new_payload)
197196

198197
# create the callback
199198
extra_info = json.dumps({

Payload_Type/sliverapi/sliverapi/agent_functions/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async def build(self) -> BuildResponse:
4040
Host="SliverAPI",
4141
Ip=ip,
4242
IntegrityLevel=3,
43+
ExtraInfo=self.uuid,
4344
))
4445
if not create_callback.Success:
4546
logger.info(create_callback.Error)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
from ..SliverRequests import SliverAPI
2+
3+
from mythic_container.MythicCommandBase import *
4+
from mythic_container.PayloadBuilder import *
5+
from mythic_container.MythicRPC import MythicRPCPayloadCreateFromScratchMessage, MythicCommandBase, SendMythicRPCPayloadCreateFromScratch, SendMythicRPCResponseCreate, MythicRPCResponseCreateMessage
6+
7+
from mythic_container.MythicGoRPC.send_mythic_rpc_payload_create_from_scratch import MythicRPCPayloadConfiguration
8+
9+
class GenerateArguments(TaskArguments):
10+
def __init__(self, command_line, **kwargs):
11+
super().__init__(command_line, **kwargs)
12+
self.args = [
13+
CommandParameter(
14+
name="os",
15+
cli_name="os",
16+
display_name="os",
17+
description="operating system",
18+
default_value='windows',
19+
type=ParameterType.ChooseOne,
20+
choices=["linux", "windows"]
21+
),
22+
CommandParameter(
23+
name="mtls",
24+
cli_name="mtls",
25+
display_name="mtls",
26+
description="mtls ip:port to use",
27+
type=ParameterType.String,
28+
),
29+
]
30+
31+
async def parse_arguments(self):
32+
self.load_args_from_json_string(self.command_line)
33+
34+
35+
class Generate(CommandBase):
36+
cmd = "generate"
37+
needs_admin = False
38+
help_cmd = "generate"
39+
description = "Generate a new sliver binary"
40+
version = 1
41+
author = "Spencer Adolph"
42+
argument_class = GenerateArguments
43+
attackmapping = []
44+
45+
async def create_go_tasking(self, taskData: MythicCommandBase.PTTaskMessageAllData) -> MythicCommandBase.PTTaskCreateTaskingMessageResponse:
46+
# TODO: paste all the config options here
47+
48+
os = taskData.args.get_arg('os')
49+
mtls = taskData.args.get_arg('mtls')
50+
51+
sliverconfig_file_uuid = taskData.BuildParameters[0].Value
52+
53+
sliver_os_table = {
54+
'linux': 'Linux'
55+
}
56+
57+
createMessage = MythicRPCPayloadCreateFromScratchMessage(
58+
TaskID=taskData.Task.ID,
59+
PayloadConfiguration=MythicRPCPayloadConfiguration(
60+
PayloadType="sliverimplant",
61+
SelectedOS=sliver_os_table[os],
62+
Description="generated payload: sliver implant",
63+
BuildParameters=[
64+
MythicRPCPayloadConfigurationBuildParameter(
65+
name='sliverconfig_file_uuid',
66+
value=sliverconfig_file_uuid
67+
),
68+
MythicRPCPayloadConfigurationBuildParameter(
69+
name='os',
70+
value=os
71+
),
72+
MythicRPCPayloadConfigurationBuildParameter(
73+
name='mtls',
74+
value=mtls
75+
),
76+
],
77+
C2Profiles=[],
78+
Commands=['ifconfig', 'download', 'upload', 'ls', 'ps', 'ping', 'whoami', 'screenshot', 'netstat', 'getgid', 'getuid', 'getpid', 'cat', 'cd', 'pwd', 'info', 'execute', 'mkdir', 'shell', 'terminate', 'rm']
79+
),
80+
)
81+
await SendMythicRPCPayloadCreateFromScratch(createMessage)
82+
83+
await SendMythicRPCResponseCreate(MythicRPCResponseCreateMessage(
84+
TaskID=taskData.Task.ID,
85+
Response="generated implant".encode("UTF8"),
86+
))
87+
88+
taskResponse = MythicCommandBase.PTTaskCreateTaskingMessageResponse(
89+
TaskID=taskData.Task.ID,
90+
Success=True,
91+
Completed=True
92+
)
93+
return taskResponse
94+
95+
async def process_response(self, task: PTTaskMessageAllData, response: any) -> PTTaskProcessResponseMessageResponse:
96+
resp = PTTaskProcessResponseMessageResponse(TaskID=task.Task.ID, Success=True)
97+
return resp

Payload_Type/sliverimplant/sliverimplant/agent_functions/builder.py

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from mythic_container.PayloadBuilder import *
33
from mythic_container.MythicCommandBase import *
44
from mythic_container.MythicRPC import *
5-
from sliver import SliverClientConfig, SliverClient
5+
from sliver import SliverClientConfig, SliverClient, client_pb2
66

77

88
class SliverImplant(PayloadType):
@@ -24,38 +24,49 @@ class SliverImplant(PayloadType):
2424
build_steps = []
2525
build_parameters = [
2626
BuildParameter(
27-
name="name",
28-
description="name",
27+
name="sliverconfig_file_uuid",
28+
description="sliverconfig_file_uuid",
29+
parameter_type=BuildParameterType.String,
30+
),
31+
BuildParameter(
32+
name="os",
33+
description="os",
34+
parameter_type=BuildParameterType.String,
35+
),
36+
BuildParameter(
37+
name="mtls",
38+
description="mtls",
2939
parameter_type=BuildParameterType.String,
3040
),
3141
]
3242

3343
async def build(self) -> BuildResponse:
34-
# Just hope they have this setup already, and not have multiple
35-
# sliverapi_payloads = await SendMythicRPCPayloadSearch(MythicRPCPayloadSearchMessage(
36-
# PayloadTypes=['sliverapi'],
37-
# ))
38-
# sliver_config_uuid = sliverapi_payloads.Payloads[0].BuildParameters[0].Value
39-
# filecontent = await SendMythicRPCFileGetContent(MythicRPCFileGetContentMessage(
40-
# AgentFileId=sliver_config_uuid
41-
# ))
42-
# config = SliverClientConfig.parse_config(filecontent.Content)
43-
# client = SliverClient(config)
44-
# await client.connect()
44+
os = self.get_parameter('os')
45+
mtls = self.get_parameter('mtls')
46+
sliverconfig_file_uuid = self.get_parameter('sliverconfig_file_uuid')
4547

46-
# self.build_parameters
48+
if (os == ''):
49+
return BuildResponse(status=BuildStatus.Success)
50+
51+
filecontent = await SendMythicRPCFileGetContent(MythicRPCFileGetContentMessage(
52+
AgentFileId=sliverconfig_file_uuid
53+
))
54+
config = SliverClientConfig.parse_config(filecontent.Content)
55+
client = SliverClient(config)
56+
await client.connect()
4757

48-
# implant_config = client_pb2.ImplantConfig(
49-
# IsBeacon=self.build_parameters[''],
50-
# Name="sliver-pytest-1",
51-
# GOARCH="amd64",
52-
# GOOS="linux",
53-
# Format=client_pb2.OutputFormat.EXECUTABLE,
54-
# ObfuscateSymbols=False,
55-
# C2=[client_pb2.ImplantC2(Priority=0, URL="http://localhost:80")],
56-
# )
58+
implant_config = client_pb2.ImplantConfig(
59+
IsBeacon=False,
60+
Name=f"{self.uuid}",
61+
GOARCH="amd64",
62+
GOOS=os,
63+
Format=client_pb2.OutputFormat.EXECUTABLE,
64+
ObfuscateSymbols=False,
65+
C2=[client_pb2.ImplantC2(Priority=0, URL=f"mtls://{mtls}")],
66+
)
5767

58-
# implant = await client.generate_implant(implant_config)
68+
implant = await client.generate_implant(implant_config)
69+
implant_bytes = implant.File.Data
5970

60-
resp = BuildResponse(status=BuildStatus.Success)
71+
resp = BuildResponse(status=BuildStatus.Success, payload=implant_bytes)
6172
return resp

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ sudo ./mythic-cli install github https://github.com/MythicAgents/sliver
4343
- Interactive Tasking (shell) 🚧🐞 (buggy)
4444
- Beacon checkin status
4545
- Documentation-payload
46-
- Build implants through Mythic ('generate' + UI)
46+
- Build implants through Mythic ('generate' + UI)
4747
- Sliver 3rd party integrations
4848
- Stretch Goal: Ability to run the sliver server within mythic
4949
- Stretch Goal: V2 everything in go💙 (match sliver official client code)
@@ -67,7 +67,7 @@ sudo ./mythic-cli install github https://github.com/MythicAgents/sliver
6767
- cursed
6868
- dns
6969
- env
70-
- generate
70+
- generate
7171
- hosts
7272
- http
7373
- https
@@ -86,7 +86,7 @@ sudo ./mythic-cli install github https://github.com/MythicAgents/sliver
8686
- tasks
8787
- update
8888
- use✅
89-
- version
89+
- version
9090
- websites
9191
- wg
9292
- operators

0 commit comments

Comments
 (0)