|
文件系统过滤驱动
Unload中的KeDelayExecutionThread(KernelMode, FALSE, &interval);是sfilter的简化写法 为了让每个device中的irp尽可能的处理完.在成熟的产品中,往往会使用IRP计数器和异步IO计数同时来保证一个device上的IO操作得到完成或完全取消后在delete设备.~~~,最后付上俺的小博 http://rerede.com 欢迎来踩踩~~ |
|
文件系统过滤驱动
文件过滤,不如虚拟文件系统,恭喜哥们一脚跨入鬼门关~ |
|
[求助]X64找SSDT疑惑(结贴吧)
你IDA看下ntoskrnl.exe从strnicmp开始搜索,搜索到KdDebuggerNotPresent。比较内容为KiSystemServiceStart_pattern。这种编码搜索方式,你还不如硬编码干脆 |
|
|
|
[讨论]3600safe检查隐藏进程功能求绕过
论坛自由交流,你可以无视。什么样的东西不重要,可以交流就行。你看不上不代表其他人看不上。 有没有VMP只不过代表交流的深浅而已 |
|
[求助]LPC的疑惑(附源码)
hListen以及hClinet被唤醒后都要对LPC的各种类型做处理 所以。我每个等待后都处理: [CODE] __try { switch(PacketBuffer->Lpc.u2.s2.Type) { case LPC_CONNECTION_REQUEST: // 处理链接请求 NewClientConnected(PacketBuffer,&PacketBuffer->Connect.Context); break; // 如果端口没有完全关闭,仅通讯端口关闭 case LPC_PORT_CLOSED: // 对方端口句柄关闭 { CloseClientConnection(PacketBuffer, PortContext, LPC_PORT_CLOSED); return TRUE; } case LPC_CLIENT_DIED: // 通讯过程被结束,客户端才有的消息 { CloseClientConnection(PacketBuffer, PortContext, LPC_CLIENT_DIED); break; } case LPC_DATAGRAM: RecvMessage(PacketBuffer, PortContext, LPC_DATAGRAM); break; case LPC_REQUEST: RecvRequest(PacketBuffer, PortContext); break; default: // // We received a message type we didn't expect, probably due to // error. BUGBUG - write an event // m_pPoolObject->PrintInfo("Message Loop # Unknow.\n"); break; } } __except(EXCEPTION_EXECUTE_HANDLER) { //KdPrint(( "[DSW] Unexpected exception on LPC port: %08X\n",GetExceptionCode())); } [CODE] |
|
[求助]LPC的疑惑(附源码)
这2个函数都是在do while中调用。 |
|
[求助]LPC的疑惑(附源码)
最近比较忙,贴段我的代码 BOOLEAN CPort::ListenPort( __in HANDLE hPortHandle, __in PPACKET PacketBuffer ) { NTSTATUS status; PVOID PortContext = NULL; status = m_pPoolObject->m_tSystemApis.NtReplyWaitReceivePortEx( hPortHandle, (PVOID *)&PortContext, (PPORT_MESSAGE)NULL, (PPORT_MESSAGE) PacketBuffer, &m_tTimePreListen ); if(status == STATUS_TIMEOUT) { return FALSE; } if ( !NT_SUCCESS(status) ) { return FALSE; } BOOLEAN CPort::MessageLoop( __in HANDLE hPortHandle, __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in PPACKET PacketBuffer ) { NTSTATUS status; PVOID PortContext = NULL; //if(IsFlagOn(m_pPortObject->Flags, PORT_STATUS_DELETE_PEDING)) { // return TRUE; //} //if(ClientInfo->ServerMode.IsTerminatePeding) { // return TRUE; //} status = m_pPoolObject->m_tSystemApis.NtReplyWaitReceivePortEx( hPortHandle, (PVOID *)&PortContext, (PPORT_MESSAGE)NULL, (PPORT_MESSAGE) PacketBuffer, &m_tTimePreListen ); if(status == STATUS_TIMEOUT) { return FALSE; } if ( !NT_SUCCESS(status) ) { return FALSE; } 有空我编译下调试好在看看。 |
|
[求助]LPC的疑惑(附源码)
即便你Sleep 2s也可能发生异常。而LZ原本的问题,应该是楼上的问题1,问题2的综合表现 |
|
[求助]LPC的疑惑(附源码)
简述下你的逻辑 Status = NtListenPort(hListenPort,&(ReceiveMessage.Header)); 这句调用产生线程挂起等待客户连接。外围的do while 保证了循环监听。所以不存在需要Sleep的情况 HANDLE hThread = (HANDLE)_beginthreadex(NULL,0,func,&ReceiveMessage,0,NULL); 工作线程,去处理连接,应该要完成Accept来接受并使用Complete唤醒 问题一: 如果没有Sleep那么fun线程得到的线程参数指针有可能被破坏,因为线程可能在执行时,调用者已经进入下一个do while循环,栈空间已被破坏。 问题二: 很有可能,你会产生某个Message无法收到的问题。在你解决了问题1后,他的表现是LPC_REQUEST时发送者无法接受返回的消息而陷入等待。 |
|
[诚聘]杭州颂格网络科技诚聘软件逆向工程师(月薪8k-30k)(诚聘结束)
186 6714 7321 |
|
|
|
|
|
[求助]LPC只能双向通信吗?支持一对多吗?
在我的封装模型下 实测1024个客户端并发20万个报文请求,2273ms完成发送 服务端在接受时处理稍微慢了几百ms. 测试机器: i7 930 OC4.0Ghz - 6GB内存 Xeon 5506 2.13G 两个平台浮动不大。 支持无限大小的报文,支持报文分包重组 |
|
[求助]LPC只能双向通信吗?支持一对多吗?
服务器可以对应多个客户端广播通讯。 LPC系统只是 简单提供接口,更多功能需要自己处理 class CPort { /*///////////////////////////////////////////////////////////////////////////////////////////////////// CPort 构造函数等.保存端口池对象 /*///////////////////////////////////////////////////////////////////////////////////////////////////// public: CPort( PCPortPool PoolObject ); ~CPort(); // 对于CPortPool来说建立友元关系 friend class CPortPool; /*///////////////////////////////////////////////////////////////////////////////////////////////////// 自定义 New 操作符 /*///////////////////////////////////////////////////////////////////////////////////////////////////// public: PVOID operator new(size_t n) { return CServerAllocatePool( n ); } VOID operator delete(PVOID p) { CServerFreePool(p); } /*///////////////////////////////////////////////////////////////////////////////////////////////////// 端口私有属性 /*///////////////////////////////////////////////////////////////////////////////////////////////////// private: // 回指端口池 PCPortPool m_pPoolObject; // 端口描述符 HPORT m_pPortObject; // 守护线程 ULONG_PTR m_pClassThread; // 线程事件, 客户端模式为监听的线程,服务器模式为链接线程 ULONG_PTR m_pThreadEvent; private: // 每次监听的超时时间 LARGE_INTEGER m_tTimePreListen; /*///////////////////////////////////////////////////////////////////////////////////////////////////// 端口描述符的引用计数管理 /*///////////////////////////////////////////////////////////////////////////////////////////////////// private: LONG IncrementPort(); LONG DecrementPort(); /*///////////////////////////////////////////////////////////////////////////////////////////////////// 内部处理接口函数 /*///////////////////////////////////////////////////////////////////////////////////////////////////// private: // 创建一个端口描述符 BOOLEAN Create( __in PWCHAR strPortName, __in PVOID SecurityDescriptor, __in ULONG Flags, __in ULONG MaxThreads, __in PVOID PortContext, __in BOOLEAN MustDoConnect, __in BOOLEAN IsConnectClient ); BOOLEAN InitializeConnectPort( __in PWCHAR strPortName, __in ULONG Flags, __in ULONG MaxThreads, __in PVOID PortContext, __in BOOLEAN MustDoConnect ); BOOLEAN InitializeServerPort( __in PWCHAR strPortName, __in PVOID SecurityDescriptor, __in ULONG Flags, __in ULONG MaxThreads, __in PVOID PortContext ); // 删除端口 BOOLEAN DeletePort( __in VOID ); BOOLEAN DeleteConnectPort( __in VOID ); BOOLEAN DeleteServerPort( __in VOID ); VOID DeleteClient( __in PPORT_CLIENT_DESCRIPTOR ClientDescriptor, __in BOOLEAN NotWait ); VOID SendMultipleItems( __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in HANDLE hPortHandle ); BOOLEAN SendSingleItem( __in PPORT_SEND_ITEM SendItem, __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in HANDLE hPortHandle ); VOID CanceSend( __in_opt PPORT_CLIENT_DESCRIPTOR TargetInfo, __in PLUID MessageId ); VOID RecvMessage( __in PPACKET PacketBuffer, __in PVOID Context, __in CSHORT MsgType ); VOID RecvRequest( __in PPACKET PacketBuffer, __in PVOID Context ); // 获取下个端口 PCPort Next(); // 获取下个快速端口 PCPort NextFastPort(); public: // 异步发送队列 virtual VOID SendWorker( __in PPORT_CLIENT_DESCRIPTOR ClientInfo ); // 消息队列 virtual VOID MessageWorker( __in PPORT_CLIENT_DESCRIPTOR ClientInfo ); virtual VOID ThreadsDaemon( __in PPORT_CLIENT_DESCRIPTOR ClientInfo ); // 链接监听线程 virtual VOID ConnectAppect( __in PVOID Paramter ); private: // 链接建立,死亡处理 BOOLEAN ListenPort( __in HANDLE hPortHandle, __in PPACKET PacketBuffer ); BOOLEAN MessageLoop( __in HANDLE hPortHandle, __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in PPACKET PacketBuffer ); // 新链接建立 VOID NewClientConnected( __in PPACKET PacketBuffer, __in PCONNECT_PAYLOAD ConnectCtx ); // 链接将关闭 VOID CloseClientConnection( __in PPACKET PacketBuffer, __in PVOID Context, __in CSHORT MsgType ); // KEY初始化 VOID KeyInitialize( __in PLUID RndKey, __in PLUID Cookies, __in ULONG Pid, __in ULONG Tid ); // 内存管理 private: // 申请PORT结构体资源 BOOLEAN InitializePort( __in VOID ); // 释放资源 VOID UninitializePort( __in VOID ); private: VOID CleanupMessageStack( __in PPACKET_HEADER PacketHeader, __in PPORT_CLIENT_DESCRIPTOR ClientInfo ); VOID CleanupPacketStackItems ( __in PPORT_MESSAGE_STACK MessageItem ); VOID FreeMessageMemory( __in PPACKET PacketBuffer ); VOID RecvMessageStackHeader( __in PPACKET PacketBuffer, __in PPORT_CLIENT_DESCRIPTOR ClientInfo ); VOID RecvMessageStackFooter( __in PPACKET PacketBuffer, __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in PPORT_MESSAGE_STACK MessageItem ); PPORT_MESSAGE_STACK CheckMessageStack( __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in PPACKET PacketBuffer ); VOID RecvMessageData( __in PPACKET PacketBuffer, __in PPORT_CLIENT_DESCRIPTOR ClientInfo, __in PPORT_MESSAGE_STACK MessageItem ); public: ULONG SendPort( __in_opt PPORT_CLIENT_DESCRIPTOR TargetInfo, __in USHORT MessageType, __in PVOID DataBuffer, __in ULONG DataSize ); BOOLEAN RequestPortEx( __in_opt PPORT_CLIENT_DESCRIPTOR TargetInfo, __in USHORT MessageType, __in PPORT_DATA_ENTRY DataEntries, __in ULONG NumberOfDataEntries, __inout_opt PVOID *ReplyPacketPtr ); BOOLEAN ReplyPortEx( __in PPACKET Packet, __in_opt PPORT_CLIENT_DESCRIPTOR TargetInfo, __in PVOID ReplyBuffer, __in ULONG ReplySize ); VOID FreeReplyPacket( __in PPORT_CLIENT_DESCRIPTOR TargetInfo, __in PVOID Packet ); VOID FreeRemoteMemory( __in_opt PPORT_CLIENT_DESCRIPTOR TargetInfo, __in PVOID Packet ); BOOLEAN RequestPort( __in_opt PPORT_CLIENT_DESCRIPTOR TargetInfo, __in USHORT MessageType, __in PVOID DataBuffer, __in ULONG DataSize, __inout_opt PVOID *ReplyPacketPtr ); // 根据LUID查找客户端信息 PPORT_CLIENT_DESCRIPTOR FindClient( __in PLUID ClientCookies ); // 根据客户端名称查找客户端 public: // 打开端口 BOOLEAN OpenPort( __in VOID ); // 关闭端口 BOOLEAN ClosePort( __in VOID ); // 挂起端口 ULONG SuspendPort( __in VOID ); // 恢复端口 ULONG ResumePort( __in VOID ); // 启动端口 VOID StartPort( __in VOID ); // 设置端口上下文 VOID SetContextPort( __in PVOID Context ); // 获取端口上下文 PVOID GetContextPort( __in VOID ); // 设置端口标志 ULONG SetPortFlags( __in ULONG NewFlags ); // 获取端口标志 ULONG GetPortFlags( __in VOID ); // 查询端口信息 BOOLEAN QueryInformationPort( __in PORT_INFORMATION_CLASS PortInformationClass, __in PVOID PortInfo, __in ULONG InfoSize, __out_opt PULONG BytesRequest ); // 设置端口信息 BOOLEAN SetInformationPort( __in PORT_INFORMATION_CLASS PortInformationClass, __in PVOID PortInfo, __in ULONG InfoSize ); // 关联一个端口到本端口 VOID AttachMasterPort( __in PCPort TargetPort ); // 关联一个属性端口到本端口 VOID AttachFastPort( __in PCPort TargetPort ); // 从本端口取消关联一个端口 VOID DetachMasterPort( __in PCPort TargetPort ); // 取消一个属性端口的关联 VOID DetachFastPort( __in PCPort TargetPort ); // 移除本端口的头部关联位置 PCPort RemoveFast( VOID ); // 移除属性端口的头部关联位置 PCPort RemoveMaster( VOID ); }; class CPortPool { public: CPortPool( USHORT MaxPorts = 1 ); // 构造函数 ~CPortPool(); // 析构函数 private: // 第一个被创建的Port PCPort m_pPortHead; // 第一个被创建的ClientPort PCPort m_pClientPortHead; // 第一个被创建的ServerPort; PCPort m_pServerPortHead; // 当前有多少个Ports LONG m_nNumberOfPorts; // 最大支持的端口数 LONG m_nMaxPorts; // 挂起线程 PVOID m_pSuspendThread; // 恢复线程 PVOID m_pResumeThread; private: // // PORT结束的信号事件 // 初始化为有信号,在创建第一个端口时设置为无信号 // 在关闭最后一个端口时为有信号 // ULONG_PTR m_pNoBody; // 操作各个链表的资源锁 ULONG_PTR m_pResource; private: // 初始化Native API virtual BOOLEAN InitializeApi(); public: // 对NoBody进行检测,等待NOBODY为信号状态 virtual VOID WaitEvent( ULONG_PTR Event ); // 设置端口池正在运行 virtual VOID SetEvent( ULONG_PTR Event ); // 设置端口池已空载 virtual VOID ClearEvent( ULONG_PTR Event ); // 测试事件是否有信号 virtual BOOLEAN ReadEvent( ULONG_PTR Event ); public: // 初始化端口池队列检测事件 virtual ULONG_PTR InitializeEvent( BOOLEAN AutoClear = TRUE ); // 反初始化... virtual VOID UninitializeEvent( ULONG_PTR Event ); // 初始化端口池链表锁定 virtual ULONG_PTR InitializeResource(); // 反初始化端口池链表锁 virtual VOID UninitializeResource( ULONG_PTR Lock); // 共享锁定对象 virtual VOID PushReadLock( ULONG_PTR Lock ); // 独占锁定 virtual VOID PushWriteLock( ULONG_PTR Lock ); // 解锁对象 virtual VOID PopLock( ULONG_PTR Lock ); public: // 申请一段内存 virtual PVOID AllocatePool( __in SIZE_T PoolSize ); // 释放申请的内存 virtual VOID FreePool( __in PVOID PoolBase ); // 挂起线程 ULONG SuspendThread( __in ULONG_PTR hThread ); // 还原线程 ULONG ResumeThread( __in ULONG_PTR hThread ); // 设置线程优先级 VOID SetThreadLevel( __in LONG Level ); //运行时环境 BOOLEAN IsWow64System( VOID ); public: // 创建线程 virtual HANDLE CreatePoolThread( __in PVOID ThreadRoutine, __in PVOID ThreadContext ); // // 转换句柄为对象 - 仅内核模式,用户模式为输入转输出返回 // 内核模式为创建对象,并且关闭句柄 // virtual ULONG_PTR GetObject( __in HANDLE hObjectHandle ); virtual HANDLE GetHandle( __in ULONG_PTR ObjectPtr ); // 关闭句柄 virtual VOID CloseHandle( __in HANDLE hObjectHandle ); // 关闭对象 - 仅内核模式 virtual VOID CloseObject( __in ULONG_PTR ObjectPtr ); public: // 创建GUID virtual BOOLEAN CreateUuid( __in GUID *Uid ); // 创建LUID virtual BOOLEAN CreateLocallyUniqueId( __in PLUID Luid ); public: // 创建服务端口 PCPort CreatePort( __in PVOID strPortName, __in PVOID SecurityDescriptor, __in ULONG Flags, __in ULONG MaxThreads, __in PVOID PortContext ); // 连接到指定的端口 PCPort ConnectPort( __in PVOID strPortName, __in ULONG Flags, __in ULONG MaxThreads, __in PVOID PortContext, __in BOOLEAN MustDoConnect ); // 摧毁端口或将指定的端口标识为正在删除 BOOLEAN DestroyPort( __in PCPort PortObject ); public: // 获取当前创建的端口数量 LONG GetNumberOfPort(); // 获取下一个端口 PCPort GetNextPort( __in PCPort PortObject ); // 获取下一个链接性质的端口 PCPort GetNextClient( __in PCPort PortObject ); // 获取下一个服务性质的端口 PCPort GetNextServer( __in PCPort PortObject ); public: // 类对象实体初始化 BOOLEAN ServiceInitSystem(); // 类对象反初始化 VOID ServiceCloseSystem(); // 端口对象实际关闭的回调通知// 同步计数器等操作 VOID PortDeletedCall( PCPort PortObject ); public: VOID PrintInfo( char *Buffer ); public: // 系统基本信息 SYSTEM_BASIC_INFORMATION m_tSystemBasicInfo; // 系统API表 SYSTEM_LPCAPI m_tSystemApis; // 是否在WOW64模式下 BOOLEAN m_bIsSystemWow64; public: PVOID operator new(size_t n) { return CServerAllocatePool( n ); } VOID operator delete(PVOID p) { CServerFreePool(p); } }; |
|
|
|
[求助]我晕,关于sfilter做文件夹保护的问题
听句劝,,那个IoCancelFileOpen 函数极度危险。尽量别用。 |
|
我晕,关于sfilter做文件夹保护的问题
首先.不推荐使用IoCancelFileOpen这个函数在CALL FileSystem后取消一个IRP。 我估计你的拦截位置肯定在IoCallDriver之后。也就是已经调用完文件系统了。 解决的办法也就是你流程的问题。 不应该在成功调用完文件系统后再失败一个请求,应该在此之前。 Ps: 文件夹的保护不一定要处理IRP_MJ_CREATE (至少在DEMO例子里可以这样说)。你完成可以针对文件夹属性本身下手 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值