Simple HTTP Web Server Creation
This rule detects the creation of a simple HTTP web server using PHP or Python built-in modules. Adversaries may create simple HTTP web servers to establish persistence on a compromised system by uploading a reverse or command shell payload to the server web root, allowing them to regain remote access to the system if lost.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/12/17"
3integration = ["endpoint", "crowdstrike", "sentinel_one_cloud_funnel"]
4maturity = "production"
5updated_date = "2025/03/20"
6
7[rule]
8author = ["Elastic"]
9description = """
10This rule detects the creation of a simple HTTP web server using PHP or Python built-in modules. Adversaries may create
11simple HTTP web servers to establish persistence on a compromised system by uploading a reverse or command shell payload
12to the server web root, allowing them to regain remote access to the system if lost.
13"""
14from = "now-9m"
15index = [
16 "logs-endpoint.events.process*",
17 "logs-crowdstrike.fdr*",
18 "logs-sentinel_one_cloud_funnel.*",
19 "endgame-*",
20]
21language = "eql"
22license = "Elastic License v2"
23name = "Simple HTTP Web Server Creation"
24note = """## Triage and analysis
25
26> **Disclaimer**:
27> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
28
29### Investigating Simple HTTP Web Server Creation
30
31Simple HTTP web servers, often created using PHP or Python, are lightweight and easy to deploy, making them ideal for quick file sharing or testing. However, adversaries exploit this simplicity to establish persistence on compromised Linux systems. By deploying a web server, they can upload malicious payloads, such as reverse shells, to maintain remote access. The detection rule identifies suspicious server creation by monitoring process executions that match specific patterns, such as PHP or Python commands indicative of server setup, thereby alerting analysts to potential threats.
32
33### Possible investigation steps
34
35- Review the process execution details to confirm the presence of PHP or Python commands with arguments matching the patterns specified in the query, such as PHP with the "-S" argument or Python with "--cgi" or "CGIHTTPServer".
36- Identify the user account under which the suspicious process was executed to determine if it aligns with expected behavior or if it indicates potential compromise.
37- Examine the network activity associated with the process to identify any unusual connections or data transfers that could suggest malicious intent or data exfiltration.
38- Check the file system for any newly created or modified files in the web server's root directory that could contain malicious payloads, such as reverse shells.
39- Investigate the parent process of the suspicious server creation to understand how the process was initiated and whether it was triggered by another potentially malicious activity.
40- Correlate the alert with other security events or logs from the same host to identify any additional indicators of compromise or related suspicious activities.
41
42### False positive analysis
43
44- Development and testing environments often use simple HTTP servers for legitimate purposes such as serving static files or testing web applications. To manage this, create exceptions for known development directories or user accounts frequently involved in these activities.
45- Automated scripts or cron jobs may start simple HTTP servers for routine tasks like file distribution or internal data sharing. Identify these scripts and exclude their execution paths or associated user accounts from triggering alerts.
46- Educational or training sessions might involve setting up simple HTTP servers as part of learning exercises. Exclude specific IP ranges or user groups associated with training environments to prevent false positives.
47- System administrators might use simple HTTP servers for quick troubleshooting or system maintenance tasks. Document these activities and create exceptions based on the administrator's user accounts or specific server names.
48- Continuous integration and deployment pipelines may temporarily start HTTP servers during build or deployment processes. Identify these pipelines and exclude their associated processes or execution contexts from the detection rule.
49
50### Response and remediation
51
52- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
53- Terminate any suspicious PHP or Python processes identified by the detection rule to halt the operation of the unauthorized web server.
54- Conduct a thorough examination of the web server's root directory to identify and remove any malicious payloads, such as reverse shells or unauthorized scripts.
55- Review system logs and network traffic to identify any additional indicators of compromise or lateral movement attempts by the adversary.
56- Restore the system from a known good backup if any critical system files or configurations have been altered by the adversary.
57- Implement stricter access controls and monitoring on the affected system to prevent similar unauthorized server setups in the future.
58- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are compromised."""
59risk_score = 21
60rule_id = "907a26f5-3eb6-4338-a70e-6c375c1cde8a"
61setup = """## Setup
62
63This rule requires data coming in from Elastic Defend.
64
65### Elastic Defend Integration Setup
66Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
67
68#### Prerequisite Requirements:
69- Fleet is required for Elastic Defend.
70- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
71
72#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
73- Go to the Kibana home page and click "Add integrations".
74- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
75- Click "Add Elastic Defend".
76- Configure the integration name and optionally add a description.
77- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
78- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
79- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
80- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
81For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
82- Click "Save and Continue".
83- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
84For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
85"""
86severity = "low"
87tags = [
88 "Domain: Endpoint",
89 "OS: Linux",
90 "Use Case: Threat Detection",
91 "Tactic: Persistence",
92 "Tactic: Execution",
93 "Tactic: Command and Control",
94 "Data Source: Elastic Defend",
95 "Data Source: Crowdstrike",
96 "Data Source: SentinelOne",
97 "Data Source: Elastic Endgame",
98 "Resources: Investigation Guide",
99]
100timestamp_override = "event.ingested"
101type = "eql"
102
103query = '''
104process where host.os.type == "linux" and event.type == "start" and
105 event.action in ("exec", "exec_event", "start", "ProcessRollup2") and
106 (
107 (process.name regex~ """php?[0-9]?\.?[0-9]{0,2}""" and process.args == "-S") or
108 (process.name like "python*" and process.args in ("--cgi", "CGIHTTPServer"))
109 ) and
110not process.parent.name in ("check_kmp_wrapper", "naemon")
111'''
112
113
114[[rule.threat]]
115framework = "MITRE ATT&CK"
116[[rule.threat.technique]]
117id = "T1505"
118name = "Server Software Component"
119reference = "https://attack.mitre.org/techniques/T1505/"
120[[rule.threat.technique.subtechnique]]
121id = "T1505.003"
122name = "Web Shell"
123reference = "https://attack.mitre.org/techniques/T1505/003/"
124
125
126
127[rule.threat.tactic]
128id = "TA0003"
129name = "Persistence"
130reference = "https://attack.mitre.org/tactics/TA0003/"
131[[rule.threat]]
132framework = "MITRE ATT&CK"
133[[rule.threat.technique]]
134id = "T1059"
135name = "Command and Scripting Interpreter"
136reference = "https://attack.mitre.org/techniques/T1059/"
137[[rule.threat.technique.subtechnique]]
138id = "T1059.004"
139name = "Unix Shell"
140reference = "https://attack.mitre.org/techniques/T1059/004/"
141
142
143
144[rule.threat.tactic]
145id = "TA0002"
146name = "Execution"
147reference = "https://attack.mitre.org/tactics/TA0002/"
148[[rule.threat]]
149framework = "MITRE ATT&CK"
150[[rule.threat.technique]]
151id = "T1071"
152name = "Application Layer Protocol"
153reference = "https://attack.mitre.org/techniques/T1071/"
154
155
156[rule.threat.tactic]
157id = "TA0011"
158name = "Command and Control"
159reference = "https://attack.mitre.org/tactics/TA0011/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating Simple HTTP Web Server Creation
Simple HTTP web servers, often created using PHP or Python, are lightweight and easy to deploy, making them ideal for quick file sharing or testing. However, adversaries exploit this simplicity to establish persistence on compromised Linux systems. By deploying a web server, they can upload malicious payloads, such as reverse shells, to maintain remote access. The detection rule identifies suspicious server creation by monitoring process executions that match specific patterns, such as PHP or Python commands indicative of server setup, thereby alerting analysts to potential threats.
Possible investigation steps
- Review the process execution details to confirm the presence of PHP or Python commands with arguments matching the patterns specified in the query, such as PHP with the "-S" argument or Python with "--cgi" or "CGIHTTPServer".
- Identify the user account under which the suspicious process was executed to determine if it aligns with expected behavior or if it indicates potential compromise.
- Examine the network activity associated with the process to identify any unusual connections or data transfers that could suggest malicious intent or data exfiltration.
- Check the file system for any newly created or modified files in the web server's root directory that could contain malicious payloads, such as reverse shells.
- Investigate the parent process of the suspicious server creation to understand how the process was initiated and whether it was triggered by another potentially malicious activity.
- Correlate the alert with other security events or logs from the same host to identify any additional indicators of compromise or related suspicious activities.
False positive analysis
- Development and testing environments often use simple HTTP servers for legitimate purposes such as serving static files or testing web applications. To manage this, create exceptions for known development directories or user accounts frequently involved in these activities.
- Automated scripts or cron jobs may start simple HTTP servers for routine tasks like file distribution or internal data sharing. Identify these scripts and exclude their execution paths or associated user accounts from triggering alerts.
- Educational or training sessions might involve setting up simple HTTP servers as part of learning exercises. Exclude specific IP ranges or user groups associated with training environments to prevent false positives.
- System administrators might use simple HTTP servers for quick troubleshooting or system maintenance tasks. Document these activities and create exceptions based on the administrator's user accounts or specific server names.
- Continuous integration and deployment pipelines may temporarily start HTTP servers during build or deployment processes. Identify these pipelines and exclude their associated processes or execution contexts from the detection rule.
Response and remediation
- Immediately isolate the affected system from the network to prevent further unauthorized access or data exfiltration.
- Terminate any suspicious PHP or Python processes identified by the detection rule to halt the operation of the unauthorized web server.
- Conduct a thorough examination of the web server's root directory to identify and remove any malicious payloads, such as reverse shells or unauthorized scripts.
- Review system logs and network traffic to identify any additional indicators of compromise or lateral movement attempts by the adversary.
- Restore the system from a known good backup if any critical system files or configurations have been altered by the adversary.
- Implement stricter access controls and monitoring on the affected system to prevent similar unauthorized server setups in the future.
- Escalate the incident to the security operations center (SOC) or incident response team for further investigation and to determine if additional systems are compromised.
Related rules
- Git Hook Child Process
- Manual Dracut Execution
- Process Backgrounded by Unusual Parent
- Unusual Pkexec Execution
- Boot File Copy