Last active
April 30, 2023 04:29
-
-
Save konsumer/23f13962e9a0478a82b4c28a2b8cd26c to your computer and use it in GitHub Desktop.
Tricks with your save-file in Hacknet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this will make a note (to be re-inserted in your save-file) for all the passwords and firewall-codes | |
// your save file here | |
var fname = '/Users/konsumer/Library/Application Support/Hacknet/Accounts/save_konsumer.xml' | |
// var fname = 'C:\\Program Files (x86)\\Steam\\userdata\\93631843\\365450\\remote\\save_konsumer.xml' | |
var fs = require('fs') | |
var xml2js = require('xml2js') | |
var parser = new xml2js.Parser() | |
fs.readFile(fname, function (err, data) { | |
parser.parseString(data, function (err, result) { | |
var out = '' | |
result.HacknetSave.NetworkMap[0].network[0].computer.map(c => { | |
var ret = c['$'] | |
if (c.firewall) { | |
ret.firewall = c.firewall[0]['$'].solution | |
} | |
ret.users = c.users[0].user.map(u => [u['$'].name, u['$'].pass].join('|')).join(', ') | |
return ret | |
}) | |
.forEach(c => { | |
out += ` | |
---------- | |
name: ${c.name} | |
ip: ${c.ip} | |
users: ${c.users} | |
firewall: ${c.firewall}` | |
}) | |
console.log(`<file name="Notes.txt">${out}</file>`) | |
}) | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// anytime the save-file changes, resave it with all server passwords known | |
var fs = require('fs') | |
var chokidar = require('chokidar') | |
// your save file here | |
var fname = '/Users/konsumer/Library/Application Support/Hacknet/Accounts/save_konsumer.xml' | |
// var fname = 'C:\\Program Files (x86)\\Steam\\userdata\\93631843\\365450\\remote\\save_konsumer.xml' | |
var watcher = chokidar.watch(fname, {persistent: true, awaitWriteFinish: true }) | |
watcher.on('change', path => { | |
var contents = fs.readFileSync(fname).toString().replace(/known="False"/g, 'known="True"') | |
fs.writeFileSync(fname, contents) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment