疧_╮線

文章 评论 浏览 28

疧_╮線 2022-05-04 13:55:50

个人理解中间人攻击利用的是客户端和服务端认证阶段syn等泄露,伪装成客户端和服务端进行身份认证,从而拿到了服务端的公钥。同时为了持续保持劫持客户端的状态,需要将服务端的报文解密之后,混淆自己的类似广告等信息到新报文(如果不返回部分服务端内容的报文很容易被客户端识别出来网站可能是被劫持了),因此需要伪装成服务端生成一个公钥和客户端持续地通信,通过两头骗的方式,将自己的报文神不知鬼不觉地推送到了客户端。(如有理解偏差,劳烦指点,谢谢)

第 91 题:介绍下 HTTPS 中间人攻击

疧_╮線 2022-05-04 13:55:45
const data = [{
    id: '1',
    name: 'test1',
    children: [
        {
            id: '11',
            name: 'test11',
            children: [
                {
                    id: '111',
                    name: 'test111'
                },
                {
                    id: '112',
                    name: 'test112'
                }
            ]
        },
        {
            id: '12',
            name: 'test12',
            children: [
                {
                    id: '121',
                    name: 'test121',
                    children: [
                        {
                            id: '1221',
                            name: 'test121',
                            children:[
                                {
                                    id:'12345'
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
},
{
    id:'1234',
    children:[
        {
            id:'567'
        }
    ]
}
]
const value = '112'
const fn = (value) => {
    let err = 'return start'
    let interim = JSON.parse(JSON.stringify(data))
    let result = []
    try {
        while (interim.length > 0) {
            let point = interim.pop() 
            let child = point.children
            let queue = child
            let cresult = []
            result.push(point.id)
            while (queue && queue.length > 0) {
                let cpoint = queue.pop()
                cresult.push(cpoint.id)
                if (!cpoint.children || cpoint.id == value) {
                    if (cresult.indexOf(value) > -1) {
                        queue.length = 0
                    } else {
                        cresult = []
                    }
                    continue
                }
                queue.push(...cpoint.children)
            }
            if (result.concat(cresult).indexOf(value) > -1) {
                result = result.concat(cresult)
                throw new Error(err)
            } else {
                result = []
            }
        }
    } catch (e) {
        if (e.message === err) {
            console.log(result.map(v => parseInt(v)))
            return result.map(v => parseInt(v))
        } else {
            throw e
        }
    }

}
fn(value) // 输出 [1, 11, 112]
fn('1234') // 输出 [1234]
fn('12345') // 输出 [1, 12, 121, 1221, 12345]

写法是深度优先, 增加了数据结构的深度与广度,能可以正确输出

第 92 题:已知数据格式,实现一个函数 fn 找出链条中所有的父级 id

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文