-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathremote_debugging.po
More file actions
782 lines (636 loc) · 72.7 KB
/
Copy pathremote_debugging.po
File metadata and controls
782 lines (636 loc) · 72.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
# Persian translations for Python package.
# Copyright (C) 2001 Python Software Foundation
# This file is distributed under the same license as the Python package.
# Automatically generated, 2026.
#
# Translators:
# Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.14\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-09-16 12:56+0000\n"
"PO-Revision-Date: 2026-09-15 07:29+0330\n"
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
"Language-Team: none\n"
"Language: fa\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.6\n"
msgid "Remote debugging attachment protocol"
msgstr "پروتکل اتصال اشکالزدایی راه دور"
msgid "This protocol enables external tools to attach to a running CPython process and execute Python code remotely."
msgstr "این پروتکل به ابزارهای خارجی امکان میدهد به یک فرآیند در حال اجرای CPython متصل شوند و کد پایتون را از راه دور اجرا کنند."
msgid "Most platforms require elevated privileges to attach to another Python process."
msgstr "بیشتر سکوها برای اتصال به یک فرآیند پایتون دیگر به دسترسیهای ارتقاءیافته نیاز دارند."
msgid "Disabling remote debugging"
msgstr "غیرفعالسازی اشکالزدایی از راه دور"
msgid "To disable remote debugging support, use any of the following:"
msgstr "برای غیرفعال کردن پشتیبانی از اشکالزدایی از راه دور، از یکی از موارد زیر استفاده کنید:"
msgid "Set the :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` environment variable to ``1`` before starting the interpreter."
msgstr "متغیر محیطی :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` را پیش از راهاندازی مفسر روی ``1`` تنظیم کنید."
msgid "Use the :option:`-X disable_remote_debug` command-line option."
msgstr "از گزینهی خط فرمان :option:`-X disable_remote_debug` استفاده کنید."
msgid "Compile Python with the :option:`--without-remote-debug` build flag."
msgstr "پایتون را با پرچم ساخت :option:`--without-remote-debug` کامپایل کنید."
msgid "Permission requirements"
msgstr "الزامات دسترسی"
msgid "Attaching to a running Python process for remote debugging requires elevated privileges on most platforms. The specific requirements and troubleshooting steps depend on your operating system:"
msgstr "اتصال به یک فرایند پایتون در حال اجرا برای اشکالزدایی از راه دور، در بیشتر پلتفرمها به دسترسیهای ارتقاءیافته نیاز دارد. نیازمندیهای خاص و مراحل عیبیابی به سیستمعامل شما بستگی دارند:"
msgid "Linux"
msgstr "لینوکس"
msgid "The tracer process must have the ``CAP_SYS_PTRACE`` capability or equivalent privileges. You can only trace processes you own and can signal. Tracing may fail if the process is already being traced, or if it is running with set-user-ID or set-group-ID. Security modules like Yama may further restrict tracing."
msgstr "فرایند ردیاب باید قابلیت ``CAP_SYS_PTRACE`` یا امتیازات معادل آن را داشته باشد. شما فقط میتوانید فرایندهایی را ردگیری کنید که مالک آنها هستید و میتوانید به آنها سیگنال بفرستید. اگر فرایند از قبل در حال ردگیری باشد، یا با set-user-ID یا set-group-ID اجرا شود، ممکن است ردگیری با شکست مواجه شود. ماژولهای امنیتی مانند Yama ممکن است ردگیری را بیشتر محدود کنند."
msgid "To temporarily relax ptrace restrictions (until reboot), run:"
msgstr "برای کاهش موقت محدودیتهای ptrace (تا راهاندازی مجدد)، اجرا کنید:"
msgid "``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``"
msgstr "``echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope``"
msgid "Disabling ``ptrace_scope`` reduces system hardening and should only be done in trusted environments."
msgstr "غیرفعال کردن ``ptrace_scope`` مستحکمسازی سیستم را کاهش میدهد و باید فقط در محیطهای مورد اعتماد انجام شود."
msgid "If running inside a container, use ``--cap-add=SYS_PTRACE`` or ``--privileged``, and run as root if needed."
msgstr "اگر داخل یک ظرف اجرا میشود، از ``--cap-add=SYS_PTRACE`` یا ``--privileged`` استفاده کنید و در صورت نیاز، بهعنوان root اجرا کنید."
msgid "Try re-running the command with elevated privileges:"
msgstr "دستور را دوباره با دسترسیهای ارتقاءیافته اجرا کنید:"
msgid "``sudo -E !!``"
msgstr "``sudo -E !!``"
msgid "macOS"
msgstr "macOS"
msgid "To attach to another process, you typically need to run your debugging tool with elevated privileges. This can be done by using ``sudo`` or running as root."
msgstr "برای اتصال به یک فرایند دیگر، معمولاً باید ابزار اشکالزدایی خود را با دسترسیهای بالاتر اجرا کنید. این کار را میتوان با استفاده از ``sudo`` یا اجرا بهعنوان root انجام داد."
msgid "Even when attaching to processes you own, macOS may block debugging unless the debugger is run with root privileges due to system security restrictions."
msgstr "حتی هنگام اتصال به فرایندهایی که متعلق به شما هستند، ممکن است macOS به دلیل محدودیتهای امنیتی سیستم، اشکالزدایی را مسدود کند، مگر اینکه اشکالزدا با امتیازات root اجرا شود."
msgid "Windows"
msgstr "ویندوز"
msgid "To attach to another process, you usually need to run your debugging tool with administrative privileges. Start the command prompt or terminal as Administrator."
msgstr "برای اتصال به یک فرایند دیگر، معمولاً باید ابزار اشکالزدایی خود را با دسترسی مدیریتی اجرا کنید. خط فرمان یا پایانه را بهعنوان مدیر اجرا کنید."
msgid "Some processes may still be inaccessible even with Administrator rights, unless you have the ``SeDebugPrivilege`` privilege enabled."
msgstr "برخی فرایندها ممکن است حتی با حقوق مدیر (Administrator) نیز همچنان غیرقابلدسترس باشند، مگر اینکه امتیاز ``SeDebugPrivilege`` را فعال کرده باشید."
msgid "To resolve file or folder access issues, adjust the security permissions:"
msgstr "برای حل مشکلات دسترسی به پرونده یا پوشه، مجوزهای امنیتی را تنظیم کنید:"
msgid "Right-click the file or folder and select **Properties**."
msgstr "روی پرونده یا پوشه راستکلیک کنید و **Properties** را انتخاب کنید."
msgid "Go to the **Security** tab to view users and groups with access."
msgstr "برای مشاهده کاربران و گروههای دارای دسترسی، به زبانه **Security** بروید."
msgid "Click **Edit** to modify permissions."
msgstr "برای تغییر مجوزها، روی **Edit** کلیک کنید."
msgid "Select your user account."
msgstr "حساب کاربری خود را انتخاب کنید."
msgid "In **Permissions**, check **Read** or **Full control** as needed."
msgstr "در **مجوزها**، **خواندن** یا **کنترل کامل** را در صورت نیاز علامت بزنید."
msgid "Click **Apply**, then **OK** to confirm."
msgstr "روی **Apply** کلیک کنید، سپس برای تأیید روی **OK** کلیک کنید."
msgid "Ensure you've satisfied all :ref:`permission-requirements` before proceeding."
msgstr "پیش از ادامه، اطمینان حاصل کنید که تمام :ref:`permission-requirements` را برآورده کردهاید."
msgid "This section describes the low-level protocol that enables external tools to inject and execute a Python script within a running CPython process."
msgstr "این بخش پروتکل سطح پایینی را توصیف میکند که به ابزارهای خارجی امکان میدهد یک اسکریپت پایتون را درون یک فرآیند در حال اجرای CPython تزریق و اجرا کنند."
msgid "This mechanism forms the basis of the :func:`sys.remote_exec` function, which instructs a remote Python process to execute a ``.py`` file. However, this section does not document the usage of that function. Instead, it provides a detailed explanation of the underlying protocol, which takes as input the ``pid`` of a target Python process and the path to a Python source file to be executed. This information supports independent reimplementation of the protocol, regardless of programming language."
msgstr "این سازوکار مبنای تابع :func:`sys.remote_exec` را تشکیل میدهد، که به یک فرآیند پایتون راه دور دستور میدهد یک پرونده ``.py`` را اجرا کند. با این حال، این بخش به مستندسازی نحوهی استفاده از آن تابع نمیپردازد. در عوض، توضیح دقیقی درباره پروتکل زیربنایی ارائه میدهد که بهعنوان ورودی، ``pid`` یک فرآیند پایتون هدف و مسیر یک پرونده منبع پایتون که باید اجرا شود را دریافت میکند. این اطلاعات از پیادهسازی مستقل پروتکل، صرفنظر از زبان برنامهنویسی، پشتیبانی میکند."
msgid "The execution of the injected script depends on the interpreter reaching a safe evaluation point. As a result, execution may be delayed depending on the runtime state of the target process."
msgstr "اجرای اسکریپت تزریقشده، به رسیدن مفسر به یک نقطه ارزیابی ایمن وابسته است. در نتیجه، ممکن است اجرا بسته به وضعیت رانتایم فرایند هدف به تأخیر بیفتد."
msgid "Once injected, the script is executed by the interpreter within the target process the next time a safe evaluation point is reached. This approach enables remote execution capabilities without modifying the behavior or structure of the running Python application."
msgstr "پس از تزریق، اسکریپت در دفعهی بعد که به یک نقطهی ارزیابی امن رسیده شود، توسط مفسر درون فرایند هدف اجرا میشود. این رویکرد قابلیتهای اجرای از راه دور را بدون تغییر رفتار یا ساختار برنامه پایتون در حال اجرا فراهم میکند."
msgid "Subsequent sections provide a step-by-step description of the protocol, including techniques for locating interpreter structures in memory, safely accessing internal fields, and triggering code execution. Platform-specific variations are noted where applicable, and example implementations are included to clarify each operation."
msgstr "بخشهای بعدی توصیفی گامبهگام از پروتکل ارائه میدهند، شامل تکنیکهایی برای یافتن ساختارهای مفسر در حافظه، دسترسی ایمن به فیلدهای داخلی و فعالسازی اجرای کد. تفاوتهای خاص پلتفرم در موارد قابل اعمال ذکر شدهاند و پیادهسازیهای نمونه برای روشنسازی هر عملیات گنجانده شدهاند."
msgid "Locating the PyRuntime structure"
msgstr "یافتن ساختار PyRuntime"
msgid "CPython places the ``PyRuntime`` structure in a dedicated binary section to help external tools find it at runtime. The name and format of this section vary by platform. For example, ``.PyRuntime`` is used on ELF systems, and ``__DATA,__PyRuntime`` is used on macOS. Tools can find the offset of this structure by examining the binary on disk."
msgstr "CPython ساختار ``PyRuntime`` را در یک بخش دودویی اختصاصی قرار میدهد تا ابزارهای خارجی بتوانند آن را در زمان رانتایم بیابند. نام و قالب این بخش بر حسب پلتفرم متفاوت است. برای مثال، در سیستمهای ELF از ``.PyRuntime`` و در macOS از ``__DATA,__PyRuntime`` استفاده میشود. ابزارها میتوانند با بررسی دودویی روی دیسک، آفست این ساختار را بیابند."
msgid "The ``PyRuntime`` structure contains CPython’s global interpreter state and provides access to other internal data, including the list of interpreters, thread states, and debugger support fields."
msgstr "ساختار ``PyRuntime`` شامل وضعیت سراسری مفسر CPython است و دسترسی به سایر دادههای داخلی، از جمله فهرست مفسرها، وضعیتهای نخ و فیلدهای پشتیبانی اشکالزدا را فراهم میکند."
msgid "To work with a remote Python process, a debugger must first find the memory address of the ``PyRuntime`` structure in the target process. This address can’t be hardcoded or calculated from a symbol name, because it depends on where the operating system loaded the binary."
msgstr "برای کار با یک فرایند پایتون راهدور، اشکالزدا باید ابتدا نشانی حافظهی ساختار ``PyRuntime`` را در فرایند هدف پیدا کند. این نشانی را نمیتوان بهصورت سختکدشده تعیین کرد یا از روی نام نماد محاسبه کرد، زیرا به این بستگی دارد که سیستمعامل پرونده دودویی را کجا بارگذاری کرده است."
msgid "The method for finding ``PyRuntime`` depends on the platform, but the steps are the same in general:"
msgstr "روش یافتن ``PyRuntime`` به پلتفرم بستگی دارد، اما مراحل بهطور کلی یکسان هستند:"
msgid "Find the base address where the Python binary or shared library was loaded in the target process."
msgstr "آدرس پایهای را بیابید که دودویی پایتون یا کتابخانه اشتراکی در فرایند هدف در آن بارگذاری شده است."
msgid "Use the on-disk binary to locate the offset of the ``.PyRuntime`` section."
msgstr "از پروندهی دودویی روی دیسک برای یافتن آفست بخش ``.PyRuntime`` استفاده کنید."
msgid "Add the section offset to the base address to compute the address in memory."
msgstr "برای محاسبهی آدرس در حافظه، آفست بخش را به آدرس پایه اضافه کنید."
msgid "The sections below explain how to do this on each supported platform and include example code."
msgstr "بخشهای زیر توضیح میدهند که چگونه این کار را در هر سکوی پشتیبانیشده انجام دهید و شامل کد نمونه هستند."
msgid "Linux (ELF)"
msgstr "لینوکس (ELF)"
msgid "To find the ``PyRuntime`` structure on Linux:"
msgstr "برای یافتن ساختار ``PyRuntime`` در لینوکس:"
msgid "Read the process’s memory map (for example, ``/proc/<pid>/maps``) to find the address where the Python executable or ``libpython`` was loaded."
msgstr "نقشهی حافظهی فرایند را بخوانید (برای مثال، ``/proc/<pid>/maps``) تا نشانیای را بیابید که پرونده اجرایی پایتون یا ``libpython`` در آن بارگذاری شده است."
msgid "Parse the ELF section headers in the binary to get the offset of the ``.PyRuntime`` section."
msgstr "سرآیندهای بخش ELF را در پرونده دودویی تجزیه کنید تا آفست بخش ``.PyRuntime`` به دست آید."
msgid "Add that offset to the base address from step 1 to get the memory address of ``PyRuntime``."
msgstr "آن آفست را به آدرس پایهی مرحلهی ۱ اضافه کنید تا آدرس حافظهی ``PyRuntime`` بهدست آید."
msgid "The following is an example implementation::"
msgstr "در ادامه یک پیادهسازی نمونه آمده است::"
msgid ""
"def find_py_runtime_linux(pid: int) -> int:\n"
" # Step 1: Try to find the Python executable in memory\n"
" binary_path, base_address = find_mapped_binary(\n"
" pid, name_contains=\"python\"\n"
" )\n"
"\n"
" # Step 2: Fallback to shared library if executable is not found\n"
" if binary_path is None:\n"
" binary_path, base_address = find_mapped_binary(\n"
" pid, name_contains=\"libpython\"\n"
" )\n"
"\n"
" # Step 3: Parse ELF headers to get .PyRuntime section offset\n"
" section_offset = parse_elf_section_offset(\n"
" binary_path, \".PyRuntime\"\n"
" )\n"
"\n"
" # Step 4: Compute PyRuntime address in memory\n"
" return base_address + section_offset"
msgstr ""
"def find_py_runtime_linux(pid: int) -> int:\n"
" # Step 1: Try to find the Python executable in memory\n"
" binary_path, base_address = find_mapped_binary(\n"
" pid, name_contains=\"python\"\n"
" )\n"
"\n"
" # Step 2: Fallback to shared library if executable is not found\n"
" if binary_path is None:\n"
" binary_path, base_address = find_mapped_binary(\n"
" pid, name_contains=\"libpython\"\n"
" )\n"
"\n"
" # Step 3: Parse ELF headers to get .PyRuntime section offset\n"
" section_offset = parse_elf_section_offset(\n"
" binary_path, \".PyRuntime\"\n"
" )\n"
"\n"
" # Step 4: Compute PyRuntime address in memory\n"
" return base_address + section_offset"
msgid "On Linux systems, there are two main approaches to read memory from another process. The first is through the ``/proc`` filesystem, specifically by reading from ``/proc/[pid]/mem`` which provides direct access to the process's memory. This requires appropriate permissions - either being the same user as the target process or having root access. The second approach is using the ``process_vm_readv()`` system call which provides a more efficient way to copy memory between processes. While ptrace's ``PTRACE_PEEKTEXT`` operation can also be used to read memory, it is significantly slower as it only reads one word at a time and requires multiple context switches between the tracer and tracee processes."
msgstr "در سیستمهای لینوکسی، دو روش اصلی برای خواندن حافظه از یک فرایند دیگر وجود دارد. روش اول از طریق سامانه فایلبندی ``/proc`` است، بهویژه با خواندن از ``/proc/[pid]/mem`` که دسترسی مستقیمی به حافظهی فرایند فراهم میکند. این کار به مجوزهای مناسب نیاز دارد؛ یا باید همان کاربرِ فرایند هدف باشید یا دسترسی root داشته باشید. روش دوم استفاده از فراخوانی سیستمی ``process_vm_readv()`` است که راهی کارآمدتر برای کپی حافظه بین فرایندها فراهم میکند. اگرچه میتوان از عملیات ``PTRACE_PEEKTEXT`` در ptrace نیز برای خواندن حافظه استفاده کرد، اما این روش بهطور قابلتوجهی کندتر است، زیرا هر بار فقط یک کلمه را میخواند و به چندین تعویض زمینه بین فرایندهای ردیاب و ردگیریشونده نیاز دارد."
msgid "For parsing ELF sections, the process involves reading and interpreting the ELF file format structures from the binary file on disk. The ELF header contains a pointer to the section header table. Each section header contains metadata about a section including its name (stored in a separate string table), offset, and size. To find a specific section like .PyRuntime, you need to walk through these headers and match the section name. The section header then provides the offset where that section exists in the file, which can be used to calculate its runtime address when the binary is loaded into memory."
msgstr "برای تجزیهی بخشهای ELF، این فرآیند شامل خواندن و تفسیر ساختارهای قالب پرونده ELF از پرونده دودویی روی دیسک است. سرآیند ELF شامل اشارهگری به جدول سرآیند بخشها است. هر سرآیند بخش شامل فرادادهای دربارهی یک بخش است، از جمله نام آن (که در یک جدول رشتهای جداگانه ذخیرهشده است)، آفست و اندازه. برای یافتن بخش خاصی مانند .PyRuntime، باید این سرآیندها را پیمایش کنید و نام بخش را تطبیق دهید. سپس سرآیند بخش آفست محل قرارگیری آن بخش در پرونده را ارائه میدهد، که میتوان از آن برای محاسبهی آدرس رانتایم آن هنگام بارگذاری پرونده دودویی در حافظه استفاده کرد."
msgid "You can read more about the ELF file format in the `ELF specification <https://en.wikipedia.org/wiki/Executable_and_Linkable_Format>`_."
msgstr "میتوانید دربارهی قالب پرونده ELF در `مشخصات ELF <https://fa.wikipedia.org/wiki/فرمت_اجرایی_و_مرتبط>`_ بیشتر بخوانید."
msgid "macOS (Mach-O)"
msgstr "macOS (Mach-O)"
msgid "To find the ``PyRuntime`` structure on macOS:"
msgstr "برای یافتن ساختار ``PyRuntime`` در macOS:"
msgid "Call ``task_for_pid()`` to get the ``mach_port_t`` task port for the target process. This handle is needed to read memory using APIs like ``mach_vm_read_overwrite`` and ``mach_vm_region``."
msgstr "برای دریافت پورت task (task port) از نوع ``mach_port_t`` برای فرایند هدف، ``task_for_pid()`` را فراخوانی کنید. برای خواندن حافظه با استفاده از APIهایی مانند ``mach_vm_read_overwrite`` و ``mach_vm_region`` به این دسته نیاز است."
msgid "Scan the memory regions to find the one containing the Python executable or ``libpython``."
msgstr "ناحیههای حافظه را پویش کنید تا ناحیهای را که شامل پرونده اجرایی Python یا ``libpython`` است بیابید."
msgid "Load the binary file from disk and parse the Mach-O headers to find the section named ``PyRuntime`` in the ``__DATA`` segment. On macOS, symbol names are automatically prefixed with an underscore, so the ``PyRuntime`` symbol appears as ``_PyRuntime`` in the symbol table, but the section name is not affected."
msgstr "پرونده دودویی را از دیسک بارگذاری کنید و سرآیندهای Mach-O را تجزیه کنید تا بخشی به نام ``PyRuntime`` در سگمنت ``__DATA`` را بیابید. در macOS، بهطور خودکار یک زیرخط به ابتدای نام نمادها اضافه میشود، بنابراین نماد ``PyRuntime`` در جدول نمادها بهصورت ``_PyRuntime`` ظاهر میشود، اما نام بخش تحت تأثیر قرار نمیگیرد."
msgid ""
"def find_py_runtime_macos(pid: int) -> int:\n"
" # Step 1: Get access to the process's memory\n"
" handle = get_memory_access_handle(pid)\n"
"\n"
" # Step 2: Try to find the Python executable in memory\n"
" binary_path, base_address = find_mapped_binary(\n"
" handle, name_contains=\"python\"\n"
" )\n"
"\n"
" # Step 3: Fallback to libpython if the executable is not found\n"
" if binary_path is None:\n"
" binary_path, base_address = find_mapped_binary(\n"
" handle, name_contains=\"libpython\"\n"
" )\n"
"\n"
" # Step 4: Parse Mach-O headers to get __DATA,__PyRuntime section offset\n"
" section_offset = parse_macho_section_offset(\n"
" binary_path, \"__DATA\", \"__PyRuntime\"\n"
" )\n"
"\n"
" # Step 5: Compute the PyRuntime address in memory\n"
" return base_address + section_offset"
msgstr ""
"def find_py_runtime_macos(pid: int) -> int:\n"
" # Step 1: Get access to the process's memory\n"
" handle = get_memory_access_handle(pid)\n"
"\n"
" # Step 2: Try to find the Python executable in memory\n"
" binary_path, base_address = find_mapped_binary(\n"
" handle, name_contains=\"python\"\n"
" )\n"
"\n"
" # Step 3: Fallback to libpython if the executable is not found\n"
" if binary_path is None:\n"
" binary_path, base_address = find_mapped_binary(\n"
" handle, name_contains=\"libpython\"\n"
" )\n"
"\n"
" # Step 4: Parse Mach-O headers to get __DATA,__PyRuntime section offset\n"
" section_offset = parse_macho_section_offset(\n"
" binary_path, \"__DATA\", \"__PyRuntime\"\n"
" )\n"
"\n"
" # Step 5: Compute the PyRuntime address in memory\n"
" return base_address + section_offset"
msgid "On macOS, accessing another process's memory requires using Mach-O specific APIs and file formats. The first step is obtaining a ``task_port`` handle via ``task_for_pid()``, which provides access to the target process's memory space. This handle enables memory operations through APIs like ``mach_vm_read_overwrite()``."
msgstr "در macOS، دسترسی به حافظهی یک فرایند دیگر نیازمند استفاده از APIها و قالبهای پرونده خاص Mach-O است. نخستین گام، به دست آوردن یک دستهی ``task_port`` از طریق ``task_for_pid()`` است که دسترسی به فضای حافظهی فرایند هدف را فراهم میکند. این دسته عملیات حافظه را از طریق APIهایی مانند ``mach_vm_read_overwrite()`` امکانپذیر میسازد."
msgid "The process memory can be examined using ``mach_vm_region()`` to scan through the virtual memory space, while ``proc_regionfilename()`` helps identify which binary files are loaded at each memory region. When the Python binary or library is found, its Mach-O headers need to be parsed to locate the ``PyRuntime`` structure."
msgstr "میتوان حافظهی فرایند را با استفاده از ``mach_vm_region()`` برای پیمایش فضای حافظهی مجازی بررسی کرد، در حالی که ``proc_regionfilename()`` کمک میکند تا شناسایی شود کدام پروندههای دودویی در هر ناحیهی حافظه بارگذاری شدهاند. هنگامی که دودویی یا کتابخانهی پایتون پیدا شد، باید سرآیندهای Mach-O آن تجزیه شوند تا محل ساختار ``PyRuntime`` پیدا شود."
msgid "The Mach-O format organizes code and data into segments and sections. The ``PyRuntime`` structure lives in a section named ``__PyRuntime`` within the ``__DATA`` segment. The actual runtime address calculation involves finding the ``__TEXT`` segment which serves as the binary's base address, then locating the ``__DATA`` segment containing our target section. The final address is computed by combining the base address with the appropriate section offsets from the Mach-O headers."
msgstr "قالب Mach-O کد و داده را در قالب قطعهها و بخشها سازماندهی میکند. ساختار ``PyRuntime`` در بخشی به نام ``__PyRuntime`` درون قطعهی ``__DATA`` قرار دارد. محاسبهی نشانی رانتایم واقعی مستلزم پیدا کردن قطعهی ``__TEXT``، که بهعنوان نشانی پایهی دودویی عمل میکند، و سپس یافتن قطعهی ``__DATA`` حاوی بخش هدف ما است. نشانی نهایی با ترکیب نشانی پایه با آفستهای مناسب بخشها از سرآیندهای Mach-O محاسبه میشود."
msgid "Note that accessing another process's memory on macOS typically requires elevated privileges - either root access or special security entitlements granted to the debugging process."
msgstr "توجه داشته باشید که دسترسی به حافظهی یک فرایند دیگر در macOS معمولاً به امتیازات بالاتری نیاز دارد - یا دسترسی root یا مجوزهای امنیتی خاص (entitlements) که به فرایند اشکالزدایی اعطا شدهاند."
msgid "Windows (PE)"
msgstr "ویندوز (PE)"
msgid "To find the ``PyRuntime`` structure on Windows:"
msgstr "برای یافتن ساختار ``PyRuntime`` در ویندوز:"
msgid "Use the ToolHelp API to enumerate all modules loaded in the target process. This is done using functions such as `CreateToolhelp32Snapshot <https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot>`_, `Module32First <https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32first>`_, and `Module32Next <https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32next>`_."
msgstr "برای برشماری همه ماژولهای بارگذاریشده در فرایند هدف از ToolHelp API استفاده کنید. این کار با استفاده از توابعی مانند `CreateToolhelp32Snapshot <https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot>`_، `Module32First <https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32first>`_ و `Module32Next <https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32next>`_ انجام میشود."
msgid "Identify the module corresponding to :file:`python.exe` or :file:`python{XY}.dll`, where ``X`` and ``Y`` are the major and minor version numbers of the Python version, and record its base address."
msgstr "ماژول متناظر با :file:`python.exe` یا :file:`python{XY}.dll` را شناسایی کنید، که در آن ``X`` و ``Y`` شمارههای اصلی و فرعی نسخه پایتون هستند، و آدرس پایهی آن را ثبت کنید."
msgid "Locate the ``PyRuntim`` section. Due to the PE format's 8-character limit on section names (defined as ``IMAGE_SIZEOF_SHORT_NAME``), the original name ``PyRuntime`` is truncated. This section contains the ``PyRuntime`` structure."
msgstr "بخش ``PyRuntim`` را بیابید. به دلیل محدودیت ۸ نویسهای قالب PE برای نام بخشها (که بهصورت ``IMAGE_SIZEOF_SHORT_NAME`` تعریف شده است)، نام اصلی ``PyRuntime`` کوتاه شده است. این بخش شامل ساختار ``PyRuntime`` است."
msgid "Retrieve the section’s relative virtual address (RVA) and add it to the base address of the module."
msgstr "آدرس مجازی نسبی بخش (RVA) را بازیابی کنید و آن را به آدرس پایه ماژول اضافه کنید."
msgid ""
"def find_py_runtime_windows(pid: int) -> int:\n"
" # Step 1: Try to find the Python executable in memory\n"
" binary_path, base_address = find_loaded_module(\n"
" pid, name_contains=\"python\"\n"
" )\n"
"\n"
" # Step 2: Fallback to shared pythonXY.dll if the executable is not\n"
" # found\n"
" if binary_path is None:\n"
" binary_path, base_address = find_loaded_module(\n"
" pid, name_contains=\"python3\"\n"
" )\n"
"\n"
" # Step 3: Parse PE section headers to get the RVA of the PyRuntime\n"
" # section. The section name appears as \"PyRuntim\" due to the\n"
" # 8-character limit defined by the PE format (IMAGE_SIZEOF_SHORT_NAME).\n"
" section_rva = parse_pe_section_offset(binary_path, \"PyRuntim\")\n"
"\n"
" # Step 4: Compute PyRuntime address in memory\n"
" return base_address + section_rva"
msgstr ""
"def find_py_runtime_windows(pid: int) -> int:\n"
" # Step 1: Try to find the Python executable in memory\n"
" binary_path, base_address = find_loaded_module(\n"
" pid, name_contains=\"python\"\n"
" )\n"
"\n"
" # Step 2: Fallback to shared pythonXY.dll if the executable is not\n"
" # found\n"
" if binary_path is None:\n"
" binary_path, base_address = find_loaded_module(\n"
" pid, name_contains=\"python3\"\n"
" )\n"
"\n"
" # Step 3: Parse PE section headers to get the RVA of the PyRuntime\n"
" # section. The section name appears as \"PyRuntim\" due to the\n"
" # 8-character limit defined by the PE format (IMAGE_SIZEOF_SHORT_NAME)\n"
" # 8-character limit defined by the PE format (IMAGE_SIZEOF_SHORT_NAME).\n"
" section_rva = parse_pe_section_offset(binary_path, \"PyRuntim\")\n"
"\n"
" # Step 4: Compute PyRuntime address in memory\n"
" return base_address + section_rva"
msgid "On Windows, accessing another process's memory requires using the Windows API functions like ``CreateToolhelp32Snapshot()`` and ``Module32First()/Module32Next()`` to enumerate loaded modules. The ``OpenProcess()`` function provides a handle to access the target process's memory space, enabling memory operations through ``ReadProcessMemory()``."
msgstr "در ویندوز، دسترسی به حافظهی یک فرایند دیگر نیازمند استفاده از توابع API ویندوز مانند ``CreateToolhelp32Snapshot()`` و ``Module32First()/Module32Next()`` برای برشماری ماژولهای بارگذاریشده است. تابع ``OpenProcess()`` یک دسته برای دسترسی به فضای حافظهی فرایند هدف فراهم میکند و عملیات حافظه را از طریق ``ReadProcessMemory()`` ممکن میسازد."
msgid "The process memory can be examined by enumerating loaded modules to find the Python binary or DLL. When found, its PE headers need to be parsed to locate the ``PyRuntime`` structure."
msgstr "حافظهی فرایند را میتوان با فهرستگیری ماژولهای بارگذاریشده برای یافتن دودویی یا DLL پایتون بررسی کرد. هنگامی که پیدا شد، باید سرآیندهای PE آن تجزیه شوند تا ساختار ``PyRuntime`` مکانیابی شود."
msgid "The PE format organizes code and data into sections. The ``PyRuntime`` structure lives in a section named \"PyRuntim\" (truncated from \"PyRuntime\" due to PE's 8-character name limit). The actual runtime address calculation involves finding the module's base address from the module entry, then locating our target section in the PE headers. The final address is computed by combining the base address with the section's virtual address from the PE section headers."
msgstr "قالب PE، کد و داده را در بخشها سازماندهی میکند. ساختار ``PyRuntime`` در بخشی به نام \"PyRuntim\" قرار دارد (که به دلیل محدودیت ۸ نویسهای نام در PE، از \"PyRuntime\" کوتاه شده است). محاسبه نشانی واقعی رانتایم شامل یافتن نشانی پایه ماژول از مدخل ماژول، و سپس یافتن بخش هدف ما در سرآیندهای PE است. نشانی نهایی با ترکیب نشانی پایه با نشانی مجازی بخش، از سرآیندهای بخش در PE محاسبه میشود."
msgid "Note that accessing another process's memory on Windows typically requires appropriate privileges - either administrative access or the ``SeDebugPrivilege`` privilege granted to the debugging process."
msgstr "توجه داشته باشید که دسترسی به حافظهی فرایندی دیگر در ویندوز معمولاً به امتیازات مناسب نیاز دارد؛ خواه دسترسی مدیریتی، خواه امتیاز ``SeDebugPrivilege`` که به فرایند اشکالزدایی اعطا شده است."
msgid "Reading _Py_DebugOffsets"
msgstr "خواندن _Py_DebugOffsets"
msgid "Once the address of the ``PyRuntime`` structure has been determined, the next step is to read the ``_Py_DebugOffsets`` structure located at the beginning of the ``PyRuntime`` block."
msgstr "پس از تعیین نشانی ساختار ``PyRuntime``، گام بعدی خواندن ساختار ``_Py_DebugOffsets`` است که در ابتدای بلوک ``PyRuntime`` قرار دارد."
msgid "This structure provides version-specific field offsets that are needed to safely read interpreter and thread state memory. These offsets vary between CPython versions and must be checked before use to ensure they are compatible."
msgstr "این ساختار، آفستهای فیلد خاص هر نسخه را فراهم میکند که برای خواندن ایمن حافظهی وضعیت مفسر و نخ لازم هستند. این آفستها در نسخههای مختلف CPython متفاوتاند و باید پیش از استفاده بررسی شوند تا از سازگاری آنها اطمینان حاصل شود."
msgid "To read and check the debug offsets, follow these steps:"
msgstr "برای خواندن و بررسی آفستهای اشکالزدایی، مراحل زیر را دنبال کنید:"
msgid "Read memory from the target process starting at the ``PyRuntime`` address, covering the same number of bytes as the ``_Py_DebugOffsets`` structure. This structure is located at the very start of the ``PyRuntime`` memory block. Its layout is defined in CPython’s internal headers and stays the same within a given minor version, but may change in major versions."
msgstr "حافظهی فرایند هدف را، شروع از نشانی ``PyRuntime``، بخوانید، بهگونهای که همان تعداد بایتِ ساختار ``_Py_DebugOffsets`` را پوشش دهد. این ساختار درست در ابتدای بلوک حافظهی ``PyRuntime`` قرار دارد. چیدمان آن در سرآیندهای داخلی CPython تعریف شده است و در یک نسخهی فرعی مشخص ثابت میماند، اما ممکن است در نسخههای اصلی تغییر کند."
msgid "Check that the structure contains valid data:"
msgstr "بررسی کنید که ساختار حاوی دادههای معتبر باشد:"
msgid "The ``cookie`` field must match the expected debug marker."
msgstr "فیلد ``cookie`` باید با نشانگر اشکالزدایی مورد انتظار مطابقت داشته باشد."
msgid "The ``version`` field must match the version of the Python interpreter used by the debugger."
msgstr "فیلد ``version`` باید با نسخهی مفسر پایتونی که اشکالزدا از آن استفاده میکند، مطابقت داشته باشد."
msgid "If either the debugger or the target process is using a pre-release version (for example, an alpha, beta, or release candidate), the versions must match exactly."
msgstr "اگر اشکالزدا یا فرایند هدف از یک نسخهی پیشانتشار (برای مثال، آلفا، بتا یا نامزد انتشار) استفاده کند، نسخهها باید دقیقاً با هم مطابقت داشته باشند."
msgid "The ``free_threaded`` field must have the same value in both the debugger and the target process."
msgstr "فیلد ``free_threaded`` باید هم در اشکالزدا و هم در فرایند هدف مقدار یکسانی داشته باشد."
msgid "If the structure is valid, the offsets it contains can be used to locate fields in memory. If any check fails, the debugger should stop the operation to avoid reading memory in the wrong format."
msgstr "اگر ساختار معتبر باشد، میتوان از آفستهای موجود در آن برای مکانیابی فیلدها در حافظه استفاده کرد. اگر هر یک از بررسیها شکست بخورد، اشکالزدا باید عملیات را متوقف کند تا از خواندن حافظه در قالب نادرست جلوگیری شود."
msgid "The following is an example implementation that reads and checks ``_Py_DebugOffsets``::"
msgstr "در ادامه یک پیادهسازی نمونه آمده است که ``_Py_DebugOffsets`` را میخواند و بررسی میکند::"
msgid ""
"def read_debug_offsets(pid: int, py_runtime_addr: int) -> DebugOffsets:\n"
" # Step 1: Read memory from the target process at the PyRuntime address\n"
" data = read_process_memory(\n"
" pid, address=py_runtime_addr, size=DEBUG_OFFSETS_SIZE\n"
" )\n"
"\n"
" # Step 2: Deserialize the raw bytes into a _Py_DebugOffsets structure\n"
" debug_offsets = parse_debug_offsets(data)\n"
"\n"
" # Step 3: Validate the contents of the structure\n"
" if debug_offsets.cookie != EXPECTED_COOKIE:\n"
" raise RuntimeError(\"Invalid or missing debug cookie\")\n"
" if debug_offsets.version != LOCAL_PYTHON_VERSION:\n"
" raise RuntimeError(\n"
" \"Mismatch between caller and target Python versions\"\n"
" )\n"
" if debug_offsets.free_threaded != LOCAL_FREE_THREADED:\n"
" raise RuntimeError(\"Mismatch in free-threaded configuration\")\n"
"\n"
" return debug_offsets"
msgstr ""
"def read_debug_offsets(pid: int, py_runtime_addr: int) -> DebugOffsets:\n"
" # Step 1: Read memory from the target process at the PyRuntime address\n"
" data = read_process_memory(\n"
" pid, address=py_runtime_addr, size=DEBUG_OFFSETS_SIZE\n"
" )\n"
"\n"
" # Step 2: Deserialize the raw bytes into a _Py_DebugOffsets structure\n"
" debug_offsets = parse_debug_offsets(data)\n"
"\n"
" # Step 3: Validate the contents of the structure\n"
" if debug_offsets.cookie != EXPECTED_COOKIE:\n"
" raise RuntimeError(\"Invalid or missing debug cookie\")\n"
" if debug_offsets.version != LOCAL_PYTHON_VERSION:\n"
" raise RuntimeError(\n"
" \"Mismatch between caller and target Python versions\"\n"
" )\n"
" if debug_offsets.free_threaded != LOCAL_FREE_THREADED:\n"
" raise RuntimeError(\"Mismatch in free-threaded configuration\")\n"
"\n"
" return debug_offsets"
msgid "**Process suspension recommended**"
msgstr "تعلیق فرایند توصیه میشود"
msgid "To avoid race conditions and ensure memory consistency, it is strongly recommended that the target process be suspended before performing any operations that read or write internal interpreter state. The Python runtime may concurrently mutate interpreter data structures—such as creating or destroying threads—during normal execution. This can result in invalid memory reads or writes."
msgstr "برای اجتناب از شرایط رقابتی و اطمینان از سازگاری حافظه، بهشدت توصیه میشود که فرایند هدف پیش از انجام هر عملیاتی که وضعیت داخلی مفسر را میخواند یا مینویسد، معلق شود. رانتایم پایتون ممکن است در حین اجرای عادی، همزمان ساختارهای داده مفسر را تغییر دهد—مانند ایجاد یا از بین بردن نخها. این میتواند منجر به خواندن یا نوشتن نامعتبر حافظه شود."
msgid "A debugger may suspend execution by attaching to the process with ``ptrace`` or by sending a ``SIGSTOP`` signal. Execution should only be resumed after debugger-side memory operations are complete."
msgstr "یک اشکالزدا ممکن است اجرا را با اتصال به فرایند از طریق ``ptrace`` یا با ارسال سیگنال ``SIGSTOP`` معلق کند. اجرا باید تنها پس از کامل شدن عملیات حافظهای در سمت اشکالزدا از سر گرفته شود."
msgid "Some tools, such as profilers or sampling-based debuggers, may operate on a running process without suspension. In such cases, tools must be explicitly designed to handle partially updated or inconsistent memory. For most debugger implementations, suspending the process remains the safest and most robust approach."
msgstr "برخی ابزارها، مانند پروفایلگیرها یا اشکالزداهای مبتنی بر نمونهبرداری، ممکن است بدون تعلیق، روی یک فرایند در حال اجرا عمل کنند. در چنین مواردی، ابزارها باید بهصراحت برای مدیریت حافظهای که بهطور ناقص بهروزرسانی شده یا ناسازگار است، طراحی شده باشند. برای بیشتر پیادهسازیهای اشکالزدا، تعلیق فرایند همچنان ایمنترین و پایدارترین رویکرد باقی میماند."
msgid "Locating the interpreter and thread state"
msgstr "یافتن وضعیت مفسر و نخ"
msgid "Before code can be injected and executed in a remote Python process, the debugger must choose a thread in which to schedule execution. This is necessary because the control fields used to perform remote code injection are located in the ``_PyRemoteDebuggerSupport`` structure, which is embedded in a ``PyThreadState`` object. These fields are modified by the debugger to request execution of injected scripts."
msgstr "پیش از آنکه بتوان کد را در یک فرایند پایتون راهدور تزریق و اجرا کرد، اشکالزدا باید نخی را انتخاب کند که اجرای کد در آن زمانبندی شود. این کار ضروری است، زیرا فیلدهای کنترلی استفادهشده برای انجام تزریق کد از راه دور در ساختار ``_PyRemoteDebuggerSupport`` قرار دارند که در یک شیء ``PyThreadState`` تعبیه شده است. این فیلدها توسط اشکالزدا تغییر داده میشوند تا اجرای اسکریپتهای تزریقشده درخواست شود."
msgid "The ``PyThreadState`` structure represents a thread running inside a Python interpreter. It maintains the thread’s evaluation context and contains the fields required for debugger coordination. Locating a valid ``PyThreadState`` is therefore a key prerequisite for triggering execution remotely."
msgstr "ساختار ``PyThreadState`` یک نخ در حال اجرا درون یک مفسر پایتون را نشان میدهد. این ساختار زمینهی ارزیابی نخ را نگه میدارد و شامل فیلدهای مورد نیاز برای هماهنگی اشکالزدا است. بنابراین، یافتن یک ``PyThreadState`` معتبر، پیشنیازی کلیدی برای راهاندازی اجرا از راه دور است."
msgid "A thread is typically selected based on its role or ID. In most cases, the main thread is used, but some tools may target a specific thread by its native thread ID. Once the target thread is chosen, the debugger must locate both the interpreter and the associated thread state structures in memory."
msgstr "یک نخ معمولاً بر اساس نقش یا شناسه آن انتخاب میشود. در بیشتر موارد، از نخ اصلی استفاده میشود، اما برخی ابزارها ممکن است نخ خاصی را با شناسه نخ بومی آن هدف قرار دهند. پس از انتخاب نخ هدف، اشکالزدا باید هم مفسر و هم ساختارهای وضعیت نخ مرتبط را در حافظه پیدا کند."
msgid "The relevant internal structures are defined as follows:"
msgstr "ساختارهای درونی مرتبط بهصورت زیر تعریف شدهاند:"
msgid "``PyInterpreterState`` represents an isolated Python interpreter instance. Each interpreter maintains its own set of imported modules, built-in state, and thread state list. Although most Python applications use a single interpreter, CPython supports multiple interpreters in the same process."
msgstr "``PyInterpreterState`` بیانگر نمونهای مجزا از مفسر پایتون است. هر مفسر مجموعهای از ماژولهای ایمپورتشده، وضعیت توکار و فهرست وضعیت نخهای خود را نگه میدارد. اگرچه بیشتر برنامههای پایتون از یک مفسر واحد استفاده میکنند، CPython از چندین مفسر در یک فرایند پشتیبانی میکند."
msgid "``PyThreadState`` represents a thread running within an interpreter. It contains execution state and the control fields used by the debugger."
msgstr "``PyThreadState`` نشاندهندهی یک نخ در حال اجرا درون یک مفسر است. این شامل وضعیت اجرا و فیلدهای کنترلی است که اشکالزدا از آنها استفاده میکند."
msgid "To locate a thread:"
msgstr "برای پیدا کردن یک نخ:"
msgid "Use the offset ``runtime_state.interpreters_head`` to obtain the address of the first interpreter in the ``PyRuntime`` structure. This is the entry point to the linked list of active interpreters."
msgstr "از آفست ``runtime_state.interpreters_head`` برای بهدست آوردن نشانی نخستین مفسر در ساختار ``PyRuntime`` استفاده کنید. این، نقطهی ورود به فهرست پیوندی مفسرهای فعال است."
msgid "Use the offset ``interpreter_state.threads_main`` to access the main thread state associated with the selected interpreter. This is typically the most reliable thread to target."
msgstr "از آفست ``interpreter_state.threads_main`` برای دسترسی به وضعیت نخ اصلی مرتبط با مفسر انتخابشده استفاده کنید. این معمولاً قابلاطمینانترین نخ برای هدف قرار دادن است."
msgid "Optionally, use the offset ``interpreter_state.threads_head`` to iterate through the linked list of all thread states. Each ``PyThreadState`` structure contains a ``native_thread_id`` field, which may be compared to a target thread ID to find a specific thread."
msgstr "بهصورت اختیاری، برای پیمایش فهرست پیوندی تمام وضعیتهای نخ، از آفست ``interpreter_state.threads_head`` استفاده کنید. هر ساختار ``PyThreadState`` شامل یک فیلد ``native_thread_id`` است که میتوان آن را با یک شناسه نخ هدف مقایسه کرد تا یک نخ خاص پیدا شود."
msgid "Once a valid ``PyThreadState`` has been found, its address can be used in later steps of the protocol, such as writing debugger control fields and scheduling execution."
msgstr "پس از یافتن یک ``PyThreadState`` معتبر، میتوان از نشانی آن در مراحل بعدی پروتکل استفاده کرد، مانند نوشتن فیلدهای کنترل اشکالزدا و زمانبندی اجرا."
msgid "The following is an example implementation that locates the main thread state::"
msgstr "در ادامه یک پیادهسازی نمونه آمده است که وضعیت نخ اصلی را پیدا میکند::"
msgid ""
"def find_main_thread_state(\n"
" pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,\n"
") -> int:\n"
" # Step 1: Read interpreters_head from PyRuntime\n"
" interp_head_ptr = (\n"
" py_runtime_addr + debug_offsets.runtime_state.interpreters_head\n"
" )\n"
" interp_addr = read_pointer(pid, interp_head_ptr)\n"
" if interp_addr == 0:\n"
" raise RuntimeError(\"No interpreter found in the target process\")\n"
"\n"
" # Step 2: Read the threads_main pointer from the interpreter\n"
" threads_main_ptr = (\n"
" interp_addr + debug_offsets.interpreter_state.threads_main\n"
" )\n"
" thread_state_addr = read_pointer(pid, threads_main_ptr)\n"
" if thread_state_addr == 0:\n"
" raise RuntimeError(\"Main thread state is not available\")\n"
"\n"
" return thread_state_addr"
msgstr ""
"def find_main_thread_state(\n"
" pid: int, py_runtime_addr: int, debug_offsets: DebugOffsets,\n"
") -> int:\n"
" # Step 1: Read interpreters_head from PyRuntime\n"
" interp_head_ptr = (\n"
" py_runtime_addr + debug_offsets.runtime_state.interpreters_head\n"
" )\n"
" interp_addr = read_pointer(pid, interp_head_ptr)\n"
" if interp_addr == 0:\n"
" raise RuntimeError(\"No interpreter found in the target process\")\n"
"\n"
" # Step 2: Read the threads_main pointer from the interpreter\n"
" threads_main_ptr = (\n"
" interp_addr + debug_offsets.interpreter_state.threads_main\n"
" )\n"
" thread_state_addr = read_pointer(pid, threads_main_ptr)\n"
" if thread_state_addr == 0:\n"
" raise RuntimeError(\"Main thread state is not available\")\n"
"\n"
" return thread_state_addr"
msgid "The following example demonstrates how to locate a thread by its native thread ID::"
msgstr "مثال زیر نشان میدهد که چگونه میتوان یک نخ را با شناسه نخ بومی آن پیدا کرد::"
msgid ""
"def find_thread_by_id(\n"
" pid: int,\n"
" interp_addr: int,\n"
" debug_offsets: DebugOffsets,\n"
" target_tid: int,\n"
") -> int:\n"
" # Start at threads_head and walk the linked list\n"
" thread_ptr = read_pointer(\n"
" pid,\n"
" interp_addr + debug_offsets.interpreter_state.threads_head\n"
" )\n"
"\n"
" while thread_ptr:\n"
" native_tid_ptr = (\n"
" thread_ptr + debug_offsets.thread_state.native_thread_id\n"
" )\n"
" native_tid = read_int(pid, native_tid_ptr)\n"
" if native_tid == target_tid:\n"
" return thread_ptr\n"
" thread_ptr = read_pointer(\n"
" pid,\n"
" thread_ptr + debug_offsets.thread_state.next\n"
" )\n"
"\n"
" raise RuntimeError(\"Thread with the given ID was not found\")"
msgstr ""
"def find_thread_by_id(\n"
" pid: int,\n"
" interp_addr: int,\n"
" debug_offsets: DebugOffsets,\n"
" target_tid: int,\n"
") -> int:\n"
" # Start at threads_head and walk the linked list\n"
" thread_ptr = read_pointer(\n"
" pid,\n"
" interp_addr + debug_offsets.interpreter_state.threads_head\n"
" )\n"
"\n"
" while thread_ptr:\n"
" native_tid_ptr = (\n"
" thread_ptr + debug_offsets.thread_state.native_thread_id\n"
" )\n"
" native_tid = read_int(pid, native_tid_ptr)\n"
" if native_tid == target_tid:\n"
" return thread_ptr\n"
" thread_ptr = read_pointer(\n"
" pid,\n"
" thread_ptr + debug_offsets.thread_state.next\n"
" )\n"
"\n"
" raise RuntimeError(\"Thread with the given ID was not found\")"
msgid "Once a valid thread state has been located, the debugger can proceed with modifying its control fields and scheduling execution, as described in the next section."
msgstr "پس از یافتن یک وضعیت نخ معتبر، اشکالزدا میتواند به اصلاح فیلدهای کنترلی آن و زمانبندی اجرا ادامه دهد، همانطور که در بخش بعدی توضیح داده شده است."
msgid "Writing control information"
msgstr "نوشتن اطلاعات کنترلی"
msgid "Once a valid ``PyThreadState`` structure has been identified, the debugger may modify control fields within it to schedule the execution of a specified Python script. These control fields are checked periodically by the interpreter, and when set correctly, they trigger the execution of remote code at a safe point in the evaluation loop."
msgstr "پس از شناسایی یک ساختار ``PyThreadState`` معتبر، اشکالزدا میتواند فیلدهای کنترلی درون آن را برای زمانبندی اجرای یک اسکریپت پایتون مشخص تغییر دهد. این فیلدهای کنترلی بهطور دورهای توسط مفسر بررسی میشوند و هنگامی که بهدرستی تنظیم شوند، باعث اجرای کد راهدور در یک نقطه امن در حلقه ارزیابی میشوند."
msgid "Each ``PyThreadState`` contains a ``_PyRemoteDebuggerSupport`` structure used for communication between the debugger and the interpreter. The locations of its fields are defined by the ``_Py_DebugOffsets`` structure and include the following:"
msgstr "هر ``PyThreadState`` شامل یک ساختار ``_PyRemoteDebuggerSupport`` است که برای ارتباط بین اشکالزدا و مفسر به کار میرود. محلهای فیلدهای آن توسط ساختار ``_Py_DebugOffsets`` تعریف شدهاند و شامل موارد زیر هستند:"
msgid "``debugger_script_path``: A fixed-size buffer that holds the full path to a Python source file (``.py``). This file must be accessible and readable by the target process when execution is triggered."
msgstr "``debugger_script_path``: یک بافر با اندازهی ثابت که مسیر کامل یک پرونده منبع پایتون (``.py``) را در خود نگه میدارد. این پرونده باید هنگامی که اجرا راهاندازی میشود، برای فرایند هدف قابل دسترسی و خواندن باشد."
msgid "``debugger_pending_call``: An integer flag. Setting this to ``1`` tells the interpreter that a script is ready to be executed."
msgstr "``debugger_pending_call``: یک پرچم عدد صحیح. تنظیم این مقدار روی ``1`` به مفسر اطلاع میدهد که یک اسکریپت آمادهی اجرا است."
msgid "``eval_breaker``: A field checked by the interpreter during execution. Setting bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``, value ``1U << 5``) in this field causes the interpreter to pause and check for debugger activity."
msgstr "``eval_breaker``: فیلدی که مفسر در حین اجرا آن را بررسی میکند. تنظیم بیت ۵ (``_PY_EVAL_PLEASE_STOP_BIT``، مقدار ``1U << 5``) در این فیلد باعث میشود مفسر مکث کند و فعالیت اشکالزدا را بررسی کند."
msgid "To complete the injection, the debugger must perform the following steps:"
msgstr "برای تکمیل تزریق، اشکالزدا باید مراحل زیر را انجام دهد:"
msgid "Write the full script path into the ``debugger_script_path`` buffer."
msgstr "مسیر کامل اسکریپت را در بافر ``debugger_script_path`` بنویسید."
msgid "Set ``debugger_pending_call`` to ``1``."
msgstr "``debugger_pending_call`` را روی ``1`` تنظیم کنید."
msgid "Read the current value of ``eval_breaker``, set bit 5 (``_PY_EVAL_PLEASE_STOP_BIT``), and write the updated value back. This signals the interpreter to check for debugger activity."
msgstr "مقدار فعلی ``eval_breaker`` را بخوانید، بیت ۵ (``_PY_EVAL_PLEASE_STOP_BIT``) را تنظیم کنید و مقدار بهروزشده را دوباره بنویسید. این کار به مفسر علامت میدهد تا فعالیت اشکالزدا را بررسی کند."
msgid ""
"def inject_script(\n"
" pid: int,\n"
" thread_state_addr: int,\n"
" debug_offsets: DebugOffsets,\n"
" script_path: str\n"
") -> None:\n"
" # Compute the base offset of _PyRemoteDebuggerSupport\n"
" support_base = (\n"
" thread_state_addr +\n"
" debug_offsets.debugger_support.remote_debugger_support\n"
" )\n"
"\n"
" # Step 1: Write the script path into debugger_script_path\n"
" script_path_ptr = (\n"
" support_base +\n"
" debug_offsets.debugger_support.debugger_script_path\n"
" )\n"
" write_string(pid, script_path_ptr, script_path)\n"
"\n"
" # Step 2: Set debugger_pending_call to 1\n"
" pending_ptr = (\n"
" support_base +\n"
" debug_offsets.debugger_support.debugger_pending_call\n"
" )\n"
" write_int(pid, pending_ptr, 1)\n"
"\n"
" # Step 3: Set _PY_EVAL_PLEASE_STOP_BIT (bit 5, value 1 << 5) in\n"
" # eval_breaker\n"
" eval_breaker_ptr = (\n"
" thread_state_addr +\n"
" debug_offsets.debugger_support.eval_breaker\n"
" )\n"
" breaker = read_int(pid, eval_breaker_ptr)\n"
" breaker |= (1 << 5)\n"
" write_int(pid, eval_breaker_ptr, breaker)"
msgstr ""
"def inject_script(\n"
" pid: int,\n"
" thread_state_addr: int,\n"
" debug_offsets: DebugOffsets,\n"
" script_path: str\n"
") -> None:\n"
" # Compute the base offset of _PyRemoteDebuggerSupport\n"
" support_base = (\n"
" thread_state_addr +\n"
" debug_offsets.debugger_support.remote_debugger_support\n"
" )\n"
"\n"
" # Step 1: Write the script path into debugger_script_path\n"
" script_path_ptr = (\n"
" support_base +\n"
" debug_offsets.debugger_support.debugger_script_path\n"
" )\n"
" write_string(pid, script_path_ptr, script_path)\n"
"\n"
" # Step 2: Set debugger_pending_call to 1\n"
" pending_ptr = (\n"
" support_base +\n"
" debug_offsets.debugger_support.debugger_pending_call\n"
" )\n"
" write_int(pid, pending_ptr, 1)\n"
"\n"
" # Step 3: Set _PY_EVAL_PLEASE_STOP_BIT (bit 5, value 1 << 5) in\n"
" # eval_breaker\n"
" eval_breaker_ptr = (\n"
" thread_state_addr +\n"
" debug_offsets.debugger_support.eval_breaker\n"
" )\n"
" breaker = read_int(pid, eval_breaker_ptr)\n"
" breaker |= (1 << 5)\n"
" write_int(pid, eval_breaker_ptr, breaker)"
msgid "Once these fields are set, the debugger may resume the process (if it was suspended). The interpreter will process the request at the next safe evaluation point, load the script from disk, and execute it."
msgstr "پس از تنظیم این فیلدها، اشکالزدا میتواند فرایند را از سر گیرد (اگر تعلیق شده باشد). مفسر درخواست را در نقطه ارزیابی امن بعدی پردازش میکند، اسکریپت را از دیسک بارگذاری میکند و آن را اجرا میکند."
msgid "It is the responsibility of the debugger to ensure that the script file remains present and accessible to the target process during execution."
msgstr "بر عهدهی اشکالزدا است که اطمینان حاصل کند پرونده اسکریپت در حین اجرا برای فرایند هدف موجود و دسترسپذیر باقی میماند."
msgid "Script execution is asynchronous. The script file cannot be deleted immediately after injection. The debugger should wait until the injected script has produced an observable effect before removing the file. This effect depends on what the script is designed to do. For example, a debugger might wait until the remote process connects back to a socket before removing the script. Once such an effect is observed, it is safe to assume the file is no longer needed."
msgstr "اجرای اسکریپت ناهمگام است. پرونده اسکریپت نمیتواند بلافاصله پس از تزریق حذف شود. اشکالزدا باید پیش از حذف پرونده صبر کند تا اسکریپت تزریقشده اثر مشاهدهپذیری ایجاد کند. این اثر به کاری بستگی دارد که اسکریپت برای انجام آن طراحی شده است. برای مثال، یک اشکالزدا ممکن است پیش از حذف اسکریپت صبر کند تا فرایند راهدور به یک سوکت اتصال برگشتی برقرار کند. هنگامی که چنین اثری مشاهده شد، میتوان با اطمینان فرض کرد که پرونده دیگر مورد نیاز نیست."
msgid "Summary"
msgstr "خلاصه"
msgid "To inject and execute a Python script in a remote process:"
msgstr "برای تزریق و اجرای یک اسکریپت پایتون در یک فرایند راهدور:"
msgid "Locate the ``PyRuntime`` structure in the target process’s memory."
msgstr "ساختار ``PyRuntime`` را در حافظهی فرایند هدف پیدا کنید."
msgid "Read and validate the ``_Py_DebugOffsets`` structure at the beginning of ``PyRuntime``."
msgstr "ساختار ``_Py_DebugOffsets`` را در ابتدای ``PyRuntime`` بخوانید و اعتبارسنجی کنید."
msgid "Use the offsets to locate a valid ``PyThreadState``."
msgstr "از آفستها برای پیدا کردن یک ``PyThreadState`` معتبر استفاده کنید."
msgid "Write the path to a Python script into ``debugger_script_path``."
msgstr "مسیر یک اسکریپت پایتون را در ``debugger_script_path`` بنویسید."
msgid "Set the ``debugger_pending_call`` flag to ``1``."
msgstr "پرچم ``debugger_pending_call`` را روی ``1`` تنظیم کنید."
msgid "Set ``_PY_EVAL_PLEASE_STOP_BIT`` in the ``eval_breaker`` field."
msgstr "``_PY_EVAL_PLEASE_STOP_BIT`` را در فیلد ``eval_breaker`` تنظیم کنید."
msgid "Resume the process (if suspended). The script will execute at the next safe evaluation point."
msgstr "از سرگیری فرایند (در صورت تعلیق). اسکریپت در نقطهی ارزیابی امن بعدی اجرا خواهد شد."
msgid "Security and threat model"
msgstr "امنیت و مدل تهدید"
msgid "The remote debugging protocol relies on the same operating system primitives used by native debuggers such as GDB and LLDB. Attaching to a process requires the **same privileges** that those debuggers require, for example ``ptrace`` / Yama LSM on Linux, ``task_for_pid`` on macOS, and ``SeDebugPrivilege`` on Windows. Python does not introduce any new privilege escalation path; if an attacker already possesses the permissions needed to attach to a process, they could equally use GDB to read memory or inject code."
msgstr "پروتکل اشکالزدایی از راه دور به همان امکانات اولیهی سیستمعامل متکی است که اشکالزداهای بومی مانند GDB و LLDB از آنها استفاده میکنند. اتصال به یک فرایند نیازمند **همان امتیازها** است که آن اشکالزداها نیاز دارند، برای مثال ``ptrace`` / Yama LSM در لینوکس، ``task_for_pid`` در macOS و ``SeDebugPrivilege`` در ویندوز. پایتون هیچ مسیر جدیدی برای ارتقاء امتیاز معرفی نمیکند؛ اگر مهاجم از قبل دارای دسترسیهای لازم برای اتصال به یک فرایند باشد، میتواند بهطور مشابه از GDB برای خواندن حافظه یا تزریق کد استفاده کند."
msgid "The following principles define what is, and is not, considered a security vulnerability in this feature:"
msgstr "اصول زیر مشخص میکنند که چه چیزی در این قابلیت، آسیبپذیری امنیتی محسوب میشود و چه چیزی محسوب نمیشود:"
msgid "Attaching requires OS-level privileges"
msgstr "اتصال نیازمند دسترسیهای سطح سیستمعامل است"
msgid "On every supported platform the operating system gates cross-process memory access behind privilege checks (``CAP_SYS_PTRACE``, root, or administrator rights). A report that demonstrates an issue only after these privileges have already been obtained is **not** a vulnerability in CPython, since the OS security boundary was already crossed."
msgstr "در همهی پلتفرمهای پشتیبانیشده، سیستمعامل دسترسی بینفرایندی به حافظه را منوط به بررسیهای امتیاز میکند (``CAP_SYS_PTRACE``، root یا حقوق مدیر). گزارشی که یک مشکل را تنها پس از آنکه این امتیازها از قبل کسب شدهاند نشان دهد، یک آسیبپذیری در CPython **نیست**، زیرا از مرز امنیتی سیستمعامل از قبل عبور شده است."
msgid "Crashes or memory errors when reading a compromised process are not vulnerabilities"
msgstr "فروپاشیها یا خطاهای حافظه هنگام خواندن یک فرایند بهخطر افتاده، آسیبپذیری محسوب نمیشوند"
msgid "A tool that reads internal interpreter state from a target process must trust that memory to be well-formed. If the target process has been corrupted or is controlled by an attacker, the debugger or profiler may crash, produce garbage output, or behave unpredictably. This is the same risk accepted by every ``ptrace``-based debugger. Bugs in this category (buffer overflows, segmentation faults, or undefined behaviour triggered by reading corrupted state) are **not** treated as security issues, though fixes that improve robustness are welcome."
msgstr "ابزاری که وضعیت داخلی مفسر را از یک فرایند هدف میخواند، باید فرض کند که آن حافظه خوشساخت است. اگر فرایند هدف تخریبشده باشد یا تحت کنترل مهاجم باشد، اشکالزدا یا پروفایلگیر ممکن است از کار بیفتد، خروجی نامعتبر تولید کند، یا بهصورت غیرقابل پیشبینی رفتار کند. این همان ریسکی است که هر اشکالزدای مبتنی بر ``ptrace`` آن را میپذیرد. اشکالهای این دسته (سرریزهای بافر، خطاهای قطعهبندی (segmentation faults)، یا رفتار تعریفنشده ناشی از خواندن وضعیت تخریبشده) بهعنوان مسائل امنیتی تلقی **نمیشوند**، هرچند از اصلاحاتی که استحکام را بهبود میبخشند استقبال میشود."
msgid "Vulnerabilities in the target process are not in scope"
msgstr "آسیبپذیریهای فرایند هدف در محدوده نیستند"
msgid "If the Python process being debugged has already been compromised, the attacker already controls execution in that process. Demonstrating further impact from that starting point does not constitute a vulnerability in the remote debugging protocol."
msgstr "اگر فرایند پایتونِ در حال اشکالزدایی از قبل به خطر افتاده باشد، مهاجم از قبل کنترل اجرا در آن فرایند را در دست دارد. نشان دادن تأثیر بیشتر از آن نقطه آغاز، آسیبپذیری در پروتکل اشکالزدایی راه دور محسوب نمیشود."
msgid "When to use ``PYTHON_DISABLE_REMOTE_DEBUG``"
msgstr "زمان استفاده از ``PYTHON_DISABLE_REMOTE_DEBUG``"
msgid "The environment variable :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` (and the equivalent :option:`-X disable_remote_debug` flag) allows operators to disable the in-process side of the protocol as a **defence-in-depth** measure. This may be useful in hardened or sandboxed deployment environments where no debugging or profiling of the process is expected and reducing attack surface is a priority, even though the OS-level privilege checks already prevent unprivileged access."
msgstr "متغیر محیطی :envvar:`PYTHON_DISABLE_REMOTE_DEBUG` (و پرچم معادل :option:`-X disable_remote_debug`) به راهبران اجازه میدهد سمت درونفرایندی پروتکل را بهعنوان تدبیری برای **دفاع در عمق** غیرفعال کنند. این ممکن است در محیطهای استقرار ایمنسازیشده یا سندباکسشده مفید باشد؛ محیطهایی که انتظار نمیرود هیچگونه اشکالزدایی یا پروفایلگیری از فرایند در آنها انجام شود و کاهش سطح حمله اولویت دارد، حتی اگر بررسیهای امتیاز در سطح سیستمعامل از پیش از دسترسی فاقد امتیاز جلوگیری کنند."
msgid "Setting this variable does **not** affect other OS-level debugging interfaces (``ptrace``, ``/proc``, ``task_for_pid``, etc.), which remain available according to their own permission models."
msgstr "تنظیم این متغیر بر سایر رابطهای اشکالزدایی در سطح سیستمعامل تأثیر **نمیگذارد** (``ptrace``، ``/proc``، ``task_for_pid`` و غیره)، که بر اساس مدلهای مجوز خود در دسترس باقی میمانند."