Przejdź do treści
Bity zamieszek

Bity zamieszek

  • Dom
  • Aktualności
  • Przewodniki
  • Przewodniki wideo
  • Opis zmian
  • Zgłoś nadużycie
  • Przełącz formularz wyszukiwania
Bitburnera

Bitburnera – Automatyzacja dostępnych serwerów Nuke

Wysłany dnia 01/20/2022 Przez koutoftimer Brak komentarzy NA Bitburnera – Automatyzacja dostępnych serwerów Nuke
  • Tytuł: Bitburnera
  • Data wydania:
  • Wywoływacz:
  • Wydawca:
Informacje o Bitburner są nadal niekompletne. Pomóż nam wypełnić szczegóły gry za pomocą tego formularz kontaktowy.

For those who are looking for something useful out here. I hope you will not blindly copy/paste it in your game but will find out a few new ideas for structuring your code.

Also I can see several rooms for improvements:

  • Create supervisor process that will watch for new available nodes and nuke them for you, so you need to execute something like `run nuke-all-supervisor.js` only once per installing augments.
  • Another room for improvement is installing backdoor. It needs you to progress in the game a bit though, in order to unlock the required API.

Stosowanie

run nuke-all.js

Nukes all the servers you have to meet hacking level. As simple as it looks. No further attention is required. Branding image contains my very first step after installing augments.

Memory consumption

As you can see below, memory consumption for this script is below 8G, which means you can use it at early game. I only now have recognized that the getPurchasedServers function takes half of RAM and it doesn’t really require it, so you can improve memory consumption for your needs.

[home ~/]> mem nuke-all.js 
This script requires 4.75GB of RAM to run for 1 nitka(S)
  2.25GB | getPurchasedServers (fn)
  1.60GB | baseCost (różne)
200.00MB | skandować (fn)
100.00MB | getServerRequiredHackingLevel (fn)
100.00MB | getServerNumPortsRequired (fn)
100.00MB | fileExists (fn)
 50.00MB | hasRootAccess (fn)
 50.00MB | getHackingLevel (fn)
 50.00MB | nuke (fn)
 50.00MB | brutessh (fn)
 50.00MB | ftpcrack (fn)
 50.00MB | relaysmtp (fn)
 50.00MB | httpworm (fn)
 50.00MB | sqlinject (fn)

Scripts

nuke-all.js – Executable script uses library functions to clarify and simplify behavior.

import { acquireRootAccess, buildNetwork, networkToServerList } from 'utils'

/** @param {Ns} ns **/
Eksportuj funkcja asynchroniczna główna(ns) {
	const network = buildNetwork(ns)
	const networkList = networkToServerList(network)
	const notNuked = networkList.filter((serwer) => !Ns. HasrootAccess(serwer))
	Do (const host of notNuked) {
		acquireRootAccess(ns, host)
	}

	ns.toast(`${ns.getScriptName()} done`)
}

utils.js – Set of utility/library functions

/**
 * Returns list of callables you can use to open ports on specified server.
 * 
 * @param {Ns} ns
 * @returns {Array.<(serwer: string): void>} 
 */
export function getAvailableMethods(ns) {
	const methods = []
	Do (const [metoda, plik] z [
	 	[ns.brutessh, 'BruteSSH.exe'],
		[ns.ftpcrack, 'FTPCrack.exe'],
		[ns.relaysmtp, 'relaySMTP.exe'],
		[ns.httpworm, 'HTTPWorm.exe'],
		[ns.sqlinject, 'SQLInject.exe']
	]) {
		Jeśli (Ns.fileExists(plik)) {
			methods.push(metoda)
		}
	}
	return methods
}

/**
 * Try to acquire Root access to the target server.
 * 
 * @param {Ns} ns
 * @param {string} target Server name to get Root access to.
 * @returns {boolean} Was attempt successful or not.
 */
export function acquireRootAccess(ns, target) {
	Jeśli (!Ns. HasrootAccess(target)) {
		Jeśli (ns.getHackingLevel() < ns.getServerRequiredHackingLevel(target)) {
			ns.print(`ERROR: Not enough hacking level for ${target}`)
			return false
		}
		const methods = getAvailableMethods(ns);
		Jeśli (methods.length < ns.getServerNumPortsRequired(target)) {
			ns.print(`ERROR: Not enough breaking methods for ${target}`)
			return false
		}
		Do (const method of methods) {
			metoda(target)
		}
		Ns.wull(target)
	}
	return true
}

/**
 * Simple directed graph representation of a network, which consists of
 * it's name and list of child nodes.
 * 
 * @typedef {{nazwa: string, dzieci: NetworkNode[]}} NetworkNode
 */

/**
 * Returns network representation in form of directed graph using DFS.
 * The most common case is that you do not care about network nodes you can 
 * not nuke right now. That is why this function only returns nodes for 
 * which you have meet hacking level.
 * 
 * @param {Ns} ns
 * @param {string} name Name of the network node/server we are working with.
 * @param {string[]} used List of nodes we have already processed.
 * @returns {NetworkNode} Directed graph
 */
export function buildNetwork(ns, name = 'home', used = []) {
	used.push(nazwa)
	const node = { nazwa: nazwa, dzieci: [] }
	const serverList = ns.getPurchasedServers()
	Do (const child of ns.scan(node.name)) {
		Jeśli (ns.getServerRequiredHackingLevel(child) <= ns.getHackingLevel() && 
		    !used.includes(child) && !serverList.includes(child)
		) {
			node.children.push(buildNetwork(ns, child, used))
		}
	}
	return node
}

/**
 * It is not strictly required to works with network in form of a graph. 
 * Sometimes we just have to know what nodes are present. This is what 
 * this function is for: to convert data structure format from directed 
 * graph to plain list of network's nodes.
 * 
 * @param {NetworkNode} węzeł
 * @returns {string[]} List of all servers in the network.
 */
export function networkToServerList(węzeł) {
	const list = [node.name]
	Jeśli (node.children.length) {
		Do (const child of node.children) {
			list.push(...networkToServerList(child))
		}
	}
	return list
}

To wszystko, co dzisiaj udostępniamy w tym celu Bitburnera przewodnik. Ten przewodnik został pierwotnie stworzony i napisany przez koutoftimer. Na wypadek, gdybyśmy nie zaktualizowali tego przewodnika, możesz znaleźć najnowszą aktualizację, postępując zgodnie z tym połączyć.

Jeśli uważasz, że jakakolwiek treść na tej stronie narusza Twoje prawa, w tym Twoje prawa własności intelektualnej, prosimy o niezwłoczny kontakt za pomocą naszego formularza kontaktowego.
Przewodniki Tagi:Bitburnera

Nawigacja po wpisach

Poprzedni post: Światło Księżyca – Informacje ogólne i przewodnik po sekretnych pokojach
Następny post: Labiryntowy – Poziom 5 Mapa + Przewodnik po lokalizacjach przedmiotów kolekcjonerskich

Zostaw odpowiedź Anuluj odpowiedź

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są zaznaczone *

  • Tytuł: Bitburnera
  • Data wydania:
  • Wywoływacz:
  • Wydawca:
Informacje o Bitburner są nadal niekompletne. Pomóż nam wypełnić szczegóły gry za pomocą tego formularz kontaktowy.

Zastrzeżenie

Wszystkie cytowane treści pochodzą z odpowiednich źródeł. Jeśli uważasz, że wykorzystaliśmy Twoje treści bez pozwolenia, upewnij się, że się z nami skontaktujesz, a my potraktujemy to poważnie.
  • O nas
  • Skontaktuj się z nami
  • Polityka prywatności
  • Warunki usługi

Prawo autorskie © 2025 Bity zamieszek.

Zasilany przez Prasa Książka Aktualności Motyw WordPressa