对于想了解使用ngBindHtml注入脚本标签的读者,本文将是一篇不可错过的文章,我们将详细介绍javascript脚本语言嵌入html页面中需要什么标记,并且为您提供关于(ZZ)SQL注入分析(手动
对于想了解使用ngBindHtml注入脚本标签的读者,本文将是一篇不可错过的文章,我们将详细介绍javascript脚本语言嵌入html页面中需要什么标记,并且为您提供关于(ZZ)SQL注入分析(手动注入检测) and 手动注入脚本命令精华版、Angular 学习系列 - - ngApp、ngBind、ngBindHtml、ngNonBindable、AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用、angularjs ng-bind-html 指令 对html标签转译的有价值信息。
本文目录一览:- 使用ngBindHtml注入脚本标签(javascript脚本语言嵌入html页面中需要什么标记)
- (ZZ)SQL注入分析(手动注入检测) and 手动注入脚本命令精华版
- Angular 学习系列 - - ngApp、ngBind、ngBindHtml、ngNonBindable
- AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用
- angularjs ng-bind-html 指令 对html标签转译
使用ngBindHtml注入脚本标签(javascript脚本语言嵌入html页面中需要什么标记)
我有外部API数据,这是用户生成的内容。客户希望使用此提要动态更新自己的站点,包括使用JavaScript的能力。
<div ng-bind-html="post.content"></div>
将显示任何HTML或CSS但不适用于JavaScript的内容:
"content":"<div>Hello Stack</div><script>alert(''whats up?'');</script>"
我已经尝试过包括ngSanitize
以及使用ng-bind-html-unsafe
。
没有骰子。
答案1
小编典典您必须包括jQuery才能正常工作。
plunkr示例:http
://plnkr.co/edit/zEXXCB459Tp25VJiyyZb?p=preview
(ZZ)SQL注入分析(手动注入检测) and 手动注入脚本命令精华版
入侵过程主要包括以下几个步骤:1、测试ASP系统是否有注入漏洞;2、获取数据库表名;3、测试管理 员ID;4、测试管理员用户名长度和管理员密码长度;5、从高到低依次测试出管理员用户名和密码。 测试ASP系统是否有注入漏洞 这很关键,没有漏洞的网站你就别瞎忙了。方法也很简单,打开ASP网 站一个分类网页,如盗帅下载系统中的/list.asp?id=11和逸风系统中的/class.asp?id=18等,在其后面 分别加入and 1=1 和and 1=2进行测试,具体形式为 /list.asp?id=11 and 1=1 (以下各测试语句都用同样的形式加入,TTY将不再说明) 注意空格。在IE浏览器里空格将自动转换为%20。如果输入and 1=1 能正常显示原页面内容,输入 and 1=2不能正常显示原页面内容,就说明有SQL注入漏洞了,可以进行下面的步骤。 测试数据库表名 一个数据库里一般有很多表,我们要找到存放管理员用户名和密码的表。对于已知 类型的ASP系统来说,可以到网上去下载一个压缩包,用辅臣数据库浏览器打开数据库查看就可以了,一 般都是admin。无论是否知道表名,都加以下语句测试一下: and 0<>(select count(*) from admin) 如果能返回正常页面,说明表名就是admin,否则继续换表名测试。; 测试管理员ID 一般网站的管理员不是很多的,ID也不是很大,依次用1、2、3 … … 测试,很快 就能测到,具体测试语句为: and (select count(*) from admin where id=1) 变换最后的数字1进行测试,直到能正常返回原页面为止。 测试管理员用户名长度和管理员密码长度 这很重要,不知道用户名和密码是几位数下面的工作就无法 进行。 用户名长度: and (select count(*) from admin where id=5 and len(username)=4) [...]Angular 学习系列 - - ngApp、ngBind、ngBindHtml、ngNonBindable

ngApp
使用这个指令自动启动一个 AngularJS 应用。ngApp 指令指定了应用程序的根节点,通常会将 ngApp 放置在网页的根节点如 <body> 或 < html > 标签的。
格式:ng-app=”value”
value:当前应用程序模块的名称。
使用代码:
<div ng-app="Demo"></div>
需要注意的是:1.3 版本以前的是可以不设置值的,1.3 只后就是必需的了,而且该模块还得被定义,网上很多部分的教程是 1.3 版本之前的,所以大家在用的时候注意下版本问题。
这个指令其实他就是告诉 Angular,应用程序的根节点在我这,并且在 1.3 版本后告诉 Angular 你该执行的模块的名称是什么。
ngBind
ngBind 告诉 Angular 去用指定的表达式的值去替换指定元素内的文本内容,并且当表达式的值变化时让文本内容也跟着变化。
格式:ng-bind=”value”
value:表达式 / 值
使用代码:
<div ng-app="Demo" ng-controller="testCtrl as ctrl"> <span ng-bind="ctrl.hello"></span> <span class="ng-bind:ctrl.world"></span><br /> <span ng-bind="ctrl.hi()"></span>
</div>
(function () {
angular.module("Demo", [])
.controller("testCtrl", testCtrl);function testCtrl() {this.hello = "Hello";this.world = "World";this.hi = function () {return "Hi!";
};
};
}());
ngBind 相对于 {{}} 形式绑定的好处就是当你快速刷新或者打开页面那瞬间,不会将绑定代码暴露;相对与 {{}} 形式来绑定的坏处就是需要载体。所以根据需求来选择用哪个也行,或者 ng-cloak 避免闪烁。
这个不用过多说明,直接就能看得出这是个绑定数据的指令。
ngBindHtml
创建一个将 innerHTML 函数所执行的结果绑定到页面指定元素的绑定方式。
格式: ng-bind-html=”value”
value: 将会被 html 转义并且绑定的字符串。
配合 $sce 使用:
.hello { width: 300px; height: 300px; background: #ccc; color: red; }
<div ng-app="Demo" ng-controller="testCtrl as ctrl"><div ng-bind-html="ctrl.htmlText"></div>
</div>
(function () {
angular.module("Demo", [])
.controller("testCtrl", ["$sce",testCtrl]);function testCtrl($sce) { this.htmlText = ''<div >Hello Wrold</div>'';// Error: [$sce:unsafe]Attempting to use an unsafe value in a safe context. this.htmlText = $sce.trustAsHtml(this.htmlText); // ok 能正常输出html了 };
}());
引入 angular-ngSanitize.js 使用:
<div ng-app="Demo" ng-controller="testCtrl as ctrl"> <div ng-bind-html="ctrl.htmlValue"></div>
</div>
(function () {
angular.module("Demo", ["ngSanitize"])
.controller("testCtrl", [testCtrl]);function testCtrl() { this.htmlText = ''<div >Hello Wrold</div>'';
};
}());
ngNonBindable
这个指令告诉 Angular 不要去对当前的 Dom 元素进行编译或者绑定值。当元素的内容需要展示 Angular 指令和绑定但是又得让 Angular 忽略他的执行的时候,这个指令就有用了。比如你有个网站,需要展示代码片段的时候。
格式:ng-non-bindable
使用代码:
<span ng-bind="greeting"></span>
<span ng-bind="greeting" ng-non-bindable></span>
<span ng-non-bindable >{{greeting}}</span>
AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用
这基本上是我在阅读的内容中使用的格式:
var myApp = angular.module('myApp',[]); function myController($scope,$sce){ $scope.myHtml = $sce.trustAsHtml($scope.sourceText); }
HTML:
<html ng-app="myApp"> <head> <script data-require="angular.js@1.2.0-rc3" data-semver="1.2.0-rc3-nonmin" src="http://code.angularjs.org/1.2.0-rc.3/angular.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body> <div ng-controller="myController"> <textarea ng-model="sourceText"></textarea> <div ng-bind-html="myHtml"></div> </div> </body> </html>
我认为这将是直截了当的,但我一定是错的,错过了一些东西.
我把这个简单的例子放到了Plunker:http://plnkr.co/edit/ZX4dONBlzv1X8BcO1IBV?p=preview
解决方法
http://plnkr.co/edit/IZkzsuKHvbYiyV07CGqp
// would strongly suggest including sanitize in your scripts and injecting it // into your app here to prevent "unsafe as safe" errors var myApp = angular.module('myApp',['ngSanitize']); myApp.controller('myController',['$scope','$sce',function myController($scope,$sce){ $scope.myHtml = "initial"; //not needed,for testing $scope.changeText = function() { $scope.myHtml = $sce.trustAsHtml($scope.sourceText); } }]);
HTML:
<head> <script data-require="angular.js@1.2.0-rc3" data-semver="1.2.0-rc3-nonmin" src="http://code.angularjs.org/1.2.0-rc.3/angular.js"></script> <script src="http://code.angularjs.org/1.2.0-rc.3/angular-sanitize.min.js"></script> <link rel="stylesheet" href="style.css" /> <script src="script.js"></script> </head> <body> <div ng-controller="myController"> <textarea ng-model="sourceText" ng-change="changeText()"></textarea> <div ng-bind-html="myHtml"></div> </div> </body> </html>
angularjs ng-bind-html 指令 对html标签转译
文章参考
http://www.tuicool.com/articles/2eIrIz
http://www.runoob.com/angularjs/ng-ng-bind-html.html
在工作中遇到问题:用户在后台添加一篇新闻,在数据库中存储的是HTML代码,从数据库查询出来之后结果把HTML代码显示出来。
解决办法:使用ng-bind-html 指令,能够对HTML代码的标签转译,在浏览器中显示
ng-bind-html 指令会自动过滤掉标签内的样式?
所谓sce即“Strict Contextual Escaping”的缩写。翻译成中文就是“严格的上下文模式”也可以理解为安全绑定吧。
$sce干的事情来看就是将语境中存在的跨站攻击的风险给干掉.
我们返回的内容中包含一系列的html标记,它可以通过使用$sce.trustAsHtml()。该方法将值转换为特权所接受并能安全地使用“ng-bind-html”。所以,我们必须在我们的控制器中引入$sce服务.
代码如下
【1】angular源码分析:angular中入境检察官$sce
【2】野兽的 Angular 学习 - -sce和sce和sceDelegate
【3】$sce官方手册
今天关于使用ngBindHtml注入脚本标签和javascript脚本语言嵌入html页面中需要什么标记的讲解已经结束,谢谢您的阅读,如果想了解更多关于(ZZ)SQL注入分析(手动注入检测) and 手动注入脚本命令精华版、Angular 学习系列 - - ngApp、ngBind、ngBindHtml、ngNonBindable、AngularJS 1.2.0 ngBindHtml和trustAsHtml不能与ngModel一起使用、angularjs ng-bind-html 指令 对html标签转译的相关知识,请在本站搜索。
本文标签: