http://bbs.hikemobile.com/thread-1644-1-1.html
http://5e76.net/show-2409.html
http://www.myexception.cn/open-source/429531.html
http://www.eoeandroid.com/thread-245052-1-1.html
http://blog.csdn.net/Zengyangtech/article/details/5579311
https://code.google.com/p/droidwall/
http://www.oschina.net/p/droidwall/similar_projects?lang=0&sort=view&p=16
http://smallnopoint.iteye.com/blog/1465138
private static boolean applyIptablesRulesImpl(Context ctx, List<Integer> uidsWifi, List<Integer> uids3g, boolean showErrors) { if (ctx == null) { return false; } assertBinaries(ctx, showErrors); final String ITFS_WIFI[] = { "tiwlan+", "wlan+", "eth+", "ra+", "mlan+" }; final String ITFS_3G[] = { "rmnet+", "pdp+", "ppp+", "uwbr+", "wimax+", "vsnet+", "ccmni+", "usb+", "qmi+", "ccinet+" }; final StringBuilder script = new StringBuilder(); try { int code; script.append(String.format("export LD_LIBRARY_PATH=%s\n", System .getenv("LD_LIBRARY_PATH"))); script.append(scriptHeader(ctx)); script.append("" + "$IPTABLES --version\n" + "# Create the DROIDWALL chains if necessary\n" + "$IPTABLES --new DROIDWALL\n" + "$IPTABLES --new DROIDWALL_MOBILE\n" + "$IPTABLES --new DROIDWALL_WIFI\n" + "$IPTABLES --new DROIDWALL_REJECT\n" + "# Add DROIDWALL chain to OUTPUT chain if necessary\n" + "$IPTABLES -D OUTPUT -j DROIDWALL\n" + "$IPTABLES -I OUTPUT -j DROIDWALL\n" + "$IPTABLES -F DROIDWALL || exit 7\n" + "$IPTABLES -F DROIDWALL_MOBILE || exit 8\n" + "$IPTABLES -F DROIDWALL_WIFI || exit 9\n" + "$IPTABLES -F DROIDWALL_REJECT || exit 10\n" + ""); script.append("" + "# Create the reject rule (log disabled)\n" + "$IPTABLES -A DROIDWALL_REJECT -j REJECT || exit 11\n" + ""); script.append("# Main rules (per interface)\n"); for (final String itf : ITFS_3G) { script.append("$IPTABLES -A DROIDWALL -o ").append(itf).append( " -j DROIDWALL_MOBILE || exit\n"); } for (final String itf : ITFS_WIFI) { script.append("$IPTABLES -A DROIDWALL -o ").append(itf).append( " -j DROIDWALL_WIFI || exit\n"); } script.append("# Filtering rules\n"); final String targetRule = "DROIDWALL_REJECT"; // final boolean any_3g = uids3g.indexOf(SPECIAL_UID_ANY) >= 0; // final boolean any_wifi = uidsWifi.indexOf(SPECIAL_UID_ANY) >= 0; if (any_3g) { script.append("$IPTABLES -A DROIDWALL_MOBILE -j ").append( targetRule).append(" || exit\n"); } else { /* release/block individual applications on this interface */ for (final Integer uid : uids3g) { if (uid >= 0) script .append( "$IPTABLES -A DROIDWALL_MOBILE -m owner --uid-owner ") .append(uid).append(" -j ").append(targetRule) .append(" || exit\n"); } } if (any_wifi) { script.append("$IPTABLES -A DROIDWALL_WIFI -j ").append( targetRule).append(" || exit\n"); } else { /* release/block individual applications on this interface */ for (final Integer uid : uidsWifi) { if (uid >= 0) script .append( "$IPTABLES -A DROIDWALL_WIFI -m owner --uid-owner ") .append(uid).append(" -j ").append(targetRule) .append(" || exit\n"); } } if (uids3g.indexOf(SPECIAL_UID_KERNEL) >= 0) { script.append("# hack to BLOCK kernel packets on black-list\n"); script .append("$IPTABLES -A DROIDWALL_MOBILE -m owner --uid-owner 0:999999999 -j RETURN || exit\n"); script .append("$IPTABLES -A DROIDWALL_MOBILE -j DROIDWALL_REJECT || exit\n"); } if (uidsWifi.indexOf(SPECIAL_UID_KERNEL) >= 0) { script.append("# hack to BLOCK kernel packets on black-list\n"); script .append("$IPTABLES -A DROIDWALL_WIFI -m owner --uid-owner 0:999999999 -j RETURN || exit\n"); script .append("$IPTABLES -A DROIDWALL_WIFI -j DROIDWALL_REJECT || exit\n"); } final StringBuilder res = new StringBuilder(); code = runScriptAsRoot(ctx, script.toString(), res); if (showErrors && code != 0) { // String msg = res.toString(); // Log.e("DroidWall", msg); // Remove unnecessary help message from output // if // (msg.indexOf("\nTry `iptables -h' or 'iptables --help' for more information.") // != -1) { // msg = // msg.replace("\nTry `iptables -h' or 'iptables --help' for more information.", // ""); // } // alert(ctx, "Error applying iptables rules. Exit code: " + // code + "\n\n" + msg.trim()); Toast.makeText(ctx, ctx.getString(R.string.kn_traffic_item_info_no_root), 300).show(); System.out.println("applyIptablesRulesImpl"); } else { return true; } } catch (Exception e) { if (showErrors) Toast.makeText(ctx, ctx.getString(R.string.kn_traffic_item_info_no_root), 300).show(); System.out.println("applyIptablesRulesImpl"); } return false; }
相关推荐
Iptables图形管理工具的设计与实现论文.pdf
JSP基于Iptables图形管理工具的设计与实现(源代码+论文).zip
jsp毕业设计——JSP基于Iptables图形管理工具的设计与实现(源代码+论文).zip
毕业论文设计-IT计算机-JSP基于Iptables图形管理工具的设计与实现(源代码+论文).zip
Linux的iptables的教程,写的不错,希望对大家学习有帮助
不错的适合练手、课程设计、毕业设计的JSP项目源码:JSP基于Iptables图形管理工具的设计与实现(源代码+论文).rar不错的适合练手、课程设计、毕业设计的JSP项目源码:JSP基于Iptables图形管理工具的设计与实现(源代码...
java基于Iptables图形管理工具的设计与实现源码java基于Iptables图形管理工具的设计与实现源码java基于Iptables图形管理工具的设计与实现源码java基于Iptables图形管理工具的设计与实现源码java基于Iptables图形管理...
iptables源码 iptables工具
iptables 防火墙 linux
Iptables图形管理工具的设计与实现 Netfilter/Iptables防火墙是Linux平台下的包过滤防火墙,Iptables防火墙不仅提供了强大的数据包过滤能力,而且还提供转发,NAT映射等功能,是个人及企业级Linux用户构建网络安全...
本资料包名为“JSP基于Iptables图形管理工具的设计与实现(源代码+论文).rar”,是一个针对计算机专业的学习资源,主要包含了一个基于Java Server Pages(JSP)技术的Iptables图形管理工具的完整开发源代码以及相关的...
本系统主要由系统JSP前台页面,Java Bean,Java源代码,Linux下Iptables防火墙配置文件组成。JSP前台做用户交互及数据传递操作;Java Bean可以提高代码的利用率,它封装了一些本系统重复使用的Java源代码,如:读...
iptables配置
iptables建立NATiptables建立NATiptables建立NATiptables建立NATiptables建立NATiptables建立NAT
Iptables图形管理工具的设计与实现
本文设计并实现了一个基于Web的Iptables图形管理工具,通过友好的配置界面,简化了Iptables防火墙的管理配置程序,更方便用户对Iptables防火墙的使用。 本工具采用Browser/Server模式,通过Web配置界面,用户可远程...
iptables和nat的配置与管理,对于iptables的配置与管理都有一定的基础。
iptables是一个管理netfilter的工具。 多个连续IP操作 1、拆分成多条命令运行 iptables -A INPUT 192.168.122.2 -j ACCEPT iptables -A INPUT 192.168.122.3 -j ACCEPT iptables -A INPUT 192.168.122.4 -j ACCEPT ...
iptables防火墙iptables防火墙iptables防火墙