├── public ├── favicon.ico ├── manifest.json └── index.html ├── ISSUE_TEMPLATE.md ├── src ├── App.test.js ├── index.css ├── index.js ├── App.css ├── App.js ├── logo.svg └── serviceWorker.js ├── Any ├── grow │ └── grow.js ├── hack │ ├── hack.js │ ├── focus_weaken.js │ ├── initial_grow.js │ ├── single_hack.js │ ├── focus_experience.js │ ├── focus_money.js │ ├── initial_weaken.js │ ├── pwn_server.js │ ├── 6-13-17 - 'Any useful scripts to share' - unnamed(4).js │ ├── 6-13-17 - 'Any useful scripts to share' - unnamed(3).js │ ├── distrAndRun.js │ ├── total_hack.js │ ├── distrAndRun_mod.js │ ├── hackemall.js │ └── hackAll.js ├── weaken │ └── weaken.js ├── weaken-grow-hack │ ├── 2.js │ ├── 1.js │ ├── foodnstuff[1-4].js │ ├── foodnstuff0.js │ ├── dynamic.js │ ├── startup.js │ ├── startup2.js │ ├── virus.js │ └── foodnstuff[0-5].js ├── scp │ ├── 6-6-17 - 'Questions-Suggestions' - unnamed(2).js │ ├── 6-6-17 - 'Questions-Suggestions' - unnamed(4).js │ ├── copy.js │ ├── 6-6-17 - 'Questions-Suggestions' - unnamed(1).js │ ├── scp.js │ └── 6-6-17 - 'Questions-Suggestions' - unnamed(3).js ├── nuke │ ├── start.js │ ├── break.js │ ├── massnuke.js │ └── nuke.js └── kill │ └── kill.js ├── Middle-game ├── grow-target.js ├── hack-target.js ├── weaken-target.js ├── change-percentage.js ├── hack-scheduler.js ├── RemoteGrow.js ├── RemoteHack.js ├── RemoteWeaken.js ├── grow-scheduler.js ├── rent.js └── start(2).js ├── Misc ├── cull.js ├── tracert.js ├── monitoring.js ├── return.js ├── grind.js ├── mapToFile.js ├── helpers.js ├── main.js ├── mapper2.js ├── max_threads.js ├── spider.js ├── text.js ├── RamEaterVirus.js ├── 4gb-auto-hack-0ram.js ├── best-server.js ├── scrape-all-servers.js ├── deepscan.js └── auto-deepscan.js ├── package.json ├── Stock Market ├── Liquidate.js ├── momentum.s ├── _InvestmentBroker_Msg.js ├── InvestmentBroker.js ├── fsig.js ├── priceChange.js ├── stock-sma.js ├── _InvestmentBroker_Data.js ├── stocktrader.js ├── momentum.js ├── stock.js └── _InvestmentBroker_Manager.js ├── Hacknet ├── 6-10-17 - 'What's Wrong With My Hacknet Nodes Script' - unnamed(1).js ├── 6-13-17 - 'Help with a hacknet script please' - unnamed(2).js ├── 6-13-17 - 'Help with a hacknet script please' - unnamed(1).js ├── 6-13-17 - 'Any useful scripts to share' - unnamed(2).js ├── 6-13-17 - 'Any useful scripts to share' - unnamed(1).js ├── manage-hacknet.js ├── rent.js ├── hacknet-script.js ├── trading.js ├── setup-hacknet.js └── sort-taget.js ├── LICENSE ├── .gitignore ├── Late-game ├── smartHack.js ├── grow.js ├── weaken.js ├── hack.js ├── calculator.js └── Autohack.js ├── README.md ├── Early-game └── 8gb-auto-deepscan.js ├── Singularity ├── faction.js └── reputation.js ├── README 2.md ├── bitburner-community.svg ├── CONTRIBUTING.md └── CODE_OF_CONDUCT.md /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/actuallyReallyAlex/Bitburner-Community/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Bugs, Edits, Suggestions 2 | 3 | Submitting an issue is pretty loose. Simply submit a bug, edit, suggestion, request, or whatever you'd like. I'll be sure to get to it as soon as possible. 4 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /Any/grow/grow.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 30th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "..." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6kirxi/v023_progression_scripts/ 13 | */ 14 | 15 | 16 | 17 | grow(args[0]); -------------------------------------------------------------------------------- /Any/hack/hack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 30th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "..." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6kirxi/v023_progression_scripts/ 13 | */ 14 | 15 | 16 | 17 | hack(args[0]); -------------------------------------------------------------------------------- /Any/weaken/weaken.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 30th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "..." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6kirxi/v023_progression_scripts/ 13 | */ 14 | 15 | 16 | 17 | weaken(args[0]); -------------------------------------------------------------------------------- /Any/weaken-grow-hack/2.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zusias (https://www.reddit.com/user/Zusias) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "..." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | s = getHostname(); 18 | while(1) { 19 | grow(s); 20 | }; -------------------------------------------------------------------------------- /Middle-game/grow-target.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "grow-target.script - COST: 1.55GB" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 13 | */ 14 | 15 | 16 | 17 | grow(args[0]); -------------------------------------------------------------------------------- /Middle-game/hack-target.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "hack-target.script - COST: 1.50GB" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 13 | */ 14 | 15 | 16 | 17 | hack(args[0]); -------------------------------------------------------------------------------- /Middle-game/weaken-target.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "weaken-target.script - COST: 1.55GB" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 13 | */ 14 | 15 | 16 | 17 | weaken(args[0]); -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 5 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /Any/weaken-grow-hack/1.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zusias (https://www.reddit.com/user/Zusias) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "..." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | a = getHostname(); 18 | while(1) { 19 | if (getServerMoneyAvailable(a) < 900000) { 20 | grow(a); 21 | } else { 22 | hack(a); 23 | } 24 | }; -------------------------------------------------------------------------------- /Any/hack/focus_weaken.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | while(1){weaken(args[0]);} -------------------------------------------------------------------------------- /Any/hack/initial_grow.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | while(grow(args[0]) > 1) {}; -------------------------------------------------------------------------------- /Any/hack/single_hack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | while(hack(args[0]) == false) {}; -------------------------------------------------------------------------------- /Middle-game/change-percentage.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "OPTIONAL!!! 10 | change-percentage.script - COST: 2.40GB 11 | 12 | Use: run change-percentage.script [percentage, eg. 0.15 for 15%]" 13 | 14 | REDDIT POST: 15 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 16 | */ 17 | 18 | 19 | 20 | newPercentage = args[0]; 21 | write(1, newPercentage); -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: http://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /Any/hack/focus_experience.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | while(true) { 18 | hack(args[0]); 19 | grow(args[0]); 20 | } -------------------------------------------------------------------------------- /Any/weaken-grow-hack/foodnstuff[1-4].js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Update Version: 10 | 11 | I have scripts such as foodnstuff[0-5].scipt for each server on home, where 0 is hack / grow, and 1-4 are weaken / grow. 12 | ..." 13 | 14 | REDDIT POST: 15 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 16 | */ 17 | 18 | 19 | 20 | s = 'foodnstuff'; 21 | while(true) { 22 | grow(s); 23 | if (getServerSecurityLevel(s) > 2) { weaken(s);}; 24 | }; -------------------------------------------------------------------------------- /Misc/cull.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 30th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Usage: run cull.script [hackLevelThreshold] (kills scripts running on servers BELOW this level [strictly less than])" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6kirxi/v023_progression_scripts/ 13 | */ 14 | 15 | 16 | 17 | hackLimit = args[0]; 18 | thisHost = getHostname(); 19 | while (isRunning('return.script', thisHost, thisHost, '', hackLimit) == false) { 20 | run('return.script', 1, thisHost, '', hackLimit); 21 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bitburner-community", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "^16.5.2", 7 | "react-dom": "^16.5.2", 8 | "react-scripts": "2.0.4" 9 | }, 10 | "scripts": { 11 | "start": "react-scripts start", 12 | "build": "react-scripts build", 13 | "test": "react-scripts test", 14 | "eject": "react-scripts eject" 15 | }, 16 | "eslintConfig": { 17 | "extends": "react-app" 18 | }, 19 | "browserslist": [ 20 | ">0.2%", 21 | "not dead", 22 | "not ie <= 11", 23 | "not op_mini all" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | } 9 | 10 | .App-header { 11 | background-color: #282c34; 12 | min-height: 100vh; 13 | display: flex; 14 | flex-direction: column; 15 | align-items: center; 16 | justify-content: center; 17 | font-size: calc(10px + 2vmin); 18 | color: white; 19 | } 20 | 21 | .App-link { 22 | color: #61dafb; 23 | } 24 | 25 | @keyframes App-logo-spin { 26 | from { 27 | transform: rotate(0deg); 28 | } 29 | to { 30 | transform: rotate(360deg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Any/weaken-grow-hack/foodnstuff0.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Update Version: 10 | 11 | I have scripts such as foodnstuff[0-5].scipt for each server on home, where 0 is hack / grow, and 1-4 are weaken / grow. 12 | ..." 13 | 14 | REDDIT POST: 15 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 16 | */ 17 | 18 | 19 | 20 | s = 'foodnstuff'; 21 | while(true) { 22 | if (getServerMoneyAvailable(s) > 49000000) { 23 | hack(s); 24 | } else { 25 | grow(s); 26 | } 27 | }; -------------------------------------------------------------------------------- /Any/scp/6-6-17 - 'Questions-Suggestions' - unnamed(2).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/LittleMissTimeLord (https://www.reddit.com/user/LittleMissTimeLord) 4 | 5 | POSTED ON: 6 | June 6th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "My Generic scripts are just: 10 | ... 11 | with the grow script just being grow instead of hack of course. 12 | 13 | Until we have proper scanning commands or array support, I'm not sure it can be much more efficient that this." 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/6fmyzo/questionssuggestions/ 17 | */ 18 | 19 | 20 | 21 | server = getHostname(); 22 | while(true){ 23 | hack(server); 24 | }; -------------------------------------------------------------------------------- /Any/hack/focus_money.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | target = args[0]; 18 | threshold = args[1]; 19 | while(true) { 20 | if (getServerMoneyAvailable(target) < threshold) { 21 | grow(target); 22 | } else { 23 | hack(target); 24 | }; 25 | }; -------------------------------------------------------------------------------- /Any/hack/initial_weaken.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | base_security = getServerBaseSecurityLevel(args[0]); 18 | min_security = base_security / 3 + 0.5; 19 | min_security = min_security - (min_security % 1); 20 | while(getServerSecurityLevel(args[0]) > min_security + 1) { 21 | weaken(args[0]); 22 | }; -------------------------------------------------------------------------------- /Stock Market/Liquidate.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/neruL02 (https://www.reddit.com/user/neruL02) 4 | 5 | POSTED ON: 6 | October 8th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "This is my script: Liquidate.script" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/74rlny/request_sell_all_stocks_button/ 13 | */ 14 | 15 | 16 | 17 | symbols = ["ECP", "MGCP", "BLD", "CLRK", "OMTK", "FSIG", "KGI", "FLCM", "STM", "DCOMM", "HLS", "VITA", "ICRS", "UNV", "AERO", "OMN", "SLRS", "GPH", "NVMD", "WDS", "LXO", "RHOC", "APHE", "SYSC", "CTK", "NTLK", "OMGA", "FNS", "SGC", "JGN", "CTYS", "MDYN", "TITN"]; 18 | 19 | for (i = 0; i < symbols.length; i++) 20 | { 21 | pos = getStockPosition(symbols[i]); 22 | sellStock(symbols[i],pos[0]); 23 | } -------------------------------------------------------------------------------- /Any/scp/6-6-17 - 'Questions-Suggestions' - unnamed(4).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zinabas (https://www.reddit.com/user/Zinabas) 4 | 5 | POSTED ON: 6 | June 6th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "its mostly useless right now, but once hacking hits 100 or so it becomes pretty efficient and self maintaining." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6fmyzo/questionssuggestions/ 13 | */ 14 | 15 | 16 | 17 | home = getHostname(); 18 | mneLevel = 10000000; 19 | secLevel = 2; 20 | 21 | while(true) { 22 | if(getServerSecurityLevel(home) > secLevel) { 23 | weaken(home); 24 | } elif(getServerMoneyAvailable(home) < mneLevel) { 25 | grow(home); 26 | } else { 27 | hack(home); 28 | } 29 | } -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | class App extends Component { 6 | render() { 7 | return ( 8 |
9 |
10 | logo 11 |

12 | Edit src/App.js and save to reload. 13 |

