Node.js에 첫 번째 앱을 개발하고 있는데, 내가 작성한 예제가 내가 생각한 것을 보여주지 않아서 리스너가 어떻게 작동하는지 정확하게 이해하지 못한다고 생각합니다. 보여줄거야.Node.js : 리스너에 문제가 있습니다.
metasploit RPC 클라이언트 인 모듈 (msfnode)을 사용하여 웹 소켓을 통해 연결합니다.
나는 클래스를 만들어 생성자이 코드가 있습니다
this.clientmsf = new MetasploitClient({
login : options.login || 'myLogin',
password : options.password || 'myPassword'
});
this.clientmsf.on('connected',function(err,token) {
if (err) throw err;
});
그래서 내가 그 클래스의 다른 기능에서 개체 "clientmsf"을 사용할 수 있다고 생각하고 오류를 보여줍니다 ERROR_MESSAGE를 : '잘못된 인증 토큰'.
this.clientmsf.exec(['console.create'], function(err,r){
consoleID = r.id;
console.log(r);
});
나는 누군가가 나에게 도움이된다면 매우 감사 할 수 있도록 내가 Node.js를 모든 개념을 모르기 때문에 나는이 오류가 있다고 생각 :이 코드입니다.
대단히 감사합니다.
PD. 이 msfnode 라이브러리의 예입니다
var metasploitClient = require('metasploitJSClient');
var onConnect = function(err,token) {
if (err) {
console.log(err.error_message);
process.exit(0);
}
metasploitVersion();
}
var metasploitVersion = function() {
// Do not care about token, it will automaticaly
// be added as the second arguments
// The first value of the array is the function
// you want to call. Full list is available
// in metasploit remote api documentation
var args = ['core.version'];
client.exec(args,function(err,r) {
if (err) return console.log('Error: '+err);
console.log('-> Version: '+r);
});
}
var client = new metasploitClient({
login:'myLogin',
password:'myPassword',
});
client.on('connected',onConnect);
오류 :
{ error: true,
error_class: 'Msf::RPC::Exception',
error_string: 'Msf::RPC::Exception',
error_backtrace:
[ 'lib/msf/core/rpc/v10/service.rb:148:in `process\'',
'lib/msf/core/rpc/v10/service.rb:90:in `on_request_uri\'',
'lib/msf/core/rpc/v10/service.rb:72:in `block in start\'',
'lib/rex/proto/http/handler/proc.rb:38:in `call\'',
'lib/rex/proto/http/handler/proc.rb:38:in `on_request\'',
'lib/rex/proto/http/server.rb:363:in `dispatch_request\'',
'lib/rex/proto/http/server.rb:297:in `on_client_data\'',
'lib/rex/proto/http/server.rb:157:in `block in start\'',
'lib/rex/io/stream_server.rb:48:in `call\'',
'lib/rex/io/stream_server.rb:48:in `on_client_data\'',
'lib/rex/io/stream_server.rb:192:in `block in monitor_clients\'',
'lib/rex/io/stream_server.rb:190:in `each\'',
'lib/rex/io/stream_server.rb:190:in `monitor_clients\'',
'lib/rex/io/stream_server.rb:73:in `block in start\'',
'lib/rex/thread_factory.rb:22:in `call\'',
'lib/rex/thread_factory.rb:22:in `block in spawn\'',
'lib/msf/core/thread_manager.rb:100:in `call\'',
'lib/msf/core/thread_manager.rb:100:in `block in spawn\'' ],
error_message: 'Invalid Authentication Token',
error_code: 401 }
편집 2 : 이것은 내가 확인하는 코드입니다
:
clientmsf.on('connected',function(err,token) {
if (err) throw err;
var consoleID;
console.log('token:' + token);
// should have connected by now
clientmsf.exec(['console.list'], function(err,r){
consoleID = r;
console.log(r);
});
console.log (consoleID);
});
는 그리고이입니다 표시되는 내용 :
token:[object Object]
undefined
{ consoles: [ { id: '0', prompt: 'msf > ', busy: false } ] }
:
내가 좋아하는 뭔가를 제안하고있어? 실제로 컴퓨터에서 msfrpcd를 시작 했습니까? –
아니요, 오류는 Metasploit API에서 발생합니다. 연결하기 전에 "exec"가 실행되고 개체가 아직 토큰을 모르기 때문에 문제가 "경쟁 조건"이라고 생각할 수 있습니다. 전체 오류를 추가하겠습니다. 관심을 가져 주셔서 감사합니다. –