Jump to content
yo20063

Probleme cu router-ul vecinului

Recommended Posts

Deci daca din intamplare vecinul tau are un router la care i se mai blocheaza wireless dar internet-ul inca ii merge, procedam asa. Activam in routerul respectiv "remote management" pe un port nu foarte folosit(6666), apoi facem un cont pe no-ip pentru DDns pentru ca aproape sigur va avea ip dinamic. Aveti nevoie de un vps ceva, important este sa aiba acces la internet, si apoi de acolo folosim un headless browser numit phantomjs.Scopul este de a restarta router-ul si de a avea din nou wireless si internet.

Acuma scripturile de care avem nevoie:

router.js >> este folosit pentru a da restart remote la router(se adapteaza in functie de router), acest script ia un argument, si acela fiind ip-ul. Ex: phantomjs router.js ip

var web = "http://";
var address = ":9999/goform/formReboot";
var page = require('webpage').create(),
system = require('system'),
cronometru, address, ip;

if (system.args.length === 1) {
console.log('Usage: router.js <http://ip>');
phantom.exit();
}

cronometru = Date.now();
ip = system.args[1];
page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:16.0) Gecko/20121026 Firefox/32.0';
page.settings.userName = 'userRouter';
page.settings.password = 'parolaRouter';
page.open(web+ip+address, function(status) {
if (status !== 'success') {
console.log('Nu s-a putut incarca pagina!');
phantom.exit();
} else {
cronometru = Date.now() - cronometru;
console.log('Timp de incarcare ' + cronometru / 1000 + ' secunde!');
console.log('Gata!');
phantom.exit();
}
});

noip.js >> acest script este pentru a citi ip-ul de pe no-ip, si pentru a il adauga intr-un fisier .txt. Acesta este configurat pentru RDS, ip-uri ce incep cu "5.13"(modificati in functie de necesitati).

var page = require('webpage').create();

page.onConsoleMessage = function(msg) {
msg1 = msg.match(/5.13......../);
console.log(msg1);
var fs = require('fs');
try {
fs.write("/adresaFileSystem/ip.txt", msg1, 'w');
} catch(e) {
console.log(e);
}
};

page.open("https://www.noip.com/login?ref_url=/members/dns/", function(status){
page.evaluate(function(){
document.querySelector("input[name='username']").value = "userulTau";
document.querySelector("input[name='password']").value = "parolaTa";
document.querySelector("#clogs").submit();
});

setTimeout(function () {
page.evaluate(function(){
console.log(jQuery(".withright").text());
});
phantom.exit();
}, 5000);

});

restart.sh >> acesta este un script shell pentru a imbina cele 2 script-uri si pentru a executa toate operatiunile dintr-o singura comanda. Ex: ./restart.sh

phantomjs --ssl-protocol=any noip.js
sleep 10
phantomjs router.js "$(< ip.txt)"

Ca idee eu folosesc de pe telefon un tool ssh de pe care dau comanda. Spor

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...