Skip to content

Commit 4f4ef7a

Browse files
wieso-itzinasbench
andauthored
Merge PR #5042 from @wieso-itzi - Update Python PTY rules
update: Python Spawning Pretty TTY Via PTY Module - Update the logic to account for the possibility of calling the spawn function via a variable, as an alias or other methods. update: Python Reverse Shell Execution Via PTY And Socket Modules - Add additional strings to increase accuracy and coverage. --------- Signed-off-by: wieso-itzi <[email protected]> Co-authored-by: nasbench <[email protected]>
1 parent 243003c commit 4f4ef7a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
title: Python Spawning Pretty TTY
1+
title: Python Spawning Pretty TTY Via PTY Module
22
id: c4042d54-110d-45dd-a0e1-05c47822c937
33
related:
44
- id: 32e62bc7-3de0-4bb1-90af-532978fe42c0
55
type: similar
66
status: test
7-
description: Detects python spawning a pretty tty which could be indicative of potential reverse shell activity
7+
description: |
8+
Detects a python process calling to the PTY module in order to spawn a pretty tty which could be indicative of potential reverse shell activity.
89
references:
910
- https://www.volexity.com/blog/2022/06/02/zero-day-exploitation-of-atlassian-confluence/
1011
author: Nextron Systems
1112
date: 2022-06-03
12-
modified: 2023-06-16
13+
modified: 2024-11-04
1314
tags:
1415
- attack.execution
1516
- attack.t1059
@@ -25,13 +26,13 @@ detection:
2526
- Image|contains:
2627
- '/python2.' # python image is always of the form ../python3.10; ../python is just a symlink
2728
- '/python3.'
28-
selection_cli_1:
29-
CommandLine|contains|all:
29+
selection_cli_import:
30+
CommandLine|contains:
3031
- 'import pty'
31-
- '.spawn('
32-
selection_cli_2:
33-
CommandLine|contains: 'from pty import spawn'
34-
condition: selection_img and 1 of selection_cli_*
32+
- 'from pty '
33+
selection_cli_spawn:
34+
CommandLine|contains: 'spawn'
35+
condition: all of selection_*
3536
falsepositives:
3637
- Unknown
37-
level: high
38+
level: medium

rules/linux/process_creation/proc_creation_lnx_python_reverse_shell.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
title: Potential Python Reverse Shell
1+
title: Python Reverse Shell Execution Via PTY And Socket Modules
22
id: 32e62bc7-3de0-4bb1-90af-532978fe42c0
33
related:
44
- id: c4042d54-110d-45dd-a0e1-05c47822c937
55
type: similar
66
status: test
7-
description: Detects executing python with keywords related to network activity that could indicate a potential reverse shell
7+
description: |
8+
Detects the execution of python with calls to the socket and pty module in order to connect and spawn a potential reverse shell.
89
references:
9-
- https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
1010
- https://www.revshells.com/
1111
author: '@d4ns4n_, Nasreddine Bencherchali (Nextron Systems)'
1212
date: 2023-04-24
13+
modified: 2024-11-04
1314
tags:
1415
- attack.execution
1516
logsource:
@@ -22,7 +23,8 @@ detection:
2223
- ' -c '
2324
- 'import'
2425
- 'pty'
25-
- 'spawn('
26+
- 'socket'
27+
- 'spawn'
2628
- '.connect'
2729
condition: selection
2830
falsepositives:

0 commit comments

Comments
 (0)