14 | 20 | Learn React 21 | 22 |
23 |
24 | ); 25 | } 26 | } 27 | 28 | export default App; 29 | -------------------------------------------------------------------------------- /Hacknet/6-10-17 - 'What's Wrong With My Hacknet Nodes Script' - unnamed(1).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Omelet (https://www.reddit.com/user/Omelet) 4 | 5 | POSTED ON: 6 | June 10th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "You don't need curly braces if the if/while/for is only executing a single command. 10 | ... 11 | The above code functions identically to what you posted." 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/6g8haa/whats_wrong_with_my_hacknet_nodes_script/ 15 | */ 16 | 17 | 18 | 19 | for (i = 0; i <= hacknetnodes.length; i = i+1) { 20 | if (hacknetnodes[i].level < 100) hacknetnodes[i].upgradeLevel(100-hacknetnodes[i].level); 21 | while (hacknetnodes[i].ram < 16) hacknetnodes[i].upgradeRam(); 22 | while (hacknetnodes[i].cores < 4) hacknetnodes[i].upgradeCore(); 23 | }; -------------------------------------------------------------------------------- /Misc/tracert.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Omelet (https://www.reddit.com/user/Omelet) 4 | 5 | POSTED ON: 6 | July 2nd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Figured someone might find this script useful - it determines the server chain you need to follow in order to reach the desired server. Mostly useful for servers which need to be manually hacked. 10 | ... 11 | It prints out to the script log in the reverse order you need to connect to servers to reach the desired server. You need to use tail to see the output. Example usage: http://imgur.com/a/XgaCe" 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/6ktz43/tracertscript_v023/ 15 | */ 16 | 17 | 18 | 19 | s = args[0]; 20 | a = scan(s); 21 | while(a[a.length - 1] != 'home'){ 22 | s = a[0]; 23 | a = scan(s); 24 | print(s); 25 | }; -------------------------------------------------------------------------------- /Misc/monitoring.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/havoc_mayhem (https://www.reddit.com/user/havoc_mayhem) 4 | 5 | POSTED ON: 6 | December 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Here's a very simple monitoring script I put together:" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/7jgxpv/tip_work_while_monitoring_a_script/ 13 | */ 14 | 15 | 16 | 17 | svName = args[0]; 18 | 19 | while(1) { 20 | getServerMoneyAvailable(svName); 21 | getServerMaxMoney(svName); 22 | getServerSecurityLevel(svName); 23 | getServerMinSecurityLevel(svName); 24 | getServerRam(svName); 25 | print("========================"); 26 | print("Script Income: " + getScriptIncome()[0]); 27 | print("Script Exp: " + getScriptExpGain()); 28 | print("========================"); 29 | sleep(10000, false); 30 | } -------------------------------------------------------------------------------- /Any/hack/pwn_server.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | name = args[0]; 18 | if fileExists("BruteSSH.exe") { 19 | brutessh(name); 20 | }; 21 | if fileExists("FTPCrack.exe") { 22 | ftpcrack(name); 23 | }; 24 | if fileExists("relaySMTP.exe") { 25 | relaysmtp(name); 26 | }; 27 | if fileExists("HTTPWorm.exe") { 28 | httpworm(name); 29 | }; 30 | if fileExists("SQLInject.exe") { 31 | sqlinject(name); 32 | }; 33 | nuke(name); -------------------------------------------------------------------------------- /Any/scp/copy.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Omelet (https://www.reddit.com/user/Omelet) 4 | 5 | POSTED ON: 6 | June 18th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "It's possible if you already know what all your scripts are called / if you use numerical naming conventions. 10 | ... 11 | Assuming your server is named GenericServer, and you wanted to copy files called GenericScript0.script through GenericScript99.script to it, you could use the following command. 12 | ... 13 | run copy.script GenericScript 100 GenericServer 14 | ... 15 | That only copies the scripts and does not run them, but running them would be very similar." 16 | 17 | REDDIT POST: 18 | https://www.reddit.com/r/Bitburner/comments/6i0n6m/scpcopy_all_scripts_function/ 19 | */ 20 | 21 | 22 | 23 | name = args[0]; 24 | n = args[1]; 25 | destination = args[2]; 26 | for(i = 0; i < n; i = i + 1) scp(name + i + '.script', destination); -------------------------------------------------------------------------------- /Misc/return.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 30th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Usage: run return.script [target] [previousHost] [hackLevelThreshold] (cascades kill/return)" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6kirxi/v023_progression_scripts/ 13 | */ 14 | 15 | 16 | 17 | scanHost = args[0]; 18 | previousHost = args[1]; 19 | hackLimit = args[2]; 20 | hosts = scan(scanHost); 21 | if (hosts.length > 0) { 22 | for (j = 0; j < hosts.length; j = j + 1) { 23 | nextHost = hosts[j]; 24 | if (nextHost != previousHost) { 25 | while (isRunning('kill.script', getHostname(), nextHost, scanHost) == false) { 26 | run('kill.script', 1, nextHost, scanHost); 27 | }; 28 | }; 29 | }; 30 | }; -------------------------------------------------------------------------------- /Any/weaken-grow-hack/dynamic.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 20th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Since it's based off so many user suggestions, it appears functionally similar, if not identical to the one above." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6i0ytr/weaken_grow_hack_script_all_in_one/ 13 | */ 14 | 15 | 16 | 17 | i = getServerMoneyAvailable(args[0]); 18 | i = i * 45; 19 | while(true) { 20 | if (getServerSecurityLevel(args[0]) > 2) { 21 | weaken(args[0]); 22 | } else { 23 | if (getServerMoneyAvailable(args[0]) >= i) { 24 | hack(args[0]); 25 | } else { 26 | grown = grow(args[0]); 27 | print('grown x ' + grown); 28 | if(grown == 1) 29 | i = i * 0.99; 30 | }; 31 | } 32 | } -------------------------------------------------------------------------------- /Any/weaken-grow-hack/startup.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zusias (https://www.reddit.com/user/Zusias) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Ram usage 4.53, nuke all 0 port servers, scp and run 1.script 2.script on those servers. When finished with the 0 port servers, starts startup2.script to hack the 1 port servers." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | places = Array ['foodnstuff', 'sigma-cosmetics', 'joesguns', 'nectar-net', 'hong-fang-tea', 'harakiri-sushi']; 18 | levels = Array [0, 5, 10, 20, 30, 40]; 19 | 20 | for(i = 0; i < 6; i = i) { 21 | if(getHackingLevel() >= levels[i]) { 22 | nuke(places[i]); 23 | for(j = 1; j < 3; j = j + 1) { 24 | scp(j + '.script', places[i]); 25 | exec(j + '.script', places[i]); 26 | }; 27 | i = i + 1; 28 | }; 29 | sleep(10000); 30 | }; 31 | 32 | run('startup2.script'); -------------------------------------------------------------------------------- /Any/nuke/start.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | July 10th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Purpose: A fire and forget way to start a nuke-and-run-daemon cascade. Read through it to understand the optional params. You will only run daemons on servers above minimum and below limit. If you want to change your conditions, you have to run the cascade all over again. By default it has no real limits. 10 | 11 | Usage: run start.script" 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/6mf6zy/v0241_progression_scripts_update/ 15 | */ 16 | 17 | 18 | 19 | minimumHackLevel = 0; 20 | if (args.length > 0) { 21 | minimumHackLevel = args[0]; 22 | } else { 23 | minimumHackLevel = 1; 24 | } 25 | 26 | if (args.length > 1) { 27 | hackLimit = args[1]; 28 | } else { 29 | hackLimit = 2147483647; 30 | } 31 | 32 | run('break.script', 1, getHostname(), '', minimumHackLevel, hackLimit); -------------------------------------------------------------------------------- /Any/scp/6-6-17 - 'Questions-Suggestions' - unnamed(1).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/LittleMissTimeLord (https://www.reddit.com/user/LittleMissTimeLord) 4 | 5 | POSTED ON: 6 | June 6th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I just handle it like so. 10 | Copy and paste for every node you need to target. Naturally this requires buying RAM upgrades for the home computer, but they aren't that expensive. And I haven't had any issue targeting deep servers with it." 11 | 12 | REDDIT POST: 13 | https://www.reddit.com/r/Bitburner/comments/6fmyzo/questionssuggestions/ 14 | */ 15 | 16 | 17 | 18 | while(hasRootAccess('harakiri-sushi') == false){ 19 | if(getHackingLevel() >= 40){ 20 | nuke('harakiri-sushi'); 21 | scp('GenericHack.script','harakiri-sushi'); 22 | scp('GenericGrow.script', 'harakiri-sushi'); 23 | exec('GenericHack.script', 'harakiri-sushi'); 24 | exec('GenericGrow.script', 'harakiri-sushi'); 25 | } else { 26 | sleep(10000); 27 | }; 28 | }; -------------------------------------------------------------------------------- /Any/weaken-grow-hack/startup2.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zusias (https://www.reddit.com/user/Zusias) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "RAM usage 4.76, nukes 1 port servers (that have money) and scps/runs 1.script and 2.script on those servers. When finished, runs startup3.script to start nuking the 2 port servers." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | places = Array ['neo-net', 'zer0', 'max-hardware', 'iron-gym']; 18 | levels = Array [50, 75, 80, 100]; 19 | 20 | for(i = 0; i < 4; i = i) { 21 | if(getHackingLevel() >= levels[i]) { 22 | if(fileExists('brutessh.exe')) { 23 | brutessh(places[i]); 24 | nuke(places[i]); 25 | for(j = 1; j < 3; j = j + 1) { 26 | scp(j + '.script', places[i]); 27 | exec(j + '.script', places[i]); 28 | }; 29 | i = i + 1; 30 | }; 31 | }; 32 | sleep(10000); 33 | }; 34 | 35 | run('startup3.script'); -------------------------------------------------------------------------------- /Any/hack/6-13-17 - 'Any useful scripts to share' - unnamed(4).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/JasonP1625 (https://www.reddit.com/user/JasonP1625) 4 | 5 | POSTED ON: 6 | June 29th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I have one that I use for hacking the ones which just require BruteSSH.exe after they're hacked." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | money = Array[1000000,1300000,1750000,2000000,2500000,3500000,4500000,7500000,11000000,20000000]; 18 | servers = Array["foodnstuff","sigma-cosmetics","joesguns","nectar-net","hong-fang-tea","harakiri-sushi","neo-net","zer0","max-hardware","iron-gym"]; 19 | t = servers.length; 20 | while(true) { 21 | for (i = 0; i < t; i = i+1) { 22 | s = servers[i]; 23 | m = money[i]; 24 | if (hasRootAccess(s) == true) { 25 | se = getServerBaseSecurityLevel(s); 26 | while (getServerSecurityLevel(s) > (se/3+1)) { 27 | weaken(s); 28 | }; 29 | if (getServerMoneyAvailable(s) > m*40) { 30 | hack(s); 31 | }; 32 | }; 33 | }; 34 | } -------------------------------------------------------------------------------- /Any/kill/kill.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 30th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Usage run kill.script [target] [previousHost] [hackLevelThreshold]" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6kirxi/v023_progression_scripts/ 13 | */ 14 | 15 | 16 | 17 | thisTarget = args[0]; 18 | previousHost = args[1]; 19 | hackLimit = args[2]; 20 | thisHost = getHostname(); 21 | allKilled = false; 22 | scriptsToKill = Array['nuke.script', 'break.script', 'daemon.script']; 23 | hackLevel = getServerRequiredHackingLevel(thisTarget); 24 | if (hackLevel < hackLimit) { 25 | for (i = 0; i < scriptsToKill.length; i = i + 1) { 26 | scriptToKill = scriptsToKill[i]; 27 | if (isRunning(scriptToKill, thisHost, thisTarget, previousHost) == true) { 28 | kill(scriptToKill, thisHost, thisTarget, previousHost); 29 | }; 30 | }; 31 | }; 32 | while (isRunning('return.script', thisHost, thisTarget, previousHost, hackLimit) == false) { 33 | run('return.script', 1, thisTarget, previousHost, hackLimit); 34 | }; -------------------------------------------------------------------------------- /Hacknet/6-13-17 - 'Help with a hacknet script please' - unnamed(2).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I'm personally very fond of: 10 | ... 11 | which attempts to level all hacknet nodes up to whatever node 0 is. I use node 0 as a baseline and upgrade it manually and let the script try to do whatever it can to maintain the rest. After I make a bit of money I add 12 | ... 13 | to the loop. I haven't gotten super far, so this has been touch-and-go. I turn it off when the costs become prohibitive, but it does well for its intended purpose, which is primarily just to save me clicking...." 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/6gx6hk/help_with_a_hacknet_script_please/ 17 | */ 18 | 19 | 20 | 21 | while (true) { 22 | hl = hacknetnodes[0].level; 23 | for (i = 1; i < hacknetnodes.length; i = i + 1) { 24 | while (hacknetnodes[i].level < hl) 25 | hacknetnodes[i].upgradeLevel(1); 26 | }; 27 | } 28 | 29 | ------------------ 30 | hacknetnodes[i].upgradeRam(); 31 | hacknetnodes[i].upgradeCore(); -------------------------------------------------------------------------------- /Any/scp/scp.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/XxZombGuyxX (https://www.reddit.com/user/XxZombGuyxX) 4 | 5 | POSTED ON: 6 | September 26th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "i just want to be able to copy more then one thing at a time D: 10 | 11 | EDIT: Figured out a script if ya guys want it, here it is 12 | 13 | This script is 2.10 GB and can copy a number of programs to another server in quick succession feel free to use it!" 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/72l0ip/scpfile1file2file3etc/ 17 | */ 18 | 19 | 20 | 21 | toServer = args[0]; //put server to send files to 22 | x = (toServer + 'has recieved all the 23 | y = (ls(toServer) + 'double check they were added'); 24 | files = ['daemon.script','start.script','grow-scheduler.script','grow-target.script','hack-scheduler.script','hack- 25 | target.script','weakentarget.script']; 26 | //remember to add or remove files as needed from the files array 27 | i = 0; 28 | //change the variable i 0) { 25 | for (j = 0; j < hosts.length; j = j + 1) { 26 | nextHost = hosts[j]; 27 | if (nextHost != previousHost) { 28 | while (isRunning('nuke.script', getHostname(), nextHost, scanHost, minimumHackLevel, hackLimit) == false) { 29 | run('nuke.script', 1, nextHost, scanHost, minimumHackLevel, hackLimit); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Misc/grind.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | print("Set up constants."); 18 | target = "foodnstuff"; 19 | initial_weaken_threads = 1200; 20 | focus_experience_threads = 1200; 21 | focus_weaken_threads = 200; 22 | 23 | print("Gain full access, if we don't already have it."); 24 | run("pwn_server.script", 1, target); 25 | while(isRunning("pwn_server.script", "home", target)) { 26 | sleep(10000); 27 | }; 28 | 29 | print("Bring server to minimum security."); 30 | run("initial_weaken.script", initial_weaken_threads, target); 31 | while(isRunning("initial_weaken.script", "home", target)) { 32 | sleep(10000); 33 | }; 34 | 35 | print("Start background process to keep it there."); 36 | run("focus_weaken.script", focus_weaken_threads, target); 37 | 38 | print("Grind"); 39 | run("focus_experience.script", focus_experience_threads, target); -------------------------------------------------------------------------------- /Middle-game/hack-scheduler.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "hack-scheduler.script - COST: 2.40GB" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 13 | */ 14 | 15 | 16 | 17 | //responsible for scheduling a single cycle of daemon work for the target server 18 | //as always.. ARRRRGS 19 | 20 | target = args[0]; 21 | threadsNeededToWeakenForHack = args[1]; 22 | threadsNeededToHack = args[2]; 23 | weakenExecutionTime = args[3]; 24 | hackExecutionTime = args[4]; 25 | i = args[5]; //i allows this script to run concurrent copies 26 | 27 | stepDelay = 7; 28 | 29 | hackWeakenSleep = (weakenExecutionTime - hackExecutionTime) - stepDelay; //fire weaken a step after 30 | discriminationVariable = 'hack'; 31 | threadsNeeded = threadsNeededToWeakenForHack; 32 | 33 | scripts = ['weaken-target.script', 'hack-target.script']; 34 | for (j = 0; j < scripts.length; j++) { 35 | run (scripts[j], threadsNeeded, target, i, discriminationVariable); 36 | sleep(hackWeakenSleep * 1000, false); 37 | threadsNeeded = threadsNeededToHack; 38 | discriminationVariable = ''; 39 | hackWeakenSleep = 0.001; 40 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Middle-game/RemoteGrow.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Working on designing a script to optimally hack servers, from early to late game. Still some more I want to do to it, but for now, heres how it works: 10 | 11 | 15.15GB Ram, + 1.55 , so 32GB should run this. 12 | 13 | Scans all servers recursively 14 | 15 | If they are a hacking target (money > 0), gathers more info on them. And determines their profit / sec. 16 | 17 | Checks number of port busters you have, gets current hacking level. Using these, if your hacking level has increased by 100 (saves rerunning calcs each time), it recaclulates the optimal profits for a list of servers you can currently hack 18 | 19 | Finds the optimal profit targets, and nukes it if needed. In order of optimal, calcs as many threads as needed, and runs weaken/grow/hack as needed 20 | 21 | Runs Weaken (if more than + 6 of min) Run Grow if not 75% of max. Hacks if above 75% of max. 22 | 23 | Big Thanks to: 24 | 25 | /user/MercuriusXeno 26 | 27 | /user/Reydien 28 | 29 | For large parts of the logic. 30 | 31 | The Script:" 32 | 33 | REDDIT POST: 34 | https://www.reddit.com/r/Bitburner/comments/70enbq/main_server_script/ 35 | */ 36 | 37 | 38 | 39 | grow(args[0]); -------------------------------------------------------------------------------- /Middle-game/RemoteHack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Working on designing a script to optimally hack servers, from early to late game. Still some more I want to do to it, but for now, heres how it works: 10 | 11 | 15.15GB Ram, + 1.55 , so 32GB should run this. 12 | 13 | Scans all servers recursively 14 | 15 | If they are a hacking target (money > 0), gathers more info on them. And determines their profit / sec. 16 | 17 | Checks number of port busters you have, gets current hacking level. Using these, if your hacking level has increased by 100 (saves rerunning calcs each time), it recaclulates the optimal profits for a list of servers you can currently hack 18 | 19 | Finds the optimal profit targets, and nukes it if needed. In order of optimal, calcs as many threads as needed, and runs weaken/grow/hack as needed 20 | 21 | Runs Weaken (if more than + 6 of min) Run Grow if not 75% of max. Hacks if above 75% of max. 22 | 23 | Big Thanks to: 24 | 25 | /user/MercuriusXeno 26 | 27 | /user/Reydien 28 | 29 | For large parts of the logic. 30 | 31 | The Script:" 32 | 33 | REDDIT POST: 34 | https://www.reddit.com/r/Bitburner/comments/70enbq/main_server_script/ 35 | */ 36 | 37 | 38 | 39 | hack(args[0]); -------------------------------------------------------------------------------- /Middle-game/RemoteWeaken.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Working on designing a script to optimally hack servers, from early to late game. Still some more I want to do to it, but for now, heres how it works: 10 | 11 | 15.15GB Ram, + 1.55 , so 32GB should run this. 12 | 13 | Scans all servers recursively 14 | 15 | If they are a hacking target (money > 0), gathers more info on them. And determines their profit / sec. 16 | 17 | Checks number of port busters you have, gets current hacking level. Using these, if your hacking level has increased by 100 (saves rerunning calcs each time), it recaclulates the optimal profits for a list of servers you can currently hack 18 | 19 | Finds the optimal profit targets, and nukes it if needed. In order of optimal, calcs as many threads as needed, and runs weaken/grow/hack as needed 20 | 21 | Runs Weaken (if more than + 6 of min) Run Grow if not 75% of max. Hacks if above 75% of max. 22 | 23 | Big Thanks to: 24 | 25 | /user/MercuriusXeno 26 | 27 | /user/Reydien 28 | 29 | For large parts of the logic. 30 | 31 | The Script:" 32 | 33 | REDDIT POST: 34 | https://www.reddit.com/r/Bitburner/comments/70enbq/main_server_script/ 35 | */ 36 | 37 | 38 | 39 | weaken(args[0]); -------------------------------------------------------------------------------- /Any/hack/6-13-17 - 'Any useful scripts to share' - unnamed(3).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/JasonP1625 (https://www.reddit.com/user/JasonP1625) 4 | 5 | POSTED ON: 6 | June 29th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I have one that I use for hacking the ones which just require BruteSSH.exe after they're hacked." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | money = Array[1000000,1300000,1750000,2000000,2500000,3500000,4500000,7500000,11000000,20000000]; 18 | servers = Array["foodnstuff","sigma-cosmetics","joesguns","nectar-net","hong-fang-tea","harakiri-sushi","neo-net","zer0","max-hardware","iron-gym"]; 19 | t = servers.length; 20 | security = Array[3,3,7,7,5,5,8,8,5,10]; 21 | while(true) { 22 | for (i = 0; i < t; i = i+1) { 23 | s = servers[i]; 24 | m = money[i]; 25 | se = security[i]; 26 | if (hasRootAccess(s) == true) { 27 | while (getServerMoneyAvailable(s) < m*45) { 28 | if (getServerSecurityLevel(s) > (se+5)) { 29 | weaken(s); 30 | } else{ 31 | grow(s); 32 | }; 33 | }; 34 | }; 35 | }; 36 | } -------------------------------------------------------------------------------- /Hacknet/6-13-17 - 'Help with a hacknet script please' - unnamed(1).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Mordredxxx (https://www.reddit.com/user/Mordredxxx) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Oh i did that script here it is : 10 | ... 11 | lvl up one by one all nodes by 5 lvls at first you have vars that you can edit to get it work more efficent :) i think my code is fine :3 it is buying nodes (because it is effecient this way trust me :)) Good game." 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/6gx6hk/help_with_a_hacknet_script_please/ 15 | */ 16 | 17 | 18 | 19 | // variables that you can change 20 | max_level = 150; 21 | power_upgrade = 5; 22 | max_node = 6; 23 | 24 | while(true){ 25 | //get the nomber of nodes 26 | nb = hacknetnodes.length; 27 | //if not max than buy one node 28 | if( nb < max_node) { 29 | purchaseHacknetNode(); 30 | }; 31 | //reget the number of node you could have just done it by nb = nb + 1; 32 | nb = hacknetnodes.length; 33 | //for each node until the last one 34 | for (i = 0; i < nb; i = i + 1) { 35 | //if lvl max of this "i" node isn't archeved buy "power_upgrade" node 36 | if( hacknetnodes[i].level <= max_level ) { 37 | hacknetnodes[i].upgradeLevel(power_upgrade); 38 | sleep(100); 39 | }; 40 | }; 41 | }; -------------------------------------------------------------------------------- /Any/nuke/massnuke.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/goku90504 (https://www.reddit.com/user/goku90504) 4 | 5 | POSTED ON: 6 | June 14th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Not sure if this is a feature or bug but this script gives root access to nearly everything as soon as you buy the 5 programs from the dark web (you know which programs the ones that don't start with Deep)" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | places = Array ['foodnstuff','sigma-cosmetics','joesguns','nectar-net','hong-fang-tea','harakiri-sushi','neo-net','zer0','max-hardware','iron-gym','phantasy','silver-helix','omega-net','crush-fitness','johnson-ortho','the-hub','comptek','netlink','rothman-uni','catalyst','summit-uni','rho-construction','millenium-fitness','aevum-police','alpha-ent','syscore','lexo-corp','snap-fitness','global-pharm','applied-energetics','unitalife','univ-energy','nova-med','zb-def','zb-institute','vitalife','titan-labs','solaris','microdyne','helios','deltaone','icarus','zeud-med','omnia','defcomm','galactic-cyber','infocomm','taiyang-digital','stormtech','aerocorp','clarkeinc','omnitek','nwo','4sigma','blade','b-and-a','ecorp','fulcrumtech','megacorp','kuai-gong','fulcrumassets','powerhouse-fitness']; 18 | 19 | for (i = 0; i < 62; i = i+1) { 20 | sqlinject(places[i]); 21 | httpworm(places[i]); 22 | relaysmtp(places[i]); 23 | ftpcrack(places[i]); 24 | brutessh(places[i]); 25 | nuke(places[i]); 26 | }; -------------------------------------------------------------------------------- /Misc/mapToFile.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/havoc_mayhem (https://www.reddit.com/user/havoc_mayhem) 4 | 5 | POSTED ON: 6 | December 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I haven't yet seen any scripts that utilize the files interface, so I put together a few of my own: 10 | 11 | Map Network to File (mapToFile.script, 4.7 GB) 12 | 13 | This file needs to be run just once at the start of your run, and will create a text file like this: 14 | 15 | home,2048,5,1,0,1,0 16 | iron-gym,32,1,100,500000000,10,20 17 | foodnstuff,16,0,1,50000000,3,5 18 | sigma-cosmetics,16,0,5,57500000,3,10 19 | ... 20 | Code:(mapToFile.script, 4.7 GB)" 21 | 22 | REDDIT POST: 23 | https://www.reddit.com/r/Bitburner/comments/7lmbpa/scripts_using_files/ 24 | */ 25 | 26 | 27 | servers = ["home"]; 28 | clear("nmap.txt"); 29 | 30 | for (i = 0; i < servers.length; ++i) { 31 | hostname = servers[i]; 32 | write("nmap.txt", hostname 33 | + "," + getServerRam(hostname)[0] 34 | + "," + getServerNumPortsRequired(hostname) 35 | + "," + getServerRequiredHackingLevel(hostname) 36 | + "," + getServerMaxMoney(hostname) 37 | + "," + getServerMinSecurityLevel(hostname) 38 | + "," + getServerGrowth(hostname) 39 | + "\r\n"); 40 | 41 | newScan = scan(hostname); 42 | for (j = 0; j < newScan.length; j++) { 43 | if (servers.indexOf(newScan[j]) == -1) { 44 | servers.push(newScan[j]); 45 | } 46 | } 47 | } 48 | 49 | tprint("Network mapped."); -------------------------------------------------------------------------------- /Middle-game/grow-scheduler.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "grow-scheduler.script - COST: 2.40GB" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 13 | */ 14 | 15 | 16 | 17 | //responsible for scheduling a single cycle of daemon work for the target server 18 | //as always.. ARRRRGS 19 | 20 | target = args[0]; 21 | threadsNeededToWeakenForGrow = args[1]; 22 | threadsNeededToGrow = args[2]; 23 | weakenExecutionTime = args[3]; 24 | growExecutionTime = args[4]; 25 | i = args[5]; //i allows this script to run concurrent copies 26 | 27 | stepDelay = 7; 28 | 29 | scripts = ['weaken-target.script', 'grow-target.script']; 30 | //moved this out of the two-script "loop" to optimize out an if statement. 31 | threadsNeeded = threadsNeededToWeakenForGrow; 32 | growWeakenSleep = (weakenExecutionTime - growExecutionTime) - stepDelay; //fire grow's weaken a step later 33 | discriminationVariable = 'grow'; //this allows two weakens with the same index-arg to exist at the same time. 34 | for (j = 0; j < scripts.length; j++) { 35 | run (scripts[j], threadsNeeded, target, i, discriminationVariable); 36 | sleep(growWeakenSleep * 1000, false); //waits a step. 37 | threadsNeeded = threadsNeededToGrow; //sets up the threads needed for the next pass. 38 | discriminationVariable = ''; 39 | growWeakenSleep = 0.001; //causes the sleep cycle to be arbitrarily slow. 40 | } -------------------------------------------------------------------------------- /Misc/helpers.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/GwenPlaysGwent (https://www.reddit.com/user/GwenPlaysGwent) 4 | 5 | POSTED ON: 6 | December 12th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I did a quick search and didn't find anything, apologize if this is already on the radar. 10 | 11 | The feature I'd like most of all for scripting is imports and exports. I have a ton of little helper functions I've written, and the best way I've found to use them is just copying them to each file, which obviously wastes RAM. I'm aware that theoretically I could setup a service that communicates on ports, but consuming the service would have a ton of boilerplate as I wait for ports to respond, make sure data is there, etc, and to me this boilerplate isn't worth the added RAM. 12 | 13 | Ideally, I'd love to have something akin to es6 modules. Example: 14 | 15 | Example 16 | helpers.script" 17 | 18 | REDDIT POST: 19 | https://www.reddit.com/r/Bitburner/comments/7jdi39/request_imports_and_exports_modules_for_scripts/ 20 | */ 21 | 22 | 23 | 24 | export function unlock(hostname){ 25 | if (fileExists("BruteSSH.exe", "home")) { 26 | brutessh(hostname); 27 | } 28 | if (fileExists("FTPCrack.exe", "home")) { 29 | ftpcrack(hostname); 30 | } 31 | if (fileExists("relaySMTP.exe", "home")) { 32 | relaysmtp(hostname); 33 | } 34 | if (fileExists("HTTPWorm.exe", "home")) { 35 | httpworm(hostname); 36 | } 37 | if (fileExists("SQLInject.exe", "home")) { 38 | sqlinject(hostname); 39 | } 40 | 41 | nuke(hostname); 42 | return true; 43 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | # See https://help.github.com/ignore-files/ for more about ignoring files. 63 | 64 | # dependencies 65 | /node_modules 66 | 67 | # testing 68 | /coverage 69 | 70 | # production 71 | /build 72 | 73 | # misc 74 | .DS_Store 75 | .env.local 76 | .env.development.local 77 | .env.test.local 78 | .env.production.local 79 | 80 | npm-debug.log* 81 | yarn-debug.log* 82 | yarn-error.log* 83 | -------------------------------------------------------------------------------- /Any/scp/6-6-17 - 'Questions-Suggestions' - unnamed(3).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zinabas (https://www.reddit.com/user/Zinabas) 4 | 5 | POSTED ON: 6 | June 6th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "you can be alittle more efficient actually, you can simulate a case switch code with 0 consequences at the moment. 10 | 11 | I have 1 file that auto hacks 11 servers from 1 loop. (I would add more but I stop after servers that only need 1 port open.)" 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/6fmyzo/questionssuggestions/ 15 | */ 16 | 17 | 18 | 19 | target = 'N/A'; 20 | for (i = 0; i < 11; i = i+1) { 21 | if (i == 0) { 22 | target = 'foodnstuff'; 23 | } elif (i == 1) { 24 | target = 'sigma-cosmetics'; 25 | } elif (i == 2) { 26 | target = 'joesguns'; 27 | } elif (i == 3) { 28 | target = 'nectar-net'; 29 | } elif (i == 4) { 30 | target = 'hong-fang-tea'; 31 | } elif (i == 5) { 32 | target = 'harakiri-sushi'; 33 | } elif (i == 6) { 34 | target = 'neo-net'; 35 | } elif (i == 7) { 36 | target = 'CSEC'; 37 | } elif (i == 8) { 38 | target = 'zer0'; 39 | } elif (i == 9) { 40 | target = 'max-hardware'; 41 | } elif (i == 10) { 42 | target = 'iron-gym'; 43 | }; 44 | 45 | while (hasRootAccess(target) == false) { 46 | if (i >= 6) { 47 | brutessh(target); 48 | }; 49 | nuke(target); 50 | sleep(5000); 51 | }; 52 | if (target == 'CSEC') { 53 | hack(target); 54 | } else { 55 | scp('autoHack.script', target); 56 | exec('autoHack.script', target); 57 | }; 58 | }; -------------------------------------------------------------------------------- /Middle-game/rent.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "rent.script - COST: 6.60 GB 10 | 11 | Use: run rent.script 12 | 13 | Description: OPTIONAL, manages hacknet. This is what you run if you want hacknet nodes purchased and upgraded, albeit slowly. This attempts to spend up to 1% of your current cash, per upgrade, on the hacknet." 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/70ikjm/progression_scripts_0286/ 17 | */ 18 | 19 | 20 | 21 | //1% of current funds, per cycle. 22 | allowancePercentage = 0.01; 23 | while (true) { 24 | currentCash = getServerMoneyAvailable('home'); 25 | currentCash *= allowancePercentage; 26 | if (getNextHacknetNodeCost() <= currentCash) { 27 | purchaseHacknetNode(); 28 | } else { 29 | for (i = 0; i < hacknetnodes.length; i++) { 30 | node = hacknetnodes[i]; 31 | upgradeCost = node.getLevelUpgradeCost(1); 32 | if (upgradeCost <= currentCash) { 33 | node.upgradeLevel(1); 34 | break; 35 | } else { 36 | ramCost = node.getRamUpgradeCost(); 37 | if (ramCost <= currentCash) { 38 | node.upgradeRam(); 39 | break; 40 | } else { 41 | coreCost = node.getCoreUpgradeCost(); 42 | if (coreCost <= currentCash) { 43 | node.upgradeCore(); 44 | break; 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Misc/main.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/GwenPlaysGwent (https://www.reddit.com/user/GwenPlaysGwent) 4 | 5 | POSTED ON: 6 | December 12th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Considerations 10 | One process. If I ran main.script, it'd only spawn one process for main.script. Helpers.script would never show up in top. 11 | 12 | RAM Usage. I suggest the ram usage should be "RAM of imports + import penalty". So, importing a function would always lead to slightly more RAM usage than simply inlining it (it's a luxury, after all). If it's too difficult to calculate the RAM of an imported function, I suggest just using the RAM of the entire file and not penalizing people for doing multiple imports from a single file. But ideally it should be per-function. 13 | 14 | Stateless functions. By only allowing stateless functions, we ensure that scripts only communicate at run-time via ports. If users are allowed to import stateful objects, they can communicate just by passing around singletons, which is kinda cheating (and maybe it's opening up a can of worms on the Netscript interpreter side?) I did a quick Google, and found "purecheck" on npm, which looks promising. Might be exactly what you want for this step. Also because they're stateless functions, it means that, if you need to, you can really bypass a lot of the importing code. You could literally copy and paste the function into the file before the interpreter executes it." 15 | 16 | Example 17 | helpers.script" 18 | 19 | REDDIT POST: 20 | https://www.reddit.com/r/Bitburner/comments/7jdi39/request_imports_and_exports_modules_for_scripts/ 21 | */ 22 | 23 | 24 | 25 | //main.script 26 | import { unlock } from helpers.script 27 | unlock(args[0); 28 | Considerations -------------------------------------------------------------------------------- /Any/hack/distrAndRun.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/havoc_mayhem (https://www.reddit.com/user/havoc_mayhem) 4 | 5 | POSTED ON: 6 | December 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Run Hacking Scripts (distrAndRun.script, 6.75 GB) 10 | 11 | Copy over scripts to all remote servers we have access to, and target them to hack the most efficient target server. 12 | 13 | Code: (distrAndRun.script, 6.75 GB)" 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/7lmbpa/scripts_using_files/ 17 | */ 18 | 19 | 20 | hackScripts = ["early-hack-template.script", "weaken.script"]; 21 | hack_mem = getScriptRam(hackScripts[0], "home"); 22 | 23 | bestTarget = read("best_target.txt").split(","); 24 | tName = bestTarget[0]; 25 | tMaxMoney = bestTarget[4]; 26 | tMinSec = bestTarget[5]; 27 | 28 | money_target = 0.75 * tMaxMoney; 29 | sec_level = (tMinSec - 0) + 2; //-0 to convert string to number 30 | 31 | tprint("Money: " + money_target); 32 | tprint("Security: " + sec_level); 33 | tprint("Memory Needed: " + hack_mem); 34 | 35 | rows = read("nmap.txt").split("\r\n"); 36 | 37 | for (i = 0; i < rows.length; ++i) { 38 | serverData = rows[i].split(','); 39 | if (serverData.length < 7) break; //Ignore last blank row 40 | 41 | svName = serverData[0]; 42 | svRamAvail = serverData[1]; 43 | if (hasRootAccess(svName) && (svName != "home")) { 44 | scp(hackScripts, "home", svName); 45 | num_threads = Math.floor(svRamAvail / hack_mem); 46 | //tprint(svName + " Numthreads: " + num_threads); 47 | if (num_threads > 0) { 48 | exec(hackScripts[0] , svName, num_threads, tName, money_target, sec_level); 49 | } 50 | exec(hackScripts[1], svName, 1, tName); 51 | } 52 | } -------------------------------------------------------------------------------- /Hacknet/6-13-17 - 'Any useful scripts to share' - unnamed(2).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/lephosto (https://www.reddit.com/user/lephosto) 4 | 5 | POSTED ON: 6 | June 14th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I made this one for my nodes. Allows some customization and levels things equally. My first time ever trying to "code" anything so I assume it could be written a -bit- better/efficient." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | ram_upgrade = 31; ram_interval = 30; cpu_core = 61; cpu_interval = 40; level_increment = 5; 18 | 19 | node_total = 0; max_level = 0; 20 | 21 | while(true) { 22 | 23 | node_total = node_total+4; 24 | max_level = max_level+20; 25 | 26 | if (node_total = 40) { 27 | kill(testnode.script); 28 | }; 29 | 30 | while(hacknetnodes.length < node_total) { 31 | purchaseHacknetNode(); 32 | }; 33 | 34 | 35 | for (node_level = 1; node_level < max_level; node_level = node_level+1) { 36 | 37 | 38 | for (node_number = 0; node_number < node_total; node_number = node_number+1) { 39 | 40 | 41 | if (hacknetnodes[node_number].level <= max_level) { 42 | 43 | if (hacknetnodes[node_number].level = ram_upgrade) { 44 | hacknetnodes[node_number].upgradeRam(); 45 | ram_upgrade = ram_upgrade+ram_interval; 46 | }; 47 | 48 | if (hacknetnodes[node_number].level = cpu_core) { 49 | hacknetnodes[node_number].upgradeCore(); 50 | cpu_core = cpu_core+cpu_interval; 51 | }; 52 | 53 | hacknetnodes[node_number].upgradeLevel(level_increment) 54 | } 55 | }; 56 | 57 | }; 58 | 59 | print(node_total); -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | React App 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Misc/mapper2.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/wingedRatite (https://www.reddit.com/user/wingedRatite) 4 | 5 | POSTED ON: 6 | January 1st, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I used your mapper script to write one that creates 3 .txt files, one storing server hostnames, one storing server money value, and one storing server security values in a comma separated array. That way I can run a separate function that has 3 arrays built in it. I run this after I run MaptoFile. It's 8.55 GB currently." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/7lmbpa/scripts_using_files/ 13 | */ 14 | 15 | 16 | servers = ["home"]; 17 | //clear("nmap.txt"); 18 | clear("hostsip.txt"); 19 | clear("hostsmon.txt"); 20 | clear("hostssec.txt"); 21 | 22 | for (i = 0; i < servers.length; ++i) { 23 | hostname = servers[i]; 24 | // write("nmap.txt", hostname 25 | // + "," + getServerRam(hostname)[0] 26 | // + "," + getServerNumPortsRequired(hostname) 27 | // + "," + getServerRequiredHackingLevel(hostname) 28 | // + "," + getServerMaxMoney(hostname) 29 | // + "," + getServerMinSecurityLevel(hostname) 30 | // + "," + getServerGrowth(hostname) 31 | // + "\r\n"); 32 | 33 | if ((getServerMaxMoney(hostname) > 0) && (hasRootAccess(hostname) === true)) { 34 | write("hostsip.txt", hostname + ","); 35 | write("hostsmon.txt", getServerMaxMoney(hostname) + ","); 36 | write("hostssec.txt", getServerMinSecurityLevel(hostname) + ","); 37 | } 38 | 39 | newScan = scan(hostname); 40 | for (j = 0; j < newScan.length; j++) { 41 | if (servers.indexOf(newScan[j]) == -1) { 42 | servers.push(newScan[j]); 43 | } 44 | } 45 | } 46 | 47 | tprint("Network mapped."); -------------------------------------------------------------------------------- /Hacknet/6-13-17 - 'Any useful scripts to share' - unnamed(1).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Zusias (https://www.reddit.com/user/Zusias) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Ram usage, 7.4. Buy nodes in a semi-optimized pattern up to level 71. I chose level 71 arbitrarily as that's about the point where any further upgrades take about an hour or longer to pay for themselves. You may want to include a sleep statement under the upgradeLevel block if it's using your money a bit too quickly." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | maxLevel = 10; 18 | nodes = 1; 19 | while(maxLevel < 71 || nodes < 19) { 20 | nodes = hacknetnodes.length; 21 | for(i = 0; i < nodes; i = i) { 22 | level = hacknetnodes[i].level; 23 | if(level < maxLevel) { 24 | hacknetnodes[i].upgradeLevel(maxLevel - level); 25 | } else { 26 | i = i + 1; 27 | }; 28 | }; 29 | 30 | purchase = false; 31 | 32 | if(nodes < 3) { 33 | purchase = true; 34 | } elif(maxLevel < 20) { 35 | maxLevel = 20; 36 | } elif(nodes < 6) { 37 | purchase = true; 38 | } elif(maxLevel < 30) { 39 | maxLevel = 30; 40 | } elif(nodes < 9) { 41 | purchase = true; 42 | } elif(maxLevel < 40) { 43 | maxLevel = 40; 44 | } elif(nodes < 12) { 45 | purchase = true; 46 | } elif(maxLevel < 50) { 47 | maxLevel = 50; 48 | } elif(nodes < 15) { 49 | purchase = true; 50 | } elif(maxLevel < 60) { 51 | maxLevel = 60; 52 | } elif(nodes < 17) { 53 | purchase = true; 54 | } elif(maxLevel < 71) { 55 | maxLevel = 71; 56 | } elif(nodes < 19) { 57 | purchase = true; 58 | }; 59 | 60 | if(purchase) { 61 | purchaseHacknetNode(); 62 | }; 63 | }; -------------------------------------------------------------------------------- /Late-game/smartHack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/i3aizey (https://www.reddit.com/user/i3aizey) 4 | 5 | POSTED ON: 6 | November 10th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "you can fill out these 4 scripts, that the 2 above uses, yourself, since they are pretty straight forward: 10 | 11 | hack.script -> hack(args[0]); RAM per thread: 1.6 12 | 13 | grow.script -> grow(args[0]); RAM per thread: 1.6 14 | 15 | weaken.script -> weaken(args[0]); RAM per thread: 1.6 16 | 17 | crack.script -> try to get root access to args[0] (RAM per thread: 3.0)" 18 | 19 | REDDIT POST: 20 | https://www.reddit.com/r/Bitburner/comments/79vncv/script_sharing_request/ 21 | */ 22 | 23 | 24 | 25 | self = getHostname(); 26 | target = args[0]; 27 | hackThreads = args[1] - 0; 28 | growThreads = args[2] - 0; 29 | weakThreads = args[3] - 0; 30 | level = args[4] - 0; 31 | 32 | /** 33 | * starts a given script with a given thread-count 34 | * ALWAYS gives the target as first and only argument 35 | */ 36 | function execute(script, threads) { while(!run(script + ".script", threads, target)){} } 37 | 38 | /** 39 | * Waits until a given script with target as only argument has ended 40 | */ 41 | function wait(script) { while(isRunning(script + ".script", self, target)){} } 42 | 43 | /* Clean-up since scripts restart from the top on reloading page */ 44 | 45 | wait("grow"); 46 | wait("weaken"); 47 | 48 | 49 | /* Actual hacking procedure */ 50 | 51 | while(true) { 52 | 53 | // Recalculate every 10 level-ups 54 | if(level + 10 < getHackingLevel()) 55 | break; 56 | 57 | // Start cycle 58 | execute("grow", growThreads); 59 | execute("weaken", weakThreads); 60 | hack(target); 61 | 62 | // Wait for cycle to end 63 | wait("grow"); 64 | wait("weaken"); 65 | 66 | } 67 | 68 | // Start re-calculation 69 | execute("calculator", 1); -------------------------------------------------------------------------------- /Any/hack/total_hack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/minno (https://www.reddit.com/user/minno) 4 | 5 | POSTED ON: 6 | July 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Designed to have a complicated script running single-threaded to control things, and simple scripts spawned off from it to run multithreaded, to efficiently use RAM." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 13 | */ 14 | 15 | 16 | 17 | print("Set up constants."); 18 | target = args[0]; 19 | hack_weaken_thread_ratio = 50 / 3.3; 20 | initial_weaken_threads = 1200; 21 | focus_money_threads = 1200; 22 | focus_weaken_threads = 200; 23 | 24 | print("Gain full access, if we don't already have it."); 25 | run("pwn_server.script", 1, target); 26 | while(isRunning("pwn_server.script", "home", target)) { 27 | sleep(10000); 28 | }; 29 | 30 | print("Bring server to minimum security."); 31 | run("initial_weaken.script", initial_weaken_threads, target); 32 | while(isRunning("initial_weaken.script", "home", target)) { 33 | sleep(10000); 34 | }; 35 | 36 | print("Start background process to keep it there."); 37 | run("focus_weaken.script", focus_weaken_threads, target); 38 | 39 | print("Grow its money to max."); 40 | run("initial_grow.script", focus_money_threads, target); 41 | while(isRunning("initial_grow.script", "home", target)) { 42 | sleep(10000); 43 | }; 44 | 45 | max_money = getServerMoneyAvailable(target); 46 | 47 | print("Hack it a few times and grow it once to measure growth rate."); 48 | run("single_hack.script", 10, target); 49 | while(isRunning("single_hack.script", "home", target)) { 50 | sleep(10000); 51 | }; 52 | 53 | growth_rate = (grow(target) - 1) * focus_money_threads; 54 | 55 | money_threshold = max_money / (1 + growth_rate); 56 | 57 | run("focus_money.script", focus_money_threads, target, money_threshold); -------------------------------------------------------------------------------- /Misc/max_threads.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Me66 (https://www.reddit.com/user/Me66) 4 | 5 | POSTED ON: 6 | June 26th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I wrote a script that calculates the max amount of threads a server can run for before running out of RAM. 10 | 11 | It's very slow and a job better suited for an excel spreadsheet or a simple equation, but it does the job in-game. 12 | 13 | Script: max_threads.script 14 | ... 15 | If you don't want it spamming how much each thread will cost simply delete the print line in the while loop. 16 | 17 | To use it simply add the base cost of the script as the first argument, and the amount of RAM (in GB) you want to use as the second. 18 | 19 | Example: run max_threads.script 2.44 64 20 | Will check how many scripts that cost 2.44GB RAM that can run on a 64GB server. 21 | 22 | To see the result you need to view the script log. 23 | 24 | I made two aliases: 25 | alias max_threads="run max_threads.script" 26 | alias rmax_threads="tail max_threads.script" 27 | 28 | I run the first then Up arrow, home, add the r and view the log with the result." 29 | 30 | REDDIT POST: 31 | https://www.reddit.com/r/Bitburner/comments/6jk2sp/max_threads_script/ 32 | */ 33 | 34 | 35 | 36 | base_cost = args[0]; 37 | ram = args[1]; 38 | 39 | thread_multiplier = 1.005; 40 | 41 | max_threads = 0; 42 | max_ram = 0; 43 | next_cost = base_cost; 44 | 45 | print("CALCULATING MAX THREADS"); 46 | print("Script RAM Cost: " + base_cost + "GB RAM"); 47 | print("Server Free RAM: " + ram + "GB RAM"); 48 | 49 | while(max_ram <= ram) { 50 | print(max_threads + " THREAD cost: " + max_ram + "/" + ram + "GB RAM"); 51 | 52 | max_ram = max_ram + next_cost; 53 | 54 | 55 | next_cost = next_cost * thread_multiplier; 56 | 57 | max_threads = max_threads + 1; 58 | 59 | }; 60 | 61 | print("CALCULATIONS DONE"); 62 | print("Max Threads: " + max_threads); -------------------------------------------------------------------------------- /Late-game/grow.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Reydien (https://www.reddit.com/user/Reydien) 4 | 5 | POSTED ON: 6 | September 15th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "FOREWARNING: This script is designed to be run on a server with tens of thousands of GB of free RAM. This script also does not always keep the full amount of necessary RAM occupied, so if you are checking server ram in other scripts it may not be accurate. 10 | 11 | This script will automatically determine how many thread of hack is needed to take a given server (at minimum security) from 100% money to 0% money, how many threads of grow is then needed to take the server back to 100% money, and finally how many threads of weaken is needed to bring the server back down to minimum security to repeat the process. It then uses those numbers and runs a set of ultra-light scripts to run each function in turn. The end result is that you receive MAX_MONEY from the server for every cycle of weaken you run. 12 | 13 | This script DOES NOT: 14 | 15 | Nuke the server. You must hack it manually or with another script first. 16 | 17 | Adjust its values as your hacking skill increases. At higher levels the hack script be overshooting the 100%, but that has no adverse effect. 18 | 19 | Check to see if the server has enough RAM for the process. Because the sub-scripts are not always running, simply checking free RAM can be deceiving. 20 | 21 | BE WARNED: If you run this when your hacking skill is exactly equal to the server's required skill, it will use A LOT of ram, like 300,000GB or more. I would recommend at least +10 skill, which would put the ram usage at about double the eventual lower limit. 22 | 23 | Scripts 24 | 25 | There are 4 scripts, Autohack.script, hack.script, grow.script, weaken.script. After saving all four, the syntax is simply "run Autohack.script target" Autohack.script" 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/70dj0q/autohack_script_set_for_midtolate_game/ 29 | */ 30 | 31 | 32 | 33 | grow(args[0]); -------------------------------------------------------------------------------- /Late-game/weaken.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Reydien (https://www.reddit.com/user/Reydien) 4 | 5 | POSTED ON: 6 | September 15th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "FOREWARNING: This script is designed to be run on a server with tens of thousands of GB of free RAM. This script also does not always keep the full amount of necessary RAM occupied, so if you are checking server ram in other scripts it may not be accurate. 10 | 11 | This script will automatically determine how many thread of hack is needed to take a given server (at minimum security) from 100% money to 0% money, how many threads of grow is then needed to take the server back to 100% money, and finally how many threads of weaken is needed to bring the server back down to minimum security to repeat the process. It then uses those numbers and runs a set of ultra-light scripts to run each function in turn. The end result is that you receive MAX_MONEY from the server for every cycle of weaken you run. 12 | 13 | This script DOES NOT: 14 | 15 | Nuke the server. You must hack it manually or with another script first. 16 | 17 | Adjust its values as your hacking skill increases. At higher levels the hack script be overshooting the 100%, but that has no adverse effect. 18 | 19 | Check to see if the server has enough RAM for the process. Because the sub-scripts are not always running, simply checking free RAM can be deceiving. 20 | 21 | BE WARNED: If you run this when your hacking skill is exactly equal to the server's required skill, it will use A LOT of ram, like 300,000GB or more. I would recommend at least +10 skill, which would put the ram usage at about double the eventual lower limit. 22 | 23 | Scripts 24 | 25 | There are 4 scripts, Autohack.script, hack.script, grow.script, weaken.script. After saving all four, the syntax is simply "run Autohack.script target" Autohack.script" 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/70dj0q/autohack_script_set_for_midtolate_game/ 29 | */ 30 | 31 | 32 | 33 | weaken(args[0]); -------------------------------------------------------------------------------- /Late-game/hack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Reydien (https://www.reddit.com/user/Reydien) 4 | 5 | POSTED ON: 6 | September 15th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "FOREWARNING: This script is designed to be run on a server with tens of thousands of GB of free RAM. This script also does not always keep the full amount of necessary RAM occupied, so if you are checking server ram in other scripts it may not be accurate. 10 | 11 | This script will automatically determine how many thread of hack is needed to take a given server (at minimum security) from 100% money to 0% money, how many threads of grow is then needed to take the server back to 100% money, and finally how many threads of weaken is needed to bring the server back down to minimum security to repeat the process. It then uses those numbers and runs a set of ultra-light scripts to run each function in turn. The end result is that you receive MAX_MONEY from the server for every cycle of weaken you run. 12 | 13 | This script DOES NOT: 14 | 15 | Nuke the server. You must hack it manually or with another script first. 16 | 17 | Adjust its values as your hacking skill increases. At higher levels the hack script be overshooting the 100%, but that has no adverse effect. 18 | 19 | Check to see if the server has enough RAM for the process. Because the sub-scripts are not always running, simply checking free RAM can be deceiving. 20 | 21 | BE WARNED: If you run this when your hacking skill is exactly equal to the server's required skill, it will use A LOT of ram, like 300,000GB or more. I would recommend at least +10 skill, which would put the ram usage at about double the eventual lower limit. 22 | 23 | Scripts 24 | 25 | There are 4 scripts, Autohack.script, hack.script, grow.script, weaken.script. After saving all four, the syntax is simply "run Autohack.script target" Autohack.script" 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/70dj0q/autohack_script_set_for_midtolate_game/ 29 | */ 30 | 31 | 32 | 33 | while (true) 34 | { 35 | if (hack(args[0])) {break;} 36 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | bitburner-community logo 4 |

5 | 6 |

bitburner-community

7 | 8 |
9 | 10 | 11 | 12 |
13 | 14 | --- 15 | 16 |

A community for Bitburner. 17 |
18 |

19 | 20 |
https://www.bitburnercommunity.site/
21 | 22 | ## 📝 Table of Contents 23 | 24 | - [About](#about) 25 | - [Author](#author) 26 | - [Acknowledgments](#acknowledgement) 27 | 28 | ## 🧐 About 29 | 30 | A community to post code and tips for the game Bitburner. 31 | 32 | ## ✍️ Author 33 | 34 | - [Alex Lee](https://github.com/alexlee-dev) - Developer 35 | 36 | ## 🎉 Acknowledgements 37 | 38 | - Icon made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [www.flaticon.com](https://www.flaticon.com/) and is licensed by [CC 3.0 BY](http://creativecommons.org/licenses/by/3.0/). 39 | 40 | [npm-image]: https://img.shields.io/npm/v/bitburner-community.svg 41 | [npm-downloads]: https://img.shields.io/npm/dt/bitburner-community.svg 42 | [npm-url]: https://www.npmjs.com/package/bitburner-community 43 | [size-image]: https://img.shields.io/bundlephobia/minzip/bitburner-community.svg 44 | [bitburner-community-icon]: https://github.com/alexlee-dev/bitburner-community/raw/master/bitburner-community.png 45 | -------------------------------------------------------------------------------- /Misc/spider.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/heyitsmikeyv (https://www.reddit.com/user/heyitsmikeyv) 4 | 5 | POSTED ON: 6 | December 19th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I'm pretty new to bitburner, just started yesterday. But web dev is a big part of what I do for a living and I love being able to write code as a gameplay mechanic. Seriously the coolest thing ever. 10 | 11 | Anyway, I did some looking around on the wiki and this subreddit and haven't been able to find a reliable prebuilt method to recursively scan machines until I've found everything. I needed to build a spidering utility. 12 | 13 | This is a standalone function you can include in any of your scripts to reliably generate an array of networked servers, useful for automating script deployments and mass-rooting of systems. 14 | 15 | Total overhead to include the function clocks in at 0.7GB. 16 | 17 | Hope this helps! 18 | 19 | EDIT: In case this needs an example for a use-case. Here's an example of a script that will upload a file to every possible server: 20 | 21 | allServers = spider(); 22 | 23 | for (i = 0; i < allServers.length; i++) { 24 | scp('botnet.script', allServers[i]); 25 | }" 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/7jgxpv/tip_work_while_monitoring_a_script/https://www.reddit.com/r/Bitburner/comments/7kqy07/useful_netscript_function_spider_returns_an_array/ 29 | */ 30 | 31 | 32 | function spider() { 33 | // Return an array of all identifiable servers 34 | 35 | // Create a serversSeen array, containing only 'home' for now 36 | serversSeen = ['home']; 37 | 38 | // For every server we've seen so far, do a scan 39 | for (i = 0; i < serversSeen.length; i++) { 40 | thisScan = scan(serversSeen[i]); 41 | // Loop through results of the scan, and add any new servers 42 | for (j = 0; j < thisScan.length; j++) { 43 | // If this server isn't in serversSeen, add it 44 | if (serversSeen.indexOf(thisScan[j]) === -1) { 45 | serversSeen.push(thisScan[j]); 46 | } 47 | } 48 | } 49 | return serversSeen; 50 | } -------------------------------------------------------------------------------- /Misc/text.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/chapt3r (https://www.reddit.com/user/chapt3r) 4 | 5 | POSTED ON: 6 | December 12th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Theoretically you can use whatever delimiters you want and then use the string split() function to parse out your data. 10 | 11 | Anything you write to the text file is stored as-is as a Javascript string. One issue right now is that if you try to display the data using Netscript's print() function, it won't display newline characters properly. However, the underlying data in the text file will still contain any newline characters that you originally wrote. Also, reading the text file using the 'cat' Terminal command does properly display line breaks. 12 | 13 | I created a small example of how you could get csv-like data using text files. (Note I play on a Windows machine so I use the '\r\n' as line breaks. This way if I download the file they will be formatted as expected)" 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/7jazor/how_do_txt_files_work/ 17 | */ 18 | 19 | 20 | 21 | //Takes an array and writes the array's data to a text file as a row in 22 | //comma-delimited csv format. 23 | function writeCsvRow(fn, arrData) { 24 | row = arrData.join(","); 25 | row += "\r\n"; 26 | write(fn, row, 'a'); 27 | } 28 | 29 | //Converts an array into a string using the format [X,X,X,X,X] 30 | function formatArray(arr) { 31 | res = "["; 32 | res += arr.join(","); 33 | res += "]"; 34 | return res; 35 | } 36 | 37 | //Reads a csv file and print it 38 | function readCsvFile(fn) { 39 | file = read(fn); 40 | 41 | 42 | rows = file.split("\r\n"); //Parse rows using newline character 43 | for (i = 0; i < rows.length; ++i) { 44 | //Parse each row into an array using split() 45 | row = rows[i].split(","); 46 | 47 | //Do whatever you want with your row. I'm just printing it 48 | print(formatArray(row)); 49 | } 50 | } 51 | 52 | 53 | 54 | fn = "foo.txt"; 55 | 56 | clear(fn); 57 | 58 | writeCsvRow(fn, [1,2,3,4,5,6,7,8,9,10]); 59 | writeCsvRow(fn, [11,12,13,14,15,16,17,18,19,20]); 60 | writeCsvRow(fn, [21,22,23,24,25,26,27,28,29,30]); 61 | 62 | readCsvFile(fn); -------------------------------------------------------------------------------- /Misc/RamEaterVirus.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/nanodemerzel (https://www.reddit.com/user/nanodemerzel) 4 | 5 | POSTED ON: 6 | June 18th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I have a script that can fix that: the RAMEaterVirus. 10 | 11 | Simply save as "RamEaterVirus.script" and run it on any computer with... 12 | run RamEaterVirus.script 13 | 14 | Then watch as your available RAM disappears (takes some time to fully vanish). Did a great job with my 16PB. Here is the script. You might need to adjust the sleep time if the next script starts too slowly. 15 | ... 16 | 17 | Edit: Just realized this could be adapted to setup a script that uses roughly half ( or 1/4, 3/4, 1/128) of your RAM. Not as good as having getServerRam() and getScriptRam(script, threads), but maybe useful." 18 | 19 | REDDIT POST: 20 | https://www.reddit.com/r/Bitburner/comments/6hyeyp/in_case_you_have_too_much_ram/ 21 | */ 22 | 23 | 24 | 25 | print("Started"); 26 | this = "RamEaterVirus.script"; 27 | if(args.length != 3){ 28 | host = getHostname(); 29 | threads = 1; 30 | layer = 1; 31 | } else { 32 | host = args[0]; 33 | threads = args[1]; 34 | layer = args[2]; 35 | }; 36 | 37 | if(host != getHostname() ) scp(this, host); 38 | 39 | steps = Array[100, 10, 1, 0]; 40 | for(i = 0; i < steps.length; i = i + 1){ 41 | t = threads + steps[i]; 42 | 43 | if( i > 0 ){ 44 | j = i - 1; 45 | } else { 46 | j = 1; 47 | }; 48 | 49 | stasis = false; 50 | if(isRunning(this, host, host, threads + steps[j], layer) ){ 51 | print("Successfully ate more RAM."); 52 | steps.clear(); 53 | } else { 54 | if ( t == threads ){ 55 | stasis = true; 56 | amt = ""; 57 | denom = 1; 58 | for(l = 0; l < layer; l = l + 1) { 59 | amt = amt + "half of "; 60 | denom = denom * 2; 61 | }; 62 | print("I'm eating about " + amt + "your available RAM (1/2^" + layer + " or 1 part in " + denom + ")."); 63 | t = 1; 64 | layer = layer + 1; 65 | }; 66 | 67 | exec(this, host, t, host, t, layer); 68 | while(stasis) "whir"; 69 | sleep(1000); 70 | }; 71 | }; -------------------------------------------------------------------------------- /Misc/4gb-auto-hack-0ram.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/desci1 (https://www.reddit.com/user/desci1) 4 | 5 | POSTED ON: 6 | July 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "This one hacks servers that are not running the loop-hack.script, which means they don't have enough memory to run scripts." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6p24g8/deepscanscript/ 13 | */ 14 | 15 | 16 | 17 | /* 18 | 4gb-auto-hack-0ram.script 19 | for bitburner's netscript 20 | version: 2 21 | winners don't use copyright 22 | remove all comments to save RAM 23 | 24 | this script hacks servers that have only 0gb of RAM and therefore can't run scripts on their own. 25 | TODO: as there's no getServerMemory() yet, the test for this is too complex and consume a lot of RAM. 26 | */ 27 | 28 | startingServer = 0; 29 | 30 | hackVersion = 3; 31 | 32 | ownServers = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31' ] 33 | 34 | allServers = [ 'foodnstuff' ]; 35 | 36 | while (true) { 37 | servers = allServers; 38 | if (startingServer == allServers.length) startingServer = 0; 39 | for (server = startingServer; server < servers.length; server++) { 40 | if (getHackingLevel() >= getServerRequiredHackingLevel(servers[server]) && hasRootAccess(servers[server]) == true && isRunning('loop-hack.script', servers[server], hackVersion) == false) hack(servers[server]); 41 | newServers = scan(servers[server]); 42 | for (newServer = 0; newServer < newServers.length; newServer++) { 43 | isNewServer = true; 44 | if (newServers[newServer] == 'home') isNewServer = false; 45 | for (checkServer = 0; checkServer < ownServers.length; checkServer++) if (newServers[newServer] == 'home-' + ownServers[checkServer]) isNewServer = false; 46 | for (checkServer = 0; checkServer < allServers.length; checkServer++) if (newServers[newServer] == allServers[checkServer]) isNewServer = false; 47 | if (isNewServer) allServers = allServers.concat(newServers[newServer]); 48 | } 49 | } 50 | startingServer = server; 51 | } -------------------------------------------------------------------------------- /Hacknet/manage-hacknet.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | July 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Thanks, it's just for fun, and there's always some kind of improvement to be made. 10 | 11 | If you don't mind it spending a lot of money, you can try something like this, and change the node limit (and other settings) to your liking. The script calls to do anything to hacknet are expensive, and so are the loops. It's 12.34 GB in all. The mincounter keeps it from having to loop through every node when it already has them maxed for a bit of extra ram overhead. You can simplify it greatly to just brute force upgrades and it will reduce cost by quite a bit. 12 | 13 | I don't really mess with the hacknet much now; hacking (and other active income) starts to outpace it fairly quickly." 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/6mf6zy/v0241_progression_scripts_update/ 17 | */ 18 | 19 | 20 | 21 | maxHacknetNodes = 30; 22 | maxLevel = 200; 23 | maxRam = 6; 24 | maxCores = 16; 25 | minCounterAlreadyMaxed = 0; 26 | while (true) { 27 | if (hacknetnodes.length < maxHacknetNodes) { 28 | purchaseHacknetNode(); 29 | } 30 | for (i = minCounterAlreadyMaxed; i < hacknetnodes.length; i = i + 1) { 31 | toLevel = maxLevel - hacknetnodes[i].level; 32 | if (toLevel > 0) { 33 | hacknetnodes[i].upgradeLevel(toLevel); 34 | } 35 | ramLoop = 1; 36 | ramCounter = 0; 37 | while (ramLoop < hacknetnodes[i].ram) { 38 | ramLoop = ramLoop * 2; 39 | ramCounter = ramCounter + 1; 40 | } 41 | toRam = maxRam - ramCounter; 42 | while (toRam > 0) { 43 | hacknetnodes[i].upgradeRam(); 44 | toRam = toRam - 1; 45 | } 46 | toCore = maxCores - hacknetnodes[i].cores; 47 | while (toCore > 0) { 48 | hacknetnodes[i].upgradeCore(); 49 | toCore = toCore - 1; 50 | } 51 | if (i == minCounterAlreadyMaxed) { 52 | if (toRam == 0 && toCore == 0 && toLevel == 0) { 53 | print ('node ' + minCounterAlreadyMaxed + ' maxed'); 54 | minCounterAlreadyMaxed++; 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /Any/weaken-grow-hack/virus.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Calebhk98 (https://www.reddit.com/user/Calebhk98) 4 | 5 | POSTED ON: 6 | November 2nd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "This script is a virus that gains access to everyone, and grows/weakens/hacks them appropriately." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/79vncv/script_sharing_request/ 13 | */ 14 | 15 | 16 | 17 | function defaultHack(server){ 18 | hack(server); 19 | return true; 20 | } 21 | function boolToNumber(check){ 22 | if(check===true){ 23 | return 1; 24 | } 25 | else{ 26 | return 0; 27 | } 28 | } 29 | Brute=boolToNumber(fileExists('brutessh.exe','home'));//Not able to add in True and false 30 | Crack=boolToNumber(fileExists('ftpcrack.exe','home')); 31 | Relay=boolToNumber(fileExists('relaysmtp.exe','home')); 32 | Http=boolToNumber(fileExists('httpworm.exe','home')); 33 | Sql=boolToNumber(fileExists('sqlinject.exe','home')); 34 | BreackThrough=Brute+(Crack)+(Relay)+(Http)+(Sql); 35 | servers=scan(); 36 | print(servers); 37 | while(true){ 38 | for(i = 0; i < servers.length; ++i) { 39 | if(servers[i]!="home"){ 40 | if(hasRootAccess(servers[i])){ 41 | scp('hackemall.script','home',servers[i]); 42 | exec('hackemall.script',servers[i]); 43 | if(getServerMoneyAvailable(servers[i])>(getServerMaxMoney(servers[i])/2)){ 44 | if(getServerSecurityLevel(servers[i])>getServerBaseSecurityLevel(servers[i])+10){ 45 | weaken(servers[i]); 46 | } 47 | else if(getHackingLevel()>=getServerRequiredHackingLevel(servers[i])) { 48 | defaultHack(servers[i]); 49 | } 50 | } 51 | else{ 52 | grow(servers[i]); 53 | } 54 | } 55 | else if(getServerNumPortsRequired(servers[i])<=BreackThrough){ 56 | if(Sql){ 57 | sqlinject(servers[i]); 58 | } 59 | if(Http){ 60 | httpworm(servers[i]); 61 | } 62 | if(Crack){ 63 | ftpcrack(servers[i]); 64 | } 65 | if(Relay){ 66 | relaysmtp(servers[i]); 67 | } 68 | if(Brute){ 69 | brutessh(servers[i]); 70 | } 71 | nuke(servers[i]); 72 | } 73 | else{ 74 | print("Too many ports needed"); 75 | print("I need "); 76 | print(getServerNumPortsRequired(servers[i])); 77 | print("For"); 78 | print (servers[i]); 79 | 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Stock Market/momentum.s: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Rinchwind (https://www.reddit.com/user/Rinchwind) 4 | 5 | POSTED ON: 6 | December 3rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "After running many, many simulations, I've come to a conclusion that in most cases, a script would perform worse than just putting money in a few stocks and forgetting about it for a few days (while letting the game run in the background). just like in real life... :) 10 | 11 | However, with the highly volatile stocks (JGN, SGC, APHE and CTYS), a well-tuned script can produce much better results (statistically speaking. It can still perform miserably in some situations, but usually it will get me to several thousand trillion within a day or two) 12 | 13 | To use the script, run InvestmentBroker.script and use _InvestmentBroker_Msg.script to send commands to it. 14 | You can run the main script on a private server (just copy InvestmentBroker.script, _InvestmentBroker.script, _InvestmentBroker_Data.script and _InvestmentBroker_Manager.script. You can run the messaging script from the home server) or on the home server, it needs at least 153Mb to manage all 4 stocks. 15 | 16 | I’ve also defined the following aliases to make using it easier: 17 | 18 | alias InvestmentBrokerStatus="run _InvestmentBroker_Msg.script S" 19 | alias InvestmentBrokerBuyStock="run _InvestmentBroker_Msg.script A" 20 | alias InvestmentBrokerLiquidate="run _InvestmentBroker_Msg.script L" 21 | 22 | For instance, to buy 25,000,000$ worth of JGN stock, type the following: 23 | 24 | InvestmentBrokerBuyStock JGN 25000000 25 | 26 | To liquidate all JGN stock, type the following: 27 | 28 | InvestmentBrokerLiquidate JGN " 29 | 30 | REDDIT POST: 31 | https://www.reddit.com/r/Bitburner/comments/78zva1/stock_script_brainstorming/ 32 | */ 33 | 34 | 35 | 36 | //-------------------------------------------------------------------------------------------------------------------------- 37 | //---------------------------_InvestmentBroker_Msg.script------------------------------------------------------------------- 38 | //-------------------------------------------------------------------------------------------------------------------------- 39 | 40 | INPUT_PORT = 10; 41 | msg = ""; 42 | for (i = 0; i < args.length; i++) 43 | { 44 | msg = msg + args[i] + " "; 45 | } 46 | write(INPUT_PORT, msg); -------------------------------------------------------------------------------- /Stock Market/_InvestmentBroker_Msg.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Rinchwind (https://www.reddit.com/user/Rinchwind) 4 | 5 | POSTED ON: 6 | December 3rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "After running many, many simulations, I've come to a conclusion that in most cases, a script would perform worse than just putting money in a few stocks and forgetting about it for a few days (while letting the game run in the background). just like in real life... :) 10 | 11 | However, with the highly volatile stocks (JGN, SGC, APHE and CTYS), a well-tuned script can produce much better results (statistically speaking. It can still perform miserably in some situations, but usually it will get me to several thousand trillion within a day or two) 12 | 13 | To use the script, run InvestmentBroker.script and use _InvestmentBroker_Msg.script to send commands to it. 14 | You can run the main script on a private server (just copy InvestmentBroker.script, _InvestmentBroker.script, _InvestmentBroker_Data.script and _InvestmentBroker_Manager.script. You can run the messaging script from the home server) or on the home server, it needs at least 153Mb to manage all 4 stocks. 15 | 16 | I’ve also defined the following aliases to make using it easier: 17 | 18 | alias InvestmentBrokerStatus="run _InvestmentBroker_Msg.script S" 19 | alias InvestmentBrokerBuyStock="run _InvestmentBroker_Msg.script A" 20 | alias InvestmentBrokerLiquidate="run _InvestmentBroker_Msg.script L" 21 | 22 | For instance, to buy 25,000,000$ worth of JGN stock, type the following: 23 | 24 | InvestmentBrokerBuyStock JGN 25000000 25 | 26 | To liquidate all JGN stock, type the following: 27 | 28 | InvestmentBrokerLiquidate JGN " 29 | 30 | REDDIT POST: 31 | https://www.reddit.com/r/Bitburner/comments/78zva1/stock_script_brainstorming/ 32 | */ 33 | 34 | 35 | 36 | //-------------------------------------------------------------------------------------------------------------------------- 37 | //---------------------------_InvestmentBroker_Msg.script------------------------------------------------------------------- 38 | //-------------------------------------------------------------------------------------------------------------------------- 39 | 40 | INPUT_PORT = 10; 41 | msg = ""; 42 | for (i = 0; i < args.length; i++) 43 | { 44 | msg = msg + args[i] + " "; 45 | } 46 | write(INPUT_PORT, msg); -------------------------------------------------------------------------------- /Hacknet/rent.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Early in the game, hacknet nodes are a modest source of passive income, but I don't like clicking things. This is a lazy and simplistic method of slowly upgrading nodes that keeps some cash on hand for more important things (like RAM). I don't really bother trying to optimize hacknet because time can be better spent. That said, feel free to recommend better strategies; I'd be interested in seeing an elaborate/optimized hacknet algorithm, regardless of the RAM pressure. 10 | 11 | Note: The "break;" calls in the script prevent it from doing more than one thing at a time - the reason for this is primarily to capitalize on only having one getServerMoneyAvailable() call at the beginning. This means it's going to move very slowly. Like I said, I tend to forget about the hacknet. 12 | 13 | It's also worth pointing out that RAM costs on the hacknet functions are rather high. It's even pricey to call "hacknetnodes[i]" which is why the immediate declaration of "node = hacknetnodes[i]" saves a bit." 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/6zrcug/increment_hacknet/ 17 | */ 18 | 19 | 20 | 21 | //1% of current funds, per cycle. 22 | allowancePercentage = 0.01; 23 | while (true) { 24 | currentCash = getServerMoneyAvailable('home'); 25 | currentCash *= allowancePercentage; 26 | if (getNextHacknetNodeCost() <= currentCash) { 27 | purchaseHacknetNode(); 28 | } else { 29 | for (i = 0; i < hacknetnodes.length; i++) { 30 | node = hacknetnodes[i]; 31 | upgradeCost = node.getLevelUpgradeCost(1); 32 | if (upgradeCost <= currentCash) { 33 | node.upgradeLevel(1); 34 | break; 35 | } else { 36 | ramCost = node.getRamUpgradeCost(); 37 | if (ramCost <= currentCash) { 38 | node.upgradeRam(); 39 | break; 40 | } else { 41 | coreCost = node.getCoreUpgradeCost(); 42 | if (coreCost <= currentCash) { 43 | node.upgradeCore(); 44 | break; 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /Any/nuke/nuke.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | July 10th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Purpose: Handles actually nuking the target. Runs break once to continue the cascade. Runs daemon only if conditions are met. Daemon does all the real work." 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6mf6zy/v0241_progression_scripts_update/ 13 | */ 14 | 15 | 16 | 17 | thisTarget = args[0]; 18 | previousHost = args[1]; 19 | minimumHackLevel = args[2]; 20 | hackLimit = args[3]; 21 | thisHost = getHostname(); 22 | portsToBust = getServerNumPortsRequired(thisTarget); 23 | hasRunBreak = false; 24 | shouldRunDaemon = true; 25 | while (hasRunBreak == false || hasRootAccess(thisTarget) == false || (isRunning('daemon.script', thisHost, thisTarget, previousHost) == false && shouldRunDaemon == true)) { 26 | portBusters = ['BruteSSH.exe', 'FTPCrack.exe', 'relaySMTP.exe', 'HTTPWorm.exe', 'SQLInject.exe']; 27 | numPortBreakers = 0; 28 | for (i = 0; i < portBusters.length; i = i + 1) { 29 | if (fileExists(portBusters[i], 'home')) { 30 | numPortBreakers = numPortBreakers + 1; 31 | } 32 | } 33 | if (portsToBust <= numPortBreakers && hasRootAccess(thisTarget) == false) { 34 | if (portsToBust > 4) 35 | sqlinject(thisTarget); 36 | if (portsToBust > 3) 37 | httpworm(thisTarget); 38 | if (portsToBust > 2) 39 | relaysmtp(thisTarget); 40 | if (portsToBust > 1) 41 | ftpcrack(thisTarget); 42 | if (portsToBust > 0) 43 | brutessh(thisTarget); 44 | nuke(thisTarget); 45 | } 46 | while (isRunning('break.script', thisHost, thisTarget, previousHost, minimumHackLevel, hackLimit) == false && hasRunBreak == false) { 47 | run('break.script', 1, thisTarget, previousHost, minimumHackLevel, hackLimit); 48 | } 49 | hasRunBreak = true; 50 | serverLevel = getServerRequiredHackingLevel(thisTarget); 51 | shouldRunDaemon = serverLevel <= hackLimit && serverLevel >= minimumHackLevel && getServerMaxMoney(thisTarget) > 0; 52 | if (hasRootAccess(thisTarget) == true && shouldRunDaemon == true) { 53 | while (isRunning('daemon.script', thisHost, thisTarget, previousHost) == false) { 54 | run('daemon.script', 1, thisTarget, previousHost); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /Early-game/8gb-auto-deepscan.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/desci1 (https://www.reddit.com/user/desci1) 4 | 5 | POSTED ON: 6 | July 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "This one shouldn't consume more than 8gb ram, making it suitable for new games 10 | Current memory usage without the comments: This script requires 7,72GB of RAM to run for 1 thread(s)" 11 | 12 | REDDIT POST: 13 | https://www.reddit.com/r/Bitburner/comments/6p24g8/deepscanscript/ 14 | */ 15 | 16 | 17 | 18 | /* 19 | 8gb-auto-deepscan.script 20 | for bitburner's netscript 21 | version: 12 22 | winners don't use copyright 23 | remove all comments to save RAM 24 | 25 | this is a lite version of the auto-deepscan.script intended for servers with a maximum of 8gb available. 26 | */ 27 | 28 | startingServer = 0; 29 | allServers = scan(getHostname()); 30 | while (true) { 31 | servers = allServers; 32 | if (startingServer == allServers.length) startingServer = 0; 33 | for (server = startingServer; server < servers.length; server++) { 34 | if (getHackingLevel() >= getServerRequiredHackingLevel(servers[server])) { 35 | if (hasRootAccess(servers[server]) == false && getServerNumPortsRequired(servers[server]) == 0) { 36 | nuke(servers[server]); 37 | } 38 | if (hasRootAccess(servers[server]) == true) { 39 | if (isRunning('loop-hack.script', servers[server]) == false) { 40 | scp('loop-hack.script', servers[server]); 41 | exec('loop-hack.script', servers[server], 1); 42 | } 43 | if (isRunning('loop-grow.script', servers[server]) == false) { 44 | scp('loop-grow.script', servers[server]); 45 | for (t = 10; t > 0; t--) { 46 | exec('loop-grow.script', servers[server], t); 47 | } 48 | } 49 | } 50 | } 51 | newServers = scan(servers[server]); 52 | for (newServer = 0; newServer < newServers.length; newServer++) { 53 | isNewServer = true; 54 | for (checkServer = 0; checkServer < allServers.length; checkServer++) if (newServers[newServer] == 'home' || newServers[newServer] == allServers[checkServer]) isNewServer = false; 55 | if (isNewServer) allServers = allServers.concat(newServers[newServer]); 56 | } 57 | } 58 | startingServer = server; 59 | } -------------------------------------------------------------------------------- /Singularity/faction.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Ninichat1 (https://www.reddit.com/user/Ninichat1) 4 | 5 | POSTED ON: 6 | January 1st, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Here's what I got so far: 10 | ... 11 | faction is the faction you wanna give reputation to. 12 | target is the company you wish to infiltrate. 13 | Example: keep_infiltrating_faction("BitRunners", "sector12-joesguns"); 14 | 15 | When you want to stop the code from running, enter: 16 | keep_going = false; 17 | in the console. 18 | 19 | Caution: this is a bit too strong imo, but it makes grinding reputation less grindy." 20 | 21 | REDDIT POST: 22 | https://www.reddit.com/r/Bitburner/comments/7n8ezq/help_with_automating_infiltrations/ 23 | */ 24 | 25 | 26 | var keep_going = false; 27 | 28 | function sleep(ms) 29 | { 30 | return new Promise(resolve => setTimeout(resolve, ms)); 31 | } 32 | 33 | function isAvailable(option) 34 | { 35 | return option.style.display === "block"; 36 | } 37 | 38 | function infiltrate_faction(faction, target, first) 39 | { 40 | document.getElementById(target).click(); 41 | document.getElementById("location-infiltrate").click(); 42 | 43 | var infiltrate_hack = document.getElementById("infiltration-hacksecurity"); 44 | var infiltrate_stealthko = document.getElementById("infiltration-stealthknockout"); 45 | var infiltrate_escape = document.getElementById("infiltration-escape"); 46 | 47 | var progress = document.getElementById("infiltration-level-text"); 48 | var infiltration_box = document.getElementById("infiltration-box-container"); 49 | 50 | for (i = 0; (first || !isAvailable(infiltration_box)) && i < 100; i++) 51 | { 52 | if (i > 50) 53 | infiltrate_escape.click(); 54 | else if (isAvailable(infiltrate_hack)) 55 | infiltrate_hack.click(); 56 | else if (isAvailable(infiltrate_stealthko)) 57 | infiltrate_stealthko.click(); 58 | } 59 | 60 | document.getElementById("infiltration-faction-select").value = faction; 61 | document.getElementById("infiltration-box-faction").click(); 62 | document.getElementById("location-hospital-treatment").click(); 63 | } 64 | 65 | async function keep_infiltrating_faction(faction, target) 66 | { 67 | keep_going = true; 68 | //target = "ishima-omegasoftware"; 69 | infiltrate_faction(faction, "sector12-joesguns", true); 70 | while (keep_going) 71 | { 72 | infiltrate_faction(faction, target, false); 73 | await sleep(500); 74 | } 75 | } -------------------------------------------------------------------------------- /Any/hack/distrAndRun_mod.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/wingedRatite (https://www.reddit.com/user/wingedRatite) 4 | 5 | POSTED ON: 6 | January 1st, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Then I run a modified version of your distrAndRun script: it only runs scripts on my created servers and so is amicable to any RAM amount. It runs a couple of my universal three argument grow-weaken-hack script (2.4 GB, lightweight enough when you have 8TB servers), and then targets every single server with money with a universal hacking script. It's 11.30 GB currently. 10 | ... 11 | It always returns 25 errors whenever it finishes because my .txt files end with a hanging comma. But I am bringing in $1.2B/sec on my first BitNode, and without any neutral servers running any scripts, just home and my dong servers. 12 | 13 | permalinkembedsavereportgive goldreply" 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/7lmbpa/scripts_using_files/ 17 | */ 18 | 19 | 20 | hackScripts = ["unihack.script"]; 21 | hack_mem = getScriptRam(hackScripts[0], "home"); 22 | bestTarget = read("best_target.txt").split(","); 23 | tName = bestTarget[0]; 24 | tMaxMoney = bestTarget[4]; 25 | tMinSec = bestTarget[5]; 26 | money_target = 0.75 * tMaxMoney; 27 | sec_level = (tMinSec - 0) + 1; //-0 to convert string to number 28 | tprint("Target: " + tName); 29 | tprint("Money: " + money_target); 30 | tprint("Security: " + sec_level); 31 | tprint("Memory Needed: " + hack_mem); 32 | dong = 0; 33 | while (dong < 25) { 34 | scp(hackScripts[0], "home", "dong"+dong); 35 | exec(hackScripts[0], "dong"+dong, 30, tName, money_target, sec_level); 36 | exec(hackScripts[0], "dong"+dong, 30, tName, money_target + 1, sec_level); 37 | exec(hackScripts[0], "dong"+dong, 30, tName, money_target + 2, sec_level); 38 | dong++; 39 | } 40 | arName = read("hostsip.txt").split(","); 41 | arMoney = read("hostsmon.txt").split(","); 42 | arSec = read("hostssec.txt").split(","); 43 | svRamAvail = getServerRam("dong0"); 44 | num_threads = Math.floor((svRamAvail[0] - svRamAvail[1]) / (arName.length * hack_mem)); 45 | dong = 0; 46 | i = 0; 47 | while(i < arName.length) { for (i = 0; i < arName.length; ++i) { 48 | dong = 0; 49 | tname = arName[i]; 50 | money = 0.75 * arMoney[i]; 51 | sec = (arSec[i] - 0) + 2; 52 | while (dong < 25) { 53 | exec(hackScripts[0], "dong"+dong, num_threads, tname, money, sec); 54 | dong++; 55 | } 56 | tprint("Dongs enlarged for: " + tname); 57 | i++; 58 | } 59 | } 60 | tprint("Fin"); -------------------------------------------------------------------------------- /Stock Market/InvestmentBroker.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Rinchwind (https://www.reddit.com/user/Rinchwind) 4 | 5 | POSTED ON: 6 | December 3rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "After running many, many simulations, I've come to a conclusion that in most cases, a script would perform worse than just putting money in a few stocks and forgetting about it for a few days (while letting the game run in the background). just like in real life... :) 10 | 11 | However, with the highly volatile stocks (JGN, SGC, APHE and CTYS), a well-tuned script can produce much better results (statistically speaking. It can still perform miserably in some situations, but usually it will get me to several thousand trillion within a day or two) 12 | 13 | To use the script, run InvestmentBroker.script and use _InvestmentBroker_Msg.script to send commands to it. 14 | You can run the main script on a private server (just copy InvestmentBroker.script, _InvestmentBroker.script, _InvestmentBroker_Data.script and _InvestmentBroker_Manager.script. You can run the messaging script from the home server) or on the home server, it needs at least 153Mb to manage all 4 stocks. 15 | 16 | I’ve also defined the following aliases to make using it easier: 17 | 18 | alias InvestmentBrokerStatus="run _InvestmentBroker_Msg.script S" 19 | alias InvestmentBrokerBuyStock="run _InvestmentBroker_Msg.script A" 20 | alias InvestmentBrokerLiquidate="run _InvestmentBroker_Msg.script L" 21 | 22 | For instance, to buy 25,000,000$ worth of JGN stock, type the following: 23 | 24 | InvestmentBrokerBuyStock JGN 25000000 25 | 26 | To liquidate all JGN stock, type the following: 27 | 28 | InvestmentBrokerLiquidate JGN " 29 | 30 | REDDIT POST: 31 | https://www.reddit.com/r/Bitburner/comments/78zva1/stock_script_brainstorming/ 32 | */ 33 | 34 | 35 | 36 | //-------------------------------------------------------------------------------------------------------------------------- 37 | //---------------------------InvestmentBroker.script------------------------------------------------------------------------ 38 | //-------------------------------------------------------------------------------------------------------------------------- 39 | 40 | // Clear database 41 | write("_Investment_DB.txt","","w"); 42 | 43 | // Clean ports 44 | for (portId = 1; portId <= 10; portId++) 45 | { 46 | inputCommand = "" 47 | while (inputCommand !== 'NULL PORT DATA') 48 | { 49 | print(inputCommand); 50 | inputCommand = read(portId); 51 | } 52 | } 53 | 54 | run("_InvestmentBroker.script", 1); -------------------------------------------------------------------------------- /Stock Market/fsig.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/XxZombGuyxX (https://www.reddit.com/user/XxZombGuyxX) 4 | 5 | POSTED ON: 6 | September 28th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I made a script with TIX API and I haven't seen a lot of people talk about it and figured I'd try it out. WITH THE WAY I SET IT UP THIS SCRIPT WILL SPAM AND UPDATE INTO THE TERMINAL. IM SORRY BUT I JUST LIKE IT THAT WAY, TO CHANGE IT CHANGE ALL tprint() FUNCTIONS to print() 10 | 11 | fsig.script is 19.00 GB: you need the TIX API first ,basically I just made a script that would capitalize on highs and lows I used FSIG and studied how >low and high it would go at times, the lowest I have seen FSIG go is about 1.4 mill but rarely at times did it always go that far so for simplicities sake I did 1.700m and 1.900m for highs and lows. but it can pay out much higher if you change the "1700000" to a lower number above "1400000"." 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/72xmgy/stock_script_i_made/ 15 | */ 16 | 17 | 18 | 19 | pos = getStockPosition('FSIG'); //defines an usable array for stocks 20 | shares = pos[0]; // gets the total amount of shares 21 | avgPriPerStock = pos[1]; //gets AvgPricePerStock 22 | //the above pos arrays are only defined because it was easier to explain and keep track of 23 | while(true){ 24 | pos = getStockPosition('FSIG'); //this is so the pos array gets updated and shows appropriate amounts every loop 25 | getServerMoneyAvailable("home"); //just cause, this wont print to terminal 26 | getStockPrice('FSIG');// same reason as getServerMoneyAvailable 27 | tprint('you own ' + pos[0] + ' shares from FSIG.');// shows how many 28 | tprint('total stocks average value ammounts to: ' + (pos[0] * pos[1])); 29 | 30 | if ((getServerMoneyAvailable("home") > 100000000000) && (getStockPrice('FSIG') < 1700000)){ 31 | buyStock('FSIG', 20); 32 | tprint("bought 20 stocks in FSIG"); 33 | tprint("stocks owned: " + pos[0]); 34 | //this block will buy 20 stocks if you have both more than 100b and the FSIG stock price is under 1.700m 35 | //PLEASE READ: if you get a spam of alot of stocks being bought this is ok! 36 | //This Script is designed to be profitable and make you moola, I have tested this myself. 37 | //if you notice anything that can be improved upon or messes up tell me! 38 | } 39 | if (getStockPrice('FSIG') > 1900000){ 40 | sellStock('FSIG', pos[0]); 41 | profit = pos[0]*(getStockPrice('FSIG') - 1900000); //simple math to get the aproximate profit you earned from selling. 42 | tprint("you gained: " + profit); 43 | //if you want you can add a sleep(30000); here 44 | } 45 | } -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Stock Market/priceChange.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/OWD2010 (https://www.reddit.com/user/OWD2010) 4 | 5 | POSTED ON: 6 | November 27th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Script to change investment amount in stock trader script (I call it priceChange) 10 | 11 | write(9, args[0]); 12 | ... I feel like the last script could be eliminated somehow since it's literally one line of code, but I'm not versed enough for it. Is this a normal feeling for programmers? 13 | 14 | In any case, testing shows it all works as intended. The script has a steadier hand with investing, and the script takes advantage of long rallys/declines to really make money. About the best I could hope for at the moment. 15 | 16 | The next improvement for this type of script (doesn't bleed money in turbulent market, sells after long rallys/declines) would probably require a design overhaul - have it look across all the whole stock exchange and buy/sell shares in everything. It would keep money flowing in more regularly, which would let you bump up the investments faster. Doing it within, say, 64 GB would be a good goal. It's just one upgrade away from being used in regular nodes if you have access to shorting stocks. 17 | 18 | The next script to attempt work on would be one that doesn't use the moving average, and instead attempts frequent trades with small gains in price (2%-5%). This would probably use the limit/stop features to cut off any stocks that drop by more than 1%-2%, and the bleed would need to be made up by trades elsewhere. It'd need to be fine-tuned to accomplish that on top of the commission fee, though. 19 | 20 | As a summarized notes of changes: 21 | 22 | -The moving average script (stock-sma.script) has additional lines to look for up-down-up or down-up-down price changes and eliminate the most recent two from consideration. Net effect is that any price change it reports has been moving in that direction for at least two consecutive data points, making trading behavior more stable. 23 | 24 | -The stock trading script (stocktrader.script) has hardcoded port stock ports (10) and window sizes (3). Small sizes work best for this since the new stock-sma is generating responses as a much slower rate due to data scrubbing, but is more accurate about sensing a trend in price changes. Also, new variables and an if statement were added to read in a new investment amount from a different port (hardcoded to port 9). 25 | 26 | -A one line script (priceChanges.script) was created to write in changes to investment amounts while the stock trading script is running." 27 | 28 | REDDIT POST: 29 | https://www.reddit.com/r/Bitburner/comments/79vncv/script_sharing_request/ 30 | */ 31 | 32 | 33 | 34 | write(9, args[0]); -------------------------------------------------------------------------------- /Any/hack/hackemall.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Calebhk98 (https://www.reddit.com/user/Calebhk98) 4 | 5 | POSTED ON: 6 | October 31st, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I just started a week ago, so this is not that great, but only using 7Gb, I like it: hackemall.script 10 | ... 11 | This finds all the servers connected to yours, and gives you access to them. Afterwards, they upload this onto them so they do it to all their neighbors. It then Grows it if the money is low, weaken it if the security gets too high, and hacks them if the other conditions are met. It may be really inefficient, but I am not very far yet, so it works for most things that are under lvl 300." 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 15 | */ 16 | 17 | 18 | 19 | function defaultHack(server){ 20 | while(true){ 21 | hack(server); 22 | return true; 23 | } 24 | } 25 | 26 | function boolToNumber(check){ 27 | if(check===true){return 1} 28 | else{return 0} 29 | } 30 | Brute=boolToNumber(fileExists('brutessh.exe','home'));//Not able to add in True and false 31 | Crack=boolToNumber(fileExists('ftpcrack.exe','home')); 32 | Relay=boolToNumber(fileExists('relaysmtp.exe','home')); 33 | Http=boolToNumber(fileExists('httpworm.exe','home')); 34 | Sql=boolToNumber(fileExists('sqlinject.exe','home')); 35 | BreackThrough=Brute+(Crack)+(Relay)+(Http)+(Sql); 36 | servers=scan(); 37 | print(servers); 38 | while(true){ 39 | for(i = 0; i < servers.length; ++i) { 40 | if(servers[i]!="home"){ 41 | if(hasRootAccess(servers[i])){ 42 | scp('hackemall.script','home',servers[i]); 43 | exec('hackemall.script',servers[i]); 44 | if(getServerMoneyAvailable(servers[i])>(getServerMaxMoney(servers[i])/2)){ 45 | if(getServerSecurityLevel(servers[i])>getServerBaseSecurityLevel(servers[i])+10){ 46 | weaken(servers[i]); 47 | } 48 | else if(getHackingLevel()>=getServerRequiredHackingLevel(servers[i])){ 49 | defaultHack(servers[i]); 50 | } 51 | } 52 | else{ 53 | grow(servers[i]); 54 | } 55 | } 56 | else if(getServerNumPortsRequired(servers[i])<=BreackThrough){ 57 | if(Sql){ 58 | sqlinject(servers[i]); 59 | } 60 | if(Http){ 61 | httpworm(servers[i]); 62 | } 63 | if(Crack){ 64 | ftpcrack(servers[i]); 65 | } 66 | if(Relay){ 67 | relaysmtp(servers[i]); 68 | } 69 | if(Brute){ 70 | brutessh(servers[i]); 71 | } 72 | nuke(servers[i]); 73 | } 74 | else{ 75 | print("Too many ports needed"); 76 | print("I need "); 77 | print(getServerNumPortsRequired(servers[i])); 78 | print("For"); 79 | print (servers[i]); 80 | } 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /Misc/best-server.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/icsbariboa (https://www.reddit.com/user/icsbariboa) 4 | 5 | POSTED ON: 6 | January 8th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Well it's pretty straight forward. I just run getServerMaxMoney(target), and choose the server with the highest max money. Ideally I would also take into account the minimum security, but I haven't gotten around to including that. 10 | 11 | Here's my script. It relies on data from my text file of servers, but you can do this with an included server scan. Or make a script to create a server list. There's another topic on here which goes into pretty good detail about how to use txt files. 12 | ... 13 | edit: Found a bug in my conditional code which pretty much kills the functionality. Have to make sure you're comparing numbers not strings." 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/7oder7/need_some_advice_for_progressing/ 17 | */ 18 | 19 | 20 | var keep_going = false; 21 | 22 | function sleep(ms) 23 | { 24 | return new Promise(resolve => setTimeout(resolve, ms)); 25 | } 26 | 27 | function isAvailable(option) 28 | { 29 | return option.style.display === "block"; 30 | } 31 | 32 | function infiltrate_faction(faction, target, first) 33 | { 34 | document.getElementById(target).click(); 35 | document.getElementById("location-infiltrate").click(); 36 | 37 | var infiltrate_hack = document.getElementById("infiltration-hacksecurity"); 38 | var infiltrate_stealthko = document.getElementById("infiltration-stealthknockout"); 39 | var infiltrate_escape = document.getElementById("infiltration-escape"); 40 | 41 | var progress = document.getElementById("infiltration-level-text"); 42 | var infiltration_box = document.getElementById("infiltration-box-container"); 43 | 44 | for (i = 0; (first || !isAvailable(infiltration_box)) && i < 100; i++) 45 | { 46 | if (i > 50) 47 | infiltrate_escape.click(); 48 | else if (isAvailable(infiltrate_hack)) 49 | infiltrate_hack.click(); 50 | else if (isAvailable(infiltrate_stealthko)) 51 | infiltrate_stealthko.click(); 52 | } 53 | 54 | document.getElementById("infiltration-faction-select").value = faction; 55 | document.getElementById("infiltration-box-faction").click(); 56 | document.getElementById("location-hospital-treatment").click(); 57 | } 58 | 59 | async function keep_infiltrating_faction(faction, target) 60 | { 61 | keep_going = true; 62 | //target = "ishima-omegasoftware"; 63 | infiltrate_faction(faction, "sector12-joesguns", true); 64 | while (keep_going) 65 | { 66 | infiltrate_faction(faction, target, false); 67 | await sleep(500); 68 | } 69 | } -------------------------------------------------------------------------------- /Any/hack/hackAll.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/havoc_mayhem (https://www.reddit.com/user/havoc_mayhem) 4 | 5 | POSTED ON: 6 | December 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Get Root Access (hackAll.script, 5.4 GB) 10 | 11 | Gets root access to as many servers on the network as possible, using the text file created above. 12 | 13 | Also determine the optimal server to target for a hack/grow/weaken cycle, and write its details to best_target.txt. 14 | 15 | I currently choose the optimal server based on 16 | 17 | svScore = (100 - svMinSec) * svMaxMoney * svGrowRt / svExecTime; 18 | I'm sure this can be optimized further, and look forward to suggestions. 19 | 20 | Code: (hackAll.script, 5.4 GB)" 21 | 22 | REDDIT POST: 23 | https://www.reddit.com/r/Bitburner/comments/7lmbpa/scripts_using_files/ 24 | */ 25 | 26 | 27 | numBusters = 0; 28 | portBusters = ['BruteSSH.exe', 'FTPCrack.exe', 'relaySMTP.exe', 'HTTPWorm.exe', 'SQLInject.exe']; 29 | for(i = 0; i < portBusters.length; i++) { 30 | if (fileExists(portBusters[i], "home")) { 31 | tprint(portBusters[i] + " exists"); 32 | ++numBusters; 33 | } 34 | else 35 | tprint(portBusters[i] + " missing"); 36 | } 37 | 38 | myHackLevel = getHackingLevel(); 39 | bestTargetIndex = 1; 40 | bestTargetScore = 0; 41 | rows = read("nmap.txt").split("\r\n"); 42 | 43 | for (i = 0; i < rows.length; ++i) { 44 | serverData = rows[i].split(','); 45 | if (serverData.length < 7) break; //Ignore last blank row 46 | 47 | svName = serverData[0]; 48 | //svRamAvail = serverData[1]; 49 | svPortsNeeded = serverData[2]; 50 | svHackLevel = serverData[3]; 51 | 52 | //tprint("Testing " + svName); 53 | 54 | if ( ! (hasRootAccess(svName)) 55 | && (numBusters >= svPortsNeeded) 56 | && (myHackLevel >= svHackLevel) ) { 57 | 58 | if (numBusters > 0) brutessh(svName); 59 | if (numBusters > 1) ftpcrack(svName); 60 | if (numBusters > 2) relaysmtp(svName); 61 | if (numBusters > 3) httpworm(svName); 62 | if (numBusters > 4) sqlinject(svName); 63 | 64 | nuke(svName); 65 | tprint("Server hacked: " + svName); 66 | } 67 | if (hasRootAccess(svName)) { 68 | svMaxMoney = serverData[4]; 69 | svMinSec = serverData[5]; 70 | svGrowRt = serverData[6]; 71 | svExecTime = getHackTime(svName); 72 | svScore = (100 - svMinSec) * svMaxMoney * svGrowRt / svExecTime; 73 | if(svScore > bestTargetScore){ 74 | bestTargetScore = svScore; 75 | bestTargetIndex = i; 76 | } 77 | } 78 | //tprint("Done Testing " + svName); 79 | } 80 | write("best_target.txt", rows[bestTargetIndex], "w"); 81 | tprint(rows[bestTargetIndex]); -------------------------------------------------------------------------------- /Stock Market/stock-sma.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/OWD2010 (https://www.reddit.com/user/OWD2010) 4 | 5 | POSTED ON: 6 | November 27th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I did some tweaks to to the stock trading scripts to try and smooth out fluctuations in pricing causing frequent swaps in position and contributing to a slow bleed in money. I also added a small script to read new investment values from since killing/restarting the scripts to set a new investment value kinda sucks. 10 | 11 | Combined, all of them running use up 31.90 GB, so any further improvements either need to cut something else or accept the fact that it can't work on a starting computer. The stock-sma script would be the best starting point, since I just bolted changes onto it without seeing if I could slim it down with its new purpose in mind. 12 | 13 | Revised stock-sma.script" 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/79vncv/script_sharing_request/ 17 | */ 18 | 19 | 20 | 21 | sym = args[0]; //Symbol of stock 22 | window = args[1]; //Number of price changes for the SMA's 'time period' 23 | outPort = args[2]; //Port to write SMA to 24 | 25 | prices = []; 26 | sum = 0; 27 | lastPrice = -1; 28 | 29 | while(true) { 30 | price = getStockPrice(sym); 31 | if (price != lastPrice) { 32 | prices.push(price); 33 | sum += price; 34 | //The next several if statements pop out the most recent value if there's a one-off up/down bump in pricing that 35 | //interrupts a streak. This means that all price averages that are fed into the port will contain at least 2 recent 36 | //data points that move in that direction, which should smooth aberrant behavior in stock trading scripts. 37 | if (prices.length > window){ 38 | if (prices[prices.length-1] > prices[prices.length-2]) { 39 | if (prices[prices.length-2] < prices[prices.length-3]) { 40 | prices.pop(); 41 | prices.pop(); 42 | sum = sum - price - lastPrice; 43 | } 44 | } 45 | if (prices[prices.length-1] < prices[prices.length-2]) { 46 | if (prices[prices.length-2] > prices[prices.length-3]) { 47 | prices.pop(); 48 | prices.pop(); 49 | sum = sum - price - lastPrice; 50 | } 51 | } 52 | } 53 | if (prices.length > window) { 54 | write(outPort, sum/window); 55 | print(sum/window); 56 | for (i = 0; i < window; i = i++) { 57 | prices.shift(); 58 | } 59 | sum = price; 60 | } 61 | lastPrice = prices[prices.length-1]; 62 | } 63 | } -------------------------------------------------------------------------------- /Stock Market/_InvestmentBroker_Data.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Rinchwind (https://www.reddit.com/user/Rinchwind) 4 | 5 | POSTED ON: 6 | December 3rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "After running many, many simulations, I've come to a conclusion that in most cases, a script would perform worse than just putting money in a few stocks and forgetting about it for a few days (while letting the game run in the background). just like in real life... :) 10 | 11 | However, with the highly volatile stocks (JGN, SGC, APHE and CTYS), a well-tuned script can produce much better results (statistically speaking. It can still perform miserably in some situations, but usually it will get me to several thousand trillion within a day or two) 12 | 13 | To use the script, run InvestmentBroker.script and use _InvestmentBroker_Msg.script to send commands to it. 14 | You can run the main script on a private server (just copy InvestmentBroker.script, _InvestmentBroker.script, _InvestmentBroker_Data.script and _InvestmentBroker_Manager.script. You can run the messaging script from the home server) or on the home server, it needs at least 153Mb to manage all 4 stocks. 15 | 16 | I’ve also defined the following aliases to make using it easier: 17 | 18 | alias InvestmentBrokerStatus="run _InvestmentBroker_Msg.script S" 19 | alias InvestmentBrokerBuyStock="run _InvestmentBroker_Msg.script A" 20 | alias InvestmentBrokerLiquidate="run _InvestmentBroker_Msg.script L" 21 | 22 | For instance, to buy 25,000,000$ worth of JGN stock, type the following: 23 | 24 | InvestmentBrokerBuyStock JGN 25000000 25 | 26 | To liquidate all JGN stock, type the following: 27 | 28 | InvestmentBrokerLiquidate JGN " 29 | 30 | REDDIT POST: 31 | https://www.reddit.com/r/Bitburner/comments/78zva1/stock_script_brainstorming/ 32 | */ 33 | 34 | 35 | 36 | //-------------------------------------------------------------------------------------------------------------------------- 37 | //---------------------------_InvestmentBroker_Data.script------------------------------------------------------------------ 38 | //-------------------------------------------------------------------------------------------------------------------------- 39 | 40 | StockSymbol = args[0]; 41 | DATA_PORT = args[1]; 42 | MovingAverageSize = args[1]; 43 | 44 | prices = []; 45 | sum = 0; 46 | lastPrice = -1; 47 | 48 | while(true) 49 | { 50 | price = getStockPrice(StockSymbol); 51 | if (price != lastPrice) 52 | { 53 | prices.push(price); 54 | sum += price; 55 | if (prices.length > MovingAverageSize) 56 | { 57 | sum -= prices.shift(); 58 | avg = sum/MovingAverageSize; 59 | write(DATA_PORT, avg); 60 | } 61 | lastPrice = price; 62 | } 63 | } -------------------------------------------------------------------------------- /Hacknet/hacknet-script.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | September 22nd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Taken from a few soucres, but here goes: 10 | 11 | For each node, figures out what the best bang for buck is and buys if less than %1 of current cash. 12 | 13 | 7.3GB ram, so have a starting script that hacks foodnstuff and then runs it there. 14 | 15 | Script:" 16 | 17 | REDDIT POST: 18 | https://www.reddit.com/r/Bitburner/comments/71sxly/hacknet_nodes_script_optimalish_calcs/ 19 | */ 20 | 21 | 22 | 23 | //1% of current funds, per cycle. 24 | allowancePercentage = 0.01; 25 | while (true) { 26 | for (i = 0; i < hacknetnodes.length; i++) { 27 | gain = [0,0,0]; 28 | currentCash = getServerMoneyAvailable('home'); 29 | currentCash *= allowancePercentage; 30 | 31 | if (getNextHacknetNodeCost() <= currentCash) { 32 | purchaseHacknetNode(); 33 | } 34 | 35 | node = hacknetnodes[i]; 36 | 37 | if (node.level < 200) { 38 | gain[0] = ((node.level + 1) * 1.6) * Math.pow(1.035, (node.ram - 1)) * ((node.cores + 5) / 6) / node.getLevelUpgradeCost(1); 39 | } else { 40 | gain[0] = 0; 41 | } 42 | 43 | if (node.ram < 64) { 44 | gain[1] = (node.level * 1.6) * Math.pow(1.035, (node.ram * 2) - 1) * ((node.cores + 5) / 6) /node.getRamUpgradeCost(); 45 | } else { 46 | gain[1] = 0; 47 | } 48 | 49 | if (node.cores < 16) { 50 | gain[2] = (node.level * 1.6) * Math.pow(1.035, node.ram - 1) * ((node.cores + 6) / 6) / node.getCoreUpgradeCost(); 51 | } else { 52 | gain[2] = 0; 53 | } 54 | 55 | print('Level Upgrade: ' + gain[0]); 56 | print('Ram Upgrade: ' + gain[1]); 57 | print('Core Upgrade: ' + gain[2]); 58 | 59 | topgain = 0; 60 | 61 | for (j = 0; j < 3; j++) { 62 | if (gain[j] > topgain) { 63 | topgain = gain[j]; 64 | } 65 | } 66 | 67 | if (topgain === 0) { 68 | print('All Gains maxed on Node' + i); 69 | break; 70 | } 71 | 72 | if (topgain == gain[0] && node.getLevelUpgradeCost(1) < currentCash) { 73 | print('Upgrading Level on Node' + i); 74 | node.upgradeLevel(1); 75 | } else if (topgain == gain[1] && node.getRamUpgradeCost(1) < currentCash) { 76 | print('Upgrading Ram on Node' + i); 77 | node.upgradeRam(); 78 | } else if (topgain == gain[2] && node.getCoreUpgradeCost(1) < currentCash) { 79 | print('Upgrading Core on Node' + i); 80 | node.upgradeCore(); 81 | } else { 82 | print('Cannot afford upgrades on Node' + i); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /README 2.md: -------------------------------------------------------------------------------- 1 | # Bitburner-Community 2 | 3 | For inspiration, assistance, and discussion around the amazing cyperpunk-themed incremental RPG, Bitburner. Even though Bitburner is set in a dystopian future where you work alone in front of a green tinted monitor, that doesn't mean we can't create a thriving community to help each other out! 4 | 5 | I've compiled every script that was ever mentioned in a post on the BitBurner subreddit, and placed them into folders for convenience. I encourage you to make edits, additions, and supply constructive criticism. 6 | 7 | *Added scripts are verified to be able to run without a runtime error. If a script was posted as needing fixing, it was not added to this database. If an update made a workaround script obsolete, it was not added. If someone wrote a script similar to another script, just with different variables or a longer loop for example, only 1 of the scripts was added to the database.* 8 | 9 | ## Getting Started 10 | 11 | If you haven't already subscribed, a good place to start is the [Bitburner subreddit](https://www.reddit.com/r/Bitburner/). 12 | 13 | ### Useful Links 14 | 15 | * [Bitburner](https://danielyxie.github.io/bitburner/) 16 | * [Bitburner Documentation](http://bitburner.readthedocs.io/en/latest/index.html) 17 | * [Bitburner Wiki](https://bitburner.wikia.com/wiki/Bitburner_Wiki) 18 | * [NetScript Functions](http://bitburner.wikia.com/wiki/Netscript_Functions) 19 | * [Location Guide](http://imgur.com/a/kE3H2) 20 | * [Getting Started Guide](http://bitburner.wikia.com/wiki/Chapt3rsGettingStartedGuide) 21 | * [Faction, Augmentation, Server Guide](https://www.reddit.com/r/Bitburner/comments/7nbzc5/updated_faction_augmentation_and_server_guide_for/) - *Updated for **0.34.0*** 22 | 23 | ## Management 24 | 25 | Each script has been organized into a category. The categories are as follows: 26 | 27 | * **Early-game** - *Scripts that are utilized when player skills are low, little/no augmentations installed, and limited access to servers.* 28 | * **Middle-game** - *Scripts for when skills/augs allow player to be moderately successful with most servers and/or tasks.* 29 | * **Late-game** - *High end server hacking, long optimizations, and scripts that may require lots of skills/augmentations to work effectively.* 30 | * **Any** - *Scripts that are applicable to any point in the game.* 31 | * **Hacknet** - *Scripts to manage, setup, or improve your hacknet experience.* 32 | * **Stock Market** - *Scripts for managing the stock market.* 33 | * **Singularity** - *Scripts that utilize singularity functions.* 34 | * **Misc.** 35 | 36 | There are also subfolders that seek to add context to the main function of the script. 37 | 38 | ## Contributing 39 | 40 | Please read [CONTRIBUTING.md](https://github.com/stavvie34/Bitburner-Community/blob/master/CONTRIBUTING.md) for details on the code of conduct, and the process for submitting pull requests. 41 | 42 | ## Authors 43 | 44 | * **stavvie34** -------------------------------------------------------------------------------- /Misc/scrape-all-servers.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/MercuriusXeno (https://www.reddit.com/user/MercuriusXeno) 4 | 5 | POSTED ON: 6 | September 12th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Iterate and scan all the game servers and save some of the most important information to an array of arrays: 10 | 11 | At the time of writing, the Array-Array looks like this: 12 | 13 | [[HostName, HackingLevel, MaxMoney, GrowthRate, MinSecurity], 14 | [HostName, HackingLevel, MaxMoney, GrowthRate, MinSecurity], 15 | [HostName, HackingLevel, MaxMoney, GrowthRate, MinSecurity]...] 16 | The reason you'd want to do this is, by using the array, you don't have to call the functions (getMaxMoney, getHackingLevel, getBaseSecurity, etc) anymore - you have them saved already. This saves you RAM in child scripts; there's a wide range of applications once you have this basic info "stored". Could be trivially modified to include Machine-RAM, Ports-Needed-To-Nuke and whatever other static values you can avoid calling twice. The whole point is to save RAM for functionality in other scripts by passing the values in as args; in RAM terms, args cost nothing. 17 | 18 | Note: It takes a while to get its array finished; ideally you should only need to build the array once. Add scripts to the end of this template and you'll be able to use the servers array to perform whatever it is you want to do, whether that's nuking, running a daemon, a complex sorting/best-target algorithm, etc." 19 | 20 | REDDIT POST: 21 | https://www.reddit.com/r/Bitburner/comments/6zoeqn/recursive_scan_array_of_server_arrays/ 22 | */ 23 | 24 | 25 | 26 | hostName = getHostname(); 27 | scanArray = [hostName]; 28 | currentScanLength = 0; 29 | servers = []; 30 | while (currentScanLength < scanArray.length) { 31 | previousScanLength = currentScanLength; 32 | currentScanLength = scanArray.length; 33 | for (i = previousScanLength; i < currentScanLength; i++) { 34 | currentHost = scanArray[i]; 35 | minSecurity = Math.max(1, Math.round(getServerBaseSecurityLevel(currentHost) / 3)); 36 | server = [currentHost, getServerRequiredHackingLevel(currentHost), getServerMaxMoney(currentHost), getServerGrowth(currentHost), minSecurity]; 37 | servers.push(server); 38 | //uncomment this if you'd like to see a printout of the array as it is being made 39 | // tprint(server[0]); 40 | // tprint('----------------'); 41 | // tprint('Difficulty: ' + server[1] + ' | Potential: $' + server[2]); 42 | // tprint('Growth Rate: ' + server[3] + ' | Security: ' + server[4]); 43 | // tprint('----------------'); 44 | newScan = scan(currentHost); 45 | for (j = 0; j < newScan.length; j++) { 46 | if (scanArray.indexOf(newScan[j]) == -1) { 47 | scanArray.push(newScan[j]); 48 | } 49 | } 50 | } 51 | } 52 | //Put stuff in me starting here. Use the servers object. Start Nukers/Watcher Daemons/Etc. -------------------------------------------------------------------------------- /bitburner-community.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | 35 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /Misc/deepscan.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/desci1 (https://www.reddit.com/user/desci1) 4 | 5 | POSTED ON: 6 | July 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "This script will scan recursively through every reachable server in the game. 10 | 11 | If you delete the print() lines between the comments you may use this very script to do more complex things like hacking all servers or whatever you may think of. 12 | 13 | Amount of memory needed (after comments and print()s removed): This script requires 3,08GB of RAM to run for 1 thread(s)" 14 | 15 | REDDIT POST: 16 | https://www.reddit.com/r/Bitburner/comments/6p24g8/deepscanscript/ 17 | */ 18 | 19 | 20 | 21 | /* 22 | deepscan.script 23 | for bitburner's netscript 24 | version: 14 25 | winners don't use copyright 26 | remove all comments to save RAM 27 | 28 | this script scans through every server and prints information about each server, as well as the whole list of all found servers. 29 | this is meant to be a skeleton to make more complex scripts. 30 | */ 31 | 32 | startingServer = 0; 33 | allServers = scan(getHostname()); 34 | while (true) { 35 | servers = allServers; 36 | // when we reach the last server, start it all over 37 | if (startingServer == allServers.length) startingServer = 0; 38 | for (server = startingServer; server < servers.length; server++) { 39 | // you can change this part to perform whatever you want to servers[server] 40 | print('============================================================'); 41 | print('all the servers we already found trough scanning:'); 42 | print(allServers); 43 | print('============================================================'); 44 | print('we are now scanning ' + servers[server]); 45 | print('root access: ' + hasRootAccess(servers[server])); 46 | getServerRequiredHackingLevel(servers[server]); 47 | getServerSecurityLevel(servers[server]); 48 | getServerBaseSecurityLevel(servers[server]); 49 | getServerMoneyAvailable(servers[server]); 50 | getServerMaxMoney(servers[server]); 51 | getServerRam(servers[server]); 52 | print('============================================================'); 53 | // end of servers[server] proccessing 54 | // scans more servers from the current server 55 | newServers = scan(servers[server]); 56 | for (newServer = 0; newServer < newServers.length; newServer++) { 57 | isNewServer = true; 58 | // we don't want home server or a server which is already in the list 59 | for (checkServer = 0; checkServer < allServers.length; checkServer++) if (newServers[newServer] == 'home' || newServers[newServer] == allServers[checkServer]) isNewServer = false; 60 | if (isNewServer) allServers = allServers.concat(newServers[newServer]); 61 | } 62 | } 63 | // next loop should start from the server we just scanned 64 | startingServer = server; 65 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Naming Convention 9 | 10 | Scripts are to be named in the following way: 11 | 12 | `**scriptname**.js` 13 | 14 | *If a script was not named when it was originally posted, it has been named in the following way:* 15 | 16 | `**DATE POSTED - NAME OF POST REFERENCED - UNNAMED(x)**.js` 17 | 18 | Note: 19 | `'x'` corresponds to the order of unnamed scripts per that particular post. 20 | Scripts are to be saved as `.js` not `.script`, as `.script` only exists within NetScript 21 | 22 | #### Examples 23 | 24 | `RemoteHack.js` - Properly named script. 25 | `6-20-17 - 'Questions-Suggestions' - unnamed(5).js` - Script that was posted on June 20th, 2017, on the Reddit post named "Questions/Suggestions". This would be the 5th unnamed script in that thread. 26 | 27 | ## Code of Conduct 28 | 29 | ### Pledge 30 | 31 | In the interest of fostering an open and welcoming environment, I pledge to making participation in our project and 32 | our community a harassment-free experience for everyone, regardless of age, body 33 | size, disability, ethnicity, gender identity and expression, level of experience, 34 | nationality, personal appearance, race, religion, or sexual identity and 35 | orientation. 36 | 37 | ### Our Standards 38 | 39 | Examples of behavior that contributes to creating a positive environment 40 | include: 41 | 42 | * Using welcoming and inclusive language 43 | * Being respectful of differing viewpoints and experiences 44 | * Gracefully accepting constructive criticism 45 | * Focusing on what is best for the community 46 | * Showing empathy towards other community members 47 | 48 | Examples of unacceptable behavior by participants include: 49 | 50 | * The use of sexualized language or imagery and unwelcome sexual attention or 51 | advances 52 | * Trolling, insulting/derogatory comments, and personal or political attacks 53 | * Public or private harassment 54 | * Publishing others' private information, such as a physical or electronic 55 | address, without explicit permission 56 | * Other conduct which could reasonably be considered inappropriate in a 57 | professional setting 58 | 59 | ### Our Responsibilities 60 | 61 | Project maintainers are responsible for clarifying the standards of acceptable 62 | behavior and are expected to take appropriate and fair corrective action in 63 | response to any instances of unacceptable behavior. 64 | 65 | Project maintainers have the right and responsibility to remove, edit, or 66 | reject comments, commits, code, wiki edits, issues, and other contributions 67 | that are not aligned to this Code of Conduct, or to ban temporarily or 68 | permanently any contributor for other behaviors that they deem inappropriate, 69 | threatening, offensive, or harmful. -------------------------------------------------------------------------------- /Any/weaken-grow-hack/foodnstuff[0-5].js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/boz987 (https://www.reddit.com/user/boz987) 4 | 5 | POSTED ON: 6 | June 13th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Update Version: 10 | 11 | I have scripts such as foodnstuff[0-5].scipt for each server on home, where 0 is hack / grow, and 1-4 are weaken / grow. 12 | ..." 13 | 14 | REDDIT POST: 15 | https://www.reddit.com/r/Bitburner/comments/6gzpxg/any_useful_scripts_to_share/ 16 | */ 17 | 18 | 19 | 20 | avialports = 0; 21 | count = 0; 22 | places = Array ['foodnstuff','sigma-cosmetics','joesguns','nectar-net','hong-fang-tea','harakiri-sushi','neo-net','zer0','max-hardware','iron-gym','phantasy','silver-helix','omega-net','crush-fitness','johnson-ortho','the-hub','comptek','netlink','rothman-uni','catalyst','summit-uni','rho-construction','millenium-fitness','aevum-police','alpha-ent','syscore','lexo-corp','snap-fitness','global-pharm','applied-energetics','unitalife','univ-energy','nova-med','zb-def','zb-institute','vitalife','titan-labs','solaris','microdyne','helios','deltaone','icarus','zeud-med','omnia','defcomm','galactic-cyber','infocomm','taiyang-digital','stormtech','aerocorp','clarkeinc','omnitek','nwo','4sigma','blade','b-and-a','ecorp','fulcrumtech','megacorp','kuai-gong','fulcrumassets','powerhouse-fitness']; 23 | levels = Array [1,5,10,20,30,40,50,75,80,100,100,150,200,250,275,300,350,400,400,425,450,500,500,425,550,600,700,750,775,775,790,790,800,800,750,775,795,800,800,800,810,810,810,825,825,825,830,850,850,850,900,900,900,900,900,900,900,900,900,925,999,1000]; 24 | ports = Array [0,0,0,0,0,0,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]; 25 | 26 | while (true) { 27 | for (i = count; i < 62; i = i+1) { 28 | if (fileExists('SQLInject.exe')) { 29 | avialports = 5; 30 | } elif (fileExists('HTTPWorm.exe')) { 31 | avialports = 4; 32 | } elif (fileExists('relaySMTP.exe')) { 33 | avialports = 3; 34 | } elif (fileExists('FTPCrack.exe')) { 35 | avialports = 2; 36 | } else { 37 | avialports = 1; 38 | }; 39 | 40 | 41 | if (ports[i] <= avialports) { 42 | if (levels[i] <= getHackingLevel()) { 43 | if (fileExists('BruteSSH.exe')) {brutessh(places[i]);}; 44 | if (fileExists('FTPCrack.exe')) {ftpcrack(places[i]);}; 45 | if (fileExists('relaySMTP.exe')) {relaysmtp(places[i]);}; 46 | if (fileExists('HTTPWorm.exe')) {httpworm(places[i]);}; 47 | if (fileExists('SQLInject.exe')) {sqlinject(places[i]);}; 48 | if (hasRootAccess(places[i]) == false) { 49 | nuke(places[i]); 50 | count = count + 1; 51 | }; 52 | if (hasRootAccess(places[i])) { 53 | if (isRunning(places[i] + '0.script') == false) {exec(places[i] + '0.script','home',10);}; 54 | if (isRunning(places[i] + '1.script') == false) {exec(places[i] + '1.script','home',90);}; 55 | if (isRunning(places[i] + '2.script') == false) {exec(places[i] + '2.script','home',90);}; 56 | if (isRunning(places[i] + '3.script') == false) {exec(places[i] + '3.script','home',90);}; 57 | if (isRunning(places[i] + '4.script') == false) {exec(places[i] + '4.script','home',90);}; 58 | }; 59 | 60 | }; 61 | }; 62 | }; 63 | }; -------------------------------------------------------------------------------- /Stock Market/stocktrader.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/OWD2010 (https://www.reddit.com/user/OWD2010) 4 | 5 | POSTED ON: 6 | November 27th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Revised stock trading script (I call it stocktrader.script)" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/79vncv/script_sharing_request/ 13 | */ 14 | 15 | 16 | 17 | sym = args[0]; //Stock symbol 18 | window = 3; //How big the 'window' should be to look for upwards/downwards momentum. 19 | //This is in term of number of price changes 20 | smaPort = 10; //Port to read SMA values from 21 | money = args[1]; //Amount of money to initially invest 22 | 23 | newMoney = 0; //Intermediate variable, used to change 'money' variable without killing/restarting script 24 | pricePort = 9; //Port to read changes to the 'newMoney' variable from 25 | 26 | COM = 100000; //Commission fee 27 | 28 | shortPos = false; //True if a short position is held 29 | longPos = false; //True if a long position is held 30 | 31 | run("stock-sma.script", 1, sym, window, smaPort); 32 | 33 | sleep((window + 5) * 6000); //Give SMA scripts time to 'calibrate' 34 | 35 | smas = []; //Stores SMA values after reading port 36 | 37 | while(true) { 38 | sma = read(smaPort); 39 | newMoney = read(pricePort); 40 | if (newMoney != 'NULL PORT DATA') { 41 | money = newMoney; 42 | } 43 | if (sma != 'NULL PORT DATA') { 44 | smas.push(sma); 45 | if (smas.length > window) { 46 | smas.shift(); 47 | //Only execute trading logic if smas is full 48 | if (smas[window-1] > smas[0]) { 49 | //Upwards momentum 50 | pos = getStockPosition(sym); 51 | stockPrice = getStockPrice(sym); 52 | if (shortPos) { 53 | //Get out of short position 54 | if (!sellShort(sym, pos[2])) { 55 | print("ERROR: sellShort failed"); 56 | } 57 | shortPos = false; 58 | } 59 | 60 | if (!longPos) { 61 | //Enter long position 62 | if (getServerMoneyAvailable('home') < money) { 63 | money = getServerMoneyAvailable('home'); 64 | } 65 | buyStock(sym, Math.floor((money - COM) / stockPrice)); 66 | longPos = true; 67 | } 68 | 69 | } else { 70 | //Downwards momentum 71 | pos = getStockPosition(sym); 72 | stockPrice = getStockPrice(sym); 73 | if (longPos) { 74 | //Get out of long position 75 | if (!sellStock(sym, pos[0])) { 76 | print("ERROR: sellStock failed"); 77 | } 78 | 79 | longPos = false; 80 | } 81 | 82 | if (!shortPos) { 83 | //Enter short position 84 | if (getServerMoneyAvailable('home') < money) { 85 | money = getServerMoneyAvailable('home'); 86 | } 87 | shortStock(sym, Math.floor((money-COM) / stockPrice)); 88 | shortPos = true; 89 | } 90 | } 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at bitburner.community@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /Hacknet/trading.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/chapt3r (https://www.reddit.com/user/chapt3r) 4 | 5 | POSTED ON: 6 | December 3rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I actually wipe my saves pretty frequently when testing different BitNodes, so I lost the exact script I was using. However, the script that worked best for me was just this script with a minor modification: 10 | 11 | Whenever one of your trades is profitable, increase the 'money' variable by that profit (have to account for commission though). This makes it so that as the script earns money, it will dynamically increase the "funds" it trades with. 12 | Also, contrary to what the author of the script wrote in his comment, I found that the script works best on megacorporation stocks like ECP MGCP rather than APHE and JGN. His/her script trades on momentum and stocks like APHE and JGN have too much volatility 13 | 14 | Here is a script I made myself. It works decently but generally not as well as the one above: 15 | 16 | https://pastebin.com/hSC2jMi0 17 | 18 | This uses a very basic and common algorithmic trading strategy: 19 | 20 | Let N > M 21 | 22 | Buy stock when its moving average after M price changes goes above the moving average after N price changes 23 | Sell the stock when its moving average after M price changes goes below the moving average after N price changes 24 | I usually use values like M = 12 and N = 30" 25 | 26 | REDDIT POST: 27 | https://www.reddit.com/r/Bitburner/comments/7h0h3n/v0330_released_added_bitnode3_corporatocracy/ 28 | */ 29 | 30 | 31 | 32 | sym = args[0]; //Stock symbol 33 | window1 = args[1]; //Window for short-term SMA 34 | window2 = args[2]; //Window for long-term SMA 35 | inPort1 = args[3]; //Port to read/write short-term SMA 36 | inPort2 = args[4]; //Port to read/write long-term SMA 37 | money = args[5]; //Initial money to use 38 | 39 | 40 | COMMISSION = 100000; //Commission fee 41 | posFlag = false; //True if has shares, false otherwise 42 | 43 | run("stock-sma.script", 1, sym, window1, inPort1); 44 | run("stock-sma.script", 1, sym, window2, inPort2); 45 | 46 | sleep((window2 + 5) * 6000); //Need to get SMA before trying to trade 47 | 48 | while(true) { 49 | sma1 = 0; 50 | sma2 = 0; 51 | port1 = read(inPort1); 52 | if (port1 != 'NULL PORT DATA') { 53 | sma1 = port1; 54 | } 55 | port2 = read(inPort2); 56 | if (port2 != 'NULL PORT DATA') { 57 | sma2 = port2; 58 | } 59 | 60 | if (sma1 && sma2) { 61 | print("SMA1: " + sma1); 62 | print("SMA2: " + sma2); 63 | price = getStockPrice(sym); 64 | if (posFlag) { //Holds position 65 | if (sma1 < sma2) { 66 | pos = getStockPosition(sym); 67 | shares = pos[0]; 68 | avgPx = pos[1]; 69 | profit = (price - avgPx) * shares - COMMISSION; 70 | if (profit > 0) { 71 | print("SMA < SMA2. Executing trade for profit: $" + profit); 72 | if (!sellStock(sym, shares)) { 73 | print("Error selling stocks. sellStock() failed"); 74 | } 75 | money += profit; 76 | posFlag = false; 77 | } else { 78 | print("SMA1 < SMA2 but this trade is not profitable. Not executing."); 79 | } 80 | } 81 | } else { //No position 82 | if (sma1 > sma2) { 83 | if (getServerMoneyAvailable("home") < money) { 84 | money = getServerMoneyAvailable('home'); 85 | } 86 | 87 | shares = Math.floor((money - COMMISSION) / price); 88 | buyStock(sym, shares); 89 | posFlag = true; 90 | print("Purchasing " + shares + " shares of " + sym); 91 | } 92 | } 93 | sleep(3000); 94 | } 95 | } -------------------------------------------------------------------------------- /Stock Market/momentum.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/inFatum (https://www.reddit.com/user/inFatum) 4 | 5 | POSTED ON: 6 | October 27th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I haven't gotten to the new BitNode yet, but a script that's been pretty successful in other BitNodes has just been one that trades on "momentum". I detect whenever the price changes for a stock and calculate a moving average. If that moving average starts increasing then I buy the stock. When the moving average starts decreasing I sell my shares, and repeat. 10 | 11 | With shorting, this will be even better because on downward momentum I can short, and on upward momentum I can long. 12 | 13 | I'll post my scripts after I get to the new BitNode and test it out 14 | 15 | Edit: 16 | 17 | I've been using the stock simple moving average script posted here. 18 | 19 | Then here is the actual stock trading script. Worth noting that this will make trades purely based on momentum even if they lose money. Over a long period of time and for certain stocks it has been profitable for me though (APHE and JGN are two stocks that it seems to do well on)" 20 | 21 | REDDIT POST: 22 | https://www.reddit.com/r/Bitburner/comments/78zva1/stock_script_brainstorming/ 23 | */ 24 | 25 | 26 | 27 | sym = args[0]; //Stock symbol 28 | window = args[1]; //How big the 'window' should be to look for upwards/downwards momentum. 29 | //This is in term of number of price changes 30 | smaPort = args[2]; //Port to read SMA values from 31 | money = args[3]; //Amount of money to initially invest 32 | 33 | COM = 100000; //Commission fee 34 | 35 | shortPos = false; //True if a short position is held 36 | longPos = false; //True if a long position is held 37 | 38 | run("stock-sma.script", 1, sym, window, smaPort); 39 | 40 | sleep((window + 5) * 6000); //Give SMA scripts time to 'calibrate' 41 | 42 | smas = []; 43 | while(true) { 44 | sma = read(smaPort); 45 | if (sma != 'NULL PORT DATA') { 46 | smas.push(sma); 47 | if (smas.length > window) { 48 | smas.shift(); 49 | //Only execute trading logic if smas is full 50 | if (smas[window-1] > smas[0]) { 51 | //Upwards momentum 52 | pos = getStockPosition(sym); 53 | stockPrice = getStockPrice(sym); 54 | if (shortPos) { 55 | //Get out of short position 56 | if (!sellShort(sym, pos[2])) { 57 | print("ERROR: sellShort failed"); 58 | } 59 | shortPos = false; 60 | } 61 | 62 | if (!longPos) { 63 | //Enter long position 64 | if (getServerMoneyAvailable('home') < money) { 65 | money = getServerMoneyAvailable('home'); 66 | } 67 | buyStock(sym, Math.floor((money - COM) / stockPrice)); 68 | longPos = true; 69 | } 70 | 71 | } else { 72 | //Downwards momentum 73 | pos = getStockPosition(sym); 74 | stockPrice = getStockPrice(sym); 75 | if (longPos) { 76 | //Get out of long position 77 | if (!sellStock(sym, pos[0])) { 78 | print("ERROR: sellStock failed"); 79 | } 80 | 81 | longPos = false; 82 | } 83 | 84 | if (!shortPos) { 85 | //Enter short position 86 | if (getServerMoneyAvailable('home') < money) { 87 | money = getServerMoneyAvailable('home'); 88 | } 89 | shortStock(sym, Math.floor((money-COM) / stockPrice)); 90 | shortPos = true; 91 | } 92 | } 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Late-game/calculator.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/i3aizey (https://www.reddit.com/user/i3aizey) 4 | 5 | POSTED ON: 6 | November 10th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "A script in style of the progression hacking, mostly meant for when you have a large amount of ram on a server It uses 'trial and error' rather than the direct game formula to figure out threads count needed 10 | 11 | calculator.script 12 | 13 | usage: 'run calculator.script target' 14 | 15 | this can easily hit a few billion per second :) 16 | 17 | When hacking ALL servers for 50% of their money: 18 | 19 | highest memory usage: ~400,000 GB < when it's calculating threads needed & growing servers to 100% 20 | 21 | normal memory usage: ~100,000 GB < when things have been calculated & it's just in the hack/grow/weaken cycle 22 | 23 | RAM per thread: 6.1 24 | 25 | target is whatever server you want, megacorp, harakiri-sushi etc." 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/79vncv/script_sharing_request/ 29 | */ 30 | 31 | 32 | 33 | target = args[0]; 34 | self = getHostname(); 35 | maxmoney = getServerMaxMoney(target); 36 | minsec = getServerMinSecurityLevel(target); 37 | 38 | // Percentage a hack will take 39 | taking = 0.5; 40 | 41 | function getLevel() { 42 | return getHackingLevel(); 43 | } 44 | 45 | function getSecurity(){ 46 | return getServerSecurityLevel(target); 47 | } 48 | 49 | function getMoney(){ 50 | return getServerMoneyAvailable(target); 51 | } 52 | 53 | 54 | function getMaxThreads(){ 55 | ram = getServerRam(self); 56 | return Math.floor((ram[0] - ram[1]) / 1.6); 57 | } 58 | 59 | function wait(script){ 60 | while(isRunning(script, self, target)){} 61 | } 62 | 63 | function end(script) { 64 | script += ".script"; 65 | kill(script, self, target); 66 | wait(script); 67 | } 68 | 69 | end("hack"); 70 | end("grow"); 71 | end("weaken"); 72 | 73 | function execute(script, threads) { 74 | maxThreads = getMaxThreads(); 75 | script += ".script"; 76 | threads = Math.min(threads, maxThreads); 77 | threads = Math.max(threads, 1); 78 | run(script, threads, target) 79 | wait(script); 80 | } 81 | 82 | function getDown(){ 83 | while(getSecurity() > minsec) 84 | execute("weaken", Math.ceil((getSecurity() - minsec) / 0.05)); 85 | } 86 | 87 | function growUp(){ 88 | money = getMoney(); 89 | while(getMoney() < maxmoney){ 90 | money = getMoney(); 91 | need = (maxmoney - money) / money; 92 | threads = Math.ceil(need / growGives); 93 | execute("grow", threads); 94 | getDown(); 95 | } 96 | } 97 | 98 | while (!hasRootAccess(target) || getServerRequiredHackingLevel(target) > getLevel()) { 99 | print("Waiting for level or root access..."); 100 | execute("crack", 1); 101 | } 102 | 103 | getDown(); 104 | // Makes sure we can get an accurate growth-read 105 | if(getMoney() > maxmoney * 0.95) 106 | execute("hack", 100); 107 | 108 | getDown(); 109 | 110 | growGives = 0; 111 | while(growGives < 0.000001) { 112 | tm = getMoney(); 113 | execute("grow", 1); 114 | growGives = Math.abs((getMoney() - (tm + 1)) / (tm + 1)); 115 | } 116 | 117 | // Make sure we can get an accurate hack-read 118 | if(getMoney() < 1000000) 119 | execute("grow", 10000); 120 | 121 | getDown(); 122 | 123 | tm = getMoney(); 124 | while(getMoney() === tm) 125 | execute("hack", 1); 126 | hackTakes = (tm - getMoney()) / tm; 127 | 128 | hackThreads = Math.floor(taking / hackTakes); 129 | growThreads = Math.ceil(1 / growGives) + 10; 130 | weakThreads = Math.ceil((0.002 * hackThreads + 0.004 * growThreads) / 0.05); 131 | 132 | print("Hack " + hackThreads + " threads"); 133 | print("Grow " + growThreads + " threads"); 134 | print("Weak " + weakThreads + " threads"); 135 | 136 | getDown(); 137 | growUp(); 138 | 139 | while(!run("smartHack.script", hackThreads, target, hackThreads, growThreads, weakThreads, getLevel())){} -------------------------------------------------------------------------------- /Hacknet/setup-hacknet.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/havoc_mayhem (https://www.reddit.com/user/havoc_mayhem) 4 | 5 | POSTED ON: 6 | January 8th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I think I've been able to put together the ultimate Hacknet script. It takes a parameter for breakeven time (in seconds) and continues to buy upgrades and nodes which will pay back their cost within the time limit specified. 10 | 11 | Features: 12 | 13 | Optimizes calculation for any combination of Bitnode & Augment multipliers. 14 | Breakeven time is currently specified as a constant, but can be passed as an argument instead if needed. 15 | Most Netscript functions are in wrapper functions, to minimize the RAM footprint. 16 | Shortcomings: 17 | 18 | I have no straightforward way to track the total cash that has been spent on upgrading a node. Without this, I can't precisely calculate the cost effectiveness of new nodes. As a workaround, I currently just buy nodes where the initial cost for the node can pay off within half the breakeven time specified. 19 | Upgrades are bought in order of cash availability, not best bang for buck, to save on calculation complexity. 20 | Code: setup-hacknet.script (7.70GB)" 21 | 22 | REDDIT POST: 23 | https://www.reddit.com/r/Bitburner/comments/7ov7a6/the_ultimate_hacknet_script_almost/ 24 | */ 25 | 26 | 27 | function calcGainRate(X, Y, Z) { 28 | return (X*1.6) * Math.pow(1.035,Y-1) * ((Z+5)/6); 29 | } 30 | function gainFromLevelUpgrade(X, Y, Z) { 31 | return (1*1.6) * Math.pow(1.035,Y-1) * ((Z+5)/6); 32 | } 33 | function gainFromRamUpgrade(X, Y, Z) { 34 | return (X*1.6) * (Math.pow(1.035,(2*Y)-1) - Math.pow(1.035,Y-1)) * ((Z+5)/6); 35 | } 36 | function gainFromCoreUpgrade(X, Y, Z) { 37 | return (X*1.6) * Math.pow(1.035,Y-1) * (1/6); 38 | } 39 | function hNodes(){ //Wrapper to save on RAM costs 40 | return hacknetnodes; 41 | } 42 | function upgradeNodeLevel(X, i, levels){ //Wrapper to save on RAM costs 43 | print("Node " + i + ": Attempting Level Upgrade: " + hNodes()[i].upgradeLevel(levels)); 44 | } 45 | function upgradeNodeRam(Y, i){ //Wrapper to save on RAM costs 46 | print("Node " + i + ": Attempting RAM Upgrade: " + hNodes()[i].upgradeRam()); 47 | } 48 | function upgradeNodeCore(Z, i){ //Wrapper to save on RAM costs 49 | print("Node " + i + ": Attempting Core Upgrade: " + hNodes()[i].upgradeCore()); 50 | } 51 | 52 | breakevenTime = 3600*4;//Time in seconds 53 | 54 | //Ensure at least one node has been purchased 55 | if(hNodes().length === 0) purchaseHacknetNode(); 56 | 57 | //Calculate the gain multiplier by checking actual gain vs theoretical 58 | firstNode = hNodes()[0]; 59 | X = firstNode.level; 60 | Y = firstNode.ram; 61 | Z = firstNode.cores; 62 | gainMul = firstNode.moneyGainRatePerSecond/calcGainRate(X,Y,Z); 63 | 64 | checkForMoreUpgrades = true; 65 | while(checkForMoreUpgrades) { 66 | checkForMoreUpgrades = false; 67 | 68 | //Update the first node 69 | if ( (X < 200) && 70 | (firstNode.getLevelUpgradeCost(1) < (breakevenTime * gainMul * gainFromLevelUpgrade(X, Y, Z))) ) { 71 | upgradeNodeLevel(X,0,1); 72 | checkForMoreUpgrades = true; 73 | } 74 | if ( (Y < 64) && 75 | (firstNode.getRamUpgradeCost() < (breakevenTime * gainMul * gainFromRamUpgrade(X, Y, Z))) ) { 76 | upgradeNodeRam(Y,0); 77 | checkForMoreUpgrades = true; 78 | } 79 | if ( (Z < 16) && 80 | (firstNode.getCoreUpgradeCost() < (breakevenTime * gainMul * gainFromCoreUpgrade(X, Y, Z))) ) { 81 | upgradeNodeCore(Z,0); 82 | checkForMoreUpgrades = true; 83 | } 84 | 85 | //Buy more nodes if cost effective 86 | if( getNextHacknetNodeCost() < (breakevenTime * hNodes()[0].moneyGainRatePerSecond / 2) ) { 87 | i = purchaseHacknetNode(); 88 | print("Bought a new node: " + i); 89 | checkForMoreUpgrades = true; 90 | } 91 | 92 | //Match all extra nodes to the first node 93 | for (i = 1; i < hNodes().length; i++){ 94 | while(hNodes()[i].level < hNodes()[0].level) 95 | upgradeNodeLevel(hNodes()[i].level, i,(hNodes()[0].level - hNodes()[i].level)); 96 | while(hNodes()[i].ram < hNodes()[0].ram) 97 | upgradeNodeRam(hNodes()[i].ram, i); 98 | while(hNodes()[i].cores < hNodes()[0].cores) 99 | upgradeNodeCore(hNodes()[i].cores, i); 100 | } 101 | } 102 | 103 | tprint("Done."); -------------------------------------------------------------------------------- /Late-game/Autohack.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Reydien (https://www.reddit.com/user/Reydien) 4 | 5 | POSTED ON: 6 | September 15th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "FOREWARNING: This script is designed to be run on a server with tens of thousands of GB of free RAM. This script also does not always keep the full amount of necessary RAM occupied, so if you are checking server ram in other scripts it may not be accurate. 10 | 11 | This script will automatically determine how many thread of hack is needed to take a given server (at minimum security) from 100% money to 0% money, how many threads of grow is then needed to take the server back to 100% money, and finally how many threads of weaken is needed to bring the server back down to minimum security to repeat the process. It then uses those numbers and runs a set of ultra-light scripts to run each function in turn. The end result is that you receive MAX_MONEY from the server for every cycle of weaken you run. 12 | 13 | This script DOES NOT: 14 | 15 | Nuke the server. You must hack it manually or with another script first. 16 | 17 | Adjust its values as your hacking skill increases. At higher levels the hack script be overshooting the 100%, but that has no adverse effect. 18 | 19 | Check to see if the server has enough RAM for the process. Because the sub-scripts are not always running, simply checking free RAM can be deceiving. 20 | 21 | BE WARNED: If you run this when your hacking skill is exactly equal to the server's required skill, it will use A LOT of ram, like 300,000GB or more. I would recommend at least +10 skill, which would put the ram usage at about double the eventual lower limit. 22 | 23 | Scripts 24 | 25 | There are 4 scripts, Autohack.script, hack.script, grow.script, weaken.script. After saving all four, the syntax is simply "run Autohack.script target" Autohack.script" 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/70dj0q/autohack_script_set_for_midtolate_game/ 29 | */ 30 | 31 | 32 | 33 | //Skill Multiplier Constants, update after augmentations 34 | hackmult = 2.6880; 35 | growmult = 1.7708; 36 | //Bitnode Multiplier Constants, update after changing Bitnodes 37 | bitnodehackmult = 1.0000; 38 | bitnodegrowmult = 1.0000; 39 | bitnodeweakenmult = 1.0000; 40 | 41 | target = args[0]; 42 | 43 | if (hasRootAccess(args[0]) === false) {tprint(target + " is not hacked yet.")} 44 | else 45 | { 46 | //Gather Hack-related Variables 47 | skill = getHackingLevel(); 48 | reqHack = getServerRequiredHackingLevel(target); 49 | minsecurity = Math.max(round(getServerBaseSecurityLevel(target)/3),1); 50 | 51 | //Calculate number of Hack Threads Required 52 | perhack = (100-minsecurity) * ((skill-reqHack+1)/skill) / 24000 * hackmult * bitnodehackmult; 53 | hacks = Math.ceil(1/perhack); 54 | 55 | //Gather Growth-related Variables 56 | growth = getServerGrowth(target); 57 | security = minsecurity + hacks * 0.002; 58 | maxmoney = getServerMaxMoney(target); 59 | 60 | //Calculate number of Grow Threads Required 61 | growpercent = Math.min(1 + 0.03/security,1.0035); 62 | pergrow = Math.pow(growpercent,growth/100 * growmult * bitnodegrowmult); 63 | var1 = maxmoney * Math.log(pergrow); 64 | lambert = Math.log(var1)-Math.log(Math.log(var1))-Math.log(1-Math.log(Math.log(var1))/Math.log(var1)); 65 | grows = Math.ceil(lambert/Math.log(pergrow)); 66 | 67 | //Calculate number of Weaken Threads Required 68 | weakens = Math.ceil((((hacks * 0.002) + (grows * 0.004)) / (0.05 * bitnodeweakenmult))); 69 | maxweakens = (100 - minsecurity) / (0.05 * bitnodeweakenmult); 70 | if (weakens > maxweakens) {weakens = maxweakens} 71 | 72 | //Add up how much memory this will use, report the value 73 | totalmem = hacks * 1.80 + grows * 1.55 + weakens * 1.55 + 6.70; 74 | tprint("Preparing to attack " + target + " with " + hacks + " hacks, " + grows + " grows, and " + weakens + "weakens for a total of " + totalmem + "GB of memory use"); 75 | 76 | currsecurity = getServerSecurityLevel(target); 77 | 78 | if (currsecurity > minsecurity) 79 | { 80 | //tprint("bringing " + target + " down to min security..."); 81 | run('weaken.script',Math.ceil((currsecurity - minsecurity) / 0.05),target); 82 | 83 | while (isRunning('weaken.script',getHostname(),target)) 84 | { 85 | sleep(1000,false); 86 | } 87 | //tprint(target + " weakened, beginning hack."); 88 | } 89 | 90 | while (true) 91 | { 92 | run('weaken.script',weakens,target); 93 | run('grow.script',grows,target); 94 | if (isRunning('hack.script',getHostname(),target) === false) {run('hack.script',hacks,target);} 95 | 96 | while (isRunning('weaken.script',getHostname(),target)) 97 | { 98 | sleep(1000,false); 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /Stock Market/stock.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Infra_asd (https://www.reddit.com/user/Infra_asd) 4 | 5 | POSTED ON: 6 | September 28th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I made a script with TIX API and I haven't seen a lot of people talk about it and figured I'd try it out. WITH THE WAY I SET IT UP THIS SCRIPT WILL SPAM AND UPDATE INTO THE TERMINAL. IM SORRY BUT I JUST LIKE IT THAT WAY, TO CHANGE IT CHANGE ALL tprint() FUNCTIONS to print() 10 | 11 | fsig.script is 19.00 GB: you need the TIX API first ,basically I just made a script that would capitalize on highs and lows I used FSIG and studied how >low and high it would go at times, the lowest I have seen FSIG go is about 1.4 mill but rarely at times did it always go that far so for simplicities sake I did 1.700m and 1.900m for highs and lows. but it can pay out much higher if you change the "1700000" to a lower number above "1400000"." 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/72xmgy/stock_script_i_made/ 15 | */ 16 | 17 | 18 | 19 | ecp = [ "ECP",0,0]; 20 | mgcp = ["MGCP",0,0]; 21 | bld = ["BLD",0,0]; 22 | clrk = ["CLRK",0,0]; 23 | omtk = ["OMTK",0,0]; 24 | fsig = ["FSIG",0,0 ]; 25 | kgi = ["KGI",0,0 ]; 26 | flcm = ["FLCM",0,0]; 27 | stm = ["STM",0,0]; 28 | dcomm = ["DCOMM",0,0]; 29 | hls = ["HLS",0,0]; 30 | vita = ["VITA",0,0]; 31 | icrs = ["ICRS",0,0]; 32 | unv = ["UNV",0,0]; 33 | aero = ["AERO",0,0]; 34 | omn = ["OMN",0,0]; 35 | slrs = ["SLRS",0,0]; 36 | gph = ["GPH",0,0]; 37 | nvmd = ["NVMD",0,0]; 38 | wds = ["WDS",0,0]; 39 | lxo = ["LXO",0,0]; 40 | rhoc = ["RHOC",0,0]; 41 | aphe = ["APHE",0,0]; 42 | sysc = ["SYSC",0,0]; 43 | ctk = ["CTK",0,0]; 44 | ntlk = ["NTLK",0,0]; 45 | omga = ["OMGA",0,0]; 46 | fns = ["FNS",0,0]; 47 | sgc = ["SGC",0,0]; 48 | jgn = ["JGN",0,0]; 49 | ctys = ["CTYS",0,0]; 50 | mdyn = ["MDYN",0,0]; 51 | titn = ["TITN",0,0]; 52 | 53 | symbols = [ecp, mgcp, bld, clrk, omtk, fsig, kgi, flcm, stm, 54 | dcomm, hls, vita, icrs, unv, aero, omn, slrs, gph, 55 | nvmd, wds, lxo, rhoc, aphe, sysc, ctk, ntlk, omga, 56 | fns, sgc, jgn, ctys, mdyn, titn]; 57 | // Infinite loop 58 | counter = 0; 59 | while (true){ 60 | //print('Times checked : ' + counter); 61 | 62 | for (i= 0; i < symbols.length; i++){ 63 | //Buy 1 share of each as a built in average price 64 | pos = getStockPosition(symbols[i][0]); 65 | if (pos[1] === 0){ 66 | buyStock(symbols[i][0], 1); 67 | } 68 | //Get the stock price 69 | stockPrice = getStockPrice(symbols[i][0]); 70 | //get stock position again 71 | pos = getStockPosition(symbols[i][0]); 72 | //Calculo de threshold para comprar, pero solo si tengo al menos un promedio de 2 pasadas 73 | //Calculate buying threshold after two, only if i have to script passes 74 | if(counter > 2){ 75 | 76 | //I buy a maximum of 3 times the same share, as this would invest everything otherwise 77 | if (symbols[i][2] > 3){ 78 | 79 | }else{ 80 | //Check if its worth buying 81 | buyThresh = pos[1]; 82 | 83 | if (stockPrice < buyThresh){ 84 | //if it is, i calculate how much shares would i buy using 15% of total money 85 | money = (getServerMoneyAvailable("home") * 0.15); //Only use 15% of cash to buy stock 86 | shareAmount = Math.floor(money / stockPrice); 87 | //I buy the stock and save the buying price on position1 of the array 88 | tprint('Investing ' + money + " on " + shareAmount + " shares of " + symbols[i][0]); 89 | buyStock(symbols[i][0], shareAmount); 90 | symbols[i][1] = stockPrice; 91 | symbols[i][2] = symbols[i][2] + 1; 92 | } 93 | } 94 | } 95 | //Calculating sells 96 | //First i check if i have any more than the 1 97 | if(pos[0] > 1){ 98 | // Calculate sellThresh using the buying price 99 | //Looking for a 3% profit on every sell 100 | //I take into account if the stocks was purchased before excecuting the script, and so i check the sellthresh to the average price of it 101 | if(symbols[i][1] === 0){ 102 | sellThresh = pos[1]; 103 | }else{ 104 | sellThresh = (symbols[i][1] * 1.03); 105 | } 106 | //If the price is met i sell every stock but the 1 for the average 107 | if (stockPrice > sellThresh){ 108 | sellAmount = pos[0] - 1; 109 | tprint('Selling all shares (' + pos[0] + ') of ' + symbols[i][0]); 110 | sellStock(symbols[i][0], sellAmount); 111 | symbols[i][2] = 0; 112 | } 113 | } 114 | 115 | 116 | 117 | 118 | 119 | 120 | } 121 | counter ++; 122 | } -------------------------------------------------------------------------------- /src/serviceWorker.js: -------------------------------------------------------------------------------- 1 | // In production, we register a service worker to serve assets from local cache. 2 | 3 | // This lets the app load faster on subsequent visits in production, and gives 4 | // it offline capabilities. However, it also means that developers (and users) 5 | // will only see deployed updates on the "N+1" visit to a page, since previously 6 | // cached resources are updated in the background. 7 | 8 | // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. 9 | // This link also includes instructions on opting out of this behavior. 10 | 11 | const isLocalhost = Boolean( 12 | window.location.hostname === 'localhost' || 13 | // [::1] is the IPv6 localhost address. 14 | window.location.hostname === '[::1]' || 15 | // 127.0.0.1/8 is considered localhost for IPv4. 16 | window.location.hostname.match( 17 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 18 | ) 19 | ); 20 | 21 | export function register(config) { 22 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 23 | // The URL constructor is available in all browsers that support SW. 24 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location); 25 | if (publicUrl.origin !== window.location.origin) { 26 | // Our service worker won't work if PUBLIC_URL is on a different origin 27 | // from what our page is served on. This might happen if a CDN is used to 28 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 29 | return; 30 | } 31 | 32 | window.addEventListener('load', () => { 33 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 34 | 35 | if (isLocalhost) { 36 | // This is running on localhost. Let's check if a service worker still exists or not. 37 | checkValidServiceWorker(swUrl, config); 38 | 39 | // Add some additional logging to localhost, pointing developers to the 40 | // service worker/PWA documentation. 41 | navigator.serviceWorker.ready.then(() => { 42 | console.log( 43 | 'This web app is being served cache-first by a service ' + 44 | 'worker. To learn more, visit https://goo.gl/SC7cgQ' 45 | ); 46 | }); 47 | } else { 48 | // Is not local host. Just register service worker 49 | registerValidSW(swUrl, config); 50 | } 51 | }); 52 | } 53 | } 54 | 55 | function registerValidSW(swUrl, config) { 56 | navigator.serviceWorker 57 | .register(swUrl) 58 | .then(registration => { 59 | registration.onupdatefound = () => { 60 | const installingWorker = registration.installing; 61 | installingWorker.onstatechange = () => { 62 | if (installingWorker.state === 'installed') { 63 | if (navigator.serviceWorker.controller) { 64 | // At this point, the old content will have been purged and 65 | // the fresh content will have been added to the cache. 66 | // It's the perfect time to display a "New content is 67 | // available; please refresh." message in your web app. 68 | console.log('New content is available; please refresh.'); 69 | 70 | // Execute callback 71 | if (config.onUpdate) { 72 | config.onUpdate(registration); 73 | } 74 | } else { 75 | // At this point, everything has been precached. 76 | // It's the perfect time to display a 77 | // "Content is cached for offline use." message. 78 | console.log('Content is cached for offline use.'); 79 | 80 | // Execute callback 81 | if (config.onSuccess) { 82 | config.onSuccess(registration); 83 | } 84 | } 85 | } 86 | }; 87 | }; 88 | }) 89 | .catch(error => { 90 | console.error('Error during service worker registration:', error); 91 | }); 92 | } 93 | 94 | function checkValidServiceWorker(swUrl, config) { 95 | // Check if the service worker can be found. If it can't reload the page. 96 | fetch(swUrl) 97 | .then(response => { 98 | // Ensure service worker exists, and that we really are getting a JS file. 99 | if ( 100 | response.status === 404 || 101 | response.headers.get('content-type').indexOf('javascript') === -1 102 | ) { 103 | // No service worker found. Probably a different app. Reload the page. 104 | navigator.serviceWorker.ready.then(registration => { 105 | registration.unregister().then(() => { 106 | window.location.reload(); 107 | }); 108 | }); 109 | } else { 110 | // Service worker found. Proceed as normal. 111 | registerValidSW(swUrl, config); 112 | } 113 | }) 114 | .catch(() => { 115 | console.log( 116 | 'No internet connection found. App is running in offline mode.' 117 | ); 118 | }); 119 | } 120 | 121 | export function unregister() { 122 | if ('serviceWorker' in navigator) { 123 | navigator.serviceWorker.ready.then(registration => { 124 | registration.unregister(); 125 | }); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /Singularity/reputation.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/RafnarC (https://www.reddit.com/user/RafnarC) 4 | 5 | POSTED ON: 6 | October 12th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I've been spending a lot of time in the first run on the singularity bitnode and as such have made a script to level my reputation in all of the faction i am currently in and can join. I still consider my self a netscript neonate so any coments improvements would be welcome. 10 | ... 11 | Edit updated script to use if (workForFaction(knownfactions[i], 'hacking') || workForFaction(knownfactions[i], 'fieldwork')) for detecting if your in a faction Edit added the the faction culling after you can get all their augments now to find out how to reduce the size but 10-15 gb" 12 | 13 | REDDIT POST: 14 | https://www.reddit.com/r/Bitburner/comments/75thik/reputation_script/ 15 | */ 16 | 17 | 18 | 19 | function work(faction){ 20 | while (getFactionRep(faction) < rep) { 21 | if(!workForFaction(faction, "hacking")){ 22 | workForFaction(faction,"fieldwork"); 23 | } 24 | sleep(sleeptime); 25 | } 26 | } 27 | 28 | function workjob(company){ 29 | if(company!="Joe's Guns"){ 30 | applyToCompany(company,"software"); 31 | } else{ 32 | applyToCompany(company,"employee"); 33 | } 34 | while (getCompanyRep(company) < corprep) { 35 | workForCompany(); 36 | sleep(sleeptime); 37 | } 38 | } 39 | 40 | //list of all corp 41 | corps = ["MegaCorp", "Blade Industries", "Four Sigma", "KuaiGong International", "NWO", "OmniTek Incorporated", "ECorp", "Bachman & Associates", "Clarke Incorporated", "Fulcrum Technolgies"]; 42 | //list of all factions 43 | knownfactions = ["Sector-12", "Aevum", "Tian Di Hui", "Chongqing", "New Tokyo", "Ishima", "Volhaven", "CyberSec", "NiteSec", "The Black Hand", "BitRunners", "Fulcrum Secret Technologies", "Bachman & Associates", "MegaCorp", "KuaiGong International", "Clarke Incorporated", "Blade Industries", "Four Sigma", "ECorp", "OmniTek Incorporated", "Netburners", "Slum Snakes", "Daedalus", "Tetrads", "Illuminati", "The Covenant", "NWO"]; 44 | // creating the a list of faction your already in 45 | currentfactions =[]; 46 | deletefactions= []; 47 | // other preset veriables 48 | rep = 5000; 49 | maxcorprep = 250000; 50 | corprep = 10000; 51 | corpindex = 0; 52 | sleeptime =240000; 53 | //starting the loop 54 | while (true){ 55 | // check faction invites and accept them then remove them from the knowfacttions list 56 | invites = checkFactionInvitations(); 57 | if (invites.length > 0 ){ 58 | for (i=0; i -1){ 63 | knownfactions.splice(index, 1); 64 | } 65 | } 66 | } 67 | 68 | 69 | // check and see if your are already in a faction and add it to the working list 70 | deletefactions = []; 71 | for(i=0;i -1){ 82 | knownfactions.splice(index, 1); 83 | } 84 | } 85 | 86 | //Cull faction you can already buy all augments from (excluding "NeuroFlux Governor") 87 | actionaugs= []; 88 | cullfactions= []; 89 | for(i=0;itopaug){ 98 | cullfactions.push(currentfactions[i]); 99 | } 100 | } 101 | tprint("done"); 102 | for(i=0;i -1){ 105 | currentfactions.splice(index,1); 106 | } 107 | 108 | } 109 | 110 | 111 | 112 | //Check if your in a faction to get rep from 113 | if(currentfactions.length>0){ 114 | 115 | // work for faction 116 | for (i=0;i250){ 123 | if (corpindex < corps.length){ 124 | workjob(corps[corpindex]); 125 | corprep += 10000; 126 | // switching to a new corp if your rep is above 250000 or the set maxcorprep 127 | if (getCompanyRep(corps[corpindex]) > maxcorprep ){ 128 | corpindex++; 129 | corprep = 10000; 130 | } 131 | } 132 | } else { 133 | workjob("Joe's Guns"); 134 | } 135 | //if(getStatLevel('Cha')<1000){ 136 | travelToCity('Volhaven'); 137 | universityCourse('ZB Institute of Technology','Leadership'); 138 | sleep(sleeptime*2); 139 | //} 140 | 141 | } -------------------------------------------------------------------------------- /Stock Market/_InvestmentBroker_Manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Rinchwind (https://www.reddit.com/user/Rinchwind) 4 | 5 | POSTED ON: 6 | December 3rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "After running many, many simulations, I've come to a conclusion that in most cases, a script would perform worse than just putting money in a few stocks and forgetting about it for a few days (while letting the game run in the background). just like in real life... :) 10 | 11 | However, with the highly volatile stocks (JGN, SGC, APHE and CTYS), a well-tuned script can produce much better results (statistically speaking. It can still perform miserably in some situations, but usually it will get me to several thousand trillion within a day or two) 12 | 13 | To use the script, run InvestmentBroker.script and use _InvestmentBroker_Msg.script to send commands to it. 14 | You can run the main script on a private server (just copy InvestmentBroker.script, _InvestmentBroker.script, _InvestmentBroker_Data.script and _InvestmentBroker_Manager.script. You can run the messaging script from the home server) or on the home server, it needs at least 153Mb to manage all 4 stocks. 15 | 16 | I’ve also defined the following aliases to make using it easier: 17 | 18 | alias InvestmentBrokerStatus="run _InvestmentBroker_Msg.script S" 19 | alias InvestmentBrokerBuyStock="run _InvestmentBroker_Msg.script A" 20 | alias InvestmentBrokerLiquidate="run _InvestmentBroker_Msg.script L" 21 | 22 | For instance, to buy 25,000,000$ worth of JGN stock, type the following: 23 | 24 | InvestmentBrokerBuyStock JGN 25000000 25 | 26 | To liquidate all JGN stock, type the following: 27 | 28 | InvestmentBrokerLiquidate JGN " 29 | 30 | REDDIT POST: 31 | https://www.reddit.com/r/Bitburner/comments/78zva1/stock_script_brainstorming/ 32 | */ 33 | 34 | 35 | 36 | //-------------------------------------------------------------------------------------------------------------------------- 37 | //---------------------------_InvestmentBroker_Manager.script--------------------------------------------------------------- 38 | //-------------------------------------------------------------------------------------------------------------------------- 39 | 40 | COMMISION_FEE = 100000; 41 | INPUT_PORT = 10; 42 | 43 | localHost = getHostname(); 44 | 45 | StockSymbol = args[0]; 46 | DATA_PORT = args[1]; 47 | HistorySize = args[2]; 48 | 49 | BuyThreshold = 1 + args[3]; 50 | SellThreshold = 1 - args[3]; 51 | 52 | cash = args[4]; 53 | 54 | movingAverageHistory = []; 55 | 56 | doLoop = true; 57 | 58 | while (doLoop) 59 | { 60 | movingAverage = read(DATA_PORT); 61 | if (movingAverage === "_L") 62 | { 63 | // Liquidate command given, terminate script 64 | doLoop = false; 65 | write(INPUT_PORT, "__L " + DATA_PORT); 66 | } 67 | else if (movingAverage !== 'NULL PORT DATA') 68 | { 69 | movingAverageHistory.push(movingAverage); 70 | if (movingAverageHistory.length > HistorySize) 71 | { 72 | previousMovingAverage = movingAverageHistory.shift(); 73 | if (movingAverage > (previousMovingAverage * BuyThreshold)) 74 | { 75 | // MA is trending up, buy stocks if cash is available 76 | additionalCost = 0; 77 | prevStockData = getStockPosition(StockSymbol); 78 | stockPrice = getStockPrice(StockSymbol); 79 | if (cash > stockPrice + COMMISION_FEE) 80 | { 81 | // Calculate amount of stocks to purchase 82 | newShares = Math.floor((cash - additionalCost - COMMISION_FEE) / stockPrice); 83 | while (!buyStock(StockSymbol, newShares) && newShares > 0) 84 | { 85 | // We failed to buy stocks, adjust cash and retry 86 | availableCash = getServerMoneyAvailable("home"); 87 | if (availableCash < cash) 88 | { 89 | // Less cash is available then should be (can happen due to purchase/sell orders happening at a different price then we measured or simply because the user spent the money on something) 90 | // Adjust cost to account for discrepency (I'm adjusting the cose instead of the available cash to reflect the missing cash in the broker script) 91 | additionalCost += (cash - availableCash); 92 | } 93 | // Recalculate amount of stocks to purchase 94 | newShares = Math.floor((cash - additionalCost - COMMISION_FEE) / getStockPrice(StockSymbol)); 95 | } 96 | if (newShares > 0) 97 | { 98 | stockData = getStockPosition(StockSymbol); 99 | if (prevStockData[0] === 0) 100 | { 101 | cost = (COMMISION_FEE + (newShares * stockData[1])); 102 | } 103 | else 104 | { 105 | cost = COMMISION_FEE + ((stockData[1] * stockData[0]) - (prevStockData[1] * prevStockData[0])); 106 | } 107 | cost += additionalCost; 108 | cash -= cost; 109 | // Send transaction data to broker 110 | write(INPUT_PORT, "_Sb " + DATA_PORT + " " + cost); 111 | } 112 | } 113 | } 114 | if (movingAverage < (previousMovingAverage * SellThreshold)) 115 | { 116 | // MA is trending down, sell stocks if it's profitable 117 | stockData = getStockPosition(StockSymbol); 118 | stockPrice = getStockPrice(StockSymbol); 119 | profit = stockData[0] * (stockPrice - stockData[1]); 120 | if (profit > COMMISION_FEE * 2) 121 | { 122 | sellStock(StockSymbol, stockData[0]); 123 | stockPrice = getStockPrice(StockSymbol); 124 | income = (stockData[0] * stockPrice) - COMMISION_FEE; 125 | cash += income; 126 | // Send transaction data to broker 127 | write(INPUT_PORT, "_Ss " + DATA_PORT + " " + income); 128 | } 129 | } 130 | } 131 | } 132 | } -------------------------------------------------------------------------------- /Hacknet/sort-taget.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/JohnHarr (https://www.reddit.com/user/JohnHarr) 4 | 5 | POSTED ON: 6 | January 16th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "I am currently trying to automate everything I can (my scripts are based off of MercuriusXeno work). I am running into difficulty with the length it takes to sort arrays by number when trying to automate targeting for my servers. I changed MercuriusXeno's start.script file to output target's server and the target's weight to a text file. I would then use another script to read that text file, create an ordered target list, and output those targets into text files for each server to read. 10 | 11 | The .txt file that the start.script outputs is called "vulnerable.txt" and it is ordered as follows (the full .txt file that I am trying to process is at the end of this post): [target0 weight0 target1 weight1 target2 weight2 ... ] 12 | 13 | For sorting, .sort() is pretty quick (I believe that this is due to it using javascript instead of going through BitBurner's code), but it sorts alphabetically. I tried a few things to get it to sort numerically, but these either did not work (due to differences in how BitBurner handles functions) or took very long to sort the file. 14 | 15 | I am hoping that someone here has run into this problem and has a potential solution. Note that I am not a programmer, so my code is extremely likely to be not optimal, so if you have any suggestions on what I can improve please let me know. 16 | 17 | My current code works, it is just much to slow for what I am aim for it to do (currently it takes >30 minutes for a list 122 long or 61 targets). My current code has a lot of tprints, but those are mainly for me to check on what is happening between steps. 18 | 19 | The current code I am using is below (Sorry if this is not formatted properly. I usually just lerk and don't post much of anything): 20 | 21 | sort-target.script - Cost: 5.60 GB 22 | 23 | use run sort-target 24 | 25 | " 26 | 27 | REDDIT POST: 28 | https://www.reddit.com/r/Bitburner/comments/7qq1rc/looking_for_faster_way_to_sort_data_by_number/ 29 | */ 30 | 31 | 32 | //this script should be run on "home" to have a central location for .txt files 33 | //this script is used to generate a optimized target list for servers 34 | //it is a separate file for troubleshooting and to keep expensive read commands out of continuous scripts 35 | //this is clunky and most likely not the optimal way to do this 36 | 37 | //define full target list as an array 38 | targetList = []; 39 | //this array will store the weight determine in start.script for each pair 40 | targetWeight = []; 41 | //sorted list of weights 42 | weightSorted = []; 43 | //this array will be the order number list 44 | targetOrder = []; 45 | //read .txt file created by the start.script 46 | targetList = read("vulnerable.txt"); 47 | //split array by spaces 48 | //the way that the write sections of start.script are written, all targets and weights are separated by spaces 49 | targetList = targetList.split(" "); 50 | //remove the space from the end of the array 51 | //the .txt file will end in a space (which is now included in the array) due to how it is written 52 | finalSpace = targetList.length - 1; 53 | targetList.splice(finalSpace,1); 54 | //this is the total length of the array starting from 1 55 | //this should always be an even number 56 | lengthTarget = targetList.length; 57 | tprint("targetList length = " + lengthTarget); 58 | //this is the number of targets included in the list 59 | numberTarget = lengthTarget / 2; 60 | tprint("number of targets = " + numberTarget); 61 | //this is to determine how many targets should be obtained by the final check 62 | //the idea is to not make the script run too long if there are more targets than you can use on servers 63 | if(numberTarget > 26) { 64 | usedTarget = 25; 65 | } else { 66 | usedTarget = numberTarget; 67 | } 68 | 69 | tprint(targetList); 70 | //as the targetList array will always be ["target","weight",etc.], we will have to account for the list being is sets of 2 71 | //we sort by the weight, but we need to drag the target along 72 | for(i = 0; i < lengthTarget; i++ ) { 73 | //the weight numbers will always be odd, this is a clunky way of forcing that with a for loop 74 | //each loop will add one and then add one here to use the weight as i in the loop 75 | i += 1; 76 | //this will be a list of only the weights for the targets 77 | //the goal is to sort this list and find the matching weight in the targetList to get the targets in order 78 | targetWeight[((i+1)/2)-1] = targetList[i]; 79 | } 80 | //create a duplicate of the orginal targetWeight array 81 | //I originally was going to use this to compare at the end, but that just adding another comparision to the targetList file 82 | weightSorted = targetWeight.slice(); 83 | 84 | tprint("Pre-sort"); 85 | //this was an attempt to get sorting to work how I wanted it to 86 | 1*weightSorted; 87 | tprint("weightSorted length = " + weightSorted.length); 88 | 89 | //this is currently a bubble sort 90 | swap = 0; 91 | swapCount = 1; 92 | while(swapCount > 0){ 93 | swapCount = 0; 94 | for (i = 0; i < weightSorted.length -1; i++){ 95 | tprint(i); 96 | if(weightSorted[i]-weightSorted[i+1] < 0){ 97 | swap = weightSorted[i]; 98 | weightSorted[i] = weightSorted[i+1]; 99 | weightSorted[i+1] = swap; 100 | swapCount += 1; 101 | } 102 | } 103 | //for debugging and knowing that the script is still working 104 | tprint("Sorting new swap"); 105 | } 106 | //debugging 107 | tprint("Post-sort"); 108 | tprint(weightSorted); 109 | 110 | //after sorting the weights, this is used to get the server name of the weights and get the in the proper order 111 | for(i = 0; i < usedTarget; i++) { 112 | tprint("Searching for targetOrder " + i); 113 | //search for the matching weight in the targetList 114 | for(j = 0; j < lengthTarget; j++){ 115 | //since this is based off of the targetList, we need to account for the ["target","weight"] issue again 116 | j += 1; 117 | //check the sorted list to the orginal list to get the server name 118 | if(weightSorted[i] == targetList[j]) { 119 | targetOrder[i] = targetList[j-1]; 120 | tprint("targetOrder " + i + " was found"); 121 | tprint("pserv-" + i + " target = " + targetOrder[i]); 122 | write("pserv-" + i + ".txt",targetOrder[i],"w"); 123 | break; 124 | } 125 | } 126 | } 127 | tprint(targetOrder); 128 | //run the script that kills all scripts on servers and retargets them using the associated .txt file 129 | run("restart-server.script",1); -------------------------------------------------------------------------------- /Misc/auto-deepscan.js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/desci1 (https://www.reddit.com/user/desci1) 4 | 5 | POSTED ON: 6 | July 23rd, 2017 7 | 8 | COMMENT CONTEXT: 9 | "Current memory usage without the comments: This script requires 13,06GB of RAM to run for 1 thread(s)" 10 | 11 | REDDIT POST: 12 | https://www.reddit.com/r/Bitburner/comments/6p24g8/deepscanscript/ 13 | */ 14 | 15 | 16 | 17 | /* 18 | auto-deepscan.script 19 | for bitburner's netscript 20 | version: 12 21 | winners don't use copyright 22 | remove all comments to save RAM 23 | */ 24 | 25 | // these variables should be incremented when the loop scripts are modified. we will overwrite the loop-scripts on all servers with the latest version, kill the scripts running old versions if any, and execute the new ones. 26 | hackVersion = 3; 27 | growVersion = 3; 28 | 29 | // these are my own servers, which shouldn't be hacked, grown, weakened, etc. 30 | ownServers = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31' ] 31 | 32 | startingServer = 0; 33 | 34 | allServers = [ 'foodnstuff' ]; 35 | newServers = scan(getHostname()); 36 | 37 | for (newServer = 0; newServer < newServers.length; newServer++) { 38 | isNewServer = true; 39 | if (newServers[newServer] == 'home') isNewServer = false; 40 | for (checkServer = 0; checkServer < ownServers.length; checkServer++) if (newServers[newServer] == 'home-' + ownServers[checkServer]) isNewServer = false; 41 | for (checkServer = 0; checkServer < allServers.length; checkServer++) if (newServers[newServer] == allServers[checkServer]) isNewServer = false; 42 | if (isNewServer) allServers = allServers.concat(newServers[newServer]); 43 | } 44 | 45 | while (true) { 46 | servers = allServers; 47 | // when we reach the last server, start it all over 48 | if (startingServer == allServers.length) startingServer = 0; 49 | for (server = startingServer; server < servers.length; server++) { 50 | if (getHackingLevel() >= getServerRequiredHackingLevel(servers[server])) { 51 | if (hasRootAccess(servers[server]) == false) { 52 | // i've decided to do this way after much testing and logic. netscript needs more features to make this code simplier for every and all possibilities. either that or my solution is not good. 53 | if (getServerNumPortsRequired(servers[server]) > 0) { 54 | if (getServerNumPortsRequired(servers[server]) == 1 && fileExists('brutessh.exe')) { 55 | brutessh(servers[server]); 56 | nuke(servers[server]); 57 | } else if (getServerNumPortsRequired(servers[server]) == 2 && fileExists('ftpcrack.exe')) { 58 | brutessh(servers[server]); 59 | ftpcrack(servers[server]); 60 | nuke(servers[server]); 61 | } else if (getServerNumPortsRequired(servers[server]) == 3 && fileExists('relaysmtp.exe')) { 62 | brutessh(servers[server]); 63 | ftpcrack(servers[server]); 64 | relaystmp(servers[server]); 65 | nuke(servers[server]); 66 | } else if (getServerNumPortsRequired(servers[server]) == 4 && fileExists('httpworm.exe')) { 67 | brutessh(servers[server]); 68 | ftpcrack(servers[server]); 69 | relaystmp(servers[server]); 70 | httpworm(servers[server]); 71 | nuke(servers[server]); 72 | } else if (getServerNumPortsRequired(servers[server]) == 5 && fileExists('sqlinject.exe')) { 73 | brutessh(servers[server]); 74 | ftpcrack(servers[server]); 75 | relaystmp(servers[server]); 76 | httpworm(servers[server]); 77 | sqlinject(servers[server]); 78 | nuke(servers[server]); 79 | } 80 | } else { 81 | nuke(servers[server]); 82 | } 83 | } 84 | if (hasRootAccess(servers[server]) == true) { 85 | if (isRunning('loop-hack.script', servers[server], hackVersion) == false) { 86 | while (isRunning('loop-hack.script', servers[server]) == true) kill('loop-hack.script', servers[server]); 87 | for (version = 0; version < hackVersion; version++) { 88 | while (isRunning('loop-hack.script', servers[server], version) == true) kill('loop-hack.script', servers[server], version); 89 | } 90 | scp('loop-hack.script', servers[server]); 91 | exec('loop-hack.script', servers[server], 1, hackVersion); 92 | } 93 | if (isRunning('loop-grow.script', servers[server], growVersion) == false) { 94 | while (isRunning('loop-grow.script', servers[server]) == true) kill('loop-grow.script', servers[server]); 95 | for (version = 0; version < growVersion; version++) { 96 | while (isRunning('loop-grow.script', servers[server], version) == true) kill('loop-grow.script', servers[server], version); 97 | } 98 | scp('loop-grow.script', servers[server]); 99 | // try to run the grow script with as much threads as possible 100 | for (threads = 10; threads > 0; threads--) { 101 | exec('loop-grow.script', servers[server], threads, growVersion); 102 | } 103 | } 104 | } 105 | } 106 | // scans more servers from the current server 107 | newServers = scan(servers[server]); 108 | for (newServer = 0; newServer < newServers.length; newServer++) { 109 | isNewServer = true; 110 | // we don't want home server 111 | if (newServers[newServer] == 'home') isNewServer = false; 112 | // i don't want my own servers 113 | for (checkServer = 0; checkServer < ownServers.length; checkServer++) if (newServers[newServer] == 'home-' + ownServers[checkServer]) isNewServer = false; 114 | // we don't want a server which is already in the list 115 | for (checkServer = 0; checkServer < allServers.length; checkServer++) if (newServers[newServer] == allServers[checkServer]) isNewServer = false; 116 | if (isNewServer) allServers = allServers.concat(newServers[newServer]); 117 | } 118 | } 119 | // next loop should start from the server we just scanned 120 | startingServer = server; 121 | } -------------------------------------------------------------------------------- /Middle-game/start(2).js: -------------------------------------------------------------------------------- 1 | /* 2 | POSTED BY: 3 | u/Mirisme (https://www.reddit.com/user/Mirisme) 4 | 5 | POSTED ON: 6 | October 4th, 2017 7 | 8 | COMMENT CONTEXT: 9 | "UPDATE Server selection modified on start.script (earlier version ignored some servers due to faulty logic). Target update fixed (earlier version didn't replace less profitable servers correctly). 10 | 11 | After using /u/MercuriusXeno progression script for a while (Found here), I wanted to have a better targetting script. 12 | 13 | What does it do? 14 | 15 | collect all potential target (it's pretty much the start.script modified to pass on target) 16 | maintain a list of best target 17 | attack target using servers 18 | upgrade servers when there's enough money 19 | How do I do that? 20 | 21 | So for starters, you'll need every script on the link before, except start.script. 22 | 23 | Warning: You may have trouble running the scripts if you have too little ram on you home server. 24 | 25 | start.script COST 9.35GB 26 | 27 | usage : run start.script" 28 | 29 | REDDIT POST: 30 | https://www.reddit.com/r/Bitburner/comments/745i64/targetting_script/ 31 | */ 32 | 33 | 34 | 35 | //presume the host to be the machine this script is running on, should probably be home, but don't let it assume so. 36 | hostName = getHostname(); 37 | //initialize the scan array with just this host, this provides a starting point and saves a scan() call. 38 | scanArray = [hostName]; 39 | //initialize the current scan length to 0 40 | currentScanLength = 0; 41 | //create an object (array) to hold our servers 42 | servers = []; 43 | 44 | canal = 10; 45 | //some optional values to change the behavior of this method. 46 | debugMode = false; 47 | nukeOnlyMode = false; 48 | 49 | mode = 0; 50 | 51 | doLoop = true; 52 | 53 | portBusters = ['BruteSSH.exe', 'FTPCrack.exe', 'relaySMTP.exe', 'HTTPWorm.exe', 'SQLInject.exe']; 54 | 55 | ownedBusters = 0; 56 | 57 | getServer = false; 58 | 59 | //arbitrary value added for valuating min security in a growth formula for speed/growth value. 60 | minSecurityWeight = 100; 61 | //here is where we keep track of the last run Daemon; when we run a new daemon, we kill the old one. 62 | //this is a less sort-heavy method of targetting "optimally", though it comes with its own imperfections 63 | targetServers = []; 64 | //Empty Canal 65 | empty = read(canal); 66 | while (empty != "NULL PORT DATA"){ 67 | empty = read(canal); 68 | } 69 | while (doLoop) { 70 | if (mode === 0) { 71 | previousScanLength = currentScanLength; 72 | currentScanLength = scanArray.length; 73 | for (i = previousScanLength; i < currentScanLength; i++) { 74 | currentHost = scanArray[i]; 75 | //hostName, numPorts, hackingLevel, maxMoney, growthRate, minSecurity 76 | //0 1 2 3 4 5 77 | server = [currentHost, getServerNumPortsRequired(currentHost), getServerRequiredHackingLevel(currentHost), getServerMaxMoney(currentHost), getServerGrowth(currentHost), Math.max(1, Math.round(getServerBaseSecurityLevel(currentHost) / 3))]; 78 | 79 | //skip home, we don't need to go nuking our machine. foodnstuff is our de facto test/staging server for debug mode. 80 | if (server[0] != 'home' && (server[0] == 'foodnstuff' || !debugMode) && !(server[1] == 5 && server[2] ==1)) { 81 | //add the server to the servers object 82 | servers.push(server); 83 | if (debugMode) { 84 | mode = 1; 85 | break; //debug mode stops at foodnstuff 86 | } 87 | } 88 | 89 | //add this servers connected nodes (other servers) to the scan list 90 | newScan = scan(currentHost); 91 | 92 | for (j = 0; j < newScan.length; j++) { 93 | //exclude anything we have already scanned. names are unique indexes which allows this to work. 94 | if (scanArray.indexOf(newScan[j]) == -1) { 95 | scanArray.push(newScan[j]); 96 | } 97 | } 98 | } 99 | //if we're about to exit the loop, switch a mode variable from 0 to 1. This moves the script to phase 2, nuking. 100 | if (currentScanLength == scanArray.length) { 101 | run("get_server.script"); 102 | mode = 1; 103 | } 104 | } 105 | if (mode == 1) { 106 | ownedBusters = 0; 107 | //get the port busters you've got so it's one less thing the nuke script has to figure out. 108 | //this is done inside the while loop for adaptability, but outside the server loop for speed. 109 | for (i = 0; i < portBusters.length; i++) { 110 | //always checking the home machine, presumes your port busters always live at home. 111 | if (fileExists(portBusters[i], 'home')) { 112 | ownedBusters++; 113 | } 114 | } 115 | print ('Portbusters the program thinks you own: ' + ownedBusters); 116 | //loop over all the servers and find potential victims. 117 | for (i = 0; i < servers.length; i++) { 118 | server = servers[i]; 119 | //we need to know hacking level and ports needed to nuke to determine viable targets. 120 | numPorts = server[1]; 121 | hackingLevel = server[2]; 122 | growthRate = server[4]; 123 | minSecurity = server[5]; 124 | //ignore servers above your level and servers you don't have the busters for. 125 | playerHackingLevel = getHackingLevel(); 126 | if (playerHackingLevel >= hackingLevel && numPorts <= ownedBusters) { 127 | print ('Vulnerable server ' + server[0] + ' found with difficulty of ' + hackingLevel + ' and ports: ' + numPorts); 128 | //now grab the other data, we're passing this to the knock script so it can pass it further to the daemon. 129 | target = server[0]; 130 | hasRun = false; 131 | //we won't nuke if we have access 132 | if (!hasRootAccess(target)) { 133 | if (numPorts > 0) { 134 | brutessh(target); 135 | } 136 | if (numPorts > 1) { 137 | ftpcrack(target); 138 | } 139 | if (numPorts > 2) { 140 | relaysmtp(target); 141 | } 142 | if (numPorts > 3) { 143 | httpworm(target); 144 | } 145 | if (numPorts > 4) { 146 | sqlinject(target); 147 | } 148 | nuke(target); 149 | } 150 | if (!nukeOnlyMode) { 151 | //we don't run a daemon on anything like CSEC - stuff with no money is nuke-only. 152 | maxMoney = server[3]; 153 | if (maxMoney > 0) { 154 | //calculate value of target 155 | weightedValueOfCurrentTarget = round(maxMoney * (minSecurityWeight / minSecurity) * growthRate); 156 | //send data of current target 157 | write(canal ,[server[0], server[3], server[4], server[5], server[2], weightedValueOfCurrentTarget]); 158 | } 159 | } 160 | //remove the server from the list, it will eventually be compromised. this lets us stop iterating on it. 161 | servers.splice(i, 1); 162 | //decrement to account for the deleted server entry 163 | i--; 164 | } 165 | } 166 | //if there are servers left in the list, keep going. 167 | doLoop = servers.length > 0; 168 | } 169 | } --------------------------------------------------------------------------------