楼主局以不良
问题:女友说的,这个问题什么时候给她搞定,就什么时候才能一起上床睡觉... ( 积分:100, 回复:23, 阅读:614 )
分类:局域网 / 通讯 ( 版主:卷起千堆雪tyn, cAkk )
来自:kenny_liao, 时间:2006-10-23 22:06:00, ID:3604265 [显示:小字体 | 大字体]
女友给我的任务,由于她公司的电脑总是被一些人偷窥,
她很想把那些人揪出...
我出点子用dos命令(Net session)
或计算机管理中的功能,
但都不是很方便,于是叫我这个搞程序的给她写一个,
本以为是一件很简单的事,可还是写不出来.
下面是网上拿来的,可是Win2000无法成功获取与本机连接的用户清单...
找不出原因.
const
MaxNetArrayItems = 512;
type
TSessionInfo50 = packed record
sesi50_cname: PChar; //remote computer name (connection id in Netware)
sesi50_username: PChar;
sesi50_key: DWORD; // used to delete session (not used in Netware)
sesi50_num_conns: Word;
sesi50_num_opens: Word; //not available in Netware
sesi50_time: DWORD;
sesi50_idle_time: DWORD; //not available in Netware
sesi50_protocol: Char;
padl: Char;
end;
TNetSessionEnum = function (const pszServer: PChar; sLevel: SmallInt;
pbBuffer: Pointer; cbBuffer: Word; var pcEntriesRead: Word;
var pcTotalAvail: Word): DWORD; stdcall;
procedure GetNetSessions(ComputerNames: TStrings);
var
SessionInfo: array[0..MaxNetArrayItems] of TSessionInfo50;
EntriesRead, TotalAvail: Word;
I: Integer;
Str: string;
NetSessionEnum: TNetSessionEnum;
LibHandle: THandle;
begin
ComputerNames.Clear;
LibHandle := LoadLibrary('NETAPI32.DLL');
if LibHandle <> 0 then
begin
try
@NetSessionEnum := GetProcAddress(LibHandle, 'NetSessionEnum');
if (@NetSessionEnum <> nil) then
if NetSessionEnum(nil, 50, @SessionInfo, Sizeof(SessionInfo), EntriesRead, TotalAvail) = 0 then
begin
for I := 0 to EntriesRead - 1 do
with SessionInfo
do
begin
SetString(Str, sesi50_cname, StrLen(sesi50_cname));
ComputerNames.Add(Str);
end;
end;
finally
FreeLibrary(LibHandle);
end;
end;
end;
来自:江远, 时间:2006-10-23 22:16:55, ID:3604273
先搞定她,再搞定它!哈哈
来自:kenny_liao, 时间:2006-10-23 22:22:52, ID:3604277
可是女友说的要先搞定它,才能搞她..
来自:crazymoon, 时间:2006-10-23 22:37:15, ID:3604285
建个WIN程序作界面,在内部使用DOS命令,将其结果导出很分析
netstat >>c:/1.txt ,结果显示出来。
http://www.2ccc.com/article.asp?articleid=2029 有个控件直接运行DOS命令,
可以直接获取结果
来自:liyong0775, 时间:2006-10-23 22:43:24, ID:3604289
[]
来自:Vision, 时间:2006-10-23 23:45:31, ID:3604318
给装个天网防火墙就行了,既能防被种木马又能知道是谁在偷窥,使用也简单,个人电脑用它足够了。
来自:kenny_liao, 时间:2006-10-23 23:50:16, ID:3604319
谢谢crazymoon的方法,虽然是显得不专业了点,
但现在主要是要解决一下睡觉问题,暂时将就一下吧!
如果能把上面的代码,在win2000中通过,
那最好了.
来自:smallhacker, 时间:2006-10-24 9:12:36, ID:3604397
重装系统做安全点,不就不被偷窥了
现在偷窥太厉害了, 不少人的裸照上网呢
来自:aizhuzhu, 时间:2006-10-24 9:15:14, ID:3604401
[8D]
来自:wukw, 时间:2006-10-24 9:19:50, ID:3604404
发这种帖子不觉得丢人吗??以后还要收录到DFW历史数据库里去!!我都替你觉得脸在发烧!!!
来自:dingbaosheng, 时间:2006-10-24 9:25:05, ID:3604409
来自:wukw, 时间:2006-10-24 9:19:50, ID:3604404
发这种帖子不觉得丢人吗??以后还要收录到DFW历史数据库里去!!我都替你觉得脸在发烧!!!
同意!!!
来自:QSmile, 时间:2006-10-24 9:30:20, ID:3604422
我比较关心楼主上了床没?
来自:bluesweet, 时间:2006-10-24 9:42:43, ID:3604442
呵呵,楼主的程序在别的操作系统上试过没有?
来自:Johnny_du, 时间:2006-10-24 9:48:07, ID:3604449
是炒作吧?这么写可能进来看的人会多些,自然得到解决的概率也就大些了...
楼主似乎更适合去做市场拓展和营销工作...
来自:jfyes, 时间:2006-10-24 9:48:30, ID:3604450
用管道
//发送令行执行结果,通过令名管道实现返回结果
//cmd/c help dir //cmd/c help
//CMD.EXE cmd/c dir D:/vc60 或是 cmd/c netstat -a -n
function SendPipe(const Command: PChar; var AReply: TStream): BOOL;
var
hReadPipe, hWritePipe: THandle;
si: STARTUPINFO;
lsa: SECURITY_ATTRIBUTES;
pi: PROCESS_INFORMATION;
cchReadBuffer: DWORD;
ph: array[0..4095] of Char;
fname: array[0..260] of Char;
begin
if AReply = nil then Exit;
fillchar(ph, sizeof(ph), #0);
lsa.nLength := sizeof(SECURITY_ATTRIBUTES);
lsa.lpSecurityDescriptor := nil;
lsa.bInheritHandle := True;
Result := False;
if CreatePipe(hReadPipe, hWritePipe, @lsa, 0) = false then
begin
Ph := 'Can not create pipe!' ;
AReply.Write(ph, Length(Ph));
exit;
end;
fillchar(si, sizeof(STARTUPINFO), 0);
si.cb := sizeof(STARTUPINFO);
si.dwFlags := (STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW);
si.wShowWindow := SW_HIDE;
si.hStdOutput := hWritePipe;
fillchar(fname, sizeof(fname), #0);
//net user user1 test /add
//net localgroup administrators user1 /add
//net user user1 /del
fname := 'cmd.exe cmd/c ';
lstrcat(fname, Command);
if CreateProcess( nil, fname, nil, nil, true, 0, nil, nil, si, pi) = False then
begin
FormatChar(Ph, 'the Command: %s, Can not create process', [Integer(@fname)]);
AReply.Write(ph, Length(Ph));
exit;
end;
while(true) do
begin
if not PeekNamedPipe(hReadPipe, @ph, 1, @cchReadBuffer, nil, nil) then break;
if cchReadBuffer <> 0 then
begin
fillchar(ph, sizeof(ph), #0);
if ReadFile(hReadPipe, ph, 4096, cchReadBuffer, nil) = false then break;
AReply.Write(ph, Length(Ph));
end
else if(WaitForSingleObject(pi.hProcess , 0) = WAIT_OBJECT_0) then break;
Sleep(50);
end;
//发送结束标记
fillchar(ph, sizeof(ph), #0);
ph := '======>>>> Client CMD END <<<<=======';
AReply.Write(ph, Length(Ph));
CloseHandle(hReadPipe);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
CloseHandle(hWritePipe);
end;
//返回命令行结果
procedure SendCmdLineResult(AData: TStream; var AReply: TStream);
var
ALength: Integer;
CmdLine: string;
begin
ALength := AData.Size - AData.Position;
if (ALength > 0) and (ALength < 10000000) then
begin
SetLength(CmdLine, ALength);
AData.Read(CmdLine[1], ALength);
SendPipe(PChar(CmdLine), AReply);
end else begin
CmdLine := 'Clinet GetCmd return Invalid data length.';
AReply.Write(CmdLine[1], Length(CmdLine));
CmdLine := '';
end;
end;
来自:tobey, 时间:2006-10-24 10:24:00, ID:3604515
楼主素质不行,楼主女朋友的素质更不行。
来自:kenny_liao, 时间:2006-10-24 12:58:02, ID:3604720
[blue]按照crazymoon的写了一个(用net session>> e:/NowConsIP.txt,然后取出想要的结果),今天给她看运行结果,真挑,说功能不够,
现在的女生,要求不一样,男人不光要会钻钱,还要会整人!
//重新提出许多功能上的要求,
//1.要随时监控谁连接到该电脑;
//2.要随时断开那在别人电脑上乱找东西的主机,最好封掉IP,让它别再烦人;
//3.要很方便地给它发个信息狠狠地批评它一翻,最好不要收到它发来的信息(类似信使);
//4.要明确知道对方正打开了哪个文件.(从中分析出它有什么意图).[/blue]
你这是让大家帮忙写什么商业的东西吧,不会的一步步提出来,有那个女的有这么多要求,能搞定就用防火墙吧