GithubHelp home page GithubHelp logo

浅说 XSS 和 CSRF about blog HOT 18 OPEN

dwqs avatar dwqs commented on May 26, 2024 5
浅说 XSS 和 CSRF

from blog.

Comments (18)

dwqs avatar dwqs commented on May 26, 2024 21

@MillionQW 对于 xss 反射型攻击,主要是诱使用户点击恶意的链接或者访问存在漏洞的内容,可以有如下方式:

  1. 攻击者可以将恶意链接直接发送给受信任用户,发送的方式有很多种,比如 email, 网站的私信、评论等
  2. 攻击者可以购买存在漏洞网站的广告,将恶意链接插入在广告的链接中

from blog.

pinple avatar pinple commented on May 26, 2024 13

请问 crf 攻击中:您说

由于 Cookie 中包含了用户的认证信息,当用户访问攻击者准备的攻击环境时,攻击者就可以对服务器发起 CSRF 攻击。在这个攻击过程中,攻击者借助受害者的 Cookie 骗取服务器的信任,但并不能拿到 Cookie,也看不到 Cookie 的内容。

那攻击者怎么借助的 cookie ,他没有获取cookie ,而且攻击者的网站和服务端也是跨域的

攻击者的网站虽然是跨域的,但是他构造的链接是源网站的,跟源网站是同源的,所以能够携带cookie发起访问

from blog.

MillionQW avatar MillionQW commented on May 26, 2024 6

xss反射型攻击的恶意链接是放在哪里的呢?插入一个受信任网站骗取用户点击吗?如果是这样那么是如何插入的呢?

from blog.

GuYueJiaJie avatar GuYueJiaJie commented on May 26, 2024 6

请问 crf 攻击中:您说

由于 Cookie 中包含了用户的认证信息,当用户访问攻击者准备的攻击环境时,攻击者就可以对服务器发起 CSRF 攻击。在这个攻击过程中,攻击者借助受害者的 Cookie 骗取服务器的信任,但并不能拿到 Cookie,也看不到 Cookie 的内容。

那攻击者怎么借助的 cookie ,他没有获取cookie ,而且攻击者的网站和服务端也是跨域的

我也是困惑这个问题,查了很多东西,原来是自己对同源的理解不对,img标签是不受同源策略的限制,可以跨域加载资源的。
你可以自己写一段代码做个尝试,同样的情况下,你用AJAX去发送跨域请求会被拦截,但是img标签的src内置这段url并不会被拦截。
我是这么理解的

from blog.

lxow456 avatar lxow456 commented on May 26, 2024 2

 感觉反射型XSS攻击的例子不太对,反射型应该是在url中包含恶意代码,服务端未经检查就把url的参数直接拼接到HTML中,导致浏览器执行恶意代码。文中的例子服务端默认返回一段恶意攻击代码,这不是自己攻击自己么?
 个人理解,服务端代码应该类似这样。比如,当用户点击http://localhost:8001?user=<script>alert('xss')</script>,导致恶意代码被拼接到HTML中。

const http = require('http');
const url = require('url');
const querystring = require('querystring');

function handleReequest(req, res) {
    let arg = url.parse(req.url).query;
    let params = querystring.parse(arg);

    res.setHeader('Access-Control-Allow-Origin', '*');
    res.writeHead(200, {'Content-Type': 'text/html; charset=UTF-8'});
    res.write(`<div>Hi, ${params.user}</div>`);
    res.end();
}
const server = new http.Server();
server.listen(8001, '127.0.0.1');
server.on('request', handleReequest);

from blog.

qingmingsang avatar qingmingsang commented on May 26, 2024 1
  • 会话状态管理(如用户登录状态、购物车、游戏分数或其它需要记录的信息)
  • 个性化设置(如用户自定义设置、主题等)
  • 浏览器行为跟踪(如跟踪分析用户行为等)

from blog.

TyrellJing avatar TyrellJing commented on May 26, 2024 1

我的理解,反射型XSS攻击注入脚本是在有XSS漏洞的被攻击者的网站执行的吧,而不是攻击者网站执行。所以第一个例子感觉有点问题

from blog.

ceerqingting avatar ceerqingting commented on May 26, 2024

这样就产生了反射型 XSS 攻击。攻击者可以注入任意的恶意脚本进行攻击,可能注入恶作剧脚本,或者注入能获取用户隐私数据(如cookie)的脚本,这取决于攻击者的目的。

请问如何获取用户隐私数据?已经跳转到另一个攻击者域名下的网页了,上一个页面的数据怎么拿到?

from blog.

Debiancc avatar Debiancc commented on May 26, 2024

@ceerqingting 反射性xss是不会跳转到攻击者的页面的。

from blog.

hugeorange avatar hugeorange commented on May 26, 2024

请问 crf 攻击中:您说

由于 Cookie 中包含了用户的认证信息,当用户访问攻击者准备的攻击环境时,攻击者就可以对服务器发起 CSRF 攻击。在这个攻击过程中,攻击者借助受害者的 Cookie 骗取服务器的信任,但并不能拿到 Cookie,也看不到 Cookie 的内容。

那攻击者怎么借助的 cookie ,他没有获取cookie ,而且攻击者的网站和服务端也是跨域的

from blog.

ddzy avatar ddzy commented on May 26, 2024

xss反射型攻击的恶意链接是放在哪里的呢?插入一个受信任网站骗取用户点击吗?如果是这样那么是如何插入的呢?

本质上也是通过存储型 XSS 注入的吧

from blog.

lanshanmao avatar lanshanmao commented on May 26, 2024

xss反射型攻击的恶意链接是放在哪里的呢?插入一个受信任网站骗取用户点击吗?如果是这样那么是如何插入的呢?

配上网络劫持后这个就很容易了。运营商通过CDN劫持,返回一个中间服务器的ip,然后始终返回302,在浏览器访问对应CDN时重定向到对应广告地址,用iframe开发你访问的原有地址,投放一些广告按钮。或者通过劫持HTTP,过滤筛选html资源,然后插入攻击的DOM、JS,这种方式更暴力。

from blog.

njleonzhang avatar njleonzhang commented on May 26, 2024

基于DOM的这种,有什么实际例子呢?博主的举例感觉只能自己攻击自己。

from blog.

Bulandent avatar Bulandent commented on May 26, 2024

也可以看看这里 浏览器专题之安全篇

from blog.

MarvinXu avatar MarvinXu commented on May 26, 2024

csrf的例子在chrome里不行,非同源发送请求时不会带cookie

from blog.

nieshuangyan avatar nieshuangyan commented on May 26, 2024

from blog.

nieshuangyan avatar nieshuangyan commented on May 26, 2024

from blog.

Jetmet avatar Jetmet commented on May 26, 2024

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.