
Simple auto farm script that can be used to learn some basics Prologue and code The guide is pretty much in the code section with my attempt at documentation It's completely plug and play :D This is best used for learning, and not for quality farming, go to my Intermediate guide if you want a serious upgrade disableLog("ALL"); tail(); clearLog();//Just for visual clarity in the console // Welcome to my messy, horribly optimised, quickly slapped together script for beginners, by a beginner, good luck with this brain aneurysm which I tried to document // This whole thing will scan for all servers you can hack, then start automatically farming them, but it's not the fastest var files = ["weak.script", "grow.script", "hack.script"]; //These are the files will be sent with 'scp' to target servers later //This part will show a yes/no prompt, with yes creating/overwriting the 3 files listed above, and no will stop the script if (prompt("This will overwrite any files in your home directory named weak.script, grow.script and hack.script, click yes to allow or no to exit")){ write(files[0], "weaken(args)", "w"); write(files[1], "grow(args)", "w"); write(files[2], "hack(args)", "w") } else {exit()} //Sets variables, I wouldn't touch them, might explode var serverList = scan("home"); var serverCount = [serverList.length, 0]; var hk = [0, 0, 0, 0, 0]; var scanLevel = 2;var approvedList = []; var index = 0; var inner = 0; var exeCount = 0; var hackType; var linked; var target; var depth = 0; var checked = 0; //Checks if you have hacks so we know for later if (fileExists("BruteSSH.exe")) { hk[0] = 1; exeCount++ }; if (fileExists("FTPCrack.exe")) { hk[1] = 1; exeCount++ }; if (fileExists("relaySMTP.exe")) { hk[2] = 1; exeCount++ }; if (fileExists("HTTPWorm.exe")) { hk[3] = 1; exeCount++ }; if (fileExists("SQLInject.exe")) { hk[4] = 1; exeCount++ }; if (fileExists("DeepscanV1.exe")) { scanLevel += 2 }; //Comment out one or both of these lines if you don't have if (fileExists("DeepscanV2.exe")) { scanLevel += 5 }; //high hack skill or want to avoid time consuming deep scans //The badly formatted fun begins... print("/=====/ SEARCHING ===== n|----| Scans to L" + [scanLevel + 1] + " n| L1 | "+ serverList.join(" n| L1 | ")) //Print is just for the visuals while (index <= serverCount[depth] - 1 && depth < scanLevel) {//The scan will stop if we hit depth limit linked = scan(serverList[checked]);checked++; //Scan will bring back all connected servers which we then run through checks below for (i = 0; i <= linked.length - 1; i++) {//If the scan results in 1 or more linked servers this area will cycle through them target = linked[i];//Targets 1 part of the scan result at a time if (target != "home" && !serverList.includes(target)) {//Makes sure our target isn't home or a server we already know of serverList.push(target);//Adds the target to the list print("| L"+ [depth + 2] + " | " + target); serverCount[depth + 1]++; } } if (index == serverCount[depth] - 1) { index = 0; depth++; serverCount.push(0) } else { index++ };//Increases index if there are still servers in this depth level, } //resets index and goes one level deeper if there isn't print("/==========/ CHECKING ========== "); for (i = 0; i <= serverList.length - 1; i++) {//Runs once for each entry in serverList target = serverList[i]; if (getServerNumPortsRequired(target) > exeCount) { print("| X HACKS | " + target) } //Denied if you cannot open enough ports else if (getServerMoneyAvailable(target) == 0) { print("| X MONEY | " + target) } //Denied if there's no loot else if (getServerMaxRam(target) < 2) { print("| X 0 RAM | " + target) } //Denied because potato else if (getHackingLevel() < getServerRequiredHackingLevel(target)) { print("| X SKILL | " + target) } //Denied because your hacking is too low else {//Server approved, 5 lines below will open ports on target if you have the required exe if (hk[0]) { brutessh(target) }; if (hk[1]) { ftpcrack(target) }; if (hk[2]) { relaysmtp(target) }; if (hk[3]) { httpworm(target) }; if (hk[4]) { sqlinject(target) }; nuke(target); scp(files, "home", target); killall(target);//Nuke, transfer files and kill running scripts on target approvedList.push(target);//This server is ready to farm, puts it in the approved list for later print("| > VALID | " + target); } } print("/=======/ HACKING ======= "); index = 0;//Reset so we can use it again while (true) {//Runs forever if (index > approvedList.length - 1) { index = 0 }//Sets index to 0 if we reach the end of list, starts cycle again target = approvedList[index];//Picks server from list based on index if (getServerUsedRam(target) == 0) { //If nothing is already running on server if (getServerSecurityLevel(target) > getServerMinSecurityLevel(target) + 5) { hackType = "weak" } //and the security is too high, weaken /You can change the 5 else if (getServerMoneyAvailable(target) < getServerMaxMoney(target) * 0.70) { hackType = "grow" }//and the money is too low, boosto /and the 0.80 else { hackType = "hack" }; //and if everything is just right... print("| " + hackType + " | " + approvedList[index]); exec(hackType + ".script", target, Math.floor(getServerMaxRam(target) / getScriptRam(hackType + ".script")), target)//Runs 1 of the 3 scripts on target server against itself } index++;//Helps us cycle through our list || Threads are maxed out based on the amount of RAM the server has divided by how much RAM the script takes to run, rounded down } //Do note that with lots of "approved servers" this will not be optimal, at all, this is just a lazy way to do things at the start //With very little thought you could make the scripts run against a different target too, hope you find this mess even slightly helpful, and have a good day :)
2026-02-15 19:00:06 发布在
Bitburner
说点好听的...
收藏
0
0
