-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathcursor-help.ps1
More file actions
554 lines (495 loc) · 24.2 KB
/
cursor-help.ps1
File metadata and controls
554 lines (495 loc) · 24.2 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
# Установка кодировки для поддержки Unicode
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
$Host.UI.RawUI.WindowTitle = "Cursor Helper"
# Настройка ANSI-цветов
if ($PSVersionTable.PSVersion.Major -ge 7) {
$PSStyle.OutputRendering = 'ANSI'
$RED = "`e[31m"
$GREEN = "`e[32m"
$YELLOW = "`e[33m"
$BLUE = "`e[34m"
$NC = "`e[0m"
} else {
$RED = "$([char]0x1b)[31m"
$GREEN = "$([char]0x1b)[32m"
$YELLOW = "$([char]0x1b)[33m"
$BLUE = "$([char]0x1b)[34m"
$NC = "$([char]0x1b)[0m"
}
# Текущий язык (по умолчанию английский)
$LANG_CHOICE = "en"
# Функция перевода
function Translate {
param (
[string]$key
)
switch ($LANG_CHOICE) {
"ru" {
switch ($key) {
"info" { "[ИНФО]" }
"warn" { "[ВНИМАНИЕ]" }
"error" { "[ОШИБКА]" }
"debug" { "[ОТЛАДКА]" }
"get_user_error" { "Не удалось получить имя пользователя" }
"run_with_admin" { "Запустите скрипт от имени администратора" }
"example" { "Пример:" }
"checking_cursor" { "Проверка процесса Cursor..." }
"process_info" { "Получение информации о процессе" }
"cursor_not_found" { "Процесс Cursor не найден" }
"cursor_found" { "Найден запущенный процесс Cursor" }
"killing_attempt" { "Попытка завершения процесса..." }
"force_kill" { "Принудительное завершение..." }
"cursor_killed" { "Процесс Cursor успешно завершен" }
"waiting_termination" { "Ожидание завершения, попытка" }
"kill_failed" { "Не удалось завершить процесс после" }
"kill_manual" { "Завершите процесс вручную и повторите попытку" }
"backup_skipped" { "Файл конфигурации не существует, пропуск резервного копирования" }
"backup_created" { "Резервная копия создана:" }
"backup_failed" { "Ошибка создания резервной копии" }
"config_not_found" { "Файл конфигурации не найден:" }
"install_first" { "Установите и запустите Cursor хотя бы раз" }
"config_updated" { "Конфигурация обновлена:" }
"rights_failed" { "Не удалось установить права только для чтения" }
"rights_success" { "Права доступа установлены успешно" }
"file_structure" { "Структура файлов:" }
"modified" { "изменен" }
"empty" { "пусто" }
"follow_telegram" { "Подпишитесь на наш Telegram канал @exmodium" }
"tool_name" { "Утилита обхода Cursor" }
"important" { "ВАЖНО" }
"version_support" { "Поддерживается текущая версия Cursor" }
"version_not_support" { "" }
"done" { "Готово!" }
"restart_required" { "Перезапустите Cursor для применения изменений" }
"disable_auto_update" { "Отключить автообновление Cursor?" }
"no" { "Нет - оставить как есть (Enter)" }
"yes" { "Да - отключить" }
"disabling_update" { "Отключение автообновления..." }
"manual_steps" { "Выполните следующие шаги вручную:" }
"open_terminal" { "Откройте PowerShell от имени администратора" }
"run_commands" { "Выполните команды:" }
"if_no_rights" { "Если нет прав:" }
"verification" { "Проверка:" }
"check_rights" { "Убедитесь что файл только для чтения" }
"restart_after" { "Перезапустите Cursor после выполнения" }
"folder_deleted" { "Папка cursor-updater удалена" }
"folder_delete_failed" { "Не удалось удалить папку cursor-updater" }
"file_create_failed" { "Не удалось создать файл" }
"rights_check_failed" { "Проверка прав не пройдена" }
"update_disabled" { "Автообновление отключено" }
"update_enabled" { "Автообновление оставлено включенным" }
"current_machineguid" { "Текущий MachineGuid:" }
"machineguid_updated" { "MachineGuid успешно обновлен на:" }
default { "[$key]" }
}
}
"zh" {
switch ($key) {
"info" { "[信息]" }
"warn" { "[警告]" }
"error" { "[错误]" }
"debug" { "[调试]" }
"get_user_error" { "无法获取用户名" }
"run_with_admin" { "请以管理员身份运行此脚本" }
"example" { "示例:" }
"checking_cursor" { "检查 Cursor 进程..." }
"process_info" { "获取进程信息" }
"cursor_not_found" { "未发现 Cursor 进程" }
"cursor_found" { "发现正在运行的 Cursor 进程" }
"killing_attempt" { "尝试终止进程..." }
"force_kill" { "强制终止..." }
"cursor_killed" { "Cursor 进程已成功终止" }
"waiting_termination" { "等待进程终止,尝试" }
"kill_failed" { "在尝试后仍无法终止进程" }
"kill_manual" { "请手动终止进程后重试" }
"backup_skipped" { "配置文件不存在,跳过备份" }
"backup_created" { "备份已创建:" }
"backup_failed" { "备份创建失败" }
"config_not_found" { "未找到配置文件:" }
"install_first" { "请先安装并运行一次 Cursor" }
"config_updated" { "配置已更新:" }
"rights_failed" { "无法设置只读权限" }
"rights_success" { "访问权限设置成功" }
"file_structure" { "文件结构:" }
"modified" { "已修改" }
"empty" { "空" }
"follow_telegram" { "关注我们的 Telegram 频道 @exmodium" }
"tool_name" { "Cursor 绕过工具" }
"important" { "重要" }
"version_support" { "支持当前版本的 Cursor" }
"version_not_support" { "" }
"done" { "完成!" }
"restart_required" { "重启 Cursor 以应用更改" }
"disable_auto_update" { "是否禁用 Cursor 自动更新?" }
"no" { "否 - 保持默认设置 (按回车)" }
"yes" { "是 - 禁用自动更新" }
"disabling_update" { "正在禁用自动更新..." }
"manual_steps" { "自动设置失败,请手动执行以下步骤:" }
"open_terminal" { "以管理员身份打开 PowerShell" }
"run_commands" { "执行以下命令:" }
"if_no_rights" { "如果没有权限:" }
"verification" { "验证:" }
"check_rights" { "确保文件为只读" }
"restart_after" { "完成后重启 Cursor" }
"folder_deleted" { "cursor-updater 文件夹已删除" }
"folder_delete_failed" { "无法删除 cursor-updater 文件夹" }
"file_create_failed" { "无法创建文件" }
"rights_check_failed" { "权限检查失败" }
"update_disabled" { "自动更新已禁用" }
"update_enabled" { "自动更新保持启用状态" }
"current_machineguid" { "当前 MachineGuid:" }
"machineguid_updated" { "MachineGuid 已成功更新为:" }
default { "[$key]" }
}
}
default { # English
switch ($key) {
"info" { "[INFO]" }
"warn" { "[WARNING]" }
"error" { "[ERROR]" }
"debug" { "[DEBUG]" }
"get_user_error" { "Failed to get username" }
"run_with_admin" { "Please run script as administrator" }
"example" { "Example:" }
"checking_cursor" { "Checking Cursor process..." }
"process_info" { "Getting process info" }
"cursor_not_found" { "No Cursor process found" }
"cursor_found" { "Found running Cursor process" }
"killing_attempt" { "Attempting to kill process..." }
"force_kill" { "Forcing termination..." }
"cursor_killed" { "Cursor process successfully terminated" }
"waiting_termination" { "Waiting for termination, attempt" }
"kill_failed" { "Failed to terminate process after" }
"kill_manual" { "Please terminate process manually and try again" }
"backup_skipped" { "Configuration file doesn't exist, skipping backup" }
"backup_created" { "Backup created at:" }
"backup_failed" { "Backup creation failed" }
"config_not_found" { "Configuration file not found:" }
"install_first" { "Please install and run Cursor at least once" }
"config_updated" { "Configuration updated:" }
"rights_failed" { "Failed to set read-only permissions" }
"rights_success" { "Access rights set successfully" }
"file_structure" { "File structure:" }
"modified" { "modified" }
"empty" { "empty" }
"follow_telegram" { "Follow our Telegram channel @exmodium" }
"tool_name" { "Cursor Bypass Tool" }
"important" { "IMPORTANT" }
"version_support" { "Current Cursor version is supported" }
"version_not_support" { "" }
"done" { "Done!" }
"restart_required" { "Restart Cursor to apply changes" }
"disable_auto_update" { "Disable Cursor auto-update?" }
"no" { "No - keep default settings (Press Enter)" }
"yes" { "Yes - disable auto-update" }
"disabling_update" { "Disabling auto-update..." }
"manual_steps" { "Automatic setup failed. Manual steps:" }
"open_terminal" { "Open PowerShell as administrator" }
"run_commands" { "Run these commands:" }
"if_no_rights" { "If permission denied:" }
"verification" { "Verification:" }
"check_rights" { "Verify file is read-only" }
"restart_after" { "Restart Cursor after completion" }
"folder_deleted" { "cursor-updater folder deleted" }
"folder_delete_failed" { "Failed to delete cursor-updater folder" }
"file_create_failed" { "Failed to create file" }
"rights_check_failed" { "Rights check failed" }
"update_disabled" { "Auto-update disabled" }
"update_enabled" { "Auto-update remains enabled" }
"current_machineguid" { "Current MachineGuid:" }
"machineguid_updated" { "MachineGuid successfully updated to:" }
default { "[$key]" }
}
}
}
}
# Функции логирования
function Write-LogInfo {
param([string]$Message)
Write-Host "$GREEN$(Translate 'info')$NC $Message"
}
function Write-LogWarn {
param([string]$Message)
Write-Host "$YELLOW$(Translate 'warn')$NC $Message"
}
function Write-LogError {
param([string]$Message)
Write-Host "$RED$(Translate 'error')$NC $Message"
}
function Write-LogDebug {
param([string]$Message)
Write-Host "$BLUE$(Translate 'debug')$NC $Message"
}
# Проверка прав администратора
function Test-AdminRights {
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-LogError $(Translate "run_with_admin")
Write-Host "$(Translate 'example'): Start-Process powershell -Verb RunAs -ArgumentList `"-File `"$PSCommandPath`"`""
exit 1
}
}
# Пути к файлам
$STORAGE_FILE = "$env:APPDATA\Cursor\User\globalStorage\storage.json"
$BACKUP_DIR = "$env:APPDATA\Cursor\User\globalStorage\backups"
# Выбор языка
function Select-Language {
Write-Host "Select language / Выберите язык / 选择语言:"
Write-Host "1) English"
Write-Host "2) Русский"
Write-Host "3) 中文"
$choice = Read-Host
switch ($choice) {
"1" { $script:LANG_CHOICE = "en" }
"2" { $script:LANG_CHOICE = "ru" }
"3" { $script:LANG_CHOICE = "zh" }
default { $script:LANG_CHOICE = "en" }
}
}
# Проверка и завершение процесса Cursor
function Stop-CursorProcess {
Write-LogInfo $(Translate "checking_cursor")
$attempt = 1
$maxAttempts = 5
function Get-ProcessDetails {
param([string]$ProcessName)
Write-LogDebug "$(Translate 'process_info') $ProcessName"
Get-Process | Where-Object { $_.ProcessName -like "*$ProcessName*" } | Format-Table -AutoSize
}
while ($attempt -le $maxAttempts) {
$cursorProcess = Get-Process "Cursor" -ErrorAction SilentlyContinue
if (-not $cursorProcess) {
Write-LogInfo $(Translate "cursor_not_found")
return
}
Write-LogWarn $(Translate "cursor_found")
Get-ProcessDetails "Cursor"
Write-LogWarn $(Translate "killing_attempt")
if ($attempt -eq $maxAttempts) {
Write-LogWarn $(Translate "force_kill")
$cursorProcess | Stop-Process -Force -ErrorAction SilentlyContinue
} else {
$cursorProcess | Stop-Process -ErrorAction SilentlyContinue
}
Start-Sleep -Seconds 1
if (-not (Get-Process "Cursor" -ErrorAction SilentlyContinue)) {
Write-LogInfo $(Translate "cursor_killed")
return
}
Write-LogWarn "$(Translate 'waiting_termination') $attempt/$maxAttempts..."
$attempt++
}
Write-LogError "$(Translate 'kill_failed') $maxAttempts"
Get-ProcessDetails "Cursor"
Write-LogError $(Translate "kill_manual")
exit 1
}
# Резервное копирование
function Backup-Config {
if (-not (Test-Path $STORAGE_FILE)) {
Write-LogWarn $(Translate "backup_skipped")
return
}
New-Item -ItemType Directory -Force -Path $BACKUP_DIR | Out-Null
$backupFile = Join-Path $BACKUP_DIR "storage.json.backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"
try {
Copy-Item $STORAGE_FILE $backupFile
Write-LogInfo "$(Translate 'backup_created') $backupFile"
} catch {
Write-LogError $(Translate "backup_failed")
exit 1
}
}
# Генерация случайного ID
function New-RandomId {
$bytes = New-Object byte[] 32
$rng = [System.Security.Cryptography.RNGCryptoServiceProvider]::new()
$rng.GetBytes($bytes)
return [System.BitConverter]::ToString($bytes) -replace '-',''
}
# Генерация UUID
function New-UUID {
return [guid]::NewGuid().ToString().ToLower()
}
# Генерация новой конфигурации
function Update-Config {
if (-not (Test-Path $STORAGE_FILE)) {
Write-LogError "$(Translate 'config_not_found') $STORAGE_FILE"
Write-LogWarn $(Translate "install_first")
exit 1
}
$machineId = "authuser_" + (New-RandomId)
$macMachineId = New-RandomId
$deviceId = New-UUID
$sqmId = "{" + (New-UUID).ToUpper() + "}"
try {
# Снимаем все атрибуты файла
attrib -r -h -s $STORAGE_FILE
# Читаем и обновляем конфигурацию
$config = Get-Content $STORAGE_FILE -Raw | ConvertFrom-Json
$config.'telemetry.machineId' = $machineId
$config.'telemetry.macMachineId' = $macMachineId
$config.'telemetry.devDeviceId' = $deviceId
$config.'telemetry.sqmId' = $sqmId
# Сохраняем обновленную конфигурацию
$config | ConvertTo-Json -Depth 100 | Set-Content $STORAGE_FILE
# Устанавливаем атрибут "только для чтения" через командную строку
attrib +r $STORAGE_FILE
Write-Host
Write-LogInfo $(Translate "config_updated")
Write-LogDebug "machineId: $machineId"
Write-LogDebug "macMachineId: $macMachineId"
Write-LogDebug "deviceId: $deviceId"
Write-LogDebug "sqmId: $sqmId"
} catch {
Write-LogError $_.Exception.Message
Write-LogError $(Translate "run_with_admin")
exit 1
}
}
# Отображение структуры файлов
function Show-FileTree {
Write-Host
Write-LogInfo $(Translate "file_structure")
$baseDir = Split-Path $STORAGE_FILE -Parent
Write-Host "$BLUE$baseDir$NC"
Write-Host "├── globalStorage"
Write-Host "│ ├── storage.json ($(Translate 'modified'))"
Write-Host "│ └── backups"
if (Test-Path $BACKUP_DIR) {
$backupFiles = Get-ChildItem $BACKUP_DIR -File
if ($backupFiles.Count -gt 0) {
foreach ($file in $backupFiles) {
Write-Host "│ └── $($file.Name)"
}
} else {
Write-Host "│ └── ($(Translate 'empty'))"
}
}
Write-Host
}
# Информация о Telegram
function Show-FollowInfo {
Write-Host
Write-Host "$GREEN================================$NC"
Write-Host "$YELLOW $(Translate 'follow_telegram') $NC"
Write-Host "$GREEN================================$NC"
Write-Host
}
# Отключение автообновлений
function Disable-AutoUpdate {
Write-Host
Write-LogWarn $(Translate "disable_auto_update")
Write-Host "1) $(Translate 'no')"
Write-Host "2) $(Translate 'yes')"
$choice = Read-Host
if ($choice -eq "2") {
Write-Host
Write-LogInfo $(Translate "disabling_update")
$updaterPath = "$env:APPDATA\cursor-updater"
try {
if (Test-Path $updaterPath) {
Remove-Item $updaterPath -Force -Recurse
Write-LogInfo $(Translate "folder_deleted")
}
New-Item -ItemType File $updaterPath -Force | Out-Null
Set-ItemProperty $updaterPath -Name IsReadOnly -Value $true
if (-not (Test-Path $updaterPath) -or (Get-Item $updaterPath).IsReadOnly -eq $false) {
Write-LogError $(Translate "rights_check_failed")
Write-Host
Write-LogWarn $(Translate "manual_steps")
Write-Host "$YELLOW$(Translate 'open_terminal')$NC"
Write-Host "$(Translate 'run_commands'):"
Write-Host "$BLUE`"rm -r '$updaterPath'; New-Item -ItemType File '$updaterPath'; Set-ItemProperty '$updaterPath' -Name IsReadOnly -Value `$true`"$NC"
Write-Host
Write-Host "$YELLOW$(Translate 'verification')$NC"
Write-Host "Get-ItemProperty '$updaterPath'"
Write-Host "$(Translate 'check_rights')"
Write-Host
Write-LogWarn $(Translate "restart_after")
return
}
Write-LogInfo $(Translate "update_disabled")
} catch {
Write-LogError $(Translate "file_create_failed")
Write-Host
Write-LogWarn $(Translate "manual_steps")
Write-Host "$YELLOW$(Translate 'open_terminal')$NC"
Write-Host "$(Translate 'run_commands'):"
Write-Host "$BLUE`"rm -r '$updaterPath'; New-Item -ItemType File '$updaterPath'; Set-ItemProperty '$updaterPath' -Name IsReadOnly -Value `$true`"$NC"
Write-Host
Write-Host "$YELLOW$(Translate 'verification')$NC"
Write-Host "Get-ItemProperty '$updaterPath'"
Write-Host "$(Translate 'check_rights')"
Write-Host
Write-LogWarn $(Translate "restart_after")
}
} else {
Write-LogInfo $(Translate "update_enabled")
}
}
# Добавляем функцию для обновления MachineGuid
function Update-MachineGuid {
try {
$newGuid = [guid]::NewGuid().ToString()
$registryPath = "HKLM:\SOFTWARE\Microsoft\Cryptography"
$currentGuid = Get-ItemPropertyValue -Path $registryPath -Name "MachineGuid"
Write-LogInfo "$(Translate 'current_machineguid') $currentGuid"
Set-ItemProperty -Path $registryPath -Name "MachineGuid" -Value $newGuid -Force
$updatedGuid = Get-ItemPropertyValue -Path $registryPath -Name "MachineGuid"
if ($updatedGuid -eq $newGuid) {
Write-LogInfo "$(Translate 'machineguid_updated') $newGuid"
} else {
Write-LogError $(Translate "machineguid_update_failed")
}
} catch {
Write-LogError "$(Translate 'machineguid_error'): $_"
}
}
# Функция для открытия сайта
function Open-Website {
$sites = @("https://assets-hub.ru", "https://assets-hub.pro")
$randomSite = $sites | Get-Random
try {
Start-Process $randomSite
} catch {
Write-LogError "Не удалось открыть сайт: $_"
}
}
# Главная функция
function Start-Main {
Clear-Host
Select-Language
Write-Host @"
██████╗██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗
██╔════╝██║ ██║██╔══██╗██╔════╝██╔═══██╗██╔══██╗
██║ ██║ ██║██████╔╝███████╗██║ ██║██████╔╝
██║ ██║ ██║██╔══██╗╚════██║██║ ██║██╔══██╗
╚██████╗╚██████╔╝██║ ██║███████║╚██████╔╝██║ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝
"@
Write-Host "$BLUE================================$NC"
Write-Host "$GREEN $(Translate 'tool_name') $NC"
Write-Host "$BLUE================================$NC"
Write-Host
Write-Host "$YELLOW[$(Translate 'important')]$NC $(Translate 'version_support')"
Write-Host
Test-AdminRights
Stop-CursorProcess
Backup-Config
Update-Config
Update-MachineGuid
Write-Host
Write-LogInfo $(Translate "done")
Show-FileTree
Show-FollowInfo
Write-LogInfo $(Translate "restart_required")
Disable-AutoUpdate
# Открываем случайный сайт после успешного выполнения
Open-Website
}
# Оставляем только прямой вызов главной функции:
Start-Main