
Cobalt Strike Malleable C2 프로필을 위한 Python 인터프리터입니다. 이를 프로그래밍 방식으로 구문 분석, 빌드 및 수정할 수 있습니다.
Cobalt Strike Malleable C2 프로필을 파싱, 수정, 프로그래매틱하게 빌드하고 구문을 검증할 수 있는 Python 인터프리터입니다.
Cobalt Strike 버전 4.3부터 모든 Malleable C2 프로필 문법을 지원합니다.
이전 Cobalt Strike 릴리스와 호환되지 않습니다.
pyMalleableC2와 다른 유사 프로젝트의 차이점은 무엇인가요?
if 문의 형태로 AI를 갖추고 있습니다.pyMalleableC2는 Python 3.9로 빌드되었지만 Python 3.6까지 하위 호환되어야 합니다.
Pip으로 설치:
pip3 install pymalleablec2pyMalleableC2는 사용자를 동의하는 성인으로 대우하며 Malleable C2 프로필 작성법을 알고 있다고 가정합니다. 구문 오류는 감지할 수 있지만 런타임 검사는 구현되지 않았습니다. 지시하면 실제로 프로덕션에서 작동하지 않는 프로필도 기꺼이 생성합니다. 프로덕션에서 사용하기 전에 항상 생성된 프로필을 c2lint로 실행하세요!
(기술적으로 이 라이브러리를 사용하여 c2lint의 Python 버전을 빌드할 수 있습니다. **기침* PR 환영합니다 **기침*)
pyMalleableC2의 주요 저자는 Marcello Salvati입니다.
트위터: @byt3bl33d3r, GitHub: @byt3bl33d3r
(자세한 내용은 예제 폴더 참조)
파일에 있는 Malleable C2 프로필의 AST를 생성한 다음 AST에서 소스 코드를 재구성:
from malleablec2 import Profile
# Parse a profile given its path
p = Profile.from_file("amazon.profile")
# Print the generated AST
print(p.ast.pretty())
# Reconstruct source code from the AST and print to console
print(p.reconstruct())
# Shortcut for the above :)
print(p)
'인라인' Malleable C2 프로필의 AST를 생성한 다음 AST에서 소스 코드를 재구성:
code = '''
set jitter "0";
set sleeptime "3000";
http-get {
set uri "/wow/this/is/cool";
}
http-post {
set uri "/pymalleablec2/is/the/shit";
}
'''
# Parse a profile from a string
p = Profile.from_string(code)
# Print the generated AST
print(p.ast.pretty())
# Reconstruct source code from the AST and print to console
print(p)
Malleable C2 프로필을 처음부터 프로그래매틱하게 빌드:
from malleablec2 import Profile
from malleablec2.components import *
# Create an empty profile
p = Profile.from_scratch()
# Set some global options
p.set_option("sleeptime", "0")
p.set_option("jitter", "0")
p.set_option("pipename", "mojo__##")
# Create an http-get block
http_get = HttpGetBlock()
# Set the uri http-get option
http_get.set_option("uri", "/wat/a/tease")
# Create a client block
client = ClientBlock()
# Add a header statement to the client block
client.add_statement("header", "Accept", "*/*")
# Create a server block
server = ServerBlock()
# Add the client and server blocks to the http-get block
http_get.add_code_block(client)
http_get.add_code_block(server)
# Create a http-post block
http_post = HttpPostBlock()
# Set the uri http-post option
http_post.set_option("uri", "/wat/ucraycray")
# Add the http-get and http-post blocks to the profile
p.add_code_block(http_get)
p.add_code_block(http_post)
# Reconstruct source code from the generated AST and print to console
print(p)
Malleable C2 프로필을 프로그래매틱하게 무작위화하는 방법을 보여주는 초간단 예제:
from malleablec2 import Profile
from malleablec2.randomizer import ProfileRandomizer
from lark import Token
class MyRandomizer(ProfileRandomizer):
# We implement the global_option_set method which will get called on every parsed global option statement in the profile
def global_option_set(self, tree):
option_name = tree.children[0]
if option_name == "pipename":
# "Randomize" the pipename value
tree.children[1].children[0] = Token('ESCAPED_STRING', '"my_random_pipename_##"')
# Parse a profile given its path
p = Profile.from_file("amazon.profile")
r = MyRandomizer()
# Walk through the generated profile AST and apply randomization rules
r.randomize(p)
# Reconstruct source code then output the profile to the console
print(p)