1.4.1HTML基础

目录

什么是 HTML

HTML 是用来描述网页的一种语言。

  • HTML 指的是超文本标记语言 (Hyper Text Markup Language)

  • HTML 不是一种编程语言,而是一种标记语言 (Markup language)

  • 标记语言是一套标记标签 (Markup tag)

  • HTML 使用标记标签来描述网页

总的来说,HTML 本身不具有编程逻辑,它是一种将格式与内容分离编排的语言。

用户在浏览器端解析的网页大都是由 HTML 语言组成。

由于是通过浏览器动态解析,因此可以使用普通文本编辑器来编写 HTML。

HTML 中的标签与元素

标签和元素共同构成了 HTML 多样的格式和丰富的功能。

HTML 元素以开始标签起始,以结束标签终止。元素处于开始标签与结束标签之间,标签之间可以嵌套,一个典型的 HTML 文档如下:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n29" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><html>

<body>

Hello World

</body>
</html></pre>

信息隐藏

HTML 中的部分标签用于元信息展示、注释等功能,并不用于内容的显示。另一方面,一些属性具有修改浏览器显示样式的功能,在 CTF 中常被用来进行信息隐藏。

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n32" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">标签
,定义注释
<!DOCTYPE>,定义文档类型
<head>,定义关于文档的信息
<meta>,定义关于HTML文档的元信息
<iframe>,定义内联框架

属性
hidden,隐藏元素</pre>

XSS

关于 XSS 漏洞的详细介绍见 1.4.5 节的 OWASP Top Ten Project 漏洞基础。导致 XSS 漏洞的原因是嵌入在 HTML 中的其它动态语言,但是 HTML 为恶意注入提供了输入口。

常见与 XSS 相关的标签或属性如下:

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n36" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; border: 1px solid rgb(231, 234, 237); border-radius: 3px; padding: 8px 4px 6px; margin-bottom: 15px; margin-top: 15px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"><script>,定义客户端脚本
<img src=>,规定显示图像的 URL
<body background=>,规定文档背景图像URL
<body onload=>,body标签的事件属性
<input onfocus= autofocus>,form表单的事件属性
<button onclick=>,击键的事件属性
<link href=>,定义外部资源链接
<object data=>,定义引用对象数据的 URL
<svg onload=>,定义SVG资源引用</pre>

HTML 编码

HTML 编码是一种用于表示问题字符已将其安全并入 HTML 文档的方案。HTML 定义了大量 HTML 实体来表示特殊的字符。

HTML 编码 特殊字符
&quot "
&apos '
&amp &
&lt <
&gt >

此外,任何字符都可以使用它的十进制或十六进制的ASCII码进行HTML编码,例如:

HTML 编码 特殊字符
&#34 "
&#39 '
&#x22 "
&#x27 '

HTML5 新特性

其实 HTML5 已经不新了,之所以还会在这里提到 HTML5,是因为更强大的功能会带来更多意想不到的问题。

HTML5 的一些新特性:

  • 新的语义元素标签

  • 新的表单控件

  • 强大的图像支持

  • 强大的多媒体支持

  • 强大的 API

参考资料

来源:GitHub

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 第七章,微习惯策略的八大规则 如果发现自己用微习惯很难取得进步,很可能是因为你违背了其中一条规则。 ...
    曾小雄_xwx阅读 233评论 0 0
  • 原文: Dyanmic Proxy Classes 介绍 一个动态代理类是实现了多个接口存在于运行时的类,这样,一...
    半黑月缺阅读 986评论 0 0
  • 5月20日 个人也存在和成子伙伴类似的问题 昨天看到教练对成子伙伴问题的解答,自己有了一些新的思考。 目前我的问题...
    Eric刘佳阅读 117评论 0 1
  • 姓名 冯二龙 企业名称 宁波惠康国际工业有限公司 组别 444期 努力一组 【日精进打卡第188天】 【知~学习】...
    冯二龙阅读 188评论 0 0