当前位置: 首页 > news >正文

无管理员权限 LCU auth-token、port 获取(全网首发 go)

一: 提要:

参考项目:
https://github.com/Zzaphkiel/Seraphine

想做一个 lol 查战绩的软件,并且满足自己的需求(把混子和大爹都表示出来),做的第一步就是获取 lcu token ,网上清一色的使用 wmic 去查询的,这样也不是不行,不过需要使用管理员权限,恰好我在用Seraphine,发现别人根本不需要管理员权限就可以获取
在这里插入图片描述

但是我在全网并没有找到其他的实现,就自己研究了一下,发现谜底就在获取 token 的方式上。
在这里插入图片描述

二:获取过程:

wmic PROCESS WHERE name='LeagueClientUx.exe' GET commandline 

一般来说其他进程的详细数据是敏感信息,如果没有管理员权限,不能随便访问。如上述代码 wmic 只能有管理员才能访问,但是 commandline 又不是非常敏感的数据,

这里最后是通过 windows api进行交互,理论上说,大部分编译型语言都没问题,这里给到go的演示

package mainimport ("fmt""golang.org/x/sys/windows""log""os/exec""strconv""strings""unsafe"
)func getProcessPidByName(name string) ([]int, error) {cmd := exec.Command("wmic", "process", "where", fmt.Sprintf("name like '%%%s%%'", name), "get", "processid")output, err := cmd.CombinedOutput()if err != nil {return nil, err}// 将输出按行分割lines := strings.Split(string(output), "\n")var pids []int// 处理每行输出for _, line := range lines {trimmed := strings.TrimSpace(line)if len(trimmed) > 0 {// 转换为数字并添加到结果中pid, err := strconv.Atoi(trimmed)if err == nil {pids = append(pids, pid)}}}return pids, nil
}const (ProcessCommandLineInformation     = 60PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
)var (modntdll                      = windows.NewLazySystemDLL("ntdll.dll")procNtQueryInformationProcess = modntdll.NewProc("NtQueryInformationProcess")
)type UNICODE_STRING struct {Length        uint16MaximumLength uint16Buffer        *uint16
}func GetProcessCommandLine(pid uint32) (string, error) {// Open the process with PROCESS_QUERY_LIMITED_INFORMATIONhandle, err := windows.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, false, pid)if err != nil {return "", fmt.Errorf("failed to open process: %v", err)}defer windows.CloseHandle(handle)// Query the buffer length for the command line informationvar bufLen uint32r1, _, err := procNtQueryInformationProcess.Call(uintptr(handle),uintptr(ProcessCommandLineInformation),0,0,uintptr(unsafe.Pointer(&bufLen)),)// Allocate buffer to hold command line informationbuffer := make([]byte, bufLen)r1, _, err = procNtQueryInformationProcess.Call(uintptr(handle),uintptr(ProcessCommandLineInformation),uintptr(unsafe.Pointer(&buffer[0])),uintptr(bufLen),uintptr(unsafe.Pointer(&bufLen)),)if r1 != 0 {return "", fmt.Errorf("NtQueryInformationProcess failed, error code: %v", err)}// Check if the buffer length is valid and non-zeroif bufLen == 0 {return "", fmt.Errorf("No command line found for process %d", pid)}// Parse the buffer into a UNICODE_STRINGucs := (*UNICODE_STRING)(unsafe.Pointer(&buffer[0]))cmdLine := windows.UTF16ToString((*[1 << 20]uint16)(unsafe.Pointer(ucs.Buffer))[:ucs.Length/2])return cmdLine, nil
}func main() {pids, _ := getProcessPidByName("LeagueClientUx.exe")cmdLine, err := GetProcessCommandLine(uint32(pids[0]))if err != nil {log.Fatalf("无法获取进程命令行: %v", err)}fmt.Printf("进程命令行: %s\n", cmdLine)
}

在这里插入图片描述

http://www.lryc.cn/news/505636.html

相关文章:

  • 【数字花园】数字花园(个人网站、博客)搭建经历教程
  • python模拟练习第一期
  • Xcode
  • RabbitMQ安装延迟消息插件(mq报错)
  • es 3期 第15节-词项查询与跨度查询实战运用
  • iOS Delegate模式
  • java-使用druid sqlparser将SQL DDL脚本转化为自定义的java对象
  • React状态管理常见面试题目(一)
  • jenkins 出现 Jenkins: 403 No valid crumb was included in the request
  • 【前端面试】list转树、拍平, 指标,
  • 游戏引擎学习第43天
  • NVM:安装配置使用(详细教程)
  • matlab测试ADC动态性能的原理
  • PostgreSQL JSON/JSONB 查询与操作指南
  • 【Isaac Lab】Ubuntu22.04安装英伟达驱动
  • JS,递归,处理树形数据组件,模糊查询树形结构数据字段
  • 神州数码DCME-320 online_list.php 任意文件读取漏洞复现
  • nginx的内置变量以及nginx的代理
  • ubuntu监测硬盘状态
  • 3.2.1.2 汇编版 原子操作 CAS
  • InnoDB事务系统(二):事务的实现
  • xdoj :模式匹配
  • Redis的基本使用命令(GET,SET,KEYS,EXISTS,DEL,EXPIRE,TTL,TYPE)
  • LruCache(本地cache)生产环境中遇到的问题及改进
  • 智慧公交指挥中枢,数据可视化 BI 驾驶舱
  • 【计算机网络】期末考试预习复习|上
  • YOLOv8目标检测(四)_图片推理
  • AI工具如何深刻改变我们的工作与生活
  • springboot中——Logback介绍
  • 【Tomcat】第一站:理解tomcat与Socket