admin管理员组

文章数量:1026125

I'm trying get page behind the login form with node.js request module.

'username' and 'password' are the names of fields of that form, 'login.php?do=login' is a form action. Doing that I don't get any headers and status codes but only [Error: no auth mechanism defined] message in console.

var request = require('request'),

var options = {
    'auth' : {
    'username':'name',
    'password':'pass'
},
url: '.php?do=login',
headers: {
    "User-Agent":"user-agent"
    }
}

request.post(options, function(err,res,body) {
if(err){
    console.log(err);
    return;
}
console.log('headers :', res.headers);
console.log('status code :', res.statusCode);
console.log($('body').text());
});

How could I investigate this? Which way it can be "sniffered" or something like that?

I'm trying get page behind the login form with node.js request module.

'username' and 'password' are the names of fields of that form, 'login.php?do=login' is a form action. Doing that I don't get any headers and status codes but only [Error: no auth mechanism defined] message in console.

var request = require('request'),

var options = {
    'auth' : {
    'username':'name',
    'password':'pass'
},
url: 'http://example./login.php?do=login',
headers: {
    "User-Agent":"user-agent"
    }
}

request.post(options, function(err,res,body) {
if(err){
    console.log(err);
    return;
}
console.log('headers :', res.headers);
console.log('status code :', res.statusCode);
console.log($('body').text());
});

How could I investigate this? Which way it can be "sniffered" or something like that?

Share Improve this question asked Dec 19, 2015 at 11:33 Pavel LPavel L 2,0673 gold badges18 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Request module's auth option is to handle basic access authentication. Most likely the page you try to load does not use BAA, but uses a simple form with a post request. To send form data with requests:

var options = {
    url: '...',
    headers: { ... },
    method: 'POST',
    formData: {
        'username':'name',
        'password':'pass'
    }
}

I'm trying get page behind the login form with node.js request module.

'username' and 'password' are the names of fields of that form, 'login.php?do=login' is a form action. Doing that I don't get any headers and status codes but only [Error: no auth mechanism defined] message in console.

var request = require('request'),

var options = {
    'auth' : {
    'username':'name',
    'password':'pass'
},
url: '.php?do=login',
headers: {
    "User-Agent":"user-agent"
    }
}

request.post(options, function(err,res,body) {
if(err){
    console.log(err);
    return;
}
console.log('headers :', res.headers);
console.log('status code :', res.statusCode);
console.log($('body').text());
});

How could I investigate this? Which way it can be "sniffered" or something like that?

I'm trying get page behind the login form with node.js request module.

'username' and 'password' are the names of fields of that form, 'login.php?do=login' is a form action. Doing that I don't get any headers and status codes but only [Error: no auth mechanism defined] message in console.

var request = require('request'),

var options = {
    'auth' : {
    'username':'name',
    'password':'pass'
},
url: 'http://example./login.php?do=login',
headers: {
    "User-Agent":"user-agent"
    }
}

request.post(options, function(err,res,body) {
if(err){
    console.log(err);
    return;
}
console.log('headers :', res.headers);
console.log('status code :', res.statusCode);
console.log($('body').text());
});

How could I investigate this? Which way it can be "sniffered" or something like that?

Share Improve this question asked Dec 19, 2015 at 11:33 Pavel LPavel L 2,0673 gold badges18 silver badges25 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 3

Request module's auth option is to handle basic access authentication. Most likely the page you try to load does not use BAA, but uses a simple form with a post request. To send form data with requests:

var options = {
    url: '...',
    headers: { ... },
    method: 'POST',
    formData: {
        'username':'name',
        'password':'pass'
    }
}

本文标签: javascriptnodejs form HTTP Authentication with request module failsStack Overflow