首 页 ┆ 源码下载 ┆ IT学院 ┆ 字体下载 ┆ 模板下载 ┆ 源码发布 ┆ 广告合作 ┆ 网站地图 ┆ 虚拟主机 ┆ 中文域名
► 设为首页
► 加入收藏
► 联系我们
源码下载 >> ASP源码 | PHP源码 | ASP.net源码 | JSP源码 | CGI源码 | VC/C++源码 | VB源码 | Delphi源码 | Flash源码
文章学院 >> 网络编程 | 网页设计 | 图形图象 | 数据库 | 服务器 | 网络媒体 | 网络安全 | 操作系统 | 办公软件 | 软件开发 | 黑客知识
字体下载 >> 精制字体 | 非英字体 | 艺术字体 | 著名字体 | 哥特式 | 简单字体 | 手写体 | 节假日 | 图案字体 | 精度像素 | 中文字体
模板下载 >> 企业门户 | 数码网络 | 休闲娱乐 | 影视音乐 | 旅游名胜 | 文化艺术 | 电子商务 | 个性展示 | 登陆导航 | Flash模板
►►您当前的位置:源码园 → IT学院 → 黑客知识 → 黑客进阶 → 文章内容

如何透过程序来控制 Windows (XP) 防火墙的开关--程序,控制,Windows,XP,防火墙,开关

作者:佚名  来源:网上收集  发布时间:2007-8-20 0:13:58

Dim objFW As Object   

    Set objFW = CreateObject("HNetCfg.FwMgr").LocalPolicy.CurrentProfile
    With objFW
        .FirewallEnabled = True ' True 开启 , False 关闭
             .ExceptionsNotAllowed = True ' [ 不允许例外 ] 选项 , True 勾 , 反之则不勾
    End With


或

procedure Set_WindowsXP_FireWall(Enable: boolean);
// 需引用 winsvc, shellapi
// Set_WindowsXP_FireWall(false); // 关闭Windows Xp 防火牆
//
var
  SCM, hService: LongWord;
  sStatus: TServiceStatus;
begin
  if Enable = false then
  begin
    SCM := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
    hService := OpenService(SCM, PChar('SharedAccess'), SERVICE_ALL_ACCESS);
    ControlService(hService, SERVICE_CONTROL_STOP, sStatus);
    CloseServiceHandle(hService);
  end;
end;

设定Port 的部份,不过还没测试!不过我还是希望写成简单形式的函数库呼叫方式,大家一起來测试吧!

出处:http://www-new.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22122056.html
Example of both adding and removing a tcp port from the globaly open ports list (in Windows XP firewall)

Regards,
Russell

// Include ActiveX and ComObj in uses clause (also Variants for D6 and up)

const
  NET_FW_PROFILE_DOMAIN      =  0;
  NET_FW_PROFILE_STANDARD    =  1;

const
  NET_FW_IP_PROTOCOL_TCP     = 6;
  NET_FW_IP_PROTOCOL_UDP     = 17;

const
  NET_FW_SCOPE_ALL           =  0;

const
  NET_FW_IP_VERSION_ANY      =  2;

implementation
{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var  ovMgr:         OleVariant;
     ovProfile:     OleVariant;
     ovPort:        OleVariant;
begin

  // Create manager interface
  ovMgr:=CreateOleObject('HNetCfg.FwMgr');

  // Resource protection
  try
     // Get local profile interface
     ovProfile:=ovMgr.LocalPolicy.CurrentProfile;
     // Resource protection
     try
        // Create new port interface
        ovPort:=CreateOleObject('HNetCfg.FwOpenPort');
        try
           // Set port properties
           ovPort.Port:=81;
           ovPort.Name:='Whatever';
           ovPort.Scope:=NET_FW_SCOPE_ALL;
           ovPort.IpVersion:=NET_FW_IP_VERSION_ANY;
           ovPort.Protocol:=NET_FW_IP_PROTOCOL_TCP;
           ovPort.Enabled:=True;
           // Resource protection
           try
              // Add to globally open ports
              ovProfile.GloballyOpenPorts.Add(ovPort);

              ////
              // .... do whatever ....
              ////

           finally
              // Remove from globally open ports
              ovProfile.GloballyOpenPorts.Remove(81, NET_FW_IP_PROTOCOL_TCP);
           end;
        finally
           // Release interface
           ovPort:=Unassigned;
        end;
     finally
        // Release interface
        ovProfile:=Unassigned;
     end;
  finally
     // Release interface
     ovMgr:=Unassigned;
  end;

end;

[] [返回上一页] [打 印]
  • 上一篇文章:黑客教你如何利用Excel剿灭DLL木马--黑客,利用,Excel,剿灭,DLL木马,木马
  • 下一篇文章:如何让你的程序安全通过windows防火墙--程序,安全通过,windows,防火墙

  • 相关文章:
  • 如何透过程序来控制 Windows (XP) 防火墙的开关--程...
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 源码发布
Copyright © 2003-2009 Ymyasp.Com. All Rights Reserved .
备案序号:粤ICP备07029071号