TorでIPアドレスを偽装して遊ぶ

Torを使ってみた。技術者倫理的には多分マナー違反なので用法用量を守って正しく遊ぼう。


TODO: 解説は後で書く

無限に投票し続けるコード

http://www.tuber-town.com/channel_detail/UCORW3zZTUVdVwlY5Mnk8q9Q.html

const tr = require('tor-request');
const child_process = require('child_process');

const url = "http://www.tuber-town.com/js/vote.php";
const cid = "UCORW3zZTUVdVwlY5Mnk8q9Q";
const password = "P@ssw0rd";

const headers = { "Content-Type": "application/x-www-form-urlencoded" };
const form = { val: 1, cid: cid };

const handleRequestCallback = (err, res, body) => {
    console.log("res.statusCode = " + res.statusCode);
};

const handleExecCallback = (error, stdout, stderr) => {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
        console.log('exec error: ' + error);
    }
};

const changeNewIp = () => {
    const signal = `echo -e 'AUTHENTICATE "${password}" \r\nsignal NEWNYM\r\nQUIT' | nc -v 127.0.0.1 9051`;
    child_process.exec(signal, { shell: '/bin/bash' }, handleExecCallback);
};

changeNewIp();
tr.request.post({ url, headers, form }, handleRequestCallback);