标题:请问如何在windows 凭据管理器中添加凭据?
只看楼主
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
结帖率:100%
已结贴  问题点数:20 回复次数:32 
请问如何在windows 凭据管理器中添加凭据?
**这个是windows 凭据管理代码,在控制面板里选凭据管理器,然后添加windows 凭据
clea
Declare Integer  CredWriteA IN Advapi32 string @PCREDENTIALA_Credential,long Flags
Declare Integer CredReadA IN Advapi32  string TargetName,long Type,long Flags,long @Credential
Declare Integer CredDeleteA  IN Advapi32 string TargetName,long Type,long  Flags
tn="192.168.10.181"
*?CredDeleteA(tn,2,0)  &&2,密码凭据,删除凭据,正确
stt=0
?CredReadA(tn,2,0,@stt)  &&读取凭据,正确,但还不会各参数分离
st2=SYS(2600,stt,1024)
?st2
?CTOBIN(SUBSTR(st2,1,4),"4rs")
?CTOBIN(SUBSTR(st2,5,4),"4rs")

?CredWriteA(?,0)  &&写入凭据,不会,请指教

retu
搜索更多相关主题的帖子: long 管理器 windows 添加 Integer 
2022-06-23 15:39
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
typedef struct _CREDENTIALA {
  DWORD                  Flags;
  DWORD                  Type;
  LPSTR                  TargetName;
  LPSTR                  Comment;
  FILETIME               LastWritten;
  DWORD                  CredentialBlobSize;
  LPBYTE                 CredentialBlob;
  DWORD                  Persist;
  DWORD                  AttributeCount;
  PCREDENTIAL_ATTRIBUTEA Attributes;
  LPSTR                  TargetAlias;
  LPSTR                  UserName;
} CREDENTIALA, *PCREDENTIALA;
先搞懂读取
读取后个参数解析
?CTOBIN(SUBSTR(st2,1,4),"4rs")  &&好像正确
?CTOBIN(SUBSTR(st2,5,4),"4rs")  &&好像正确
剩下的就不知道怎么分离了


[此贴子已经被作者于2022-6-23 17:13编辑过]

2022-06-23 17:11
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
CREDENTIALA结构大小52byte,其中FILETIME占8byte,其余各占4byte
2022-06-23 17:48
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
好的,谢谢,我先试试
2022-06-24 08:17
mywisdom88
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:190
帖 子:3125
专家分:8340
注 册:2015-3-25
得分:0 
以下是引用吹水佬在2022-6-23 17:48:24的发言:

CREDENTIALA结构大小52byte,其中FILETIME占8byte,其余各占4byte


怎么解释这个出来。
2022-06-24 09:08
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
咱们是通样的问题
2022-06-24 10:01
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
我现在准备搜点资料,来个自动添加、删除、读取
2022-06-24 10:02
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
Declare Integer CredReadA IN Advapi32  string TargetName,long Type,long Flags,long @Credential
tn="192.168.10.181"

stt=0
?CredReada(tn,2,0,@stt)  &&读取凭据,正确,但还不会各参数分离
st2=SYS(2600,stt,520)

?STREXTRACT(SYS(2600,CTOBIN(SUBSTR(st2,9,4),"4rs"),40),"",CHR(0))  &&位置全靠猜
?STREXTRACT(SYS(2600,CTOBIN(SUBSTR(st2,49,4),"4rs"),40),"",CHR(0))  &&位置全靠猜
?"密码不知道在哪里取"
2022-06-24 12:47
吹水佬
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:432
帖 子:10064
专家分:41463
注 册:2014-5-20
得分:0 
?CredReada(tn,2,0,@stt)
这句显示什么?
再看看stt是什么
?stt
2022-06-24 13:54
sych
Rank: 3Rank: 3
等 级:论坛游侠
威 望:6
帖 子:179
专家分:183
注 册:2019-10-11
得分:0 
这个好像更接近真相,但密码在哪里呢?
clea
DECLARE INTEGER FileTimeToLocalFileTime IN KERNEL32.DLL ;
    STRING lpFileTime, ;
    STRING @ lpLocalFileTime
DECLARE INTEGER FileTimeToSystemTime IN KERNEL32.DLL ;
    STRING lpFileTime, ;
    STRING @ lpSystemTime
Declare Integer CredReadA IN Advapi32  string TargetName,long Type,long Flags,long @Credential
tn="192.168.10.181"

stt=0
?CredReada(tn,2,0,@stt)  &&读取凭据,正确,但还不会各参数分离
st2=SYS(2600,stt,520)
?CTOBIN(SYS(2600,stt,4),"4rs")
?CTOBIN(SYS(2600,stt+4,4),"4rs")
?STREXTRACT(SYS(2600,CTOBIN(SYS(2600,stt+8,4),"4rs"),256),"",CHR(0))
*?SYS(2600,CTOBIN(SYS(2600,stt+12,4),"4rs"),100)  &&不知道这个为什么不对
lTime =REPLICATE(CHR(0),8)
FileTimeToLocalFileTime(SYS(2600,stt+16,8), @LTime)
?FTime2SysTime(LTime)
?CTOBIN(SYS(2600,stt+24,4),"4rs")
?CTOBIN(SYS(2600,stt+28,4),"4rs")
?CTOBIN(SYS(2600,stt+32,4),"4rs")
?CTOBIN(SYS(2600,stt+36,4),"4rs")
?CTOBIN(SYS(2600,stt+40,4),"4rs")
?CTOBIN(SYS(2600,stt+44,4),"4rs")
?STREXTRACT(SYS(2600,CTOBIN(SYS(2600,stt+48,4),"4rs"),256),"",CHR(0))
retu

FUNCTION FTime2SysTime
lPARAMETERS sFileTime
LOCAL sSystemTime,rc,wYear,wMonth,wDayOfWeek,wDay,wHour,wMinute,wSecond,wMilliseconds,sDateTime
sSystemTime = REPLICATE(CHR(0),16)
rc = FileTimeToSystemTime(sFileTime, @sSystemTime)
wYear         = ctobin(SUBSTR(sSystemTime, 1,2),"2rs")
wMonth        = ctobin(SUBSTR(sSystemTime, 3,2),"2rs")
wDayOfWeek    = ctobin(SUBSTR(sSystemTime, 5,2),"2rs")
wDay          = ctobin(SUBSTR(sSystemTime, 7,2),"2rs")
wHour         = ctobin(SUBSTR(sSystemTime, 9,2),"2rs")
wMinute       = ctobin(SUBSTR(sSystemTime, 11,2),"2rs")
wSecond       = ctobin(SUBSTR(sSystemTime, 13,2),"2rs")
wMilliseconds = ctobin(SUBSTR(sSystemTime, 15,2),"2rs")
sDateTime = trans(wYear) + [.] + trans(wMonth,"@l 99") + [.] + trans(wDay,"@l 99") + [ ] + ;
    trans(wHour, "@l 99") + [:] + trans(wMinute, "@l 99") + [:] + trans(wSecond, "@l 99") + [.] + trans(wMilliseconds,"@l 999")
RETURN IIF(rc=1,sDateTime,SPACE(23))

[此贴子已经被作者于2022-6-24 14:58编辑过]

2022-06-24 14:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-509405-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.056233 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved