Skip to content

Commit

Permalink
Fixed huge security flaw, miner needs to be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
encloinc committed Jan 22, 2019
1 parent a8db033 commit 11cc714
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions miner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ require('http').createServer().listen(3000)

const config = JSON.parse(fs.readFileSync('config.json', 'utf8'))
console.log(config.username)
function hasher(){

function hasher(s){

return new Promise(function(resolve, reject){

const val = crypto.randomBytes(32).toString('hex')
const hash = crypto.createHash('sha256').update(val).digest('hex');
const hash = crypto.createHash('sha256').update(val + s).digest('hex');

resolve({'val': val, 'hash': hash})
resolve({'val': val + s, 'hash': hash})
});

}
Expand Down Expand Up @@ -65,6 +66,7 @@ function get(url){

let hashCount = 0;
let minerKey = null;
let salt = null;
let lastSecond = null;


Expand All @@ -86,12 +88,15 @@ async function loop(){
if (minerKey != serverConfig.key){

minerKey = serverConfig.key;

salt = serverConfig.salt

console.log(`# Block key integrity nullified! New key ${minerKey} registered.`)

}
}

let hashObject = await hasher();
let hashObject = await hasher(salt);

hashCount++;

Expand All @@ -113,13 +118,19 @@ async function loop(){

minerKey = serverConfig.key;

salt = serverConfig.salt



}else{

console.log(`# An error occured with the provided hash, mining has continued.`)

minerKey = serverConfig.key;

salt = serverConfig.salt


}


Expand Down

0 comments on commit 11cc714

Please sign in to comment.