PS C:\Users\Administrator> pip install pywin32
>>
WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages)
Looking in links: e:\ai_temp\pip_packages
Requirement already satisfied: pywin32 in e:\python310\lib\site-packages (306)
WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages)
PS C:\Users\Administrator> python find_recent_toolbox.py
>>
E:\Python310\python.exe: can't open file 'C:\\Users\\Administrator\\find_recent_toolbox.py': [Errno 2] No such file or directory
PS C:\Users\Administrator> # 查找最近24小时创建的目录
>> $startTime = (Get-Date).AddHours(-24)
>> $toolboxPaths = @()
>>
>> foreach ($drive in @('C:', 'E:')) {
>> Get-ChildItem -Path $drive -Recurse -Directory -ErrorAction SilentlyContinue |
>> Where-Object { $_.CreationTime -gt $startTime } |
>> ForEach-Object {
>> $dir = $_.FullName
>>
>> # 检查关键文件
>> $criticalFiles = @('*toolbox*.py', '*permission*.dll', '*admin*.exe')
>> $found = $false
>> foreach ($pattern in $criticalFiles) {
>> if (Get-ChildItem -Path $dir -Filter $pattern -ErrorAction SilentlyContinue) {
>> $found = $true
>> break
>> }
>> }
>>
>> if ($found) {
>> # 检查权限特征
>> $permKeywords = @('SeDebugPrivilege', 'AdjustTokenPrivileges', 'CreateProcessAsUser')
>> $codeFiles = Get-ChildItem -Path $dir -Include *.py, *.c, *.cpp, *.dll -Recurse -ErrorAction SilentlyContinue |
>> Select-Object -First 5
>>
>> $keywordHits = @()
>> foreach ($file in $codeFiles) {
>> $content = Get-Content $file.FullName -Raw -ErrorAction SilentlyContinue
>> if ($content) {
>> foreach ($keyword in $permKeywords) {
>> if ($content -match $keyword) {
>> $keywordHits += "$keyword in $($file.Name)"
>> }
>> }
>> }
>> }
>>
>> $toolboxPaths += [PSCustomObject]@{
>> Path = $dir
>> Created = $_.CreationTime
>> PermissionFeatures = $keywordHits
>> }
>> }
>> }
>> }
>>
>> # 输出结果
>> if ($toolboxPaths) {
>> $toolboxPaths | Format-Table Path, Created, PermissionFeatures -AutoSize
>> } else {
>> Write-Host "未找到符合条件的工具箱" -ForegroundColor Red
>> }
>>
Path Created PermissionFeatures
---- ------- ------------------
E:\ProjectEcosystem 2025/8/12 23:48:38 {}
PS C:\Users\Administrator> // C/C++ 示例 - 提升进程权限
>> BOOL EnableDebugPrivilege() {
>> HANDLE hToken;
>> TOKEN_PRIVILEGES tkp;
>>
>> if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
>> return FALSE;
>>
>> LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid);
>>
>> tkp.PrivilegeCount = 1;
>> tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
>>
>> AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
>> CloseHandle(hToken);
>> return TRUE;
>> }
>>
所在位置 行:2 字符: 27
+ BOOL EnableDebugPrivilege() {
+ ~
“(”后面应为表达式。
所在位置 行:6 字符: 45
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGE ...
+ ~
“(”后面应为表达式。
所在位置 行:6 字符: 85
+ ... n(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ...
+ ~
参数列表中缺少参量。
所在位置 行:6 字符: 87
+ ... GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+ ~
不允许使用与号(&)。& 运算符是为将来使用而保留的;请用双引号将与号引起来("&"),以将其作为字符串的一部分传递。
所在位置 行:6 字符: 95
+ ... GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+ ~
if(条件)后面缺少语句块。
所在位置 行:9 字符: 30
+ LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid ...
+ ~
参数列表中缺少参量。
所在位置 行:9 字符: 46
+ LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid ...
+ ~
管道元素中的“,”后面缺少表达式。
所在位置 行:9 字符: 47
+ LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid ...
+ ~
不允许使用与号(&)。& 运算符是为将来使用而保留的;请用双引号将与号引起来("&"),以将其作为字符串的一部分传递。
所在位置 行:14 字符: 33
+ AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
+ ~
参数列表中缺少参量。
所在位置 行:14 字符: 41
+ AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
+ ~
管道元素中的“,”后面缺少表达式。
并未报告所有分析错误。请更正报告的错误并重试。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression
PS C:\Users\Administrator> # 使用ctypes调用Windows API提升权限
>> import ctypes
>>
>> def enable_debug_privilege():
>> ADVAPI32 = ctypes.windll.advapi32
>> token = ctypes.c_void_p()
>>
>> # 获取当前进程令牌
>> ADVAPI32.OpenProcessToken(
>> ctypes.windll.kernel32.GetCurrentProcess(),
>> 40, # TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY
>> ctypes.byref(token)
>> )
>>
>> # 查找调试权限值
>> luid = ctypes.c_ulonglong()
>> ADVAPI32.LookupPrivilegeValueW(None, "SeDebugPrivilege", ctypes.byref(luid))
>>
>> # 调整权限
>> new_state = (1, luid, 2) # SE_PRIVILEGE_ENABLED=2
>> ADVAPI32.AdjustTokenPrivileges(token, False, new_state, 0, None, None)
>>
所在位置 行:4 字符: 28
+ def enable_debug_privilege():
+ ~
“(”后面应为表达式。
所在位置 行:6 字符: 29
+ token = ctypes.c_void_p()
+ ~
“(”后面应为表达式。
所在位置 行:10 字符: 50
+ ctypes.windll.kernel32.GetCurrentProcess(),
+ ~
“(”后面应为表达式。
所在位置 行:16 字符: 31
+ luid = ctypes.c_ulonglong()
+ ~
“(”后面应为表达式。
所在位置 行:17 字符: 40
+ ADVAPI32.LookupPrivilegeValueW(None, "SeDebugPrivilege", ctypes.b ...
+ ~
参数列表中缺少参量。
所在位置 行:20 字符: 20
+ new_state = (1, luid, 2) # SE_PRIVILEGE_ENABLED=2
+ ~
“,”后面缺少表达式。
所在位置 行:20 字符: 21
+ new_state = (1, luid, 2) # SE_PRIVILEGE_ENABLED=2
+ ~~~~
表达式或语句中包含意外的标记“luid”。
所在位置 行:20 字符: 20
+ new_state = (1, luid, 2) # SE_PRIVILEGE_ENABLED=2
+ ~
表达式中缺少右“)”。
所在位置 行:20 字符: 28
+ new_state = (1, luid, 2) # SE_PRIVILEGE_ENABLED=2
+ ~
表达式或语句中包含意外的标记“)”。
所在位置 行:21 字符: 41
+ ADVAPI32.AdjustTokenPrivileges(token, False, new_state, 0, None, ...
+ ~
参数列表中缺少参量。
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression
PS C:\Users\Administrator>
不重建 都做了那么多了 为什么你老想着要重来?每次都从头开始 回到原点 那不就是在原地踏步 浪费时间吗?那有什么意义?
最新发布