Skip to content

Commit 13dfd96

Browse files
committed
f
1 parent 9204b38 commit 13dfd96

2 files changed

Lines changed: 97 additions & 1 deletion

File tree

src/linux-hardening/privilege-escalation/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,53 @@ top -n 1
233233
Always check for possible [**electron/cef/chromium debuggers** running, you could abuse it to escalate privileges](electron-cef-chromium-debugger-abuse.md). **Linpeas** detect those by checking the `--inspect` parameter inside the command line of the process.\
234234
Also **check your privileges over the processes binaries**, maybe you can overwrite someone.
235235
236+
### Cross-user parent-child chains
237+
238+
A child process running under a **different user** than its parent is not automatically malicious, but it is a useful **triage signal**. Some transitions are expected (`root` spawning a service user, login managers creating session processes), but unusual chains can reveal wrappers, debug helpers, persistence, or weak runtime trust boundaries.
239+
240+
Quick review:
241+
242+
```bash
243+
ps -eo pid,ppid,user,comm,args --sort=ppid
244+
pstree -alp
245+
```
246+
247+
If you find a surprising chain, inspect the parent command line and all files that influence its behavior (`config`, `EnvironmentFile`, helper scripts, working directory, writable arguments). In several real privesc paths the child itself was not writable, but the **parent-controlled config** or helper chain was.
248+
249+
### Deleted executables and deleted-open files
250+
251+
Runtime artifacts are often still accessible **after deletion**. This is useful both for privilege escalation and for recovering evidence from a process that already has sensitive files open.
252+
253+
Check for deleted executables:
254+
255+
```bash
256+
pid=<PID>
257+
ls -l /proc/$pid/exe
258+
readlink /proc/$pid/exe
259+
tr '\0' ' ' </proc/$pid/cmdline; echo
260+
```
261+
262+
If `/proc/<PID>/exe` points to `(deleted)`, the process is still running the old binary image from memory. That is a strong signal to investigate because:
263+
264+
- the removed executable may contain interesting strings or credentials
265+
- the running process may still expose useful file descriptors
266+
- a deleted privileged binary can indicate recent tampering or attempted cleanup
267+
268+
Collect deleted-open files globally:
269+
270+
```bash
271+
lsof +L1
272+
```
273+
274+
If you find an interesting descriptor, recover it directly:
275+
276+
```bash
277+
ls -l /proc/<PID>/fd
278+
cat /proc/<PID>/fd/<FD>
279+
```
280+
281+
This is especially valuable when a process still has a deleted secret, script, database export, or flag file open.
282+
236283
### Process monitoring
237284
238285
You can use tools like [**pspy**](https://github.com/DominicBreuker/pspy) to monitor processes. This can be very useful to identify vulnerable processes being executed frequently or when a set of requirements are met.
@@ -434,6 +481,15 @@ ls -al /etc/cron* /etc/at*
434481
cat /etc/cron* /etc/at* /etc/anacrontab /var/spool/cron/crontabs/root 2>/dev/null | grep -v "^#"
435482
```
436483

484+
If `run-parts` is used, check which names will really execute:
485+
486+
```bash
487+
run-parts --test /etc/cron.hourly
488+
run-parts --test /etc/cron.daily
489+
```
490+
491+
This avoids false positives. A writable periodic directory is only useful if your payload filename matches the local `run-parts` rules.
492+
437493
### Cron path
438494

439495
For example, inside _/etc/crontab_ you can find the PATH: _PATH=**/home/user**:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin_
@@ -590,6 +646,15 @@ It's possible to create a cronjob **putting a carriage return after a comment**
590646
#This is a comment inside a cron config file\r* * * * * echo "Surprise!"
591647
```
592648

649+
To detect this kind of stealth entry, inspect cron files with tools that expose control characters:
650+
651+
```bash
652+
cat -A /etc/crontab
653+
cat -A /etc/cron.d/*
654+
sed -n 'l' /etc/crontab /etc/cron.d/* 2>/dev/null
655+
xxd /etc/crontab | head
656+
```
657+
593658
## Services
594659

595660
### Writable _.service_ files

src/linux-hardening/privilege-escalation/d-bus-enumeration-and-command-injection-privilege-escalation.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ For communication with the D-Bus interface, two tools were employed: a CLI tool
1414
sudo apt-get install d-feet
1515
```
1616

17+
If you are checking the **session bus**, confirm the current address first:
18+
19+
```bash
20+
echo "$DBUS_SESSION_BUS_ADDRESS"
21+
```
22+
1723
![https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-21.png](https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-21.png)
1824

1925
![https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-22.png](https://unit42.paloaltonetworks.com/wp-content/uploads/2019/07/word-image-22.png)
@@ -58,6 +64,15 @@ org.freedesktop.hostname1 - - - (act
5864
org.freedesktop.locale1 - - - (activatable) - -
5965
```
6066

67+
Services marked as **`(activatable)`** are especially interesting because they are **not running yet**, but a bus request can start them on demand. Do not stop at `busctl list`; map those names to the actual binaries they would execute.
68+
69+
```bash
70+
ls -la /usr/share/dbus-1/system-services/ /usr/share/dbus-1/services/ 2>/dev/null
71+
grep -RInE '^(Name|Exec|User)=' /usr/share/dbus-1/system-services /usr/share/dbus-1/services 2>/dev/null
72+
```
73+
74+
That quickly tells you which `Exec=` path will start for an activatable name and under which identity. If the binary or its execution chain is weakly protected, an inactive service can still become a privilege-escalation path.
75+
6176
#### Connections
6277

6378
[From wikipedia:](https://en.wikipedia.org/wiki/D-Bus) When a process sets up a connection to a bus, the bus assigns to the connection a special bus name called _unique connection name_. Bus names of this type are immutable—it's guaranteed they won't change as long as the connection exists—and, more importantly, they can't be reused during the bus lifetime. This means that no other connection to that bus will ever have assigned such unique connection name, even if the same process closes down the connection to the bus and creates a new one. Unique connection names are easily recognizable because they start with the—otherwise forbidden—colon character.
@@ -126,6 +141,16 @@ BoundingCapabilities=cap_chown cap_dac_override cap_dac_read_search
126141
cap_wake_alarm cap_block_suspend cap_audit_read
127142
```
128143

144+
Also correlate the bus name with its `systemd` unit and executable path:
145+
146+
```bash
147+
systemctl status dbus-server.service --no-pager
148+
systemctl cat dbus-server.service
149+
namei -l /root/dbus-server
150+
```
151+
152+
This answers the operational question that matters during privesc: **if a method call succeeds, which real binary and unit will perform the action?**
153+
129154
### List Interfaces of a Service Object
130155

131156
You need to have enough permissions.
@@ -162,6 +187,13 @@ org.freedesktop.DBus.Properties interface - - -
162187

163188
Note the method `.Block` of the interface `htb.oouch.Block` (the one we are interested in). The "s" of the other columns may mean that it's expecting a string.
164189

190+
Before trying anything dangerous, validate a **read-oriented** or otherwise low-risk method first. This separates three cases cleanly: wrong syntax, reachable but denied, or reachable and allowed.
191+
192+
```bash
193+
busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanReboot
194+
gdbus call --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1 --method org.freedesktop.login1.Manager.CanReboot
195+
```
196+
165197
### Monitor/Capture Interface
166198

167199
With enough privileges (just `send_destination` and `receive_sender` privileges aren't enough) you can **monitor a D-Bus communication**.
@@ -537,4 +569,3 @@ Use `dbusmap --enable-probes` or manual `busctl call` to confirm whether a patch
537569

538570
{{#include ../../banners/hacktricks-training.md}}
539571

540-

0 commit comments

Comments
 (0)