Skip to content

Commit

Permalink
Egress Network Connection by MOTD Child Sync RTA (#3945)
Browse files Browse the repository at this point in the history
Co-authored-by: shashank-elastic <91139415 [email protected]>

(cherry picked from commit fff326a)
  • Loading branch information
protectionsmachine authored and github-actions[bot] committed Aug 8, 2024
1 parent 2537b97 commit d30f3f1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions rta/linux_persistence_motd_netcon_parent_child.py
Original file line number Diff line number Diff line change
@@ -0,0 1,53 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

from . import common
from . import RtaMetadata

metadata = RtaMetadata(
uuid="a67ba2b1-cace-4cb9-9b7e-12c9ffe136cb",
platforms=["linux"],
endpoint=[
{
"rule_name": "Egress Network Connection by MOTD Child",
"rule_id": "da02d81a-d432-4cfe-8aa4-fc1a31c29c98"
}
],
techniques=["T1037", "T1059", "T1071"],
)


@common.requires_os(*metadata.platforms)
def main():

# Path for the fake motd executable
masquerade = "/etc/update-motd.d/rta"
source = common.get_path("bin", "netcon_exec_chain.elf")

common.log("Creating a fake motd executable..")
common.copy_file(source, masquerade)
common.log("Granting execute permissions...")
common.execute(['chmod', ' x', masquerade])

# Execute the fake motd executable
common.log("Executing the fake motd executable..")
commands = [
masquerade,
'chain',
'-h',
'8.8.8.8',
'-p',
'53',
'-c',
'/etc/update-motd.d/rta netcon -h 8.8.8.8 -p 53'
]
common.execute([*commands], timeout=5, kill=True)

# Cleanup
common.remove_file(masquerade)


if __name__ == "__main__":
exit(main())

0 comments on commit d30f3f1

Please sign in to comment.